Commit 3a45bb20 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba
Browse files

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: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent bf89d38f
......@@ -2056,7 +2056,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
out:
if (!search_commit_root) {
btrfs_put_tree_mod_seq(fs_info, &tree_mod_seq_elem);
btrfs_end_transaction(trans, fs_info->extent_root);
btrfs_end_transaction(trans);
} else {
up_read(&fs_info->commit_root_sem);
}
......
......@@ -1280,7 +1280,7 @@ int btrfs_commit_inode_delayed_inode(struct inode *inode)
btrfs_free_path(path);
trans->block_rsv = block_rsv;
trans_out:
btrfs_end_transaction(trans, delayed_node->root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
out:
btrfs_release_delayed_node(delayed_node);
......@@ -1345,7 +1345,7 @@ again:
__btrfs_commit_inode_delayed_items(trans, path, delayed_node);
trans->block_rsv = block_rsv;
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty_nodelay(root->fs_info);
release_path:
......
......@@ -335,7 +335,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name,
*/
trans = btrfs_attach_transaction(root);
if (!IS_ERR(trans)) {
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
if (ret)
return ret;
} else if (PTR_ERR(trans) != -ENOENT) {
......@@ -397,7 +397,7 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, char *tgtdev_name,
goto leave;
}
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
WARN_ON(ret);
/* the disk copy procedure reuses the scrub code */
......@@ -513,7 +513,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
return PTR_ERR(trans);
}
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
WARN_ON(ret);
mutex_lock(&uuid_mutex);
......@@ -603,7 +603,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
/* write back the superblocks */
trans = btrfs_start_transaction(root, 0);
if (!IS_ERR(trans))
btrfs_commit_transaction(trans, root);
btrfs_commit_transaction(trans);
mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
......@@ -718,7 +718,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
return PTR_ERR(trans);
}
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
WARN_ON(ret);
if (tgt_device)
btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device);
......
......@@ -1913,7 +1913,7 @@ sleep:
} else {
int ret;
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
if (ret)
btrfs_err(fs_info,
"cleaner open transaction commit returned %d",
......@@ -1965,9 +1965,9 @@ static int transaction_kthread(void *arg)
goto sleep;
}
if (transid == trans->transid) {
btrfs_commit_transaction(trans, root);
btrfs_commit_transaction(trans);
} else {
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
}
sleep:
wake_up_process(fs_info->cleaner_kthread);
......@@ -3901,7 +3901,7 @@ int btrfs_commit_super(struct btrfs_fs_info *fs_info)
trans = btrfs_join_transaction(root);
if (IS_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)
......
......@@ -2868,7 +2868,7 @@ static void delayed_ref_async_start(struct btrfs_work *work)
if (ret)
async->error = ret;
end:
ret = btrfs_end_transaction(trans, async->root);
ret = btrfs_end_transaction(trans);
if (ret && !async->error)
async->error = ret;
done:
......@@ -4175,7 +4175,7 @@ alloc:
ret = do_chunk_alloc(trans, fs_info, alloc_target,
CHUNK_ALLOC_NO_FORCE);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret < 0) {
if (ret != -ENOSPC)
return ret;
......@@ -4220,7 +4220,7 @@ commit_trans:
test_bit(BTRFS_TRANS_HAVE_FREE_BGS,
&trans->transaction->flags) ||
need_commit > 0) {
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
if (ret)
return ret;
/*
......@@ -4232,7 +4232,7 @@ commit_trans:
mutex_unlock(&fs_info->cleaner_delayed_iput_mutex);
goto again;
} else {
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
}
}
......@@ -4824,7 +4824,7 @@ commit:
if (IS_ERR(trans))
return -ENOSPC;
return btrfs_commit_transaction(trans, root);
return btrfs_commit_transaction(trans);
}
struct reserve_ticket {
......@@ -4857,7 +4857,7 @@ static int flush_space(struct btrfs_root *root,
break;
}
ret = btrfs_run_delayed_items_nr(trans, fs_info, nr);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
break;
case FLUSH_DELALLOC:
case FLUSH_DELALLOC_WAIT:
......@@ -4873,7 +4873,7 @@ static int flush_space(struct btrfs_root *root,
ret = do_chunk_alloc(trans, fs_info,
btrfs_get_alloc_profile(root, 0),
CHUNK_ALLOC_NO_FORCE);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret > 0 || ret == -ENOSPC)
ret = 0;
break;
......@@ -7854,7 +7854,7 @@ loop:
else
ret = 0;
if (!exist)
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret)
goto out;
}
......@@ -9106,7 +9106,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
}
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))) {
ret = btrfs_update_root(trans, tree_root,
&root->root_key,
......@@ -9117,7 +9117,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
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)) {
btrfs_debug(fs_info,
"drop snapshot early exit");
......@@ -9171,7 +9171,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
}
root_dropped = true;
out_end_trans:
btrfs_end_transaction_throttle(trans, tree_root);
btrfs_end_transaction_throttle(trans);
out_free:
kfree(wc);
btrfs_free_path(path);
......@@ -9380,7 +9380,7 @@ again:
u64 transid = trans->transid;
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);
if (ret)
......@@ -9425,7 +9425,7 @@ out:
}
mutex_unlock(&fs_info->ro_block_group_mutex);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
return ret;
}
......@@ -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",
block_group->key.objectid);
mutex_unlock(&fs_info->chunk_mutex);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
out:
btrfs_put_block_group(block_group);
return ret;
......@@ -10596,7 +10596,6 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
{
struct btrfs_block_group_cache *block_group;
struct btrfs_space_info *space_info;
struct btrfs_root *root = fs_info->extent_root;
struct btrfs_trans_handle *trans;
int ret = 0;
......@@ -10747,7 +10746,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
btrfs_get_block_group(block_group);
}
end_trans:
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
next:
mutex_unlock(&fs_info->delete_unused_bgs_mutex);
btrfs_put_block_group(block_group);
......
......@@ -4540,7 +4540,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
root->objectid,
btrfs_ino(inode), bytenr);
if (trans)
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret < 0)
goto out_free;
if (ret)
......
......@@ -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.
*/
if (ctx.io_err) {
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
ret = ctx.io_err;
goto out;
}
......@@ -2155,20 +2155,20 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
if (!ret) {
ret = btrfs_sync_log(trans, root, &ctx);
if (!ret) {
ret = btrfs_end_transaction(trans, root);
ret = btrfs_end_transaction(trans);
goto out;
}
}
if (!full_sync) {
ret = btrfs_wait_ordered_range(inode, start, len);
if (ret) {
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
goto out;
}
}
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
} else {
ret = btrfs_end_transaction(trans, root);
ret = btrfs_end_transaction(trans);
}
out:
return ret > 0 ? -EIO : ret;
......@@ -2574,7 +2574,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
break;
}
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
trans = btrfs_start_transaction(root, rsv_count);
......@@ -2642,7 +2642,7 @@ out_trans:
trans->block_rsv = &fs_info->trans_block_rsv;
ret = btrfs_update_inode(trans, root, inode);
updated_inode = true;
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
out_free:
btrfs_free_path(path);
......@@ -2664,7 +2664,7 @@ out_only_mutex:
err = PTR_ERR(trans);
} else {
err = btrfs_update_inode(trans, root, inode);
ret = btrfs_end_transaction(trans, root);
ret = btrfs_end_transaction(trans);
}
}
inode_unlock(inode);
......@@ -2906,9 +2906,9 @@ static long btrfs_fallocate(struct file *file, int mode,
btrfs_ordered_update_i_size(inode, actual_end, NULL);
ret = btrfs_update_inode(trans, root, inode);
if (ret)
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
else
ret = btrfs_end_transaction(trans, root);
ret = btrfs_end_transaction(trans);
}
}
out_unlock:
......
......@@ -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);
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)
return ret;
......@@ -1198,7 +1198,7 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info)
abort:
clear_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags);
btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, tree_root);
btrfs_end_transaction(trans);
return ret;
}
......@@ -1278,7 +1278,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
free_extent_buffer(free_space_root->commit_root);
kfree(free_space_root);
ret = btrfs_commit_transaction(trans, tree_root);
ret = btrfs_commit_transaction(trans);
if (ret)
return ret;
......@@ -1286,7 +1286,7 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info)
abort:
btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, tree_root);
btrfs_end_transaction(trans);
return ret;
}
......
......@@ -326,7 +326,7 @@ out:
*/
btrfs_qgroup_free_data(inode, 0, PAGE_SIZE);
btrfs_free_path(path);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
return ret;
}
......@@ -1534,7 +1534,7 @@ out_check:
}
error:
err = btrfs_end_transaction(trans, root);
err = btrfs_end_transaction(trans);
if (!ret)
ret = err;
......@@ -2665,7 +2665,7 @@ again:
out_free_path:
btrfs_release_path(path);
path->leave_spinning = 0;
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
out_unlock:
unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start, lock_end,
&cached, GFP_NOFS);
......@@ -3011,7 +3011,7 @@ out:
if (root != fs_info->tree_root)
btrfs_delalloc_release_metadata(inode, ordered_extent->len);
if (trans)
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret || truncated) {
u64 start, end;
......@@ -3519,7 +3519,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
found_key.objectid);
ret = btrfs_del_orphan_item(trans, root,
found_key.objectid);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret)
goto out;
continue;
......@@ -3549,7 +3549,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
goto out;
}
ret = btrfs_orphan_add(trans, inode);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret) {
iput(inode);
goto out;
......@@ -3580,7 +3580,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state)) {
trans = btrfs_join_transaction(root);
if (!IS_ERR(trans))
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
}
if (nr_unlink)
......@@ -4156,7 +4156,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
}
out:
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(root->fs_info);
return ret;
}
......@@ -4293,7 +4293,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
BTRFS_I(dir)->last_unlink_trans = last_unlink_trans;
}
out:
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(root->fs_info);
return err;
......@@ -4453,7 +4453,7 @@ search_again:
* bytes_deleted is > 0, it will be huge by the time we get here
*/
if (be_nice && bytes_deleted > SZ_32M) {
if (btrfs_should_end_transaction(trans, root)) {
if (btrfs_should_end_transaction(trans)) {
err = -EAGAIN;
goto error;
}
......@@ -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);
if (ret) {
btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
return ret;
}
......@@ -4868,7 +4868,7 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
btrfs_abort_transaction(trans, ret);
else
btrfs_update_inode(trans, root, inode);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
return ret;
}
......@@ -5032,7 +5032,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
pagecache_isize_extended(inode, oldsize, newsize);
ret = btrfs_update_inode(trans, root, inode);
btrfs_end_write_no_snapshoting(root);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
} else {
/*
......@@ -5063,7 +5063,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
* will be consistent.
*/
ret = btrfs_orphan_add(trans, inode);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret)
return ret;
......@@ -5094,7 +5094,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
err = btrfs_orphan_del(trans, inode);
if (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)
* again.
*/
if (ret) {
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
if (ret) {
btrfs_orphan_del(NULL, inode);
btrfs_free_block_rsv(fs_info, rsv);
......@@ -5373,7 +5373,7 @@ void btrfs_evict_inode(struct inode *inode)
break;
trans->block_rsv = &fs_info->trans_block_rsv;
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
trans = NULL;
btrfs_btree_balance_dirty(fs_info);
}
......@@ -5396,7 +5396,7 @@ void btrfs_evict_inode(struct inode *inode)
root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID))
btrfs_return_ino(root, btrfs_ino(inode));
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
no_delete:
btrfs_remove_delayed_node(inode);
......@@ -5975,7 +5975,7 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc)
trans = btrfs_join_transaction(root);
if (IS_ERR(trans))
return PTR_ERR(trans);
ret = btrfs_commit_transaction(trans, root);
ret = btrfs_commit_transaction(trans);
}
return ret;
}
......@@ -6003,14 +6003,14 @@ static int btrfs_dirty_inode(struct inode *inode)
ret = btrfs_update_inode(trans, root, inode);
if (ret && ret == -ENOSPC) {
/* whoops, lets try again with the full transaction */
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans))
return PTR_ERR(trans);
ret = btrfs_update_inode(trans, root, inode);
}
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (BTRFS_I(inode)->delayed_node)
btrfs_balance_delayed_items(fs_info);
......@@ -6448,7 +6448,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
}
out_unlock:
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_balance_delayed_items(fs_info);
btrfs_btree_balance_dirty(fs_info);
if (drop_inode) {
......@@ -6524,7 +6524,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
d_instantiate(dentry, inode);
out_unlock:
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (err && drop_inode_on_err) {
inode_dec_link_count(inode);
iput(inode);
......@@ -6606,7 +6606,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
btrfs_balance_delayed_items(fs_info);
fail:
if (trans)
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (drop_inode) {
inode_dec_link_count(inode);
iput(inode);
......@@ -6675,7 +6675,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
drop_on_err = 0;
out_fail:
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (drop_on_err) {
inode_dec_link_count(inode);
iput(inode);
......@@ -7063,7 +7063,7 @@ out:
btrfs_free_path(path);
if (trans) {
ret = btrfs_end_transaction(trans, root);
ret = btrfs_end_transaction(trans);
if (!err)
err = ret;
}
......@@ -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),
key.offset - backref_offset, disk_bytenr);
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret) {
ret = 0;
goto out;
......@@ -9200,7 +9200,7 @@ static int btrfs_truncate(struct inode *inode)
break;
}
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
trans = btrfs_start_transaction(root, 2);
......@@ -9229,7 +9229,7 @@ static int btrfs_truncate(struct inode *inode)
if (ret && !err)
err = ret;
ret = btrfs_end_transaction(trans, root);
ret = btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
}
out:
......@@ -9697,7 +9697,7 @@ out_fail:
dest_log_pinned = false;
}
}
ret = btrfs_end_transaction(trans, root);
ret = btrfs_end_transaction(trans);
out_notrans:
if (new_ino == BTRFS_FIRST_FREE_OBJECTID)
up_read(&fs_info->subvol_sem);
......@@ -9967,7 +9967,7 @@ out_fail:
btrfs_end_log_trans(root);
log_pinned = false;
}
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
out_notrans:
if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
up_read(&fs_info->subvol_sem);
......@@ -10300,7 +10300,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
d_instantiate(dentry, inode);
out_unlock:
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (drop_inode) {
inode_dec_link_count(inode);
iput(inode);
......@@ -10356,7 +10356,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
min_size, 0, *alloc_hint, &ins, 1, 0);
if (ret) {
if (own_trans)