提交 3a45bb20 编写于 作者: J Jeff Mahoney 提交者: David Sterba

btrfs: remove root parameter from transaction commit/end routines

Now we only use the root parameter to print the root objectid in
a tracepoint.  We can use the root parameter from the transaction
handle for that.  It's also used to join the transaction with
async commits, so we remove the comment that it's just for checking.
Signed-off-by: NJeff Mahoney <jeffm@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 bf89d38f
...@@ -2056,7 +2056,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, ...@@ -2056,7 +2056,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
out: out:
if (!search_commit_root) { if (!search_commit_root) {
btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem); btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem);
btrfs_end_transaction(trans, fs_info->extent_root); btrfs_end_transaction(trans);
} else { } else {
up_read(&fs_info->commit_root_sem); up_read(&fs_info->commit_root_sem);
} }
......
...@@ -1280,7 +1280,7 @@ int btrfs_commit_inode_delayed_inode(struct inode *inode) ...@@ -1280,7 +1280,7 @@ int btrfs_commit_inode_delayed_inode(struct inode *inode)
btrfs_free_path(path); btrfs_free_path(path);
trans->block_rsv = block_rsv; trans->block_rsv = block_rsv;
trans_out: trans_out:
btrfs_end_transaction(trans, delayed_node->root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
out: out:
btrfs_release_delayed_node(delayed_node); btrfs_release_delayed_node(delayed_node);
...@@ -1345,7 +1345,7 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work) ...@@ -1345,7 +1345,7 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work)
__btrfs_commit_inode_delayed_items(trans, path, delayed_node); __btrfs_commit_inode_delayed_items(trans, path, delayed_node);
trans->block_rsv = block_rsv; trans->block_rsv = block_rsv;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty_nodelay(root->fs_info); btrfs_btree_balance_dirty_nodelay(root->fs_info);
release_path: release_path:
......
...@@ -335,7 +335,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name, ...@@ -335,7 +335,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name,
*/ */
trans = btrfs_attach_transaction(root); trans = btrfs_attach_transaction(root);
if (!IS_ERR(trans)) { if (!IS_ERR(trans)) {
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
return ret; return ret;
} else if (PTR_ERR(trans) != -ENOENT) { } else if (PTR_ERR(trans) != -ENOENT) {
...@@ -397,7 +397,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name, ...@@ -397,7 +397,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name,
goto leave; goto leave;
} }
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
WARN_ON(ret); WARN_ON(ret);
/* the disk copy procedure reuses the scrub code */ /* the disk copy procedure reuses the scrub code */
...@@ -513,7 +513,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, ...@@ -513,7 +513,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
return PTR_ERR(trans); return PTR_ERR(trans);
} }
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
WARN_ON(ret); WARN_ON(ret);
mutex_lock(&uuid_mutex); mutex_lock(&uuid_mutex);
...@@ -603,7 +603,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, ...@@ -603,7 +603,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
/* write back the superblocks */ /* write back the superblocks */
trans = btrfs_start_transaction(root, 0); trans = btrfs_start_transaction(root, 0);
if (!IS_ERR(trans)) if (!IS_ERR(trans))
btrfs_commit_transaction(trans, root); btrfs_commit_transaction(trans);
mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
...@@ -718,7 +718,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info) ...@@ -718,7 +718,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
return PTR_ERR(trans); return PTR_ERR(trans);
} }
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
WARN_ON(ret); WARN_ON(ret);
if (tgt_device) if (tgt_device)
btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device); btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
......
...@@ -1913,7 +1913,7 @@ static int cleaner_kthread(void *arg) ...@@ -1913,7 +1913,7 @@ static int cleaner_kthread(void *arg)
} else { } else {
int ret; int ret;
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
btrfs_err(fs_info, btrfs_err(fs_info,
"cleaner open transaction commit returned %d", "cleaner open transaction commit returned %d",
...@@ -1965,9 +1965,9 @@ static int transaction_kthread(void *arg) ...@@ -1965,9 +1965,9 @@ static int transaction_kthread(void *arg)
goto sleep; goto sleep;
} }
if (transid == trans->transid) { if (transid == trans->transid) {
btrfs_commit_transaction(trans, root); btrfs_commit_transaction(trans);
} else { } else {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
} }
sleep: sleep:
wake_up_process(fs_info->cleaner_kthread); wake_up_process(fs_info->cleaner_kthread);
...@@ -3901,7 +3901,7 @@ int btrfs_commit_super(struct btrfs_fs_info *fs_info) ...@@ -3901,7 +3901,7 @@ int btrfs_commit_super(struct btrfs_fs_info *fs_info)
trans = btrfs_join_transaction(root); trans = btrfs_join_transaction(root);
if (IS_ERR(trans)) if (IS_ERR(trans))
return PTR_ERR(trans); return PTR_ERR(trans);
return btrfs_commit_transaction(trans, root); return btrfs_commit_transaction(trans);
} }
void close_ctree(struct btrfs_fs_info *fs_info) void close_ctree(struct btrfs_fs_info *fs_info)
......
...@@ -2868,7 +2868,7 @@ static void delayed_ref_async_start(struct btrfs_work *work) ...@@ -2868,7 +2868,7 @@ static void delayed_ref_async_start(struct btrfs_work *work)
if (ret) if (ret)
async->error = ret; async->error = ret;
end: end:
ret = btrfs_end_transaction(trans, async->root); ret = btrfs_end_transaction(trans);
if (ret && !async->error) if (ret && !async->error)
async->error = ret; async->error = ret;
done: done:
...@@ -4175,7 +4175,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes) ...@@ -4175,7 +4175,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)
ret = do_chunk_alloc(trans, fs_info, alloc_target, ret = do_chunk_alloc(trans, fs_info, alloc_target,
CHUNK_ALLOC_NO_FORCE); CHUNK_ALLOC_NO_FORCE);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret < 0) { if (ret < 0) {
if (ret != -ENOSPC) if (ret != -ENOSPC)
return ret; return ret;
...@@ -4220,7 +4220,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes) ...@@ -4220,7 +4220,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)
test_bit(BTRFS_TRANS_HAVE_FREE_BGS, test_bit(BTRFS_TRANS_HAVE_FREE_BGS,
&trans->transaction->flags) || &trans->transaction->flags) ||
need_commit > 0) { need_commit > 0) {
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
return ret; return ret;
/* /*
...@@ -4232,7 +4232,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes) ...@@ -4232,7 +4232,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)
mutex_unlock(&fs_info->cleaner_delayed_iput_mutex); mutex_unlock(&fs_info->cleaner_delayed_iput_mutex);
goto again; goto again;
} else { } else {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
} }
} }
...@@ -4824,7 +4824,7 @@ static int may_commit_transaction(struct btrfs_root *root, ...@@ -4824,7 +4824,7 @@ static int may_commit_transaction(struct btrfs_root *root,
if (IS_ERR(trans)) if (IS_ERR(trans))
return -ENOSPC; return -ENOSPC;
return btrfs_commit_transaction(trans, root); return btrfs_commit_transaction(trans);
} }
struct reserve_ticket { struct reserve_ticket {
...@@ -4857,7 +4857,7 @@ static int flush_space(struct btrfs_root *root, ...@@ -4857,7 +4857,7 @@ static int flush_space(struct btrfs_root *root,
break; break;
} }
ret = btrfs_run_delayed_items_nr(trans, fs_info, nr); ret = btrfs_run_delayed_items_nr(trans, fs_info, nr);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
break; break;
case FLUSH_DELALLOC: case FLUSH_DELALLOC:
case FLUSH_DELALLOC_WAIT: case FLUSH_DELALLOC_WAIT:
...@@ -4873,7 +4873,7 @@ static int flush_space(struct btrfs_root *root, ...@@ -4873,7 +4873,7 @@ static int flush_space(struct btrfs_root *root,
ret = do_chunk_alloc(trans, fs_info, ret = do_chunk_alloc(trans, fs_info,
btrfs_get_alloc_profile(root, 0), btrfs_get_alloc_profile(root, 0),
CHUNK_ALLOC_NO_FORCE); CHUNK_ALLOC_NO_FORCE);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret > 0 || ret == -ENOSPC) if (ret > 0 || ret == -ENOSPC)
ret = 0; ret = 0;
break; break;
...@@ -7854,7 +7854,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root, ...@@ -7854,7 +7854,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
else else
ret = 0; ret = 0;
if (!exist) if (!exist)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret) if (ret)
goto out; goto out;
} }
...@@ -9106,7 +9106,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -9106,7 +9106,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
} }
BUG_ON(wc->level == 0); BUG_ON(wc->level == 0);
if (btrfs_should_end_transaction(trans, tree_root) || if (btrfs_should_end_transaction(trans) ||
(!for_reloc && btrfs_need_cleaner_sleep(fs_info))) { (!for_reloc && btrfs_need_cleaner_sleep(fs_info))) {
ret = btrfs_update_root(trans, tree_root, ret = btrfs_update_root(trans, tree_root,
&root->root_key, &root->root_key,
...@@ -9117,7 +9117,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -9117,7 +9117,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
goto out_end_trans; goto out_end_trans;
} }
btrfs_end_transaction_throttle(trans, tree_root); btrfs_end_transaction_throttle(trans);
if (!for_reloc && btrfs_need_cleaner_sleep(fs_info)) { if (!for_reloc && btrfs_need_cleaner_sleep(fs_info)) {
btrfs_debug(fs_info, btrfs_debug(fs_info,
"drop snapshot early exit"); "drop snapshot early exit");
...@@ -9171,7 +9171,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -9171,7 +9171,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
} }
root_dropped = true; root_dropped = true;
out_end_trans: out_end_trans:
btrfs_end_transaction_throttle(trans, tree_root); btrfs_end_transaction_throttle(trans);
out_free: out_free:
kfree(wc); kfree(wc);
btrfs_free_path(path); btrfs_free_path(path);
...@@ -9380,7 +9380,7 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root, ...@@ -9380,7 +9380,7 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root,
u64 transid = trans->transid; u64 transid = trans->transid;
mutex_unlock(&fs_info->ro_block_group_mutex); mutex_unlock(&fs_info->ro_block_group_mutex);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
ret = btrfs_wait_for_commit(fs_info, transid); ret = btrfs_wait_for_commit(fs_info, transid);
if (ret) if (ret)
...@@ -9425,7 +9425,7 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root, ...@@ -9425,7 +9425,7 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root,
} }
mutex_unlock(&fs_info->ro_block_group_mutex); mutex_unlock(&fs_info->ro_block_group_mutex);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -9644,7 +9644,7 @@ int btrfs_can_relocate(struct btrfs_fs_info *fs_info, u64 bytenr) ...@@ -9644,7 +9644,7 @@ int btrfs_can_relocate(struct btrfs_fs_info *fs_info, u64 bytenr)
"no space to allocate a new chunk for block group %llu", "no space to allocate a new chunk for block group %llu",
block_group->key.objectid); block_group->key.objectid);
mutex_unlock(&fs_info->chunk_mutex); mutex_unlock(&fs_info->chunk_mutex);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
out: out:
btrfs_put_block_group(block_group); btrfs_put_block_group(block_group);
return ret; return ret;
...@@ -10596,7 +10596,6 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) ...@@ -10596,7 +10596,6 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
{ {
struct btrfs_block_group_cache *block_group; struct btrfs_block_group_cache *block_group;
struct btrfs_space_info *space_info; struct btrfs_space_info *space_info;
struct btrfs_root *root = fs_info->extent_root;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
int ret = 0; int ret = 0;
...@@ -10747,7 +10746,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) ...@@ -10747,7 +10746,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
btrfs_get_block_group(block_group); btrfs_get_block_group(block_group);
} }
end_trans: end_trans:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
next: next:
mutex_unlock(&fs_info->delete_unused_bgs_mutex); mutex_unlock(&fs_info->delete_unused_bgs_mutex);
btrfs_put_block_group(block_group); btrfs_put_block_group(block_group);
......
...@@ -4540,7 +4540,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -4540,7 +4540,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
root->objectid, root->objectid,
btrfs_ino(inode), bytenr); btrfs_ino(inode), bytenr);
if (trans) if (trans)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret < 0) if (ret < 0)
goto out_free; goto out_free;
if (ret) if (ret)
......
...@@ -2146,7 +2146,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -2146,7 +2146,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* which are indicated by ctx.io_err. * which are indicated by ctx.io_err.
*/ */
if (ctx.io_err) { if (ctx.io_err) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
ret = ctx.io_err; ret = ctx.io_err;
goto out; goto out;
} }
...@@ -2155,20 +2155,20 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -2155,20 +2155,20 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
if (!ret) { if (!ret) {
ret = btrfs_sync_log(trans, root, &ctx); ret = btrfs_sync_log(trans, root, &ctx);
if (!ret) { if (!ret) {
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
goto out; goto out;
} }
} }
if (!full_sync) { if (!full_sync) {
ret = btrfs_wait_ordered_range(inode, start, len); ret = btrfs_wait_ordered_range(inode, start, len);
if (ret) { if (ret) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
} }
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
} else { } else {
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
} }
out: out:
return ret > 0 ? -EIO : ret; return ret > 0 ? -EIO : ret;
...@@ -2574,7 +2574,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -2574,7 +2574,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
break; break;
} }
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
trans = btrfs_start_transaction(root, rsv_count); trans = btrfs_start_transaction(root, rsv_count);
...@@ -2642,7 +2642,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -2642,7 +2642,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
trans->block_rsv = &fs_info->trans_block_rsv; trans->block_rsv = &fs_info->trans_block_rsv;
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
updated_inode = true; updated_inode = true;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
out_free: out_free:
btrfs_free_path(path); btrfs_free_path(path);
...@@ -2664,7 +2664,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -2664,7 +2664,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
err = PTR_ERR(trans); err = PTR_ERR(trans);
} else { } else {
err = btrfs_update_inode(trans, root, inode); err = btrfs_update_inode(trans, root, inode);
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
} }
} }
inode_unlock(inode); inode_unlock(inode);
...@@ -2906,9 +2906,9 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -2906,9 +2906,9 @@ static long btrfs_fallocate(struct file *file, int mode,
btrfs_ordered_update_i_size(inode, actual_end, NULL); btrfs_ordered_update_i_size(inode, actual_end, NULL);
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
if (ret) if (ret)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
else else
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
} }
} }
out_unlock: out_unlock:
......
...@@ -1189,7 +1189,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info) ...@@ -1189,7 +1189,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
btrfs_set_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID); btrfs_set_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID);
clear_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags); clear_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags);
ret = btrfs_commit_transaction(trans, tree_root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
return ret; return ret;
...@@ -1198,7 +1198,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info) ...@@ -1198,7 +1198,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
abort: abort:
clear_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags); clear_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, tree_root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -1278,7 +1278,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info) ...@@ -1278,7 +1278,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
free_extent_buffer(free_space_root->commit_root); free_extent_buffer(free_space_root->commit_root);
kfree(free_space_root); kfree(free_space_root);
ret = btrfs_commit_transaction(trans, tree_root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
return ret; return ret;
...@@ -1286,7 +1286,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info) ...@@ -1286,7 +1286,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
abort: abort:
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, tree_root); btrfs_end_transaction(trans);
return ret; return ret;
} }
......
...@@ -326,7 +326,7 @@ static noinline int cow_file_range_inline(struct btrfs_root *root, ...@@ -326,7 +326,7 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
*/ */
btrfs_qgroup_free_data(inode, 0, PAGE_SIZE); btrfs_qgroup_free_data(inode, 0, PAGE_SIZE);
btrfs_free_path(path); btrfs_free_path(path);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -1534,7 +1534,7 @@ static noinline int run_delalloc_nocow(struct inode *inode, ...@@ -1534,7 +1534,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
} }
error: error:
err = btrfs_end_transaction(trans, root); err = btrfs_end_transaction(trans);
if (!ret) if (!ret)
ret = err; ret = err;
...@@ -2665,7 +2665,7 @@ static noinline int relink_extent_backref(struct btrfs_path *path, ...@@ -2665,7 +2665,7 @@ static noinline int relink_extent_backref(struct btrfs_path *path,
out_free_path: out_free_path:
btrfs_release_path(path); btrfs_release_path(path);
path->leave_spinning = 0; path->leave_spinning = 0;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
out_unlock: out_unlock:
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start, lock_end, unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start, lock_end,
&cached, GFP_NOFS); &cached, GFP_NOFS);
...@@ -3011,7 +3011,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -3011,7 +3011,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
if (root != fs_info->tree_root) if (root != fs_info->tree_root)
btrfs_delalloc_release_metadata(inode, ordered_extent->len); btrfs_delalloc_release_metadata(inode, ordered_extent->len);
if (trans) if (trans)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret || truncated) { if (ret || truncated) {
u64 start, end; u64 start, end;
...@@ -3519,7 +3519,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) ...@@ -3519,7 +3519,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
found_key.objectid); found_key.objectid);
ret = btrfs_del_orphan_item(trans, root, ret = btrfs_del_orphan_item(trans, root,
found_key.objectid); found_key.objectid);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret) if (ret)
goto out; goto out;
continue; continue;
...@@ -3549,7 +3549,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) ...@@ -3549,7 +3549,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
goto out; goto out;
} }
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, inode);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret) { if (ret) {
iput(inode); iput(inode);
goto out; goto out;
...@@ -3580,7 +3580,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) ...@@ -3580,7 +3580,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state)) { test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state)) {
trans = btrfs_join_transaction(root); trans = btrfs_join_transaction(root);
if (!IS_ERR(trans)) if (!IS_ERR(trans))
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
} }
if (nr_unlink) if (nr_unlink)
...@@ -4156,7 +4156,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -4156,7 +4156,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
} }
out: out:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(root->fs_info); btrfs_btree_balance_dirty(root->fs_info);
return ret; return ret;
} }
...@@ -4293,7 +4293,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -4293,7 +4293,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
BTRFS_I(dir)->last_unlink_trans = last_unlink_trans; BTRFS_I(dir)->last_unlink_trans = last_unlink_trans;
} }
out: out:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(root->fs_info); btrfs_btree_balance_dirty(root->fs_info);
return err; return err;
...@@ -4453,7 +4453,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4453,7 +4453,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
* bytes_deleted is > 0, it will be huge by the time we get here * bytes_deleted is > 0, it will be huge by the time we get here
*/ */
if (be_nice && bytes_deleted > SZ_32M) { if (be_nice && bytes_deleted > SZ_32M) {
if (btrfs_should_end_transaction(trans, root)) { if (btrfs_should_end_transaction(trans)) {
err = -EAGAIN; err = -EAGAIN;
goto error; goto error;
} }
...@@ -4858,7 +4858,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode, ...@@ -4858,7 +4858,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
ret = btrfs_drop_extents(trans, root, inode, offset, offset + len, 1); ret = btrfs_drop_extents(trans, root, inode, offset, offset + len, 1);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -4868,7 +4868,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode, ...@@ -4868,7 +4868,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
else else
btrfs_update_inode(trans, root, inode); btrfs_update_inode(trans, root, inode);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -5032,7 +5032,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -5032,7 +5032,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
pagecache_isize_extended(inode, oldsize, newsize); pagecache_isize_extended(inode, oldsize, newsize);
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
btrfs_end_write_no_snapshoting(root); btrfs_end_write_no_snapshoting(root);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
} else { } else {
/* /*
...@@ -5063,7 +5063,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -5063,7 +5063,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
* will be consistent. * will be consistent.
*/ */
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, inode);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret) if (ret)
return ret; return ret;
...@@ -5094,7 +5094,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -5094,7 +5094,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
err = btrfs_orphan_del(trans, inode); err = btrfs_orphan_del(trans, inode);
if (err) if (err)
btrfs_abort_transaction(trans, err); btrfs_abort_transaction(trans, err);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
} }
} }
...@@ -5355,7 +5355,7 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5355,7 +5355,7 @@ void btrfs_evict_inode(struct inode *inode)
* again. * again.
*/ */
if (ret) { if (ret) {
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
if (ret) { if (ret) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, inode);
btrfs_free_block_rsv(fs_info, rsv); btrfs_free_block_rsv(fs_info, rsv);
...@@ -5373,7 +5373,7 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5373,7 +5373,7 @@ void btrfs_evict_inode(struct inode *inode)
break; break;
trans->block_rsv = &fs_info->trans_block_rsv; trans->block_rsv = &fs_info->trans_block_rsv;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
trans = NULL; trans = NULL;
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
} }
...@@ -5396,7 +5396,7 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5396,7 +5396,7 @@ void btrfs_evict_inode(struct inode *inode)
root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)) root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID))
btrfs_return_ino(root, btrfs_ino(inode)); btrfs_return_ino(root, btrfs_ino(inode));
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
no_delete: no_delete:
btrfs_remove_delayed_node(inode); btrfs_remove_delayed_node(inode);
...@@ -5975,7 +5975,7 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -5975,7 +5975,7 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc)
trans = btrfs_join_transaction(root); trans = btrfs_join_transaction(root);
if (IS_ERR(trans)) if (IS_ERR(trans))
return PTR_ERR(trans); return PTR_ERR(trans);
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
} }
return ret; return ret;
} }
...@@ -6003,14 +6003,14 @@ static int btrfs_dirty_inode(struct inode *inode) ...@@ -6003,14 +6003,14 @@ static int btrfs_dirty_inode(struct inode *inode)
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
if (ret && ret == -ENOSPC) { if (ret && ret == -ENOSPC) {
/* whoops, lets try again with the full transaction */ /* whoops, lets try again with the full transaction */
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
trans = btrfs_start_transaction(root, 1); trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans)) if (IS_ERR(trans))
return PTR_ERR(trans); return PTR_ERR(trans);
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
} }
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (BTRFS_I(inode)->delayed_node) if (BTRFS_I(inode)->delayed_node)
btrfs_balance_delayed_items(fs_info); btrfs_balance_delayed_items(fs_info);
...@@ -6448,7 +6448,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -6448,7 +6448,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
} }
out_unlock: out_unlock:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_balance_delayed_items(fs_info); btrfs_balance_delayed_items(fs_info);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
if (drop_inode) { if (drop_inode) {
...@@ -6524,7 +6524,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, ...@@ -6524,7 +6524,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
out_unlock: out_unlock:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (err && drop_inode_on_err) { if (err && drop_inode_on_err) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
...@@ -6606,7 +6606,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -6606,7 +6606,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
btrfs_balance_delayed_items(fs_info); btrfs_balance_delayed_items(fs_info);
fail: fail:
if (trans) if (trans)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (drop_inode) { if (drop_inode) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
...@@ -6675,7 +6675,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -6675,7 +6675,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
drop_on_err = 0; drop_on_err = 0;
out_fail: out_fail:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (drop_on_err) { if (drop_on_err) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
...@@ -7063,7 +7063,7 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page, ...@@ -7063,7 +7063,7 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
btrfs_free_path(path); btrfs_free_path(path);
if (trans) { if (trans) {
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
if (!err) if (!err)
err = ret; err = ret;
} }
...@@ -7386,7 +7386,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, ...@@ -7386,7 +7386,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
ret = btrfs_cross_ref_exist(trans, root, btrfs_ino(inode), ret = btrfs_cross_ref_exist(trans, root, btrfs_ino(inode),
key.offset - backref_offset, disk_bytenr); key.offset - backref_offset, disk_bytenr);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret) { if (ret) {
ret = 0; ret = 0;
goto out; goto out;
...@@ -9200,7 +9200,7 @@ static int btrfs_truncate(struct inode *inode) ...@@ -9200,7 +9200,7 @@ static int btrfs_truncate(struct inode *inode)
break; break;
} }
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
trans = btrfs_start_transaction(root, 2); trans = btrfs_start_transaction(root, 2);
...@@ -9229,7 +9229,7 @@ static int btrfs_truncate(struct inode *inode) ...@@ -9229,7 +9229,7 @@ static int btrfs_truncate(struct inode *inode)
if (ret && !err) if (ret && !err)
err = ret; err = ret;
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
} }
out: out:
...@@ -9697,7 +9697,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9697,7 +9697,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
dest_log_pinned = false; dest_log_pinned = false;
} }
} }
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
out_notrans: out_notrans:
if (new_ino == BTRFS_FIRST_FREE_OBJECTID) if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
up_read(&fs_info->subvol_sem); up_read(&fs_info->subvol_sem);
...@@ -9967,7 +9967,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -9967,7 +9967,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
btrfs_end_log_trans(root); btrfs_end_log_trans(root);
log_pinned = false; log_pinned = false;
} }
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
out_notrans: out_notrans:
if (old_ino == BTRFS_FIRST_FREE_OBJECTID) if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
up_read(&fs_info->subvol_sem); up_read(&fs_info->subvol_sem);
...@@ -10300,7 +10300,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -10300,7 +10300,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
out_unlock: out_unlock:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (drop_inode) { if (drop_inode) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
...@@ -10356,7 +10356,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, ...@@ -10356,7 +10356,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
min_size, 0, *alloc_hint, &ins, 1, 0); min_size, 0, *alloc_hint, &ins, 1, 0);
if (ret) { if (ret) {
if (own_trans) if (own_trans)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
break; break;
} }
btrfs_dec_block_group_reservations(fs_info, ins.objectid); btrfs_dec_block_group_reservations(fs_info, ins.objectid);
...@@ -10372,7 +10372,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, ...@@ -10372,7 +10372,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
ins.offset, 0); ins.offset, 0);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
if (own_trans) if (own_trans)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
break; break;
} }
...@@ -10432,12 +10432,12 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode, ...@@ -10432,12 +10432,12 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
if (own_trans) if (own_trans)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
break; break;
} }
if (own_trans) if (own_trans)
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
} }
if (cur_offset < end) if (cur_offset < end)
btrfs_free_reserved_data_space(inode, cur_offset, btrfs_free_reserved_data_space(inode, cur_offset,
...@@ -10542,7 +10542,7 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -10542,7 +10542,7 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
mark_inode_dirty(inode); mark_inode_dirty(inode);
out: out:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (ret) if (ret)
iput(inode); iput(inode);
btrfs_balance_delayed_items(fs_info); btrfs_balance_delayed_items(fs_info);
......
...@@ -352,7 +352,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg) ...@@ -352,7 +352,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
inode->i_ctime = current_time(inode); inode->i_ctime = current_time(inode);
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
out_drop: out_drop:
if (ret) { if (ret) {
ip->flags = ip_oldflags; ip->flags = ip_oldflags;
...@@ -617,11 +617,11 @@ static noinline int create_subvol(struct inode *dir, ...@@ -617,11 +617,11 @@ static noinline int create_subvol(struct inode *dir,
if (async_transid) { if (async_transid) {
*async_transid = trans->transid; *async_transid = trans->transid;
err = btrfs_commit_transaction_async(trans, root, 1); err = btrfs_commit_transaction_async(trans, 1);
if (err) if (err)
err = btrfs_commit_transaction(trans, root); err = btrfs_commit_transaction(trans);
} else { } else {
err = btrfs_commit_transaction(trans, root); err = btrfs_commit_transaction(trans);
} }
if (err && !ret) if (err && !ret)
ret = err; ret = err;
...@@ -727,13 +727,11 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir, ...@@ -727,13 +727,11 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
spin_unlock(&fs_info->trans_lock); spin_unlock(&fs_info->trans_lock);
if (async_transid) { if (async_transid) {
*async_transid = trans->transid; *async_transid = trans->transid;
ret = btrfs_commit_transaction_async(trans, ret = btrfs_commit_transaction_async(trans, 1);
fs_info->extent_root, 1);
if (ret) if (ret)
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
} else { } else {
ret = btrfs_commit_transaction(trans, ret = btrfs_commit_transaction(trans);
fs_info->extent_root);
} }
if (ret) if (ret)
goto fail; goto fail;
...@@ -1615,7 +1613,7 @@ static noinline int btrfs_ioctl_resize(struct file *file, ...@@ -1615,7 +1613,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
goto out_free; goto out_free;
} }
ret = btrfs_grow_device(trans, device, new_size); ret = btrfs_grow_device(trans, device, new_size);
btrfs_commit_transaction(trans, root); btrfs_commit_transaction(trans);
} else if (new_size < old_size) { } else if (new_size < old_size) {
ret = btrfs_shrink_device(device, new_size); ret = btrfs_shrink_device(device, new_size);
} /* equal, nothing need to do */ } /* equal, nothing need to do */
...@@ -1873,7 +1871,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file, ...@@ -1873,7 +1871,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
ret = btrfs_update_root(trans, fs_info->tree_root, ret = btrfs_update_root(trans, fs_info->tree_root,
&root->root_key, &root->root_item); &root->root_key, &root->root_item);
btrfs_commit_transaction(trans, root); btrfs_commit_transaction(trans);
out_reset: out_reset:
if (ret) if (ret)
btrfs_set_root_flags(&root->root_item, root_flags); btrfs_set_root_flags(&root->root_item, root_flags);
...@@ -2552,7 +2550,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, ...@@ -2552,7 +2550,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
out_end_trans: out_end_trans:
trans->block_rsv = NULL; trans->block_rsv = NULL;
trans->bytes_reserved = 0; trans->bytes_reserved = 0;
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
if (ret && !err) if (ret && !err)
err = ret; err = ret;
inode->i_flags |= S_DEAD; inode->i_flags |= S_DEAD;
...@@ -3311,10 +3309,10 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans, ...@@ -3311,10 +3309,10 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
out: out:
return ret; return ret;
} }
...@@ -3715,7 +3713,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -3715,7 +3713,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
if (ret != -EOPNOTSUPP) if (ret != -EOPNOTSUPP)
btrfs_abort_transaction(trans, btrfs_abort_transaction(trans,
ret); ret);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
...@@ -3723,7 +3721,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -3723,7 +3721,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
&new_key, size); &new_key, size);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
...@@ -3756,8 +3754,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -3756,8 +3754,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
if (ret) { if (ret) {
btrfs_abort_transaction(trans, btrfs_abort_transaction(trans,
ret); ret);
btrfs_end_transaction(trans, btrfs_end_transaction(trans);
root);
goto out; goto out;
} }
...@@ -3776,7 +3773,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -3776,7 +3773,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
if (comp && (skip || trim)) { if (comp && (skip || trim)) {
ret = -EINVAL; ret = -EINVAL;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
size -= skip + trim; size -= skip + trim;
...@@ -3792,7 +3789,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -3792,7 +3789,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
if (ret != -EOPNOTSUPP) if (ret != -EOPNOTSUPP)
btrfs_abort_transaction(trans, btrfs_abort_transaction(trans,
ret); ret);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
leaf = path->nodes[0]; leaf = path->nodes[0];
...@@ -3852,7 +3849,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -3852,7 +3849,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
if (ret) { if (ret) {
if (ret != -EOPNOTSUPP) if (ret != -EOPNOTSUPP)
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
clone_update_extent_map(inode, trans, NULL, last_dest_end, clone_update_extent_map(inode, trans, NULL, last_dest_end,
...@@ -4114,7 +4111,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) ...@@ -4114,7 +4111,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
dir_id, "default", 7, 1); dir_id, "default", 7, 1);
if (IS_ERR_OR_NULL(di)) { if (IS_ERR_OR_NULL(di)) {
btrfs_free_path(path); btrfs_free_path(path);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_err(fs_info, btrfs_err(fs_info,
"Umm, you don't have the default diritem, this isn't going to work"); "Umm, you don't have the default diritem, this isn't going to work");
ret = -ENOENT; ret = -ENOENT;
...@@ -4127,7 +4124,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) ...@@ -4127,7 +4124,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
btrfs_free_path(path); btrfs_free_path(path);
btrfs_set_fs_incompat(fs_info, DEFAULT_SUBVOL); btrfs_set_fs_incompat(fs_info, DEFAULT_SUBVOL);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
out: out:
mnt_drop_write_file(file); mnt_drop_write_file(file);
return ret; return ret;
...@@ -4307,7 +4304,7 @@ long btrfs_ioctl_trans_end(struct file *file) ...@@ -4307,7 +4304,7 @@ long btrfs_ioctl_trans_end(struct file *file)
return -EINVAL; return -EINVAL;
file->private_data = NULL; file->private_data = NULL;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
atomic_dec(&root->fs_info->open_ioctl_trans); atomic_dec(&root->fs_info->open_ioctl_trans);
...@@ -4332,9 +4329,9 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, ...@@ -4332,9 +4329,9 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root,
goto out; goto out;
} }
transid = trans->transid; transid = trans->transid;
ret = btrfs_commit_transaction_async(trans, root, 0); ret = btrfs_commit_transaction_async(trans, 0);
if (ret) { if (ret) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
out: out:
...@@ -4885,7 +4882,7 @@ static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg) ...@@ -4885,7 +4882,7 @@ static long btrfs_ioctl_quota_ctl(struct file *file, void __user *arg)
break; break;
} }
err = btrfs_commit_transaction(trans, fs_info->tree_root); err = btrfs_commit_transaction(trans);
if (err && !ret) if (err && !ret)
ret = err; ret = err;
out: out:
...@@ -4939,7 +4936,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg) ...@@ -4939,7 +4936,7 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
if (err < 0) if (err < 0)
btrfs_handle_fs_error(fs_info, err, btrfs_handle_fs_error(fs_info, err,
"failed to update qgroup status and info"); "failed to update qgroup status and info");
err = btrfs_end_transaction(trans, root); err = btrfs_end_transaction(trans);
if (err && !ret) if (err && !ret)
ret = err; ret = err;
...@@ -4991,7 +4988,7 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg) ...@@ -4991,7 +4988,7 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
ret = btrfs_remove_qgroup(trans, fs_info, sa->qgroupid); ret = btrfs_remove_qgroup(trans, fs_info, sa->qgroupid);
} }
err = btrfs_end_transaction(trans, root); err = btrfs_end_transaction(trans);
if (err && !ret) if (err && !ret)
ret = err; ret = err;
...@@ -5041,7 +5038,7 @@ static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg) ...@@ -5041,7 +5038,7 @@ static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg)
/* FIXME: check if the IDs really exist */ /* FIXME: check if the IDs really exist */
ret = btrfs_limit_qgroup(trans, fs_info, qgroupid, &sa->lim); ret = btrfs_limit_qgroup(trans, fs_info, qgroupid, &sa->lim);
err = btrfs_end_transaction(trans, root); err = btrfs_end_transaction(trans);
if (err && !ret) if (err && !ret)
ret = err; ret = err;
...@@ -5187,7 +5184,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file, ...@@ -5187,7 +5184,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
ret = btrfs_update_root(trans, fs_info->tree_root, ret = btrfs_update_root(trans, fs_info->tree_root,
&root->root_key, &root->root_item); &root->root_key, &root->root_item);
if (ret < 0) { if (ret < 0) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
goto out; goto out;
} }
if (received_uuid_changed && !btrfs_is_empty_uuid(sa->uuid)) { if (received_uuid_changed && !btrfs_is_empty_uuid(sa->uuid)) {
...@@ -5199,7 +5196,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file, ...@@ -5199,7 +5196,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
goto out; goto out;
} }
} }
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
if (ret < 0) { if (ret < 0) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
...@@ -5347,7 +5344,7 @@ static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg) ...@@ -5347,7 +5344,7 @@ static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg)
spin_lock(&fs_info->super_lock); spin_lock(&fs_info->super_lock);
strcpy(super_block->label, label); strcpy(super_block->label, label);
spin_unlock(&fs_info->super_lock); spin_unlock(&fs_info->super_lock);
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
out_unlock: out_unlock:
mnt_drop_write_file(file); mnt_drop_write_file(file);
...@@ -5519,7 +5516,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg) ...@@ -5519,7 +5516,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
btrfs_set_super_incompat_flags(super_block, newflags); btrfs_set_super_incompat_flags(super_block, newflags);
spin_unlock(&fs_info->super_lock); spin_unlock(&fs_info->super_lock);
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
out_drop_write: out_drop_write:
mnt_drop_write_file(file); mnt_drop_write_file(file);
......
...@@ -2576,9 +2576,9 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work) ...@@ -2576,9 +2576,9 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
err = qgroup_rescan_leaf(fs_info, path, trans); err = qgroup_rescan_leaf(fs_info, path, trans);
} }
if (err > 0) if (err > 0)
btrfs_commit_transaction(trans, fs_info->fs_root); btrfs_commit_transaction(trans);
else else
btrfs_end_transaction(trans, fs_info->fs_root); btrfs_end_transaction(trans);
} }
out: out:
...@@ -2613,7 +2613,7 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work) ...@@ -2613,7 +2613,7 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
err = ret; err = ret;
btrfs_err(fs_info, "fail to update qgroup status: %d", err); btrfs_err(fs_info, "fail to update qgroup status: %d", err);
} }
btrfs_end_transaction(trans, fs_info->quota_root); btrfs_end_transaction(trans);
if (btrfs_fs_closing(fs_info)) { if (btrfs_fs_closing(fs_info)) {
btrfs_info(fs_info, "qgroup scan paused"); btrfs_info(fs_info, "qgroup scan paused");
...@@ -2732,7 +2732,7 @@ btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info) ...@@ -2732,7 +2732,7 @@ btrfs_qgroup_rescan(struct btrfs_fs_info *fs_info)
fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_RESCAN; fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_RESCAN;
return PTR_ERR(trans); return PTR_ERR(trans);
} }
ret = btrfs_commit_transaction(trans, fs_info->fs_root); ret = btrfs_commit_transaction(trans);
if (ret) { if (ret) {
fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_RESCAN; fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_RESCAN;
return ret; return ret;
......
...@@ -2270,7 +2270,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, ...@@ -2270,7 +2270,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
path->slots[level]); path->slots[level]);
root_item->drop_level = level; root_item->drop_level = level;
btrfs_end_transaction_throttle(trans, root); btrfs_end_transaction_throttle(trans);
trans = NULL; trans = NULL;
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
...@@ -2301,7 +2301,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, ...@@ -2301,7 +2301,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
} }
if (trans) if (trans)
btrfs_end_transaction_throttle(trans, root); btrfs_end_transaction_throttle(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
...@@ -2346,7 +2346,7 @@ int prepare_to_merge(struct reloc_control *rc, int err) ...@@ -2346,7 +2346,7 @@ int prepare_to_merge(struct reloc_control *rc, int err)
if (!err) { if (!err) {
if (num_bytes != rc->merging_rsv_size) { if (num_bytes != rc->merging_rsv_size) {
btrfs_end_transaction(trans, rc->extent_root); btrfs_end_transaction(trans);
btrfs_block_rsv_release(fs_info, rc->block_rsv, btrfs_block_rsv_release(fs_info, rc->block_rsv,
num_bytes); num_bytes);
goto again; goto again;
...@@ -2378,9 +2378,9 @@ int prepare_to_merge(struct reloc_control *rc, int err) ...@@ -2378,9 +2378,9 @@ int prepare_to_merge(struct reloc_control *rc, int err)
list_splice(&reloc_roots, &rc->reloc_roots); list_splice(&reloc_roots, &rc->reloc_roots);
if (!err) if (!err)
btrfs_commit_transaction(trans, rc->extent_root); btrfs_commit_transaction(trans);
else else
btrfs_end_transaction(trans, rc->extent_root); btrfs_end_transaction(trans);
return err; return err;
} }
...@@ -3555,7 +3555,7 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info, ...@@ -3555,7 +3555,7 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info,
ret = btrfs_truncate_free_space_cache(root, trans, block_group, inode); ret = btrfs_truncate_free_space_cache(root, trans, block_group, inode);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
out: out:
iput(inode); iput(inode);
...@@ -3986,7 +3986,7 @@ int prepare_to_relocate(struct reloc_control *rc) ...@@ -3986,7 +3986,7 @@ int prepare_to_relocate(struct reloc_control *rc)
*/ */
return PTR_ERR(trans); return PTR_ERR(trans);
} }
btrfs_commit_transaction(trans, rc->extent_root); btrfs_commit_transaction(trans);
return 0; return 0;
} }
...@@ -4033,7 +4033,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -4033,7 +4033,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
} }
restart: restart:
if (update_backref_cache(trans, &rc->backref_cache)) { if (update_backref_cache(trans, &rc->backref_cache)) {
btrfs_end_transaction(trans, rc->extent_root); btrfs_end_transaction(trans);
continue; continue;
} }
...@@ -4121,7 +4121,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -4121,7 +4121,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
} }
} }
btrfs_end_transaction_throttle(trans, rc->extent_root); btrfs_end_transaction_throttle(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
trans = NULL; trans = NULL;
...@@ -4150,7 +4150,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -4150,7 +4150,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
clear_extent_bits(&rc->processed_blocks, 0, (u64)-1, EXTENT_DIRTY); clear_extent_bits(&rc->processed_blocks, 0, (u64)-1, EXTENT_DIRTY);
if (trans) { if (trans) {
btrfs_end_transaction_throttle(trans, rc->extent_root); btrfs_end_transaction_throttle(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
} }
...@@ -4181,7 +4181,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -4181,7 +4181,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
err = PTR_ERR(trans); err = PTR_ERR(trans);
goto out_free; goto out_free;
} }
btrfs_commit_transaction(trans, rc->extent_root); btrfs_commit_transaction(trans);
out_free: out_free:
btrfs_free_block_rsv(fs_info, rc->block_rsv); btrfs_free_block_rsv(fs_info, rc->block_rsv);
btrfs_free_path(path); btrfs_free_path(path);
...@@ -4257,7 +4257,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info, ...@@ -4257,7 +4257,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
err = btrfs_orphan_add(trans, inode); err = btrfs_orphan_add(trans, inode);
out: out:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
if (err) { if (err) {
if (inode) if (inode)
...@@ -4442,7 +4442,7 @@ static noinline_for_stack int mark_garbage_root(struct btrfs_root *root) ...@@ -4442,7 +4442,7 @@ static noinline_for_stack int mark_garbage_root(struct btrfs_root *root)
ret = btrfs_update_root(trans, fs_info->tree_root, ret = btrfs_update_root(trans, fs_info->tree_root,
&root->root_key, &root->root_item); &root->root_key, &root->root_item);
err = btrfs_end_transaction(trans, fs_info->tree_root); err = btrfs_end_transaction(trans);
if (err) if (err)
return err; return err;
return ret; return ret;
...@@ -4573,7 +4573,7 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -4573,7 +4573,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
fs_root->reloc_root = reloc_root; fs_root->reloc_root = reloc_root;
} }
err = btrfs_commit_transaction(trans, rc->extent_root); err = btrfs_commit_transaction(trans);
if (err) if (err)
goto out_free; goto out_free;
...@@ -4586,7 +4586,7 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -4586,7 +4586,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
err = PTR_ERR(trans); err = PTR_ERR(trans);
goto out_free; goto out_free;
} }
err = btrfs_commit_transaction(trans, rc->extent_root); err = btrfs_commit_transaction(trans);
out_free: out_free:
kfree(rc); kfree(rc);
out: out:
......
...@@ -303,7 +303,7 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info) ...@@ -303,7 +303,7 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info)
} }
err = btrfs_del_orphan_item(trans, tree_root, err = btrfs_del_orphan_item(trans, tree_root,
root_key.objectid); root_key.objectid);
btrfs_end_transaction(trans, tree_root); btrfs_end_transaction(trans);
if (err) { if (err) {
btrfs_handle_fs_error(fs_info, err, btrfs_handle_fs_error(fs_info, err,
"Failed to delete root orphan item"); "Failed to delete root orphan item");
......
...@@ -839,7 +839,7 @@ static void scrub_fixup_nodatasum(struct btrfs_work *work) ...@@ -839,7 +839,7 @@ static void scrub_fixup_nodatasum(struct btrfs_work *work)
out: out:
if (trans && !IS_ERR(trans)) if (trans && !IS_ERR(trans))
btrfs_end_transaction(trans, fixup->root); btrfs_end_transaction(trans);
if (uncorrectable) { if (uncorrectable) {
spin_lock(&sctx->stat_lock); spin_lock(&sctx->stat_lock);
++sctx->stat.uncorrectable_errors; ++sctx->stat.uncorrectable_errors;
...@@ -3616,8 +3616,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, ...@@ -3616,8 +3616,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
if (IS_ERR(trans)) if (IS_ERR(trans))
ret = PTR_ERR(trans); ret = PTR_ERR(trans);
else else
ret = btrfs_commit_transaction(trans, ret = btrfs_commit_transaction(trans);
root);
if (ret) { if (ret) {
scrub_pause_off(fs_info); scrub_pause_off(fs_info);
btrfs_put_block_group(cache); btrfs_put_block_group(cache);
...@@ -4202,7 +4201,7 @@ static void copy_nocow_pages_worker(struct btrfs_work *work) ...@@ -4202,7 +4201,7 @@ static void copy_nocow_pages_worker(struct btrfs_work *work)
goto out; goto out;
} }
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
trans = NULL; trans = NULL;
while (!list_empty(&nocow_ctx->inodes)) { while (!list_empty(&nocow_ctx->inodes)) {
struct scrub_nocow_inode *entry; struct scrub_nocow_inode *entry;
...@@ -4230,7 +4229,7 @@ static void copy_nocow_pages_worker(struct btrfs_work *work) ...@@ -4230,7 +4229,7 @@ static void copy_nocow_pages_worker(struct btrfs_work *work)
kfree(entry); kfree(entry);
} }
if (trans && !IS_ERR(trans)) if (trans && !IS_ERR(trans))
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
if (not_written) if (not_written)
btrfs_dev_replace_stats_inc(&fs_info->dev_replace. btrfs_dev_replace_stats_inc(&fs_info->dev_replace.
num_uncorrectable_read_errors); num_uncorrectable_read_errors);
......
...@@ -6112,7 +6112,7 @@ static int ensure_commit_roots_uptodate(struct send_ctx *sctx) ...@@ -6112,7 +6112,7 @@ static int ensure_commit_roots_uptodate(struct send_ctx *sctx)
goto commit_trans; goto commit_trans;
if (trans) if (trans)
return btrfs_end_transaction(trans, sctx->send_root); return btrfs_end_transaction(trans);
return 0; return 0;
...@@ -6125,7 +6125,7 @@ static int ensure_commit_roots_uptodate(struct send_ctx *sctx) ...@@ -6125,7 +6125,7 @@ static int ensure_commit_roots_uptodate(struct send_ctx *sctx)
goto again; goto again;
} }
return btrfs_commit_transaction(trans, sctx->send_root); return btrfs_commit_transaction(trans);
} }
static void btrfs_root_dec_send_in_progress(struct btrfs_root* root) static void btrfs_root_dec_send_in_progress(struct btrfs_root* root)
......
...@@ -1206,7 +1206,7 @@ int btrfs_sync_fs(struct super_block *sb, int wait) ...@@ -1206,7 +1206,7 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
if (IS_ERR(trans)) if (IS_ERR(trans))
return PTR_ERR(trans); return PTR_ERR(trans);
} }
return btrfs_commit_transaction(trans, root); return btrfs_commit_transaction(trans);
} }
static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
...@@ -2251,7 +2251,7 @@ static int btrfs_freeze(struct super_block *sb) ...@@ -2251,7 +2251,7 @@ static int btrfs_freeze(struct super_block *sb)
return 0; return 0;
return PTR_ERR(trans); return PTR_ERR(trans);
} }
return btrfs_commit_transaction(trans, root); return btrfs_commit_transaction(trans);
} }
static int btrfs_unfreeze(struct super_block *sb) static int btrfs_unfreeze(struct super_block *sb)
......
...@@ -577,7 +577,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, ...@@ -577,7 +577,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
if (cur_trans->state >= TRANS_STATE_BLOCKED && if (cur_trans->state >= TRANS_STATE_BLOCKED &&
may_wait_transaction(fs_info, type)) { may_wait_transaction(fs_info, type)) {
current->journal_info = h; current->journal_info = h;
btrfs_commit_transaction(h, root); btrfs_commit_transaction(h);
goto again; goto again;
} }
...@@ -637,7 +637,7 @@ struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv( ...@@ -637,7 +637,7 @@ struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv(
ret = btrfs_cond_migrate_bytes(fs_info, &fs_info->trans_block_rsv, ret = btrfs_cond_migrate_bytes(fs_info, &fs_info->trans_block_rsv,
num_bytes, min_factor); num_bytes, min_factor);
if (ret) { if (ret) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -795,11 +795,10 @@ static int should_end_transaction(struct btrfs_trans_handle *trans) ...@@ -795,11 +795,10 @@ static int should_end_transaction(struct btrfs_trans_handle *trans)
return !!btrfs_block_rsv_check(&fs_info->global_block_rsv, 5); return !!btrfs_block_rsv_check(&fs_info->global_block_rsv, 5);
} }
int btrfs_should_end_transaction(struct btrfs_trans_handle *trans, int btrfs_should_end_transaction(struct btrfs_trans_handle *trans)
struct btrfs_root *root)
{ {
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_transaction *cur_trans = trans->transaction; struct btrfs_transaction *cur_trans = trans->transaction;
struct btrfs_fs_info *fs_info = trans->fs_info;
int updates; int updates;
int err; int err;
...@@ -820,10 +819,10 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans, ...@@ -820,10 +819,10 @@ int btrfs_should_end_transaction(struct btrfs_trans_handle *trans,
} }
static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int throttle) int throttle)
{ {
struct btrfs_fs_info *info = trans->fs_info;
struct btrfs_transaction *cur_trans = trans->transaction; struct btrfs_transaction *cur_trans = trans->transaction;
struct btrfs_fs_info *info = root->fs_info;
u64 transid = trans->transid; u64 transid = trans->transid;
unsigned long cur = trans->delayed_ref_updates; unsigned long cur = trans->delayed_ref_updates;
int lock = (trans->type != TRANS_JOIN_NOLOCK); int lock = (trans->type != TRANS_JOIN_NOLOCK);
...@@ -876,7 +875,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, ...@@ -876,7 +875,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
if (lock && ACCESS_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) { if (lock && ACCESS_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
if (throttle) if (throttle)
return btrfs_commit_transaction(trans, root); return btrfs_commit_transaction(trans);
else else
wake_up_process(info->transaction_kthread); wake_up_process(info->transaction_kthread);
} }
...@@ -918,16 +917,14 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, ...@@ -918,16 +917,14 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
return err; return err;
} }
int btrfs_end_transaction(struct btrfs_trans_handle *trans, int btrfs_end_transaction(struct btrfs_trans_handle *trans)
struct btrfs_root *root)
{ {
return __btrfs_end_transaction(trans, root, 0); return __btrfs_end_transaction(trans, 0);
} }
int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans)
struct btrfs_root *root)
{ {
return __btrfs_end_transaction(trans, root, 1); return __btrfs_end_transaction(trans, 1);
} }
/* /*
...@@ -1319,7 +1316,7 @@ int btrfs_defrag_root(struct btrfs_root *root) ...@@ -1319,7 +1316,7 @@ int btrfs_defrag_root(struct btrfs_root *root)
ret = btrfs_defrag_leaves(trans, root); ret = btrfs_defrag_leaves(trans, root);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(info); btrfs_btree_balance_dirty(info);
cond_resched(); cond_resched();
...@@ -1794,7 +1791,6 @@ static void wait_current_trans_commit_start_and_unblock( ...@@ -1794,7 +1791,6 @@ static void wait_current_trans_commit_start_and_unblock(
*/ */
struct btrfs_async_commit { struct btrfs_async_commit {
struct btrfs_trans_handle *newtrans; struct btrfs_trans_handle *newtrans;
struct btrfs_root *root;
struct work_struct work; struct work_struct work;
}; };
...@@ -1808,19 +1804,18 @@ static void do_async_commit(struct work_struct *work) ...@@ -1808,19 +1804,18 @@ static void do_async_commit(struct work_struct *work)
* Tell lockdep about it. * Tell lockdep about it.
*/ */
if (ac->newtrans->type & __TRANS_FREEZABLE) if (ac->newtrans->type & __TRANS_FREEZABLE)
__sb_writers_acquired(ac->root->fs_info->sb, SB_FREEZE_FS); __sb_writers_acquired(ac->newtrans->fs_info->sb, SB_FREEZE_FS);
current->journal_info = ac->newtrans; current->journal_info = ac->newtrans;
btrfs_commit_transaction(ac->newtrans, ac->root); btrfs_commit_transaction(ac->newtrans);
kfree(ac); kfree(ac);
} }
int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
int wait_for_unblock) int wait_for_unblock)
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_async_commit *ac; struct btrfs_async_commit *ac;
struct btrfs_transaction *cur_trans; struct btrfs_transaction *cur_trans;
...@@ -1829,8 +1824,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, ...@@ -1829,8 +1824,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
return -ENOMEM; return -ENOMEM;
INIT_WORK(&ac->work, do_async_commit); INIT_WORK(&ac->work, do_async_commit);
ac->root = root; ac->newtrans = btrfs_join_transaction(trans->root);
ac->newtrans = btrfs_join_transaction(root);
if (IS_ERR(ac->newtrans)) { if (IS_ERR(ac->newtrans)) {
int err = PTR_ERR(ac->newtrans); int err = PTR_ERR(ac->newtrans);
kfree(ac); kfree(ac);
...@@ -1841,7 +1835,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, ...@@ -1841,7 +1835,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
cur_trans = trans->transaction; cur_trans = trans->transaction;
atomic_inc(&cur_trans->use_count); atomic_inc(&cur_trans->use_count);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
/* /*
* Tell lockdep we've released the freeze rwsem, since the * Tell lockdep we've released the freeze rwsem, since the
...@@ -1938,10 +1932,9 @@ btrfs_wait_pending_ordered(struct btrfs_transaction *cur_trans) ...@@ -1938,10 +1932,9 @@ btrfs_wait_pending_ordered(struct btrfs_transaction *cur_trans)
atomic_read(&cur_trans->pending_ordered) == 0); atomic_read(&cur_trans->pending_ordered) == 0);
} }
int btrfs_commit_transaction(struct btrfs_trans_handle *trans, int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
struct btrfs_root *root)
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = trans->fs_info;
struct btrfs_transaction *cur_trans = trans->transaction; struct btrfs_transaction *cur_trans = trans->transaction;
struct btrfs_transaction *prev_trans = NULL; struct btrfs_transaction *prev_trans = NULL;
int ret; int ret;
...@@ -1949,7 +1942,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1949,7 +1942,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
/* Stop the commit early if ->aborted is set */ /* Stop the commit early if ->aborted is set */
if (unlikely(ACCESS_ONCE(cur_trans->aborted))) { if (unlikely(ACCESS_ONCE(cur_trans->aborted))) {
ret = cur_trans->aborted; ret = cur_trans->aborted;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -1958,7 +1951,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1958,7 +1951,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
*/ */
ret = btrfs_run_delayed_refs(trans, fs_info, 0); ret = btrfs_run_delayed_refs(trans, fs_info, 0);
if (ret) { if (ret) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -1979,7 +1972,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1979,7 +1972,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
ret = btrfs_run_delayed_refs(trans, fs_info, 0); ret = btrfs_run_delayed_refs(trans, fs_info, 0);
if (ret) { if (ret) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -2009,7 +2002,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -2009,7 +2002,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
ret = btrfs_start_dirty_block_groups(trans, fs_info); ret = btrfs_start_dirty_block_groups(trans, fs_info);
} }
if (ret) { if (ret) {
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -2017,7 +2010,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -2017,7 +2010,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
if (cur_trans->state >= TRANS_STATE_COMMIT_START) { if (cur_trans->state >= TRANS_STATE_COMMIT_START) {
spin_unlock(&fs_info->trans_lock); spin_unlock(&fs_info->trans_lock);
atomic_inc(&cur_trans->use_count); atomic_inc(&cur_trans->use_count);
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans);
wait_for_commit(cur_trans); wait_for_commit(cur_trans);
...@@ -2293,7 +2286,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -2293,7 +2286,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
if (trans->type & __TRANS_FREEZABLE) if (trans->type & __TRANS_FREEZABLE)
sb_end_intwrite(fs_info->sb); sb_end_intwrite(fs_info->sb);
trace_btrfs_transaction_commit(root); trace_btrfs_transaction_commit(trans->root);
btrfs_scrub_continue(fs_info); btrfs_scrub_continue(fs_info);
...@@ -2321,7 +2314,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -2321,7 +2314,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
btrfs_warn(fs_info, "Skipping commit of aborted transaction."); btrfs_warn(fs_info, "Skipping commit of aborted transaction.");
if (current->journal_info == trans) if (current->journal_info == trans)
current->journal_info = NULL; current->journal_info = NULL;
cleanup_transaction(trans, root, ret); cleanup_transaction(trans, trans->root, ret);
return ret; return ret;
} }
......
...@@ -123,11 +123,6 @@ struct btrfs_trans_handle { ...@@ -123,11 +123,6 @@ struct btrfs_trans_handle {
bool sync; bool sync;
bool dirty; bool dirty;
unsigned int type; unsigned int type;
/*
* this root is only needed to validate that the root passed to
* start_transaction is the same as the one passed to end_transaction.
* Subvolume quota depends on this
*/
struct btrfs_root *root; struct btrfs_root *root;
struct btrfs_fs_info *fs_info; struct btrfs_fs_info *fs_info;
struct seq_list delayed_ref_elem; struct seq_list delayed_ref_elem;
...@@ -185,8 +180,7 @@ static inline void btrfs_clear_skip_qgroup(struct btrfs_trans_handle *trans) ...@@ -185,8 +180,7 @@ static inline void btrfs_clear_skip_qgroup(struct btrfs_trans_handle *trans)
delayed_refs->qgroup_to_skip = 0; delayed_refs->qgroup_to_skip = 0;
} }
int btrfs_end_transaction(struct btrfs_trans_handle *trans, int btrfs_end_transaction(struct btrfs_trans_handle *trans);
struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
unsigned int num_items); unsigned int num_items);
struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv( struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv(
...@@ -207,15 +201,11 @@ int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid); ...@@ -207,15 +201,11 @@ int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid);
void btrfs_add_dead_root(struct btrfs_root *root); void btrfs_add_dead_root(struct btrfs_root *root);
int btrfs_defrag_root(struct btrfs_root *root); int btrfs_defrag_root(struct btrfs_root *root);
int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
int btrfs_commit_transaction(struct btrfs_trans_handle *trans, int btrfs_commit_transaction(struct btrfs_trans_handle *trans);
struct btrfs_root *root);
int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
int wait_for_unblock); int wait_for_unblock);
int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans);
struct btrfs_root *root); int btrfs_should_end_transaction(struct btrfs_trans_handle *trans);
int btrfs_should_end_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
void btrfs_throttle(struct btrfs_fs_info *fs_info); void btrfs_throttle(struct btrfs_fs_info *fs_info);
int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_root *root);
......
...@@ -5695,7 +5695,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -5695,7 +5695,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
btrfs_free_path(path); btrfs_free_path(path);
/* step 4: commit the transaction, which also unpins the blocks */ /* step 4: commit the transaction, which also unpins the blocks */
ret = btrfs_commit_transaction(trans, fs_info->tree_root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
return ret; return ret;
...@@ -5707,7 +5707,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree) ...@@ -5707,7 +5707,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
return 0; return 0;
error: error:
if (wc.trans) if (wc.trans)
btrfs_end_transaction(wc.trans, fs_info->tree_root); btrfs_end_transaction(wc.trans);
btrfs_free_path(path); btrfs_free_path(path);
return ret; return ret;
} }
......
...@@ -252,7 +252,7 @@ static int btrfs_uuid_iter_rem(struct btrfs_root *uuid_root, u8 *uuid, u8 type, ...@@ -252,7 +252,7 @@ static int btrfs_uuid_iter_rem(struct btrfs_root *uuid_root, u8 *uuid, u8 type,
} }
ret = btrfs_uuid_tree_rem(trans, uuid_root->fs_info, uuid, type, subid); ret = btrfs_uuid_tree_rem(trans, uuid_root->fs_info, uuid, type, subid);
btrfs_end_transaction(trans, uuid_root); btrfs_end_transaction(trans);
out: out:
return ret; return ret;
......
...@@ -1773,7 +1773,7 @@ static int btrfs_rm_dev_item(struct btrfs_fs_info *fs_info, ...@@ -1773,7 +1773,7 @@ static int btrfs_rm_dev_item(struct btrfs_fs_info *fs_info,
goto out; goto out;
out: out:
btrfs_free_path(path); btrfs_free_path(path);
btrfs_commit_transaction(trans, root); btrfs_commit_transaction(trans);
return ret; return ret;
} }
...@@ -2475,7 +2475,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path) ...@@ -2475,7 +2475,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path)
fs_info->num_tolerated_disk_barrier_failures = fs_info->num_tolerated_disk_barrier_failures =
btrfs_calc_num_tolerated_disk_barrier_failures(fs_info); btrfs_calc_num_tolerated_disk_barrier_failures(fs_info);
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
if (seeding_dev) { if (seeding_dev) {
mutex_unlock(&uuid_mutex); mutex_unlock(&uuid_mutex);
...@@ -2494,7 +2494,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path) ...@@ -2494,7 +2494,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path)
return 0; return 0;
return PTR_ERR(trans); return PTR_ERR(trans);
} }
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
} }
/* Update ctime/mtime for libblkid */ /* Update ctime/mtime for libblkid */
...@@ -2502,7 +2502,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path) ...@@ -2502,7 +2502,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, char *device_path)
return ret; return ret;
error_trans: error_trans:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
rcu_string_free(device->name); rcu_string_free(device->name);
btrfs_sysfs_rm_device_link(fs_info->fs_devices, device); btrfs_sysfs_rm_device_link(fs_info->fs_devices, device);
kfree(device); kfree(device);
...@@ -2899,7 +2899,6 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, ...@@ -2899,7 +2899,6 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
static int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset) static int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
{ {
struct btrfs_root *root = fs_info->chunk_root; struct btrfs_root *root = fs_info->chunk_root;
struct btrfs_root *extent_root = fs_info->extent_root;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
int ret; int ret;
...@@ -2941,7 +2940,7 @@ static int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset) ...@@ -2941,7 +2940,7 @@ static int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
* chunk tree entries * chunk tree entries
*/ */
ret = btrfs_remove_chunk(trans, fs_info, chunk_offset); ret = btrfs_remove_chunk(trans, fs_info, chunk_offset);
btrfs_end_transaction(trans, extent_root); btrfs_end_transaction(trans);
return ret; return ret;
} }
...@@ -3067,7 +3066,7 @@ static int insert_balance_item(struct btrfs_fs_info *fs_info, ...@@ -3067,7 +3066,7 @@ static int insert_balance_item(struct btrfs_fs_info *fs_info,
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
out: out:
btrfs_free_path(path); btrfs_free_path(path);
err = btrfs_commit_transaction(trans, root); err = btrfs_commit_transaction(trans);
if (err && !ret) if (err && !ret)
ret = err; ret = err;
return ret; return ret;
...@@ -3106,7 +3105,7 @@ static int del_balance_item(struct btrfs_fs_info *fs_info) ...@@ -3106,7 +3105,7 @@ static int del_balance_item(struct btrfs_fs_info *fs_info)
ret = btrfs_del_item(trans, root, path); ret = btrfs_del_item(trans, root, path);
out: out:
btrfs_free_path(path); btrfs_free_path(path);
err = btrfs_commit_transaction(trans, root); err = btrfs_commit_transaction(trans);
if (err && !ret) if (err && !ret)
ret = err; ret = err;
return ret; return ret;
...@@ -3513,7 +3512,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info) ...@@ -3513,7 +3512,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
ret = btrfs_grow_device(trans, device, old_size); ret = btrfs_grow_device(trans, device, old_size);
if (ret) { if (ret) {
btrfs_end_transaction(trans, dev_root); btrfs_end_transaction(trans);
/* btrfs_grow_device never returns ret > 0 */ /* btrfs_grow_device never returns ret > 0 */
WARN_ON(ret > 0); WARN_ON(ret > 0);
btrfs_info_in_rcu(fs_info, btrfs_info_in_rcu(fs_info,
...@@ -3523,7 +3522,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info) ...@@ -3523,7 +3522,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
goto error; goto error;
} }
btrfs_end_transaction(trans, dev_root); btrfs_end_transaction(trans);
} }
/* step two, relocate all the chunks */ /* step two, relocate all the chunks */
...@@ -3653,7 +3652,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info) ...@@ -3653,7 +3652,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
ret = btrfs_force_chunk_alloc(trans, fs_info, ret = btrfs_force_chunk_alloc(trans, fs_info,
BTRFS_BLOCK_GROUP_DATA); BTRFS_BLOCK_GROUP_DATA);
btrfs_end_transaction(trans, chunk_root); btrfs_end_transaction(trans);
if (ret < 0) { if (ret < 0) {
mutex_unlock(&fs_info->delete_unused_bgs_mutex); mutex_unlock(&fs_info->delete_unused_bgs_mutex);
goto error; goto error;
...@@ -4182,7 +4181,7 @@ static int btrfs_uuid_scan_kthread(void *data) ...@@ -4182,7 +4181,7 @@ static int btrfs_uuid_scan_kthread(void *data)
skip: skip:
if (trans) { if (trans) {
ret = btrfs_end_transaction(trans, fs_info->uuid_root); ret = btrfs_end_transaction(trans);
trans = NULL; trans = NULL;
if (ret) if (ret)
break; break;
...@@ -4207,7 +4206,7 @@ static int btrfs_uuid_scan_kthread(void *data) ...@@ -4207,7 +4206,7 @@ static int btrfs_uuid_scan_kthread(void *data)
out: out:
btrfs_free_path(path); btrfs_free_path(path);
if (trans && !IS_ERR(trans)) if (trans && !IS_ERR(trans))
btrfs_end_transaction(trans, fs_info->uuid_root); btrfs_end_transaction(trans);
if (ret) if (ret)
btrfs_warn(fs_info, "btrfs_uuid_scan_kthread failed %d", ret); btrfs_warn(fs_info, "btrfs_uuid_scan_kthread failed %d", ret);
else else
...@@ -4301,13 +4300,13 @@ int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info) ...@@ -4301,13 +4300,13 @@ int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info)
if (IS_ERR(uuid_root)) { if (IS_ERR(uuid_root)) {
ret = PTR_ERR(uuid_root); ret = PTR_ERR(uuid_root);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, tree_root); btrfs_end_transaction(trans);
return ret; return ret;
} }
fs_info->uuid_root = uuid_root; fs_info->uuid_root = uuid_root;
ret = btrfs_commit_transaction(trans, tree_root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
return ret; return ret;
...@@ -4479,7 +4478,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) ...@@ -4479,7 +4478,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
checked_pending_chunks = true; checked_pending_chunks = true;
failed = 0; failed = 0;
retried = false; retried = false;
ret = btrfs_commit_transaction(trans, root); ret = btrfs_commit_transaction(trans);
if (ret) if (ret)
goto done; goto done;
goto again; goto again;
...@@ -4497,7 +4496,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size) ...@@ -4497,7 +4496,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
/* Now btrfs_update_device() will change the on-disk size. */ /* Now btrfs_update_device() will change the on-disk size. */
ret = btrfs_update_device(trans, device); ret = btrfs_update_device(trans, device);
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
done: done:
btrfs_free_path(path); btrfs_free_path(path);
if (ret) { if (ret) {
......
...@@ -259,7 +259,7 @@ int __btrfs_setxattr(struct btrfs_trans_handle *trans, ...@@ -259,7 +259,7 @@ int __btrfs_setxattr(struct btrfs_trans_handle *trans,
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
BUG_ON(ret); BUG_ON(ret);
out: out:
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册