Commit f9f28e5
btrfs: zoned: fix negative space_info->bytes_readonly
Consider we have a using block group on zoned btrfs.
|<- ZU ->|<- used ->|<---free--->|
`- Alloc offset
ZU: Zone unusable
Marking the block group read-only will migrate the zone unusable bytes
to the read-only bytes. So, we will have this.
|<- RO ->|<- used ->|<--- RO --->|
RO: Read only
When marking it back to read-write, btrfs_dec_block_group_ro()
subtracts the above "RO" bytes from the
space_info->bytes_readonly. And, it moves the zone unusable bytes back
and again subtracts those bytes from the space_info->bytes_readonly,
leading to negative bytes_readonly.
This can be observed in the output as eg.:
Data, single: total=512.00MiB, used=165.21MiB, zone_unusable=16.00EiB
Data, single: total=536870912, used=173256704, zone_unusable=18446744073603186688
This commit fixes the issue by reordering the operations.
Link: naota/linux#37
Reported-by: David Sterba <[email protected]>
Fixes: 169e0da ("btrfs: zoned: track unusable bytes for zones")
CC: [email protected] # 5.12+
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Naohiro Aota <[email protected]>
Signed-off-by: David Sterba <[email protected]>1 parent aefd7f7 commit f9f28e5
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2442 | 2442 | | |
2443 | 2443 | | |
2444 | 2444 | | |
2445 | | - | |
2446 | | - | |
2447 | | - | |
2448 | | - | |
2449 | 2445 | | |
2450 | 2446 | | |
2451 | 2447 | | |
2452 | 2448 | | |
2453 | 2449 | | |
2454 | 2450 | | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
2455 | 2455 | | |
2456 | 2456 | | |
2457 | 2457 | | |
| |||
0 commit comments