Commit 7447555f authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Factor out common extent locking code in submit_compressed_extents

Irrespective of whether the compress code fell back to uncompressed or
a compressed extent has to be submitted, the extent range is always
locked. So factor out the common lock_extent call at the beginning of
the loop. No functional changes just removes one duplicate lock_extent
call.
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4336650a
...@@ -725,16 +725,15 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk) ...@@ -725,16 +725,15 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
async_extent = list_entry(async_chunk->extents.next, async_extent = list_entry(async_chunk->extents.next,
struct async_extent, list); struct async_extent, list);
list_del(&async_extent->list); list_del(&async_extent->list);
retry: retry:
lock_extent(io_tree, async_extent->start,
async_extent->start + async_extent->ram_size - 1);
/* did the compression code fall back to uncompressed IO? */ /* did the compression code fall back to uncompressed IO? */
if (!async_extent->pages) { if (!async_extent->pages) {
int page_started = 0; int page_started = 0;
unsigned long nr_written = 0; unsigned long nr_written = 0;
lock_extent(io_tree, async_extent->start,
async_extent->start +
async_extent->ram_size - 1);
/* allocate blocks */ /* allocate blocks */
ret = cow_file_range(inode, async_chunk->locked_page, ret = cow_file_range(inode, async_chunk->locked_page,
async_extent->start, async_extent->start,
...@@ -766,9 +765,6 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk) ...@@ -766,9 +765,6 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
continue; continue;
} }
lock_extent(io_tree, async_extent->start,
async_extent->start + async_extent->ram_size - 1);
ret = btrfs_reserve_extent(root, async_extent->ram_size, ret = btrfs_reserve_extent(root, async_extent->ram_size,
async_extent->compressed_size, async_extent->compressed_size,
async_extent->compressed_size, async_extent->compressed_size,
......
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