btrfs: don't run delayed_iputs in commit
[sfrench/cifs-2.6.git] / fs / btrfs / transaction.c
index ff5f6c719976699429599d780d71feec2868aa8f..d1eeef9ec5dac512faa62e50766602dc9f110223 100644 (file)
@@ -44,7 +44,8 @@ void btrfs_put_transaction(struct btrfs_transaction *transaction)
        WARN_ON(refcount_read(&transaction->use_count) == 0);
        if (refcount_dec_and_test(&transaction->use_count)) {
                BUG_ON(!list_empty(&transaction->list));
-               WARN_ON(!RB_EMPTY_ROOT(&transaction->delayed_refs.href_root));
+               WARN_ON(!RB_EMPTY_ROOT(
+                               &transaction->delayed_refs.href_root.rb_root));
                if (transaction->delayed_refs.pending_csums)
                        btrfs_err(transaction->fs_info,
                                  "pending csums is %llu",
@@ -118,7 +119,7 @@ static noinline void switch_commit_roots(struct btrfs_transaction *trans)
                list_del_init(&root->dirty_list);
                free_extent_buffer(root->commit_root);
                root->commit_root = btrfs_root_node(root);
-               if (is_fstree(root->objectid))
+               if (is_fstree(root->root_key.objectid))
                        btrfs_unpin_free_ino(root);
                clear_btree_io_tree(&root->dirty_log_pages);
        }
@@ -241,11 +242,11 @@ loop:
        refcount_set(&cur_trans->use_count, 2);
        atomic_set(&cur_trans->pending_ordered, 0);
        cur_trans->flags = 0;
-       cur_trans->start_time = get_seconds();
+       cur_trans->start_time = ktime_get_seconds();
 
        memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs));
 
-       cur_trans->delayed_refs.href_root = RB_ROOT;
+       cur_trans->delayed_refs.href_root = RB_ROOT_CACHED;
        cur_trans->delayed_refs.dirty_extent_root = RB_ROOT;
        atomic_set(&cur_trans->delayed_refs.num_entries, 0);
 
@@ -680,7 +681,7 @@ btrfs_attach_transaction_barrier(struct btrfs_root *root)
 
        trans = start_transaction(root, 0, TRANS_ATTACH,
                                  BTRFS_RESERVE_NO_FLUSH, true);
-       if (IS_ERR(trans) && PTR_ERR(trans) == -ENOENT)
+       if (trans == ERR_PTR(-ENOENT))
                btrfs_wait_for_commit(root->fs_info, 0);
 
        return trans;
@@ -759,7 +760,7 @@ static int should_end_transaction(struct btrfs_trans_handle *trans)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
 
-       if (btrfs_check_space_for_delayed_refs(trans, fs_info))
+       if (btrfs_check_space_for_delayed_refs(trans))
                return 1;
 
        return !!btrfs_block_rsv_check(&fs_info->global_block_rsv, 5);
@@ -834,7 +835,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
        trans->delayed_ref_updates = 0;
        if (!trans->sync) {
                must_run_delayed_refs =
-                       btrfs_should_throttle_delayed_refs(trans, info);
+                       btrfs_should_throttle_delayed_refs(trans);
                cur = max_t(unsigned long, cur, 32);
 
                /*
@@ -1152,7 +1153,7 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans)
        ret = btrfs_run_dev_replace(trans, fs_info);
        if (ret)
                return ret;
-       ret = btrfs_run_qgroups(trans, fs_info);
+       ret = btrfs_run_qgroups(trans);
        if (ret)
                return ret;
 
@@ -1197,7 +1198,10 @@ again:
 
        list_add_tail(&fs_info->extent_root->dirty_list,
                      &trans->transaction->switch_commits);
-       btrfs_after_dev_replace_commit(fs_info);
+
+       /* Update dev-replace pointer once everything is committed */
+       fs_info->dev_replace.committed_cursor_left =
+               fs_info->dev_replace.cursor_left_last_write_of_item;
 
        return 0;
 }
@@ -1355,8 +1359,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans,
                goto out;
 
        /* Now qgroup are all updated, we can inherit it to new qgroups */
-       ret = btrfs_qgroup_inherit(trans, fs_info,
-                                  src->root_key.objectid, dst_objectid,
+       ret = btrfs_qgroup_inherit(trans, src->root_key.objectid, dst_objectid,
                                   inherit);
        if (ret < 0)
                goto out;
@@ -1574,7 +1577,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        /*
         * insert root back/forward references
         */
-       ret = btrfs_add_root_ref(trans, fs_info, objectid,
+       ret = btrfs_add_root_ref(trans, objectid,
                                 parent_root->root_key.objectid,
                                 btrfs_ino(BTRFS_I(parent_inode)), index,
                                 dentry->d_name.name, dentry->d_name.len);
@@ -1614,10 +1617,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        if (ret < 0)
                goto fail;
 
-       ret = btrfs_insert_dir_item(trans, parent_root,
-                                   dentry->d_name.name, dentry->d_name.len,
-                                   BTRFS_I(parent_inode), &key,
-                                   BTRFS_FT_DIR, index);
+       ret = btrfs_insert_dir_item(trans, dentry->d_name.name,
+                                   dentry->d_name.len, BTRFS_I(parent_inode),
+                                   &key, BTRFS_FT_DIR, index);
        /* We have check then name at the beginning, so it is impossible. */
        BUG_ON(ret == -EEXIST || ret == -EOVERFLOW);
        if (ret) {
@@ -1930,6 +1932,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
                return ret;
        }
 
+       btrfs_trans_release_metadata(trans);
+       trans->block_rsv = NULL;
+
        /* make a pass through all the delayed refs we have so far
         * any runnings procs may add more while we are here
         */
@@ -1939,9 +1944,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
                return ret;
        }
 
-       btrfs_trans_release_metadata(trans);
-       trans->block_rsv = NULL;
-
        cur_trans = trans->transaction;
 
        /*
@@ -2281,15 +2283,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
 
        kmem_cache_free(btrfs_trans_handle_cachep, trans);
 
-       /*
-        * If fs has been frozen, we can not handle delayed iputs, otherwise
-        * it'll result in deadlock about SB_FREEZE_FS.
-        */
-       if (current != fs_info->transaction_kthread &&
-           current != fs_info->cleaner_kthread &&
-           !test_bit(BTRFS_FS_FROZEN, &fs_info->flags))
-               btrfs_run_delayed_iputs(fs_info);
-
        return ret;
 
 scrub_continue:
@@ -2331,7 +2324,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
        list_del_init(&root->root_list);
        spin_unlock(&fs_info->trans_lock);
 
-       btrfs_debug(fs_info, "cleaner removing %llu", root->objectid);
+       btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid);
 
        btrfs_kill_all_delayed_nodes(root);