Skip to content

Commit 00009d7

Browse files
josefbacikkdave
authored andcommitted
btrfs: push extent lock into run_delalloc_cow
This is used by zoned but also as the fallback for uncompressed extents when we fail to compress the ranges. Push the extent lock into run_dealloc_cow(), and adjust the compression case to take the extent lock after calling run_delalloc_cow(). 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 0e128d4 commit 00009d7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

fs/btrfs/inode.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,13 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
11671167
if (!(start >= locked_page_end || end <= locked_page_start))
11681168
locked_page = async_chunk->locked_page;
11691169
}
1170-
lock_extent(io_tree, start, end, NULL);
11711170

11721171
if (async_extent->compress_type == BTRFS_COMPRESS_NONE) {
11731172
submit_uncompressed_range(inode, async_extent, locked_page);
11741173
goto done;
11751174
}
11761175

1176+
lock_extent(io_tree, start, end, NULL);
11771177
ret = btrfs_reserve_extent(root, async_extent->ram_size,
11781178
async_extent->compressed_size,
11791179
async_extent->compressed_size,
@@ -1722,6 +1722,8 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode,
17221722
u64 done_offset = end;
17231723
int ret;
17241724

1725+
lock_extent(&inode->io_tree, start, end, NULL);
1726+
17251727
while (start <= end) {
17261728
ret = cow_file_range(inode, locked_page, start, end, &done_offset,
17271729
true, false);
@@ -2280,17 +2282,14 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
22802282
run_delalloc_compressed(inode, locked_page, start, end, wbc))
22812283
return 1;
22822284

2283-
/*
2284-
* We're unlocked by the different fill functions below.
2285-
*/
2286-
lock_extent(&inode->io_tree, start, end, NULL);
2287-
2288-
if (zoned)
2285+
if (zoned) {
22892286
ret = run_delalloc_cow(inode, locked_page, start, end, wbc,
22902287
true);
2291-
else
2288+
} else {
2289+
lock_extent(&inode->io_tree, start, end, NULL);
22922290
ret = cow_file_range(inode, locked_page, start, end, NULL,
22932291
false, false);
2292+
}
22942293

22952294
out:
22962295
if (ret < 0)

0 commit comments

Comments
 (0)