Message ID | 20230106083317.93938-5-p.raghav@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block zoned cleanups | expand |
On 1/6/23 17:33, Pankaj Raghav wrote: > Use bdev_zone_no() helper instead of opencoding the logic to find the > zone index. > > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> > --- > fs/zonefs/super.c | 8 +++----- > fs/zonefs/zonefs.h | 1 - > 2 files changed, 3 insertions(+), 6 deletions(-) > > diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c > index 2c53fbb8d918..c2ddc62e99dc 100644 > --- a/fs/zonefs/super.c > +++ b/fs/zonefs/super.c > @@ -487,7 +487,6 @@ static void __zonefs_io_error(struct inode *inode, bool write) > { > struct zonefs_inode_info *zi = ZONEFS_I(inode); > struct super_block *sb = inode->i_sb; > - struct zonefs_sb_info *sbi = ZONEFS_SB(sb); > unsigned int noio_flag; > unsigned int nr_zones = 1; > struct zonefs_ioerr_data err = { > @@ -502,8 +501,8 @@ static void __zonefs_io_error(struct inode *inode, bool write) > * size is always larger than the device zone size. > */ > if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev)) > - nr_zones = zi->i_zone_size >> > - (sbi->s_zone_sectors_shift + SECTOR_SHIFT); > + nr_zones = > + bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT); This is a number of zones, not a zone number. So this at least needs a comment to make clear. Otherwise, I find this confusing. I would also prefer you hold on this patch. I am about to post a big series reworking many things in zonefs. That will conflict. > > /* > * Memory allocations in blkdev_report_zones() can trigger a memory > @@ -1420,7 +1419,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone, > struct zonefs_inode_info *zi = ZONEFS_I(inode); > int ret = 0; > > - inode->i_ino = zone->start >> sbi->s_zone_sectors_shift; > + inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start); > inode->i_mode = S_IFREG | sbi->s_perm; > > zi->i_ztype = type; > @@ -1804,7 +1803,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent) > * interface constraints. > */ > sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev)); > - sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev)); > sbi->s_uid = GLOBAL_ROOT_UID; > sbi->s_gid = GLOBAL_ROOT_GID; > sbi->s_perm = 0640; > diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h > index 1dbe78119ff1..703bc4505b29 100644 > --- a/fs/zonefs/zonefs.h > +++ b/fs/zonefs/zonefs.h > @@ -179,7 +179,6 @@ struct zonefs_sb_info { > kgid_t s_gid; > umode_t s_perm; > uuid_t s_uuid; > - unsigned int s_zone_sectors_shift; > > unsigned int s_nr_files[ZONEFS_ZTYPE_MAX]; >
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index 2c53fbb8d918..c2ddc62e99dc 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -487,7 +487,6 @@ static void __zonefs_io_error(struct inode *inode, bool write) { struct zonefs_inode_info *zi = ZONEFS_I(inode); struct super_block *sb = inode->i_sb; - struct zonefs_sb_info *sbi = ZONEFS_SB(sb); unsigned int noio_flag; unsigned int nr_zones = 1; struct zonefs_ioerr_data err = { @@ -502,8 +501,8 @@ static void __zonefs_io_error(struct inode *inode, bool write) * size is always larger than the device zone size. */ if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev)) - nr_zones = zi->i_zone_size >> - (sbi->s_zone_sectors_shift + SECTOR_SHIFT); + nr_zones = + bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT); /* * Memory allocations in blkdev_report_zones() can trigger a memory @@ -1420,7 +1419,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone, struct zonefs_inode_info *zi = ZONEFS_I(inode); int ret = 0; - inode->i_ino = zone->start >> sbi->s_zone_sectors_shift; + inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start); inode->i_mode = S_IFREG | sbi->s_perm; zi->i_ztype = type; @@ -1804,7 +1803,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent) * interface constraints. */ sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev)); - sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev)); sbi->s_uid = GLOBAL_ROOT_UID; sbi->s_gid = GLOBAL_ROOT_GID; sbi->s_perm = 0640; diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h index 1dbe78119ff1..703bc4505b29 100644 --- a/fs/zonefs/zonefs.h +++ b/fs/zonefs/zonefs.h @@ -179,7 +179,6 @@ struct zonefs_sb_info { kgid_t s_gid; umode_t s_perm; uuid_t s_uuid; - unsigned int s_zone_sectors_shift; unsigned int s_nr_files[ZONEFS_ZTYPE_MAX];
Use bdev_zone_no() helper instead of opencoding the logic to find the zone index. Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> --- fs/zonefs/super.c | 8 +++----- fs/zonefs/zonefs.h | 1 - 2 files changed, 3 insertions(+), 6 deletions(-)