diff options
author | Naohiro Aota <naota@elisp.net> | 2023-04-26 00:19:40 +0900 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2023-05-09 21:09:25 +0200 |
commit | 32f5319a3c12cde98160771cb1b4931ae3037acd (patch) | |
tree | 215d98d4024f6964ba7c2cce164bc227447ef4a6 /fs/btrfs/misc.h | |
parent | 5fe597327b082833f001bab1b68281d04861ca70 (diff) | |
download | linux-next-32f5319a3c12cde98160771cb1b4931ae3037acd.tar.gz |
btrfs: export bitmap_test_range_all_{set,zero}
bitmap_test_range_all_{set,zero} defined in subpage.c are useful for other
components. Move them to misc.h and use them in zoned.c. Also, as
find_next{,_zero}_bit take/return "unsigned long" instead of "unsigned
int", convert the type to "unsigned long".
While at it, also rewrite the "if (...) return true; else return false;"
pattern and add const to the input bitmap.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/misc.h')
-rw-r--r-- | fs/btrfs/misc.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/btrfs/misc.h b/fs/btrfs/misc.h index 768583a440e1..005751a12911 100644 --- a/fs/btrfs/misc.h +++ b/fs/btrfs/misc.h @@ -143,4 +143,24 @@ static inline struct rb_node *rb_simple_insert(struct rb_root *root, u64 bytenr, return NULL; } +static inline bool bitmap_test_range_all_set(const unsigned long *addr, + unsigned long start, + unsigned long nbits) +{ + unsigned long found_zero; + + found_zero = find_next_zero_bit(addr, start + nbits, start); + return (found_zero == start + nbits); +} + +static inline bool bitmap_test_range_all_zero(const unsigned long *addr, + unsigned long start, + unsigned long nbits) +{ + unsigned long found_set; + + found_set = find_next_bit(addr, start + nbits, start); + return (found_set == start + nbits); +} + #endif |