Skip to content

Commit

Permalink
btrfs: remove root parameter from transaction commit/end routines
Browse files Browse the repository at this point in the history
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: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Jeff Mahoney authored and David Sterba committed Dec 6, 2016
1 parent bf89d38 commit 3a45bb2
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 211 deletions.
2 changes: 1 addition & 1 deletion fs/btrfs/backref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/delayed-inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1345,7 +1345,7 @@ static void btrfs_async_run_delayed_root(struct btrfs_work *work)
__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:
Expand Down
10 changes: 5 additions & 5 deletions fs/btrfs/dev-replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ static int cleaner_kthread(void *arg)
} 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",
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
31 changes: 15 additions & 16 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -4175,7 +4175,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)

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;
Expand Down Expand Up @@ -4220,7 +4220,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)
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;
/*
Expand All @@ -4232,7 +4232,7 @@ int btrfs_alloc_data_chunk_ondemand(struct inode *inode, u64 bytes)
mutex_unlock(&fs_info->cleaner_delayed_iput_mutex);
goto again;
} else {
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
}
}

Expand Down Expand Up @@ -4824,7 +4824,7 @@ static int may_commit_transaction(struct btrfs_root *root,
if (IS_ERR(trans))
return -ENOSPC;

return btrfs_commit_transaction(trans, root);
return btrfs_commit_transaction(trans);
}

struct reserve_ticket {
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand Down Expand Up @@ -7854,7 +7854,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
else
ret = 0;
if (!exist)
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
if (ret)
goto out;
}
Expand Down Expand Up @@ -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,
Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -9380,7 +9380,7 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root,
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)
Expand Down Expand Up @@ -9425,7 +9425,7 @@ int btrfs_inc_block_group_ro(struct btrfs_root *root,
}
mutex_unlock(&fs_info->ro_block_group_mutex);

btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans);
return ret;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
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);
Expand All @@ -2664,7 +2664,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
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);
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/free-space-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down Expand Up @@ -1278,15 +1278,15 @@ 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;

return 0;

abort:
btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans, tree_root);
btrfs_end_transaction(trans);
return ret;
}

Expand Down
Loading

0 comments on commit 3a45bb2

Please sign in to comment.