Skip to content

Commit 7c9acd4

Browse files
josefbacikkdave
authored andcommitted
btrfs: push extent lock into run_delalloc_nocow
run_delalloc_nocow is a bit special as it walks through the file extents for the inode and determines what it can nocow and what it can't. This is the more complicated area for extent locking, so start with this function. Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent c0707c9 commit 7c9acd4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

fs/btrfs/inode.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,8 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
19771977
*/
19781978
ASSERT(!btrfs_is_zoned(fs_info) || btrfs_is_data_reloc_root(root));
19791979

1980+
lock_extent(&inode->io_tree, start, end, NULL);
1981+
19801982
path = btrfs_alloc_path();
19811983
if (!path) {
19821984
ret = -ENOMEM;
@@ -2249,11 +2251,6 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
22492251
const bool zoned = btrfs_is_zoned(inode->root->fs_info);
22502252
int ret;
22512253

2252-
/*
2253-
* We're unlocked by the different fill functions below.
2254-
*/
2255-
lock_extent(&inode->io_tree, start, end, NULL);
2256-
22572254
/*
22582255
* The range must cover part of the @locked_page, or a return of 1
22592256
* can confuse the caller.
@@ -2266,6 +2263,11 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
22662263
goto out;
22672264
}
22682265

2266+
/*
2267+
* We're unlocked by the different fill functions below.
2268+
*/
2269+
lock_extent(&inode->io_tree, start, end, NULL);
2270+
22692271
if (btrfs_inode_can_compress(inode) &&
22702272
inode_need_compress(inode, start, end) &&
22712273
run_delalloc_compressed(inode, locked_page, start, end, wbc))

0 commit comments

Comments
 (0)