Commit 4c5d166f authored by David Sterba's avatar David Sterba

btrfs: pass btrfs_inode to btrfs_set_delalloc_extent

The function is for internal interfaces so we should use the
btrfs_inode.
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 2454151c
...@@ -471,7 +471,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans, ...@@ -471,7 +471,7 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args); void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args);
struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns, struct inode *btrfs_new_subvol_inode(struct user_namespace *mnt_userns,
struct inode *dir); struct inode *dir);
void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state, void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
u32 bits); u32 bits);
void btrfs_clear_delalloc_extent(struct inode *inode, void btrfs_clear_delalloc_extent(struct inode *inode,
struct extent_state *state, u32 bits); struct extent_state *state, u32 bits);
......
...@@ -373,7 +373,7 @@ static void set_state_bits(struct extent_io_tree *tree, ...@@ -373,7 +373,7 @@ static void set_state_bits(struct extent_io_tree *tree,
int ret; int ret;
if (tree->inode) if (tree->inode)
btrfs_set_delalloc_extent(&tree->inode->vfs_inode, state, bits); btrfs_set_delalloc_extent(tree->inode, state, bits);
ret = add_extent_changeset(state, bits_to_set, changeset, 1); ret = add_extent_changeset(state, bits_to_set, changeset, 1);
BUG_ON(ret < 0); BUG_ON(ret < 0);
......
...@@ -2421,10 +2421,10 @@ static void btrfs_del_delalloc_inode(struct btrfs_root *root, ...@@ -2421,10 +2421,10 @@ static void btrfs_del_delalloc_inode(struct btrfs_root *root,
* Properly track delayed allocation bytes in the inode and to maintain the * Properly track delayed allocation bytes in the inode and to maintain the
* list of inodes that have pending delalloc work to be done. * list of inodes that have pending delalloc work to be done.
*/ */
void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state, void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
u32 bits) u32 bits)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
if ((bits & EXTENT_DEFRAG) && !(bits & EXTENT_DELALLOC)) if ((bits & EXTENT_DEFRAG) && !(bits & EXTENT_DELALLOC))
WARN_ON(1); WARN_ON(1);
...@@ -2434,14 +2434,14 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state, ...@@ -2434,14 +2434,14 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
* bit, which is only set or cleared with irqs on * bit, which is only set or cleared with irqs on
*/ */
if (!(state->state & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) { if (!(state->state & EXTENT_DELALLOC) && (bits & EXTENT_DELALLOC)) {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = inode->root;
u64 len = state->end + 1 - state->start; u64 len = state->end + 1 - state->start;
u32 num_extents = count_max_extents(fs_info, len); u32 num_extents = count_max_extents(fs_info, len);
bool do_list = !btrfs_is_free_space_inode(BTRFS_I(inode)); bool do_list = !btrfs_is_free_space_inode(inode);
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&inode->lock);
btrfs_mod_outstanding_extents(BTRFS_I(inode), num_extents); btrfs_mod_outstanding_extents(inode, num_extents);
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&inode->lock);
/* For sanity tests */ /* For sanity tests */
if (btrfs_is_testing(fs_info)) if (btrfs_is_testing(fs_info))
...@@ -2449,22 +2449,21 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state, ...@@ -2449,22 +2449,21 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
percpu_counter_add_batch(&fs_info->delalloc_bytes, len, percpu_counter_add_batch(&fs_info->delalloc_bytes, len,
fs_info->delalloc_batch); fs_info->delalloc_batch);
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&inode->lock);
BTRFS_I(inode)->delalloc_bytes += len; inode->delalloc_bytes += len;
if (bits & EXTENT_DEFRAG) if (bits & EXTENT_DEFRAG)
BTRFS_I(inode)->defrag_bytes += len; inode->defrag_bytes += len;
if (do_list && !test_bit(BTRFS_INODE_IN_DELALLOC_LIST, if (do_list && !test_bit(BTRFS_INODE_IN_DELALLOC_LIST,
&BTRFS_I(inode)->runtime_flags)) &inode->runtime_flags))
btrfs_add_delalloc_inodes(root, BTRFS_I(inode)); btrfs_add_delalloc_inodes(root, inode);
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&inode->lock);
} }
if (!(state->state & EXTENT_DELALLOC_NEW) && if (!(state->state & EXTENT_DELALLOC_NEW) &&
(bits & EXTENT_DELALLOC_NEW)) { (bits & EXTENT_DELALLOC_NEW)) {
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&inode->lock);
BTRFS_I(inode)->new_delalloc_bytes += state->end + 1 - inode->new_delalloc_bytes += state->end + 1 - state->start;
state->start; spin_unlock(&inode->lock);
spin_unlock(&BTRFS_I(inode)->lock);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment