linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Cc: "hch@lst.de" <hch@lst.de>,
	"kbusch@kernel.org" <kbusch@kernel.org>,
	"sagi@grimberg.me" <sagi@grimberg.me>
Subject: Re: [PATCH V11 2/4] nvmet: add ZBD over ZNS backend support
Date: Thu, 11 Mar 2021 05:39:02 +0000	[thread overview]
Message-ID: <BL0PR04MB65140897830F157825CE72CCE7909@BL0PR04MB6514.namprd04.prod.outlook.com> (raw)
In-Reply-To: BYAPR04MB49656EEBF4AA66D1B4F4596686909@BYAPR04MB4965.namprd04.prod.outlook.com

On 2021/03/11 14:29, Chaitanya Kulkarni wrote:
>>> +
>>> +bool nvmet_bdev_zns_enable(struct nvmet_ns *ns)
>>> +{
>>> +	if (nvmet_bdev_has_conv_zones(ns->bdev))
>>> +		return false;
>>> +
>>> +	ns->blksize_shift = blksize_bits(bdev_physical_block_size(ns->bdev));
>> Shouldn't this be using logical block size ? Otherwise, zsze calculation in
>> nvmet_execute_identify_cns_cs_ns() could be wrong.
> 
> Okay, will send out V12 with that fix.
> 
>>> +
>>> +	if (!nvmet_zns_update_zasl(ns))
>>> +		return false;
>>> +
>>> +	return !(get_capacity(ns->bdev->bd_disk) &
>>> +			(bdev_zone_sectors(ns->bdev) - 1));
>>> +}
>>> +
>>> +void nvmet_execute_identify_cns_cs_ctrl(struct nvmet_req *req)
>>>
>>> +
>>> +void nvmet_bdev_execute_zone_mgmt_recv(struct nvmet_req *req)
>>> +{
>>> +	sector_t sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba);
>>> +	u32 bufsize = (le32_to_cpu(req->cmd->zmr.numd) + 1) << 2;
>>> +	struct nvmet_report_zone_data data = { .ns = req->ns };
>>> +	unsigned int nr_zones;
>>> +	int reported_zones;
>>> +	u16 status;
>>> +
>>> +	status = nvmet_bdev_zns_checks(req);
>>> +	if (status)
>>> +		goto out;
>>> +
>>> +	data.rz = __vmalloc(bufsize, GFP_KERNEL | __GFP_NORETRY | __GFP_ZERO);
>>> +	if (!data.rz) {
>>> +		status = NVME_SC_INTERNAL;
>>> +		goto out;
>>> +	}
>>> +
>>> +	nr_zones = (bufsize - sizeof(struct nvme_zone_report)) /
>>> +			sizeof(struct nvme_zone_descriptor);
>> What if nr_zones is 0 ? This should be failed.
> 
> blkdev_report_zones() already handles that check. I thinkthe error condition
> below blkdev_report_zones() should include<= 0 case instead of just <.

Reporting 0 zones with a valid buffer size (nr_zones > 0) is a valid reply, not
an error. This can happen depending on reporting options. Even though
blkdev_report_zones() does not allow reporting options, it would be strange to
fail empty reports.

> 
> Will send V12 with the <= fix.
> 
>>
>>> +	reported_zones = blkdev_report_zones(req->ns->bdev, sect, nr_zones,
>>> +					     nvmet_bdev_report_zone_cb, &data);
>>> +	if (reported_zones < 0) {
>>> +		status = NVME_SC_INTERNAL;
>>> +		goto out_free_report_zones;
>>> +	}
>>> +
>>> +	data.rz->nr_zones = cpu_to_le64(reported_zones);
>>> +
>>> +	status = nvmet_copy_to_sgl(req, 0, data.rz, bufsize);
>>> +
>>> +out_free_report_zones:
>>> +	kvfree(data.rz);
>>> +out:
>>> +	nvmet_req_complete(req, status);
>>> +}
>>> +
>>>
> 
> 


-- 
Damien Le Moal
Western Digital Research

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2021-03-11  5:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  4:39 [PATCH V11 0/4] nvmet: add ZBD backend support Chaitanya Kulkarni
2021-03-11  4:39 ` [PATCH V11 1/4] nvmet: add NVM Command Set Identifier support Chaitanya Kulkarni
2021-03-11  4:39 ` [PATCH V11 2/4] nvmet: add ZBD over ZNS backend support Chaitanya Kulkarni
2021-03-11  5:14   ` Damien Le Moal
2021-03-11  5:29     ` Chaitanya Kulkarni
2021-03-11  5:39       ` Damien Le Moal [this message]
2021-03-11  5:41         ` Chaitanya Kulkarni
2021-03-11  4:39 ` [PATCH V11 3/4] nvmet: add nvmet_req_bio put helper for backends Chaitanya Kulkarni
2021-03-11  4:39 ` [PATCH V11 4/4] nvme: add comments to nvme_zns_alloc_report_buffer Chaitanya Kulkarni
2021-03-11  5:08   ` Damien Le Moal
2021-03-11  5:36     ` Chaitanya Kulkarni
2021-03-11  6:22       ` hch
2021-03-11  6:22         ` Chaitanya Kulkarni

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=BL0PR04MB65140897830F157825CE72CCE7909@BL0PR04MB6514.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@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).