public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: undisclosed-recipients:;
Subject: Re: [PATCH 05/16] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size
Date: Wed, 4 May 2022 10:03:43 -0700	[thread overview]
Message-ID: <6a1c06e8-bedd-47b0-2a3f-9c51468fc029@suse.de> (raw)
In-Reply-To: <20220427160255.300418-6-p.raghav@samsung.com>

On 4/27/22 09:02, 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>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>   drivers/nvme/host/zns.c | 11 ++---------
>   1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 9f81beb4df4e..2087de0768ee 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);
> @@ -129,7 +122,7 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns,
>   				   sizeof(struct nvme_zone_descriptor);
>   
>   	nr_zones = min_t(unsigned int, nr_zones,
> -			 get_capacity(ns->disk) >> ilog2(ns->zsze));
> +			 div64_u64(get_capacity(ns->disk), ns->zsze));
>   
Same here; please add a helper calculating the number of zones for a 
given disk.

>   	bufsize = sizeof(struct nvme_zone_report) +
>   		nr_zones * sizeof(struct nvme_zone_descriptor);
> @@ -197,7 +190,7 @@ 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);
> +	sector = rounddown(sector, ns->zsze);
>   	while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) {
>   		memset(report, 0, buflen);
>   
Please be a bit more consistent. In the previous patches you always had 
a condition to check if it's a power_of_2 zone size, but here you are 
using the same calculation for each disk.
So please use the check in all locations, or add a comment why the 
generic calculation is okay to use here.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

  parent reply	other threads:[~2022-05-04 17:32 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220427160256eucas1p2db2b58792ffc93026d870c260767da14@eucas1p2.samsung.com>
2022-04-27 16:02 ` [PATCH 00/16] support non power of 2 zoned devices Pankaj Raghav
2022-04-27 16:02   ` [PATCH 01/16] block: make blkdev_nr_zones and blk_queue_zone_no generic for npo2 zsze Pankaj Raghav
2022-04-29 17:16     ` Adam Manzanares
2022-05-03 16:37     ` Bart Van Assche
2022-05-03 16:43       ` Damien Le Moal
2022-05-04  8:35       ` Pankaj Raghav
2022-05-04 16:52     ` Hannes Reinecke
2022-04-27 16:02   ` [PATCH 02/16] block: add blk_queue_zone_aligned and bdev_zone_aligned helper Pankaj Raghav
2022-04-27 23:52     ` Bart Van Assche
2022-05-04 16:55     ` Hannes Reinecke
2022-04-27 16:02   ` [PATCH 03/16] block: add bdev_zone_no helper Pankaj Raghav
2022-04-27 23:31     ` Damien Le Moal
2022-04-27 23:53     ` Bart Van Assche
2022-05-04 16:55     ` Hannes Reinecke
2022-04-27 16:02   ` [PATCH 04/16] block: allow blk-zoned devices to have non-power-of-2 zone size Pankaj Raghav
2022-04-27 23:37     ` Damien Le Moal
2022-04-28 17:29       ` Luis Chamberlain
2022-05-04 16:59     ` Hannes Reinecke
2022-04-27 16:02   ` [PATCH 05/16] nvme: zns: Allow ZNS drives that have non-power_of_2 " Pankaj Raghav
2022-04-29 17:23     ` Adam Manzanares
2022-05-03 16:50     ` Bart Van Assche
2022-05-04  8:38       ` Pankaj Raghav
2022-05-04 17:03     ` Hannes Reinecke [this message]
2022-04-27 16:02   ` [PATCH 06/16] nvmet: use blk_queue_zone_no() Pankaj Raghav
2022-04-29 17:27     ` Adam Manzanares
2022-05-03 16:54     ` Bart Van Assche
2022-05-04 17:05     ` Hannes Reinecke
2022-04-27 16:02   ` [PATCH 07/16] btrfs: zoned: Cache superblock location in btrfs_zoned_device_info Pankaj Raghav
2022-04-27 16:02   ` [PATCH 08/16] btrfs: zoned: add generic btrfs helpers for zoned devices Pankaj Raghav
2022-04-27 16:02   ` [PATCH 09/16] btrfs: zoned: Make sb_zone_number function non power of 2 compatible Pankaj Raghav
2022-04-27 16:02   ` [PATCH 10/16] btrfs: zoned: use btrfs zone helpers to support non po2 zoned devices Pankaj Raghav
2022-04-27 16:02   ` [PATCH 11/16] btrfs: zoned: relax the alignment constraint for " Pankaj Raghav
2022-04-27 16:02   ` [PATCH 12/16] zonefs: allow non power of 2 " Pankaj Raghav
2022-04-27 23:39     ` Damien Le Moal
2022-04-27 16:02   ` [PATCH 13/16] null_blk: " Pankaj Raghav
2022-04-29 17:30     ` Adam Manzanares
2022-05-03 17:01     ` Bart Van Assche
2022-05-04 17:10     ` Hannes Reinecke
2022-04-27 16:02   ` [PATCH 14/16] f2fs: call bdev_zone_sectors() only once on init_blkz_info() Pankaj Raghav
2022-05-03 20:04     ` Jaegeuk Kim
2022-04-27 16:02   ` [PATCH 15/16] f2fs: ensure only power of 2 zone sizes are allowed Pankaj Raghav
2022-05-03 20:05     ` Jaegeuk Kim
2022-05-04  8:53       ` Pankaj Raghav
2022-04-27 16:02   ` [PATCH 16/16] dm-zoned: " Pankaj Raghav
2022-04-27 23:42     ` Damien Le Moal
2022-04-28 17:34       ` Luis Chamberlain
2022-04-28 21:43         ` Damien Le Moal
2022-04-28 22:06           ` Luis Chamberlain
2022-05-04 17:11     ` Hannes Reinecke
2022-05-02 22:07   ` [PATCH 00/16] support non power of 2 zoned devices Johannes Thumshirn
2022-05-03  9:12     ` Pankaj Raghav
2022-05-04 21:14       ` David Sterba
2022-05-05  7:28         ` 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=6a1c06e8-bedd-47b0-2a3f-9c51468fc029@suse.de \
    --to=hare@suse.de \
    /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