Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2575291ioo; Tue, 24 May 2022 00:37:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5wcRecIrQwrBWYNqTAwEvDjv9biL2z9TldZM4ZCRBaZ/BNr/2egabb4x6lTnLzIoCOkTO X-Received: by 2002:aa7:d54c:0:b0:42b:7dbb:3a8b with SMTP id u12-20020aa7d54c000000b0042b7dbb3a8bmr3753326edr.130.1653377862063; Tue, 24 May 2022 00:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653377862; cv=none; d=google.com; s=arc-20160816; b=MhFCybeYIiS7bcsexJ+i3ooY63bSoFT48najufvc/7nhBZl/ZZ6M/ilecvC9l1EN3j wd3Zh2B6AYKb424guXQp/Js6uMItT0LWXQCG7/zmHr3LQ44GOoc0siigSBxPuft+pCuF XHba+LKCLbq4MnslGXeZuyReFdiRVfBLT8JXUU9iqMxgxn4lg4jm+zwULoU8MlhyN4aZ IhXDLftV8hRlhRsM0GHyKvJuoh2/HJ8Agjo714THFA1NVKx3UmPxBKmUzxEpNaFhO3rG 2WsCnUi4Fy5SE8w6hJUfcLJVbjjjtbZk+oHVSlxE91vqBsU37Ex1QpXspy8Hrvnx6GGw 6Odw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=6N0POl2iQ8Az4MtvrLWH5CpfHov/zRWX8h4ikAa4V9M=; b=qlzWdP9oOj2UsfCmNtQA6NlztQW445wkOdvJ3Z4m0YEJkMOm2Oel7av9DCep2q+lK9 vIEHf+fSjjrvbZNV8SAqSDEk/zeOSyWgQsh1EaVPXliyJXtdaTLgD8IPEL1XoASgrRxm wKT2kwWzzw6FfM0yCUh2pGgOByurR51cyVYv6vmhI9WyKwSKQZyPjVjGiO0WZgFAFoSu F/RruYkI2iwCd9qj91YpTaVnULrMfcHkMeWiXntt01Us5TLTmiVry25Dm9LjktsXZ7qg 2PHfajzRNOcGl9Qjda1j/4A+S43pH2jHSrCb+KLgOtRUeocGiphn4E/q8swp8zwz7oof KASQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F8qmKYzc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=oSQEYDIT; 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=pass (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 s11-20020aa7d78b000000b0042ab5db8777si15810798edq.223.2022.05.24.00.37.15; Tue, 24 May 2022 00:37:42 -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=pass header.i=@suse.de header.s=susede2_rsa header.b=F8qmKYzc; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=oSQEYDIT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233645AbiEXFVg (ORCPT + 99 others); Tue, 24 May 2022 01:21:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbiEXFVe (ORCPT ); Tue, 24 May 2022 01:21:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507CB396B8; Mon, 23 May 2022 22:21:33 -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 A0FE3219F5; Tue, 24 May 2022 05:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1653369691; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6N0POl2iQ8Az4MtvrLWH5CpfHov/zRWX8h4ikAa4V9M=; b=F8qmKYzcqEYtyxAg3FCttUbpnzwR0DzGVBXkXpao09ZoeLrzMhcERj/SMncGjUaqLkqzHB ATTKnAGB4uYsQw5XOVmYR+egE9Mmg15nFVoEoo49eFeW9YkBlQbQejgaBY4yyxM8uVJcf1 VndOEEphoQfGGZCrrrWXWusteoL8+Bw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1653369691; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6N0POl2iQ8Az4MtvrLWH5CpfHov/zRWX8h4ikAa4V9M=; b=oSQEYDIT335op081U1V2un8S1fmeYacOPLEdvqbHm6FLK8ET2MCpBK5jvg5cmLRXNIZ8qJ yVVh1OVj0FqxWGDQ== 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 39A1413ADF; Tue, 24 May 2022 05:21:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1UwoDVtrjGK6GgAAMHmgww (envelope-from ); Tue, 24 May 2022 05:21:31 +0000 Message-ID: Date: Tue, 24 May 2022 07:21:30 +0200 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 v5 3/7] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size Content-Language: en-US To: Pankaj Raghav , axboe@kernel.dk, hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, Johannes.Thumshirn@wdc.com Cc: linux-nvme@lists.infradead.org, dm-devel@redhat.com, dsterba@suse.com, jiangbo.365@bytedance.com, linux-kernel@vger.kernel.org, gost.dev@samsung.com, linux-block@vger.kernel.org, jaegeuk@kernel.org, Luis Chamberlain References: <20220523161601.58078-1-p.raghav@samsung.com> <20220523161601.58078-4-p.raghav@samsung.com> From: Hannes Reinecke In-Reply-To: <20220523161601.58078-4-p.raghav@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 5/23/22 18:15, 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. > > As rounddown macro from math.h does not work for 32 bit architectures, > round down operation is open coded. > > Reviewed-by: Luis Chamberlain > Reviewed by: Adam Manzanares > Signed-off-by: Pankaj Raghav > --- > drivers/nvme/host/zns.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c > index 9f81beb4df4e..d92f937d5cb9 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 > + */ > 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,11 @@ 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); > + /* > + * 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); > Reviewed-by: Hannes Reinecke 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: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman