From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Pankaj Raghav <p.raghav@samsung.com>,
axboe@kernel.dk, naohiro.aota@wdc.com,
Johannes.Thumshirn@wdc.com, snitzer@kernel.org, dsterba@suse.com,
jaegeuk@kernel.org, hch@lst.de
Cc: jiangbo.365@bytedance.com, Jens Axboe <axboe@fb.com>,
Chaitanya Kulkarni <kch@nvidia.com>,
bvanassche@acm.org, Chris Mason <clm@fb.com>,
matias.bjorling@wdc.com, gost.dev@samsung.com,
Luis Chamberlain <mcgrof@kernel.org>,
linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
Josef Bacik <josef@toxicpanda.com>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
dm-devel@redhat.com, Alasdair Kergon <agk@redhat.com>,
jonathan.derrick@linux.dev, Keith Busch <kbusch@kernel.org>,
Johannes Thumshirn <jth@kernel.org>,
linux-btrfs@vger.kernel.org, Sagi Grimberg <sagi@grimberg.me>
Subject: Re: [dm-devel] [PATCH v4 03/13] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size
Date: Mon, 16 May 2022 16:02:18 +0200 [thread overview]
Message-ID: <501aba4d-f4a3-8a4d-ec2a-99c7319b6a4d@opensource.wdc.com> (raw)
In-Reply-To: <20220516133921.126925-4-p.raghav@samsung.com>
On 2022/05/16 15:39, Pankaj Raghav wrote:
> Remove the condition which disallows non-power_of_2 zone size ZNS drive
> to be updated and use generic method to calculate number of zones
> instead of relying on log and shift based calculation on zone size.
>
> The power_of_2 calculation has been replaced directly with generic
> calculation without special handling. Both modified functions are not
> used in hot paths, they are only used during initialization &
> revalidation of the ZNS device.
>
> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
> Reviewed by: Adam Manzanares <a.manzanares@samsung.com>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
> drivers/nvme/host/zns.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 9f81beb4d..65d2aa68a 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -101,13 +101,6 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
> }
>
> ns->zsze = nvme_lba_to_sect(ns, le64_to_cpu(id->lbafe[lbaf].zsze));
> - if (!is_power_of_2(ns->zsze)) {
> - dev_warn(ns->ctrl->device,
> - "invalid zone size:%llu for namespace:%u\n",
> - ns->zsze, ns->head->ns_id);
> - status = -ENODEV;
> - goto free_data;
> - }
>
> blk_queue_set_zoned(ns->disk, BLK_ZONED_HM);
> blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
> @@ -128,8 +121,13 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns,
> const size_t min_bufsize = sizeof(struct nvme_zone_report) +
> sizeof(struct nvme_zone_descriptor);
>
> + /*
> + * Division is used to calculate nr_zones with no special handling
> + * for power of 2 zone sizes as this function is not invoked in a
> + * hot path
> + */
Comment not very useful.
> nr_zones = min_t(unsigned int, nr_zones,
> - get_capacity(ns->disk) >> ilog2(ns->zsze));
> + div64_u64(get_capacity(ns->disk), ns->zsze));
>
> bufsize = sizeof(struct nvme_zone_report) +
> nr_zones * sizeof(struct nvme_zone_descriptor);
> @@ -182,6 +180,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
> int ret, zone_idx = 0;
> unsigned int nz, i;
> size_t buflen;
> + u64 remainder = 0;
>
> if (ns->head->ids.csi != NVME_CSI_ZNS)
> return -EINVAL;
> @@ -197,7 +196,14 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
> c.zmr.zrasf = NVME_ZRASF_ZONE_REPORT_ALL;
> c.zmr.pr = NVME_REPORT_ZONE_PARTIAL;
>
> - sector &= ~(ns->zsze - 1);
> + /*
> + * rounddown the sector value to the nearest zone size. roundown macro
> + * provided in math.h will not work for 32 bit architectures.
> + * Division is used here with no special handling for power of 2
> + * zone sizes as this function is not invoked in a hot path
> + */
Please simplify this to:
/* Round down the sector value to the nearest zone start */
> + div64_u64_rem(sector, ns->zsze, &remainder);
> + sector -= remainder;
> while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) {
> memset(report, 0, buflen);
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-05-16 14:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220516133922eucas1p1c891cd1d82539b4e792acb5d1aa74444@eucas1p1.samsung.com>
2022-05-16 13:39 ` [PATCH v4 00/13] support non power of 2 zoned devices Pankaj Raghav
[not found] ` <CGME20220516133924eucas1p1817f306e3f2442088bf49ab513657cbe@eucas1p1.samsung.com>
2022-05-16 13:39 ` [PATCH v4 01/13] block: make blkdev_nr_zones and blk_queue_zone_no generic for npo2 zsze Pankaj Raghav
2022-05-16 13:54 ` Damien Le Moal
[not found] ` <CGME20220516133925eucas1p1414fab2cfa7da1d6258315cbd33e1685@eucas1p1.samsung.com>
2022-05-16 13:39 ` [PATCH v4 02/13] block: allow blk-zoned devices to have non-power-of-2 zone size Pankaj Raghav
2022-05-16 14:00 ` Damien Le Moal
[not found] ` <CGME20220516133926eucas1p15c7ba425b67ce4ac824c6bd3263e2dd4@eucas1p1.samsung.com>
2022-05-16 13:39 ` [PATCH v4 03/13] nvme: zns: Allow ZNS drives that have non-power_of_2 " Pankaj Raghav
2022-05-16 14:02 ` Damien Le Moal [this message]
[not found] ` <CGME20220516133927eucas1p1bab57e07c14c1194705e254afdd5d346@eucas1p1.samsung.com>
2022-05-16 13:39 ` [PATCH v4 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Pankaj Raghav
2022-05-16 14:15 ` [dm-devel] [PATCH v4 00/13] support non power of 2 zoned devices Damien Le Moal
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=501aba4d-f4a3-8a4d-ec2a-99c7319b6a4d@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=Johannes.Thumshirn@wdc.com \
--cc=agk@redhat.com \
--cc=axboe@fb.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=clm@fb.com \
--cc=dm-devel@redhat.com \
--cc=dsterba@suse.com \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=jiangbo.365@bytedance.com \
--cc=jonathan.derrick@linux.dev \
--cc=josef@toxicpanda.com \
--cc=jth@kernel.org \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=matias.bjorling@wdc.com \
--cc=mcgrof@kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=p.raghav@samsung.com \
--cc=sagi@grimberg.me \
--cc=snitzer@kernel.org \
/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
all inboxes | Powered by JetHome®