diff options
author | Qu Wenruo <wqu@suse.com> | 2023-07-15 14:08:29 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2023-08-21 15:52:16 +0300 |
commit | cb22964f1dad228fc2a1e5aba50c16b4b5680cd5 (patch) | |
tree | 64636d60c2c03f5438a567c6b1f3b20444f8eedc /rust/bindings/bindings_helper.h | |
parent | 5864f1da6b165fc4735f02140b04fbfcb6ff27bf (diff) | |
download | linux-cb22964f1dad228fc2a1e5aba50c16b4b5680cd5.tar.xz |
btrfs: refactor extent buffer bitmaps operations
[BACKGROUND]
Currently we handle extent bitmaps manually in
extent_buffer_bitmap_set() and extent_buffer_bitmap_clear().
Although with various helpers like eb_bitmap_offset() it's still a little
messy to read. The code seems to be a copy of bitmap_set(), but with
all the cross-page handling embedded into the code.
[ENHANCEMENT]
This patch would enhance the readability by introducing two helpers:
- memset_extent_buffer()
To handle the byte aligned range, thus all the cross-page handling is
done there.
- extent_buffer_get_byte()
This for the first and the last byte operations, which only need to
grab one byte, thus no need for any cross-page handling.
So we can split both extent_buffer_bitmap_set() and
extent_buffer_bitmap_clear() into 3 parts:
- Handle the first byte
If the range fits inside the first byte, we can exit early.
- Handle the byte aligned part
This is the part which can have cross-page operations, and it would
be handled by memset_extent_buffer().
- Handle the last byte
This refactoring does not only make the code a little easier to read,
but also makes later folio/page switch much easier, as the switch only
needs to be done inside memset_extent_buffer() and extent_buffer_get_byte().
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'rust/bindings/bindings_helper.h')
0 files changed, 0 insertions, 0 deletions