All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pankaj Raghav <p.raghav@samsung.com>
To: axboe@kernel.dk, hch@lst.de, snitzer@redhat.com,
	damien.lemoal@opensource.wdc.com, hare@suse.de,
	Johannes.Thumshirn@wdc.com
Cc: linux-nvme@lists.infradead.org, dm-devel@redhat.com,
	dsterba@suse.com, jiangbo.365@bytedance.com,
	linux-kernel@vger.kernel.org, gost.dev@samsung.com,
	linux-block@vger.kernel.org, jaegeuk@kernel.org,
	Pankaj Raghav <p.raghav@samsung.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH v5 4/7] nvmet: Allow ZNS target to support non-power_of_2 zone sizes
Date: Mon, 23 May 2022 18:15:58 +0200	[thread overview]
Message-ID: <20220523161601.58078-5-p.raghav@samsung.com> (raw)
In-Reply-To: <20220523161601.58078-1-p.raghav@samsung.com>

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@samsung.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.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 e34718b09550..e41b6a6ef048 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -243,7 +243,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 f5c7a41032ba..ed8742a72dcb 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1382,6 +1382,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


WARNING: multiple messages have this Message-ID (diff)
From: Pankaj Raghav <p.raghav@samsung.com>
To: axboe@kernel.dk, hch@lst.de, snitzer@redhat.com,
	damien.lemoal@opensource.wdc.com, hare@suse.de,
	Johannes.Thumshirn@wdc.com
Cc: Pankaj Raghav <p.raghav@samsung.com>,
	Bart Van Assche <bvanassche@acm.org>,
	gost.dev@samsung.com, jiangbo.365@bytedance.com,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	Luis Chamberlain <mcgrof@kernel.org>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	dsterba@suse.com, jaegeuk@kernel.org
Subject: [dm-devel] [PATCH v5 4/7] nvmet: Allow ZNS target to support non-power_of_2 zone sizes
Date: Mon, 23 May 2022 18:15:58 +0200	[thread overview]
Message-ID: <20220523161601.58078-5-p.raghav@samsung.com> (raw)
In-Reply-To: <20220523161601.58078-1-p.raghav@samsung.com>

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@samsung.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.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 e34718b09550..e41b6a6ef048 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -243,7 +243,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 f5c7a41032ba..ed8742a72dcb 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1382,6 +1382,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

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  parent reply	other threads:[~2022-05-23 16:16 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220523161603eucas1p1719a165f769b5ad69717ad9b5f4decc3@eucas1p1.samsung.com>
2022-05-23 16:15 ` [PATCH v5 0/7] support non power of 2 zoned devices Pankaj Raghav
2022-05-23 16:15   ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20220523161604eucas1p2927e20dbd0602c08b6df4fc41e62dfbe@eucas1p2.samsung.com>
2022-05-23 16:15     ` [PATCH v5 1/7] block: make blkdev_nr_zones and blk_queue_zone_no generic for npo2 zsze Pankaj Raghav
2022-05-23 16:15       ` [dm-devel] " Pankaj Raghav
     [not found]   ` <CGME20220523161606eucas1p2676c4d47f9fcb145f69b29db1f04fe6e@eucas1p2.samsung.com>
2022-05-23 16:15     ` [PATCH v5 2/7] block: allow blk-zoned devices to have non-power-of-2 zone size Pankaj Raghav
2022-05-23 16:15       ` [dm-devel] " Pankaj Raghav
2022-05-24  5:19       ` Hannes Reinecke
2022-05-24  5:19         ` [dm-devel] " Hannes Reinecke
2022-05-24  7:10         ` Pankaj Raghav
2022-05-24  7:10           ` [dm-devel] " Pankaj Raghav
2022-05-24  7:14           ` Hannes Reinecke
2022-05-24  7:14             ` [dm-devel] " Hannes Reinecke
     [not found]   ` <CGME20220523161607eucas1p2b6245eafb81dee3e2efbec3ab86a854d@eucas1p2.samsung.com>
2022-05-23 16:15     ` [PATCH v5 3/7] nvme: zns: Allow ZNS drives that have non-power_of_2 " Pankaj Raghav
2022-05-23 16:15       ` [dm-devel] " Pankaj Raghav
2022-05-24  5:21       ` Hannes Reinecke
2022-05-24  5:21         ` [dm-devel] " Hannes Reinecke
     [not found]   ` <CGME20220523161609eucas1p16c381cd9438240905bfdb0a739132e65@eucas1p1.samsung.com>
2022-05-23 16:15     ` Pankaj Raghav [this message]
2022-05-23 16:15       ` [dm-devel] [PATCH v5 4/7] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Pankaj Raghav
     [not found]   ` <CGME20220523161610eucas1p212e81eda6b03a2d1ce8b763c9ec933ca@eucas1p2.samsung.com>
2022-05-23 16:15     ` [PATCH v5 5/7] null_blk: allow non power of 2 zoned devices Pankaj Raghav
2022-05-23 16:15       ` [dm-devel] " Pankaj Raghav
2022-05-24  2:40       ` kernel test robot
2022-05-24  2:40         ` [dm-devel] " kernel test robot
2022-05-24  7:30         ` Pankaj Raghav
2022-05-24  7:30           ` Pankaj Raghav
2022-05-24  7:30           ` [dm-devel] " Pankaj Raghav
2022-05-24 15:22           ` Nathan Chancellor
2022-05-24 15:22             ` Nathan Chancellor
2022-05-24 15:22             ` [dm-devel] " Nathan Chancellor
2022-05-24 15:32             ` Pankaj Raghav
2022-05-24 15:32               ` Pankaj Raghav
2022-05-24 15:32               ` [dm-devel] " Pankaj Raghav
2022-05-24 19:07       ` kernel test robot
2022-05-24 19:07         ` [dm-devel] " kernel test robot
     [not found]   ` <CGME20220523161612eucas1p102a76ba431c934230309042521018915@eucas1p1.samsung.com>
2022-05-23 16:16     ` [PATCH v5 6/7] null_blk: use zone_size_sects_shift for " Pankaj Raghav
2022-05-23 16:16       ` [dm-devel] " Pankaj Raghav
2022-05-23 18:11       ` Luis Chamberlain
2022-05-23 18:11         ` [dm-devel] " Luis Chamberlain
2022-05-24  5:22       ` Hannes Reinecke
2022-05-24  5:22         ` [dm-devel] " Hannes Reinecke
     [not found]   ` <CGME20220523161613eucas1p256b21b1a631324b4814465decf3958ce@eucas1p2.samsung.com>
2022-05-23 16:16     ` [PATCH v5 7/7] dm-zoned: ensure only power of 2 zone sizes are allowed Pankaj Raghav
2022-05-23 16:16       ` [dm-devel] " Pankaj Raghav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220523161601.58078-5-p.raghav@samsung.com \
    --to=p.raghav@samsung.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=dm-devel@redhat.com \
    --cc=dsterba@suse.com \
    --cc=gost.dev@samsung.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jaegeuk@kernel.org \
    --cc=jiangbo.365@bytedance.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=mcgrof@kernel.org \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.