[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220516133921.126925-5-p.raghav@samsung.com>
Date: Mon, 16 May 2022 15:39:12 +0200
From: Pankaj Raghav <p.raghav@...sung.com>
To: <axboe@...nel.dk>, <naohiro.aota@....com>,
<damien.lemoal@...nsource.wdc.com>, <Johannes.Thumshirn@....com>,
<snitzer@...nel.org>, <dsterba@...e.com>, <jaegeuk@...nel.org>,
<hch@....de>
CC: <linux-btrfs@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<jonathan.derrick@...ux.dev>, <bvanassche@....org>,
Keith Busch <kbusch@...nel.org>, <gost.dev@...sung.com>,
<linux-nvme@...ts.infradead.org>,
Johannes Thumshirn <jth@...nel.org>,
"Josef Bacik" <josef@...icpanda.com>,
<linux-block@...r.kernel.org>, Alasdair Kergon <agk@...hat.com>,
<matias.bjorling@....com>, Jens Axboe <axboe@...com>,
"Sagi Grimberg" <sagi@...mberg.me>, <dm-devel@...hat.com>,
<jiangbo.365@...edance.com>, Chaitanya Kulkarni <kch@...dia.com>,
<linux-fsdevel@...r.kernel.org>, Chris Mason <clm@...com>,
Pankaj Raghav <p.raghav@...sung.com>,
Hannes Reinecke <hare@...e.de>,
Luis Chamberlain <mcgrof@...nel.org>
Subject: [PATCH v4 04/13] nvmet: Allow ZNS target to support non-power_of_2
zone sizes
A generic bdev_zone_no helper is added to calculate zone number for a given
sector in a block device. This helper internally uses blk_queue_zone_no to
find the zone number.
Use the helper bdev_zone_no() to calculate nr of zones. This let's us
make modifications to the math if needed in one place and adds now
support for npo2 zone devices.
Reviewed by: Adam Manzanares <a.manzanares@...sung.com>
Reviewed-by: Bart Van Assche <bvanassche@....org>
Reviewed-by: Hannes Reinecke <hare@...e.de>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
---
drivers/nvme/target/zns.c | 2 +-
include/linux/blkdev.h | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 82b61acf7..5516dd6cc 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -242,7 +242,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req)
unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba);
return blkdev_nr_zones(req->ns->bdev->bd_disk) -
- (sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
+ bdev_zone_no(req->ns->bdev, sect);
}
static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 32d7bd7b1..967790f51 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1370,6 +1370,13 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
return 0;
}
+static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
+{
+ struct request_queue *q = bdev_get_queue(bdev);
+
+ return blk_queue_zone_no(q, sec);
+}
+
static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
{
struct request_queue *q = bdev_get_queue(bdev);
--
2.25.1
Powered by blists - more mailing lists