]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Preallocate chunks in cow_file_range_async
authorNikolay Borisov <nborisov@suse.com>
Tue, 12 Mar 2019 15:20:24 +0000 (17:20 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 2 May 2019 11:48:18 +0000 (13:48 +0200)
commitd4ae605d61531bc0c03bbc177d81a58190f7fb90
tree4669ab3bb24a9279b35c61efb0f4cf5b990b611a
parent1d6a6e7ac984ed1ec02a4f5450a82e9b68a84857
btrfs: Preallocate chunks in cow_file_range_async

This commit changes the implementation of cow_file_range_async in order
to get rid of the BUG_ON in the middle of the loop. Additionally it
reworks the inner loop in the hopes of making it more understandable.

The idea is to make async_cow be a top-level structured, shared amongst
all chunks being sent for compression. This allows to perform one memory
allocation at the beginning and gracefully fail the IO if there isn't
enough memory. Now, each chunk is going to be described by an
async_chunk struct. It's the responsibility of the final chunk
to actually free the memory.

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>
fs/btrfs/inode.c