Skip to content

Commit

Permalink
btrfs: root->fs_info cleanup, access fs_info->delayed_root directly
Browse files Browse the repository at this point in the history
This results in btrfs_assert_delayed_root_empty and
btrfs_destroy_delayed_inode taking an fs_info instead of a root.

Signed-off-by: Jeff Mahoney <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
jeffmahoney authored and kdave committed Dec 6, 2016
1 parent 0b246af commit ccdf9b3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
23 changes: 6 additions & 17 deletions fs/btrfs/delayed-inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ static inline int btrfs_is_continuous_delayed_item(
return 0;
}

static inline struct btrfs_delayed_root *btrfs_get_delayed_root(
struct btrfs_root *root)
{
return root->fs_info->delayed_root;
}

static struct btrfs_delayed_node *btrfs_get_delayed_node(struct inode *inode)
{
struct btrfs_inode *btrfs_inode = BTRFS_I(inode);
Expand Down Expand Up @@ -1163,7 +1157,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans,
block_rsv = trans->block_rsv;
trans->block_rsv = &fs_info->delayed_block_rsv;

delayed_root = btrfs_get_delayed_root(root);
delayed_root = fs_info->delayed_root;

curr_node = btrfs_first_delayed_node(delayed_root);
while (curr_node && (!count || (count && nr--))) {
Expand Down Expand Up @@ -1390,11 +1384,9 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
return 0;
}

void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
void btrfs_assert_delayed_root_empty(struct btrfs_fs_info *fs_info)
{
struct btrfs_delayed_root *delayed_root;
delayed_root = btrfs_get_delayed_root(root);
WARN_ON(btrfs_first_delayed_node(delayed_root));
WARN_ON(btrfs_first_delayed_node(fs_info->delayed_root));
}

static int could_end_wait(struct btrfs_delayed_root *delayed_root, int seq)
Expand All @@ -1415,7 +1407,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
struct btrfs_delayed_root *delayed_root;
struct btrfs_fs_info *fs_info = root->fs_info;

delayed_root = btrfs_get_delayed_root(root);
delayed_root = fs_info->delayed_root;

if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
return;
Expand Down Expand Up @@ -1980,14 +1972,11 @@ void btrfs_kill_all_delayed_nodes(struct btrfs_root *root)
}
}

void btrfs_destroy_delayed_inodes(struct btrfs_root *root)
void btrfs_destroy_delayed_inodes(struct btrfs_fs_info *fs_info)
{
struct btrfs_delayed_root *delayed_root;
struct btrfs_delayed_node *curr_node, *prev_node;

delayed_root = btrfs_get_delayed_root(root);

curr_node = btrfs_first_delayed_node(delayed_root);
curr_node = btrfs_first_delayed_node(fs_info->delayed_root);
while (curr_node) {
__btrfs_kill_delayed_node(curr_node);

Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/delayed-inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int btrfs_delayed_delete_inode_ref(struct inode *inode);
void btrfs_kill_all_delayed_nodes(struct btrfs_root *root);

/* Used for clean the transaction */
void btrfs_destroy_delayed_inodes(struct btrfs_root *root);
void btrfs_destroy_delayed_inodes(struct btrfs_fs_info *fs_info);

/* Used for readdir() */
bool btrfs_readdir_get_delayed_items(struct inode *inode,
Expand All @@ -153,6 +153,6 @@ int __init btrfs_delayed_inode_init(void);
void btrfs_delayed_inode_exit(void);

/* for debugging */
void btrfs_assert_delayed_root_empty(struct btrfs_root *root);
void btrfs_assert_delayed_root_empty(struct btrfs_fs_info *fs_info);

#endif
8 changes: 4 additions & 4 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4587,8 +4587,8 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
cur_trans->state = TRANS_STATE_UNBLOCKED;
wake_up(&fs_info->transaction_wait);

btrfs_destroy_delayed_inodes(root);
btrfs_assert_delayed_root_empty(root);
btrfs_destroy_delayed_inodes(fs_info);
btrfs_assert_delayed_root_empty(fs_info);

btrfs_destroy_marked_extents(root, &cur_trans->dirty_pages,
EXTENT_DIRTY);
Expand Down Expand Up @@ -4649,8 +4649,8 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root)
}
spin_unlock(&fs_info->trans_lock);
btrfs_destroy_all_ordered_extents(fs_info);
btrfs_destroy_delayed_inodes(root);
btrfs_assert_delayed_root_empty(root);
btrfs_destroy_delayed_inodes(fs_info);
btrfs_assert_delayed_root_empty(fs_info);
btrfs_destroy_pinned_extent(root, fs_info->pinned_extents);
btrfs_destroy_all_delalloc_inodes(fs_info);
mutex_unlock(&fs_info->transaction_kthread_mutex);
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
* make sure none of the code above managed to slip in a
* delayed item
*/
btrfs_assert_delayed_root_empty(root);
btrfs_assert_delayed_root_empty(fs_info);

WARN_ON(cur_trans != trans->transaction);

Expand Down

0 comments on commit ccdf9b3

Please sign in to comment.