OSDN Git Service

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)
commit97db120451e20c65bc5f2addfd63e1e8a3f0a39e
tree4669ab3bb24a9279b35c61efb0f4cf5b990b611a
parentc8eaeac7b734347c3afba7008b7af62f37b9c140
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