Message ID | e6519c3681550015fbeeb0565f707d72705a39f1.1614331998.git.naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fixes for zoned mode | expand |
On Fri, Feb 26, 2021 at 06:34:37PM +0900, Naohiro Aota wrote: > We need to cast zone_sectors from u32 to u64 when setting the zone_size, or > it set the zone size = 0 when the size >= 4G. > > Fixes: 5b316468983d ("btrfs: get zone information of zoned block devices") > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> > --- > fs/btrfs/zoned.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c > index 40cb99854844..4de82da39c10 100644 > --- a/fs/btrfs/zoned.c > +++ b/fs/btrfs/zoned.c > @@ -312,7 +312,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) > nr_sectors = bdev_nr_sectors(bdev); > /* Check if it's power of 2 (see is_power_of_2) */ > ASSERT(zone_sectors != 0 && (zone_sectors & (zone_sectors - 1)) == 0); > - zone_info->zone_size = zone_sectors << SECTOR_SHIFT; > + zone_info->zone_size = (u64)zone_sectors << SECTOR_SHIFT; That should be fixed by changing type to sector_t, it's already so in other functions (btrfs_reset_sb_log_zones, emulate_report_zones). In btrfs_get_dev_zone_info thers's already a type mismatch near line 300: zone_sectors = bdev_zone_sectors(bdev); linux/blkdev.h: static inline sector_t bdev_zone_sectors(struct block_device *bdev) > zone_info->zone_size_shift = ilog2(zone_info->zone_size); > zone_info->max_zone_append_size = > (u64)queue_max_zone_append_sectors(queue) << SECTOR_SHIFT; > -- > 2.30.1
On Fri, Feb 26, 2021 at 08:18:58PM +0100, David Sterba wrote: > On Fri, Feb 26, 2021 at 06:34:37PM +0900, Naohiro Aota wrote: > > We need to cast zone_sectors from u32 to u64 when setting the zone_size, or > > it set the zone size = 0 when the size >= 4G. > > > > Fixes: 5b316468983d ("btrfs: get zone information of zoned block devices") > > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> > > --- > > fs/btrfs/zoned.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c > > index 40cb99854844..4de82da39c10 100644 > > --- a/fs/btrfs/zoned.c > > +++ b/fs/btrfs/zoned.c > > @@ -312,7 +312,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) > > nr_sectors = bdev_nr_sectors(bdev); > > /* Check if it's power of 2 (see is_power_of_2) */ > > ASSERT(zone_sectors != 0 && (zone_sectors & (zone_sectors - 1)) == 0); > > - zone_info->zone_size = zone_sectors << SECTOR_SHIFT; > > + zone_info->zone_size = (u64)zone_sectors << SECTOR_SHIFT; > > That should be fixed by changing type to sector_t, it's already so in > other functions (btrfs_reset_sb_log_zones, emulate_report_zones). > > In btrfs_get_dev_zone_info thers's already a type mismatch near line > 300: > > zone_sectors = bdev_zone_sectors(bdev); > > linux/blkdev.h: > static inline sector_t bdev_zone_sectors(struct block_device *bdev) Ah, yes, I forgot that point. I'll repost by fixing the type of zone_sectors. > > zone_info->zone_size_shift = ilog2(zone_info->zone_size); > > zone_info->max_zone_append_size = > > (u64)queue_max_zone_append_sectors(queue) << SECTOR_SHIFT; > > -- > > 2.30.1
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 40cb99854844..4de82da39c10 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -312,7 +312,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device) nr_sectors = bdev_nr_sectors(bdev); /* Check if it's power of 2 (see is_power_of_2) */ ASSERT(zone_sectors != 0 && (zone_sectors & (zone_sectors - 1)) == 0); - zone_info->zone_size = zone_sectors << SECTOR_SHIFT; + zone_info->zone_size = (u64)zone_sectors << SECTOR_SHIFT; zone_info->zone_size_shift = ilog2(zone_info->zone_size); zone_info->max_zone_append_size = (u64)queue_max_zone_append_sectors(queue) << SECTOR_SHIFT;
We need to cast zone_sectors from u32 to u64 when setting the zone_size, or it set the zone size = 0 when the size >= 4G. Fixes: 5b316468983d ("btrfs: get zone information of zoned block devices") Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)