btrfs: optimize free space tree bitmap conversion
authorHoward McLauchlan <hmclauchlan@fb.com>
Thu, 19 Apr 2018 01:02:36 +0000 (18:02 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 28 May 2018 16:07:18 +0000 (18:07 +0200)
commita565971ff3e0f584ec163a32abf95196be623041
tree8ddc9f1f6b1d487fb7715aa621d5d6d415250588
parent6faa8f475eeaf5d89f985ad3b91b90ab0cf219e6
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.

Suggested-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Howard McLauchlan <hmclauchlan@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/free-space-tree.c