Skip to content

Commit 631003e

Browse files
naotakdave
authored andcommitted
btrfs: zoned: fix wrong use of bitops API in btrfs_ensure_empty_zones
find_next_bit and find_next_zero_bit take @SiZe as the second parameter and @offset as the third parameter. They are specified opposite in btrfs_ensure_empty_zones(). Thanks to the later loop, it never failed to detect the empty zones. Fix them and (maybe) return the result a bit faster. Note: the naming is a bit confusing, size has two meanings here, bitmap and our range size. Fixes: 1cd6121 ("btrfs: zoned: implement zoned chunk allocator") CC: [email protected] # 5.15+ Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 64b5d5b commit 631003e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/btrfs/zoned.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,12 @@ int btrfs_ensure_empty_zones(struct btrfs_device *device, u64 start, u64 size)
11681168
return -ERANGE;
11691169

11701170
/* All the zones are conventional */
1171-
if (find_next_bit(zinfo->seq_zones, begin, end) == end)
1171+
if (find_next_bit(zinfo->seq_zones, end, begin) == end)
11721172
return 0;
11731173

11741174
/* All the zones are sequential and empty */
1175-
if (find_next_zero_bit(zinfo->seq_zones, begin, end) == end &&
1176-
find_next_zero_bit(zinfo->empty_zones, begin, end) == end)
1175+
if (find_next_zero_bit(zinfo->seq_zones, end, begin) == end &&
1176+
find_next_zero_bit(zinfo->empty_zones, end, begin) == end)
11771177
return 0;
11781178

11791179
for (pos = start; pos < start + size; pos += zinfo->zone_size) {

0 commit comments

Comments
 (0)