diff mbox series

btrfs: zoned: fix comparison of alloc_offset vs meta_write_pointer

Message ID 72f5f60036d5f9a3b096365f5c72cc1ad8db588b.1651705923.git.naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: zoned: fix comparison of alloc_offset vs meta_write_pointer | expand

Commit Message

Naohiro Aota May 4, 2022, 11:12 p.m. UTC
The block_group->alloc_offset is an offset from the start of the block
group. OTOH, the ->meta_write_pointer is an address in the logical
space. So, we should compare the alloc_offset shifted with the
block_group->start.

Fixes: afba2bc036b0 ("btrfs: zoned: implement active zone tracking")
CC: stable@vger.kernel.org # 5.16+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba May 9, 2022, 7:10 p.m. UTC | #1
On Wed, May 04, 2022 at 04:12:48PM -0700, Naohiro Aota wrote:
> The block_group->alloc_offset is an offset from the start of the block
> group. OTOH, the ->meta_write_pointer is an address in the logical
> space. So, we should compare the alloc_offset shifted with the
> block_group->start.
> 
> Fixes: afba2bc036b0 ("btrfs: zoned: implement active zone tracking")
> CC: stable@vger.kernel.org # 5.16+
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index db1848a24d44..253cba8c73ca 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1900,7 +1900,7 @@  static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
 	/* Check if we have unwritten allocated space */
 	if ((block_group->flags &
 	     (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_SYSTEM)) &&
-	    block_group->alloc_offset > block_group->meta_write_pointer) {
+	    block_group->start + block_group->alloc_offset > block_group->meta_write_pointer) {
 		spin_unlock(&block_group->lock);
 		return -EAGAIN;
 	}