btrfs: remove le_bitmap_clear()
PATCH 1/2 btrfs: remove le_bitmap_clear()
le_bitmap_clear() was implemented as a parallel to le_bitmap_set() but is actually not being used. This patch removes it.
--- fs/btrfs/extent_io.c | 20 -------------------- fs/btrfs/extent_io.h | 1 - 2 files changed, 21 deletions(-)
fs/btrfs/extent_io.c +0 -20
@@ -5640,26 +5640,6 @@ void le_bitmap_set(u8 *map, unsigned int start, int len) } } -void le_bitmap_clear (u8 *map,unsigned int start,int len) -{ -u8 *p = map +BIT_BYTE (start); -const unsigned int size = start + len; -int bits_to_clear =BITS_PER_BYTE - (start %BITS_PER_BYTE ); -u8 mask_to_clear =BITMAP_FIRST_BYTE_MASK (start); - -while (len - bits_to_clear >=0 ) { - *p &= ~mask_to_clear; - len -= bits_to_clear; - bits_to_clear =BITS_PER_BYTE ; - mask_to_clear = ~0 ; - p++; - } -if (len) { - mask_to_clear &=BITMAP_LAST_BYTE_MASK (size); - *p &= ~mask_to_clear; - } -} -/* * eb_bitmap_offset() - calculate the page and offset of the byte containing the * given bit number
fs/btrfs/extent_io.h +0 -1
@@ -85,7 +85,6 @@ static inline int le_test_bit(int nr, const u8 *addr) }void le_bitmap_set (u8 *map,unsigned int start,int len); -void le_bitmap_clear (u8 *map,unsigned int start,int len);struct extent_state ;struct btrfs_root ;
Signature · 1 line
2.17.0
PATCH 2/2 btrfs: optimize free space tree bitmap conversion
Presently, convert_free_space_to_extents() does a linear scan of the bitmap. We can speed this up with find_next_{bit,zero_bit}_le().
This patch replaces the linear scan with find_next_{bit,zero_bit}_le(). Testing shows a 20-33% decrease in execution time for convert_free_space_to_extents().
---
Since we change bitmap to be unsigned long, we have to do some casting for the bitmap cursor. In le_bitmap_set() it makes sense to use u8, as we are doing bit operations. Everywhere else, we're just using it for pointer arithmetic and not directly accessing it, so char seems more appropriate.
Howard
fs/btrfs/extent_io.c | 4 +-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/free-space-tree.c | 54 ++++++++++++++------------------------ 3 files changed, 22 insertions(+), 38 deletions(-)
fs/btrfs/extent_io.c +2 -2
@@ -5620,9 +5620,9 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, } } -void le_bitmap_set (u8 *map,unsigned int start,int len) +void le_bitmap_set (unsigned long *map,unsigned int start,int len) { -u8 *p = map +BIT_BYTE (start); +u8 *p = ((u8 *)map) +BIT_BYTE (start);const unsigned int size = start + len;int bits_to_set =BITS_PER_BYTE - (start %BITS_PER_BYTE );u8 mask_to_set =BITMAP_FIRST_BYTE_MASK (start);
fs/btrfs/extent_io.h +1 -1
@@ -84,7 +84,7 @@ static inline int le_test_bit(int nr, const u8 *addr)return 1U & (addr[BIT_BYTE (nr)] >> (nr & (BITS_PER_BYTE -1 ))); } -void le_bitmap_set (u8 *map,unsigned int start,int len); +void le_bitmap_set (unsigned long *map,unsigned int start,int len);struct extent_state ;struct btrfs_root ;
fs/btrfs/free-space-tree.c +19 -35
107 lines not on this page · raw message
Signature · 1 line
2.17.0
Re: [PATCH 2/2] btrfs: optimize free space tree bitmap conversion
Quoted 7 lines · Howard McLauchlan
Presently,
convert_free_space_to_extents()does a linear scan of the bitmap. We can speed this up with find_next_{bit,zero_bit}_le().This patch replaces the linear scan with find_next_{bit,zero_bit}_le(). Testing shows a 20-33% decrease in execution time for
convert_free_space_to_extents().
Quoted 8 lines
Suggested-by Omar Sandoval <[email protected]>Signed-off-by Howard McLauchlan <[email protected]>---
Since we change bitmap to be unsigned long, we have to do some casting for the bitmap cursor. In
le_bitmap_set()it makes sense to use u8, as we are doing bit operations. Everywhere else, we're just using it for pointer arithmetic and not directly accessing it, so char seems more appropriate.
Ok, makes sense for just passing the pointers around. I'll add the text to changelog and apply the patch to next.
fs/btrfs/free-space-tree.c int convert_free_space_to_extents(struct btrfs_trans_handle *trans, · line 398
Quoted 1 line
fs/btrfs/free-space-tree.c +0
-1- bit = !!le_test_bit (bitnr, bitmap);
This is the last use of le_test_bit, so it can be removed (in another patch).
Re: [PATCH 2/2] btrfs: optimize free space tree bitmap conversion
Quoted 16 lines · David Sterba
Quoted 7 lines · Howard McLauchlan
Presently,
convert_free_space_to_extents()does a linear scan of the bitmap. We can speed this up with find_next_{bit,zero_bit}_le().This patch replaces the linear scan with find_next_{bit,zero_bit}_le(). Testing shows a 20-33% decrease in execution time for
convert_free_space_to_extents().Quoted 8 lines
Suggested-by Omar Sandoval <[email protected]>Signed-off-by Howard McLauchlan <[email protected]>---
Since we change bitmap to be unsigned long, we have to do some casting for the bitmap cursor. In
le_bitmap_set()it makes sense to use u8, as we are doing bit operations. Everywhere else, we're just using it for pointer arithmetic and not directly accessing it, so char seems more appropriate.
Quoted 6 lines
Ok, makes sense for just passing the pointers around. I'll add the text to changelog and apply the patch to next.
fs/btrfs/free-space-tree.c int convert_free_space_to_extents(struct btrfs_trans_handle *trans, · line 398
Quoted 1 line
fs/btrfs/free-space-tree.c +0
-1- bit = !!le_test_bit (bitnr, bitmap);This is the last use of
le_test_bit, so it can be removed (in another patch).
I just found an issue in this patch that should be fixed. I'll address moving le_bitmap_set(), le_test_bit and send a V2 for both these patches.
Howard
Quoted 4 lines · Howard McLauchlan
le_bitmap_clear()was implemented as a parallel tole_bitmap_set()but is actually not being used. This patch removes it.Signed-off-by Howard McLauchlan <[email protected]>
I've noticed that le_bitmap_set is only used for the free-space-tree so it can be moved there and made static.