From: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
To: Keith Busch <Keith.Busch@wdc.com>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Sagi Grimberg <sagi@grimberg.me>,
Aravind Ramesh <Aravind.Ramesh@wdc.com>,
Christoph Hellwig <hch@lst.de>,
Matias Bjorling <Matias.Bjorling@wdc.com>
Subject: Re: [PATCH 2/5] null_blk: introduce zone capacity for zoned device
Date: Mon, 15 Jun 2020 23:46:25 +0000 [thread overview]
Message-ID: <BYAPR04MB4965573D0109F13F1E6BA8D1869C0@BYAPR04MB4965.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20200615233424.13458-3-keith.busch@wdc.com
Apart from couple of nits this looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
On 6/15/20 4:35 PM, Keith Busch wrote:
> From: Aravind Ramesh <aravind.ramesh@wdc.com>
>
> Allow emulation of a zoned device with a per zone capacity smaller than
> the zone size as as defined in the Zoned Namespace (ZNS) Command Set
> specification. The zone capacity defaults to the zone size if not
> specified and must be smaller than the zone size otherwise.
>
> Signed-off-by: Aravind Ramesh <aravind.ramesh@wdc.com>
> ---
> drivers/block/null_blk.h | 2 ++
> drivers/block/null_blk_main.c | 9 ++++++++-
> drivers/block/null_blk_zoned.c | 17 +++++++++++++++--
> 3 files changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/null_blk.h b/drivers/block/null_blk.h
> index 81b311c9d781..7eadf190528c 100644
> --- a/drivers/block/null_blk.h
> +++ b/drivers/block/null_blk.h
> @@ -44,11 +44,13 @@ struct nullb_device {
> unsigned int nr_zones;
> struct blk_zone *zones;
> sector_t zone_size_sects;
> + sector_t zone_capacity_sects;
>
> unsigned long size; /* device size in MB */
> unsigned long completion_nsec; /* time in ns to complete a request */
> unsigned long cache_size; /* disk cache size in MB */
> unsigned long zone_size; /* zone size in MB if device is zoned */
> + unsigned long zone_capacity; /* zone cap in MB if device is zoned */
> unsigned int zone_nr_conv; /* number of conventional zones */
> unsigned int submit_queues; /* number of submission queues */
> unsigned int home_node; /* home node for the device */
> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
> index 87b31f9ca362..54c5b5df399d 100644
> --- a/drivers/block/null_blk_main.c
> +++ b/drivers/block/null_blk_main.c
> @@ -200,6 +200,10 @@ static unsigned long g_zone_size = 256;
> module_param_named(zone_size, g_zone_size, ulong, S_IRUGO);
> MODULE_PARM_DESC(zone_size, "Zone size in MB when block device is zoned. Must be power-of-two: Default: 256");
>
> +static unsigned long g_zone_capacity;
> +module_param_named(zone_capacity, g_zone_capacity, ulong, 0444);
> +MODULE_PARM_DESC(zone_capacity, "Zone capacity in MB when block device is zoned. Can be less than or equal to zone size. Default: Zone size");
> +
> static unsigned int g_zone_nr_conv;
> module_param_named(zone_nr_conv, g_zone_nr_conv, uint, 0444);
> MODULE_PARM_DESC(zone_nr_conv, "Number of conventional zones when block device is zoned. Default: 0");
> @@ -341,6 +345,7 @@ NULLB_DEVICE_ATTR(mbps, uint, NULL);
> NULLB_DEVICE_ATTR(cache_size, ulong, NULL);
> NULLB_DEVICE_ATTR(zoned, bool, NULL);
> NULLB_DEVICE_ATTR(zone_size, ulong, NULL);
> +NULLB_DEVICE_ATTR(zone_capacity, ulong, NULL);
> NULLB_DEVICE_ATTR(zone_nr_conv, uint, NULL);
>
> static ssize_t nullb_device_power_show(struct config_item *item, char *page)
> @@ -457,6 +462,7 @@ static struct configfs_attribute *nullb_device_attrs[] = {
> &nullb_device_attr_badblocks,
> &nullb_device_attr_zoned,
> &nullb_device_attr_zone_size,
> + &nullb_device_attr_zone_capacity,
> &nullb_device_attr_zone_nr_conv,
> NULL,
> };
> @@ -510,7 +516,7 @@ nullb_group_drop_item(struct config_group *group, struct config_item *item)
>
> static ssize_t memb_group_features_show(struct config_item *item, char *page)
> {
> - return snprintf(page, PAGE_SIZE, "memory_backed,discard,bandwidth,cache,badblocks,zoned,zone_size,zone_nr_conv\n");
> + return snprintf(page, PAGE_SIZE, "memory_backed,discard,bandwidth,cache,badblocks,zoned,zone_size,zone_capacity,zone_nr_conv\n");
This line is becoming ridiculously long even for new 100 char limit.
Maybe we should do a cleanup patch for feature to string conversion.
> }
>
> CONFIGFS_ATTR_RO(memb_group_, features);
> @@ -571,6 +577,7 @@ static struct nullb_device *null_alloc_dev(void)
> dev->use_per_node_hctx = g_use_per_node_hctx;
> dev->zoned = g_zoned;
> dev->zone_size = g_zone_size;
> + dev->zone_capacity = g_zone_capacity;
> dev->zone_nr_conv = g_zone_nr_conv;
> return dev;
> }
> diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
> index 624aac09b005..b05832eb21b2 100644
> --- a/drivers/block/null_blk_zoned.c
> +++ b/drivers/block/null_blk_zoned.c
> @@ -28,7 +28,17 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
> return -EINVAL;
> }
>
> + if (!dev->zone_capacity)
> + dev->zone_capacity = dev->zone_size;
> +
> + if (dev->zone_capacity > dev->zone_size) {
> + pr_err("null_blk: zone capacity %lu more than its size %lu\n",
> + dev->zone_capacity, dev->zone_size);
> + return -EINVAL;
> + }
> +
> dev->zone_size_sects = dev->zone_size << ZONE_SIZE_SHIFT;
> + dev->zone_capacity_sects = dev->zone_capacity << ZONE_SIZE_SHIFT;
Do we really need zone_capacity_sects ? As far as I can see its is not
used into fast path, correct me if I'm wrong.
> dev->nr_zones = dev_size >>
> (SECTOR_SHIFT + ilog2(dev->zone_size_sects));
> dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct blk_zone),
> @@ -60,7 +70,7 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
>
> zone->start = zone->wp = sector;
> zone->len = dev->zone_size_sects;
> - zone->capacity = zone->len;
> + zone->capacity = dev->zone_capacity_sects;
We can just dev->zone_capacity << ZONE_SIZE_SHIFT here.
> zone->type = BLK_ZONE_TYPE_SEQWRITE_REQ;
> zone->cond = BLK_ZONE_COND_EMPTY;
>
> @@ -187,6 +197,9 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
> return BLK_STS_IOERR;
> }
>
> + if (zone->wp + nr_sectors > zone->start + zone->capacity)
> + return BLK_STS_IOERR;
> +
> if (zone->cond != BLK_ZONE_COND_EXP_OPEN)
> zone->cond = BLK_ZONE_COND_IMP_OPEN;
>
> @@ -195,7 +208,7 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
> return ret;
>
> zone->wp += nr_sectors;
> - if (zone->wp == zone->start + zone->len)
> + if (zone->wp == zone->start + zone->capacity)
> zone->cond = BLK_ZONE_COND_FULL;
> return BLK_STS_OK;
> default:
>
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-06-15 23:46 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 23:34 [PATCH 0/5] nvme support for zoned namespace command set Keith Busch
2020-06-15 23:34 ` [PATCH 1/5] block: add capacity field to zone descriptors Keith Busch
2020-06-15 23:49 ` Chaitanya Kulkarni
2020-06-16 10:28 ` Javier González
2020-06-16 13:47 ` Daniel Wagner
2020-06-16 13:54 ` Johannes Thumshirn
2020-06-16 15:41 ` Martin K. Petersen
2020-06-15 23:34 ` [PATCH 2/5] null_blk: introduce zone capacity for zoned device Keith Busch
2020-06-15 23:46 ` Chaitanya Kulkarni [this message]
2020-06-16 14:18 ` Daniel Wagner
2020-06-16 15:48 ` Martin K. Petersen
2020-06-15 23:34 ` [PATCH 3/5] nvme: implement I/O Command Sets Command Set support Keith Busch
2020-06-16 10:33 ` Javier González
2020-06-16 17:14 ` Niklas Cassel
2020-06-16 15:58 ` Martin K. Petersen
2020-06-16 17:01 ` Keith Busch
2020-06-17 9:50 ` Niklas Cassel
2020-06-16 17:06 ` Niklas Cassel
2020-06-17 2:01 ` Martin K. Petersen
2020-06-15 23:34 ` [PATCH 4/5] nvme: support for multi-command set effects Keith Busch
2020-06-16 10:34 ` Javier González
2020-06-16 16:03 ` Martin K. Petersen
2020-06-15 23:34 ` [PATCH 5/5] nvme: support for zoned namespaces Keith Busch
2020-06-16 10:41 ` Javier González
2020-06-16 11:18 ` Matias Bjørling
2020-06-16 12:00 ` Javier González
2020-06-16 12:06 ` Matias Bjørling
2020-06-16 12:24 ` Javier González
2020-06-16 12:27 ` Matias Bjørling
2020-06-16 12:35 ` Damien Le Moal
[not found] ` <CGME20200616130815uscas1p1be34e5fceaa548eac31fb30790a689d4@uscas1p1.samsung.com>
2020-06-16 13:08 ` Judy Brock
2020-06-16 13:32 ` Matias Bjørling
2020-06-16 13:34 ` Damien Le Moal
2020-06-16 14:16 ` Javier González
2020-06-16 14:42 ` Damien Le Moal
2020-06-16 15:02 ` Javier González
2020-06-16 15:20 ` Matias Bjørling
2020-06-16 16:03 ` Javier González
2020-06-16 16:07 ` Matias Bjorling
2020-06-16 16:21 ` Javier González
2020-06-16 16:25 ` Matias Bjørling
2020-06-16 15:48 ` Keith Busch
2020-06-16 15:55 ` Javier González
2020-06-16 16:04 ` Matias Bjorling
2020-06-16 16:07 ` Keith Busch
2020-06-16 16:13 ` Javier González
2020-06-17 0:38 ` Damien Le Moal
2020-06-17 6:18 ` Javier González
2020-06-17 6:54 ` Damien Le Moal
2020-06-17 7:11 ` Javier González
2020-06-17 7:29 ` Damien Le Moal
2020-06-17 7:34 ` Javier González
2020-06-17 0:14 ` Damien Le Moal
2020-06-17 6:09 ` Javier González
2020-06-17 6:47 ` Damien Le Moal
2020-06-17 7:02 ` Javier González
2020-06-17 7:24 ` Damien Le Moal
2020-06-17 7:29 ` Javier González
[not found] ` <CGME20200616123503uscas1p22ce22054a1b4152a20437b5abdd55119@uscas1p2.samsung.com>
2020-06-16 12:35 ` Judy Brock
2020-06-16 12:37 ` Damien Le Moal
2020-06-16 12:37 ` Matias Bjørling
2020-06-16 13:12 ` Judy Brock
2020-06-16 13:18 ` Judy Brock
2020-06-16 13:32 ` Judy Brock
2020-06-16 13:39 ` Damien Le Moal
2020-06-17 7:43 ` Christoph Hellwig
2020-06-17 12:01 ` Martin K. Petersen
2020-06-17 15:00 ` Javier González
2020-06-17 14:42 ` Javier González
2020-06-17 17:57 ` Matias Bjørling
2020-06-17 18:28 ` Javier González
2020-06-17 18:55 ` Matias Bjorling
2020-06-17 19:09 ` Javier González
2020-06-17 19:23 ` Matias Bjørling
2020-06-17 19:40 ` Javier González
2020-06-17 23:44 ` Heiner Litz
2020-06-18 1:55 ` Keith Busch
2020-06-18 4:24 ` Heiner Litz
2020-06-18 5:15 ` Damien Le Moal
2020-06-18 20:47 ` Heiner Litz
2020-06-18 21:04 ` Matias Bjorling
2020-06-18 21:19 ` Keith Busch
2020-06-18 22:05 ` Heiner Litz
2020-06-19 0:57 ` Damien Le Moal
2020-06-19 10:29 ` Matias Bjorling
2020-06-19 18:08 ` Heiner Litz
2020-06-19 18:10 ` Keith Busch
2020-06-19 18:17 ` Heiner Litz
2020-06-19 18:22 ` Keith Busch
2020-06-19 18:25 ` Matias Bjørling
2020-06-19 18:40 ` Heiner Litz
2020-06-19 18:18 ` Matias Bjørling
2020-06-20 6:33 ` Christoph Hellwig
2020-06-20 17:52 ` Heiner Litz
2022-03-02 21:11 ` Luis Chamberlain
2020-06-17 2:08 ` Martin K. Petersen
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=BYAPR04MB4965573D0109F13F1E6BA8D1869C0@BYAPR04MB4965.namprd04.prod.outlook.com \
--to=chaitanya.kulkarni@wdc.com \
--cc=Aravind.Ramesh@wdc.com \
--cc=Damien.LeMoal@wdc.com \
--cc=Keith.Busch@wdc.com \
--cc=Matias.Bjorling@wdc.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).