lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230106083317.93938-5-p.raghav@samsung.com>
Date:   Fri,  6 Jan 2023 09:33:14 +0100
From:   Pankaj Raghav <p.raghav@...sung.com>
To:     axboe@...nel.dk
Cc:     kernel@...kajraghav.com, linux-kernel@...r.kernel.org,
        hare@...e.de, bvanassche@....org, snitzer@...nel.org,
        dm-devel@...hat.com, damien.lemoal@...nsource.wdc.com,
        linux-nvme@...ts.infradead.org, hch@....de,
        linux-block@...r.kernel.org, gost.dev@...sung.com,
        Pankaj Raghav <p.raghav@...sung.com>
Subject: [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone
 index

Use bdev_zone_no() helper instead of opencoding the logic to find the
zone index.

Signed-off-by: Pankaj Raghav <p.raghav@...sung.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);
 
 	/*
 	 * 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];
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ