Skip to content

Commit 7447555

Browse files
lorddoskiaskdave
authored andcommitted
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: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 4336650 commit 7447555

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

‎fs/btrfs/inode.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -725,16 +725,15 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
725725
async_extent = list_entry(async_chunk->extents.next,
726726
struct async_extent, list);
727727
list_del(&async_extent->list);
728+
728729
retry:
730+
lock_extent(io_tree, async_extent->start,
731+
async_extent->start + async_extent->ram_size - 1);
729732
/* did the compression code fall back to uncompressed IO? */
730733
if (!async_extent->pages) {
731734
int page_started = 0;
732735
unsigned long nr_written = 0;
733736

734-
lock_extent(io_tree, async_extent->start,
735-
async_extent->start +
736-
async_extent->ram_size - 1);
737-
738737
/* allocate blocks */
739738
ret = cow_file_range(inode, async_chunk->locked_page,
740739
async_extent->start,
@@ -766,9 +765,6 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
766765
continue;
767766
}
768767

769-
lock_extent(io_tree, async_extent->start,
770-
async_extent->start + async_extent->ram_size - 1);
771-
772768
ret = btrfs_reserve_extent(root, async_extent->ram_size,
773769
async_extent->compressed_size,
774770
async_extent->compressed_size,

0 commit comments

Comments
 (0)