]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Optimize unallocated chunks discard
authorNikolay Borisov <nborisov@suse.com>
Wed, 27 Mar 2019 12:24:16 +0000 (14:24 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Apr 2019 17:02:38 +0000 (19:02 +0200)
commitb91058182ee3fc868fb7c204cb2fbbd2e6d4f8a9
tree85a126b664476600d44b3f352f8917635bc7e625
parentc7bca79da592ccfc487b1bb5965d0c6e623e01e9
btrfs: Optimize unallocated chunks discard

Currently unallocated chunks are always trimmed. For example
2 consecutive trims on large storage would trim freespace twice
irrespective of whether the space was actually allocated or not between
those trims.

Optimise this behavior by exploiting the newly introduced alloc_state
tree of btrfs_device. A new CHUNK_TRIMMED bit is used to mark
those unallocated chunks which have been trimmed and have not been
allocated afterwards. On chunk allocation the respective underlying devices'
physical space will have its CHUNK_TRIMMED flag cleared. This avoids
submitting discards for space which hasn't been changed since the last
time discard was issued.

This applies to the single mount period of the filesystem as the
information is not stored permanently.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.h
fs/btrfs/extent_map.c