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: <20220920091119.115879-10-p.raghav@samsung.com>
Date:   Tue, 20 Sep 2022 11:11:15 +0200
From:   Pankaj Raghav <p.raghav@...sung.com>
To:     agk@...hat.com, snitzer@...nel.org, axboe@...nel.dk,
        damien.lemoal@...nsource.wdc.com, hch@....de
Cc:     gost.dev@...sung.com, jaegeuk@...nel.org,
        Johannes.Thumshirn@....com, hare@...e.de, bvanassche@....org,
        dm-devel@...hat.com, matias.bjorling@....com,
        linux-kernel@...r.kernel.org, linux-nvme@...ts.infradead.org,
        pankydev8@...il.com, linux-block@...r.kernel.org,
        Pankaj Raghav <p.raghav@...sung.com>,
        Luis Chamberlain <mcgrof@...nel.org>,
        Johannes Thumshirn <johannes.thumshirn@....com>
Subject: [PATCH v14 09/13] dm-zone: use generic helpers to calculate offset
 from zone start

Use the bdev_offset_from_zone_start() helper function to calculate
the offset from zone start instead of using power of 2 based
calculation.

Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
Reviewed-by: Luis Chamberlain <mcgrof@...nel.org>
Reviewed-by: Damien Le Moal <damien.lemoal@...nsource.wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@....org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@....com>
Reviewed-by: Mike Snitzer <snitzer@...nel.org>
---
 drivers/md/dm-zone.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 3dafc0e8b7a9..ac6fc1293d41 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
 	case REQ_OP_WRITE_ZEROES:
 	case REQ_OP_WRITE:
 		/* Writes must be aligned to the zone write pointer */
-		if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
+		if (bdev_offset_from_zone_start(md->disk->part0,
+						clone->bi_iter.bi_sector) != zwp_offset)
 			return false;
 		break;
 	case REQ_OP_ZONE_APPEND:
@@ -602,11 +603,8 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
 		 */
 		if (clone->bi_status == BLK_STS_OK &&
 		    bio_op(clone) == REQ_OP_ZONE_APPEND) {
-			sector_t mask =
-				(sector_t)bdev_zone_sectors(disk->part0) - 1;
-
 			orig_bio->bi_iter.bi_sector +=
-				clone->bi_iter.bi_sector & mask;
+				bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);
 		}
 
 		return;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ