Thread (3 messages) 3 messages, 3 authors, 2021-06-17

Re: [PATCH] btrfs: fix negative space_info->bytes_readonly

From: David Sterba <hidden>
Date: 2021-06-17 09:16:27
Also in: stable

On Thu, Jun 17, 2021 at 01:56:18PM +0900, Naohiro Aota wrote:
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 commit fixes the issue by reordering the operations.

Link: https://github.com/naota/linux/issues/37
I've copied the 'fi df' output to changelog.
Fixes: 169e0da91a21 ("btrfs: zoned: track unusable bytes for zones")
Cc: stable@vger.kernel.org # 5.12+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Added to misc-next, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help