Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2448719iob; Fri, 6 May 2022 03:11:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuGrv73M7v/75uALG41RLAhc6JJ5wEarehCSNEEjcHJxkiymU0SLJ/pCUsSnJowM8/A0NY X-Received: by 2002:a17:906:7f02:b0:6cf:86d8:c31c with SMTP id d2-20020a1709067f0200b006cf86d8c31cmr2286965ejr.518.1651831903059; Fri, 06 May 2022 03:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651831903; cv=none; d=google.com; s=arc-20160816; b=g9ivj4L/+NWrWMRk5LzGp0mg3t+tPY9LeaA1Pk1aiiFvM3x7SDtE3Gbaoip4OY/9bq g/vW3fAXc4Q/6gKJa39ocOsdbZOarvhz0hwKnwxlhGQEB3rrNS7sPFvSrJo4O6D26jxM LhIKkPZuCS4e80ALINlEWxwdRhcc/jQMA2SSnihrHz50oXpaTWll2lcIhsL5QBUSgmop iLTxHkuZk4UhGyvsn/k7V7lMvlDu9n3B69MrXDnlU0JkJqIAXbVwr5Hmfj/l4SPqn2Tn VGanFaRms65S9iP0pWeOA1i9eWjzfmwa+MV2pCZxznM8rEMdX034DQAv3hcAZU40SNGe yfRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:to:from :references:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=r48NN8K17+Vaycp2fcoUaY8PZRHqW5yBueK7iYcVfJY=; b=If7tB3K6XMG8tk7PfzKwNMH1+FYGHrLVxzHX7rd69fEeYaDpooB3/Pokmq02tDDBQe 9qpwmEXU/6tbM0bB9EMUmWPsd/1DW7UhHx/FFKY9/Y7YoTb3ct5oIMiKNuWXdIDvf+kB oMbSPvHCHJwQtHkdqKVEgDhfIns3wJcFn26qabpZpTsMJ4HLuvGrtbjAupBAE1M4P20O 5sNOCvksYwgyiolJICcP6h7HfCGbRIvkskqvp5LX1mYfadoeB5swgAtJxy0o3X/whtnt TgfgJPGaPUDsYDkVA8QWW34fxyH6yjz2puv/MCNspeIksaD1vgl+bOdQemE+VwL/zEfc nOwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@suse.de header.s=susede2_rsa header.b=u0Oe4gfc; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp3-20020a1709071b0300b006e8baf14cc8si5374804ejc.927.2022.05.06.03.11.18; Fri, 06 May 2022 03:11:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@suse.de header.s=susede2_rsa header.b=u0Oe4gfc; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376929AbiEDRz3 (ORCPT + 99 others); Wed, 4 May 2022 13:55:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359048AbiEDRfk (ORCPT ); Wed, 4 May 2022 13:35:40 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF2BE5BE71; Wed, 4 May 2022 10:04:03 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 54385210E6; Wed, 4 May 2022 17:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1651683831; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r48NN8K17+Vaycp2fcoUaY8PZRHqW5yBueK7iYcVfJY=; b=u0Oe4gfc1OhFZsT1UUyMuMt08draDSwEqD3AdD9jt9/qwYg9acWkqsrrpzW0WvJ4UDM6lE fFO3SASX2LtgEe4r0IVMUg78LBBRhVHEBvaFggznA1XDSGAr3gl99IR6AeUBYaOZFdVTnh MsqkFs2WaX9f9VkewxprCasGCDulyqU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1651683831; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r48NN8K17+Vaycp2fcoUaY8PZRHqW5yBueK7iYcVfJY=; b=WL7Mwjzvc7qZd7CxcdYyzSZtHL135g1bMXjbrTJTi51amF5aezAaa5HJ0UGqmtv/m5zq6L MC+BAh7W/YAJU5Cw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3897131BD; Wed, 4 May 2022 17:03:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Ob9+GvGxcmJMWAAAMHmgww (envelope-from ); Wed, 04 May 2022 17:03:45 +0000 Message-ID: <6a1c06e8-bedd-47b0-2a3f-9c51468fc029@suse.de> Date: Wed, 4 May 2022 10:03:43 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 05/16] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size Content-Language: en-US References: <20220427160255.300418-1-p.raghav@samsung.com> <20220427160255.300418-6-p.raghav@samsung.com> From: Hannes Reinecke To: undisclosed-recipients:; In-Reply-To: <20220427160255.300418-6-p.raghav@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Pankaj Raghav > --- > 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