Skip to content

Commit 7467bc5

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: zoned: calculate max_extent_size properly on non-zoned setup
Since commit 559218d ("block: pre-calculate max_zone_append_sectors"), queue_limits's max_zone_append_sectors is default to be 0 and it is only updated when there is a zoned device. So, we have lim->max_zone_append_sectors = 0 when there is no zoned device in the filesystem. That leads to fs_info->max_zone_append_size and thus fs_info->max_extent_size to be 0, which is wrong and can for example lead to a divide by zero in count_max_extents(). Fix this by only capping fs_info->max_extent_size to fs_info->max_zone_append_size when it is non-zero. Based on a patch from Naohiro Aota <naohiro.aota@wdc.com>, from which much of this commit message is stolen as well. Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Fixes: 559218d ("block: pre-calculate max_zone_append_sectors") Tested-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 6aecd91 commit 7467bc5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/btrfs/zoned.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,9 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info)
745745
(u64)lim->max_segments << PAGE_SHIFT),
746746
fs_info->sectorsize);
747747
fs_info->fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_ZONED;
748-
if (fs_info->max_zone_append_size < fs_info->max_extent_size)
749-
fs_info->max_extent_size = fs_info->max_zone_append_size;
748+
749+
fs_info->max_extent_size = min_not_zero(fs_info->max_extent_size,
750+
fs_info->max_zone_append_size);
750751

751752
/*
752753
* Check mount options here, because we might change fs_info->zoned

0 commit comments

Comments
 (0)