Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4720331ioa; Wed, 27 Apr 2022 09:37:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOmAeLZktEJEBs8enNkMtj/dXl2iSHWfkh7ORKvBRyW3iV7+s6m5WUfsBQngQ1sa9k6EbI X-Received: by 2002:a17:902:bb90:b0:158:a031:2ff2 with SMTP id m16-20020a170902bb9000b00158a0312ff2mr29796234pls.117.1651077438379; Wed, 27 Apr 2022 09:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077438; cv=none; d=google.com; s=arc-20160816; b=cDan/QCN5zt+EzTl2LWb3JvZ1trm4XnglfdEhRTkw3dgoTSMYh8+0nvh78Nvczbabh iORjJoEACrMA4fQ2jIJNwYxtLlmApKfqNd6Hwz9fivlb4BYdGXQTW3+7xpryp6oVVr/+ xVME24/aEnHGCzckn9Q8sNYvT5VPJasJgR55ZibepengHaQN0mzg8bfI8H/QctjGwXxr eHQLxxmcI6lBOvSMZ8uWZpnFAmv2yt2u1XS6rmYAsECaxx8RdrmMX10P7gTsWVJdbMra /kgjzid/8YnXnvSIbZypvmsLwssaoQXTj0J7OFXpJzqjbiW2ZphQdJxgbje2a1DSG+jZ ipbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=K2H4xPkIz91YDFdyCv2zwfrxVTdulhy1N1SKCVAIbPs=; b=tWtO5g8gJSMGH+TV6AQ1RBP/uKISJVbAAhmM+RWt0PtkF6athOojoIrARBGf9VZ0Gi a1EL+ArATe97IvayTjxNqZl6p1100xvHx9hphsCO2plrD6mFmb+JzTY1CV1jJ5Q2Xg4C Q7HM1BtaiMqmEQhgrMdx7crNoLY1StmkezxNEX4+TN4Xmq7Y5QiIGIpIc9BF0kPrzBpj Ou7gk76GgnyShPU6y+zv0GbUwV97Rs5K6YhM85TkiqoFJUz0uP0GSJX5iYzN8XqW8Ap+ tOBJ6/tbl64/01T/1FHbTB8XORp2A3XzAAd4wtGV1ZtxQEyN3QEgCMeVlzN5ZQLNvTQt Mhnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Sp9VM4Td; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oc3-20020a17090b1c0300b001d942616147si2535557pjb.9.2022.04.27.09.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:37:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Sp9VM4Td; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DFA8249F4E6; Wed, 27 Apr 2022 09:07:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241785AbiD0QHq (ORCPT + 99 others); Wed, 27 Apr 2022 12:07:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241647AbiD0QGy (ORCPT ); Wed, 27 Apr 2022 12:06:54 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 195D53CE9BB for ; Wed, 27 Apr 2022 09:03:08 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220427160304euoutp0294b0e859a0ec2ed3fa26000bec3afc7a~pzFBp3SMF1400814008euoutp02x for ; Wed, 27 Apr 2022 16:03:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220427160304euoutp0294b0e859a0ec2ed3fa26000bec3afc7a~pzFBp3SMF1400814008euoutp02x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651075384; bh=K2H4xPkIz91YDFdyCv2zwfrxVTdulhy1N1SKCVAIbPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sp9VM4Td3vG0k/ykXWvXxR97Y5i8f0rspVz80mZPqaOhHumhgp4oLd1W8BLafa8E2 3RbXSp50mXqyaR3MMrmEGSO7olnmxv+LbJjrs7YBgPFTVwViPj6MLFBnkolTteuyzm 0rqWeHE7dXk8asdvUZUddbVpo2lcA9uM/SY+7G6c= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220427160302eucas1p21c415084c0ee2461ca1f2112d95ba2cb~pzFAAgkwA2336123361eucas1p2m; Wed, 27 Apr 2022 16:03:02 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 27.0A.10260.63969626; Wed, 27 Apr 2022 17:03:02 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224~pzE-LcsQc0330603306eucas1p1R; Wed, 27 Apr 2022 16:03:01 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220427160301eusmtrp22fb9b18976fb07e36270ff54bf0dfad9~pzE-HzO9m2598325983eusmtrp2i; Wed, 27 Apr 2022 16:03:01 +0000 (GMT) X-AuditID: cbfec7f5-bf3ff70000002814-87-62696936abd5 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D1.81.09522.53969626; Wed, 27 Apr 2022 17:03:01 +0100 (BST) Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220427160301eusmtip23507d9cdffdd2cc397776ec30d69ca54~pzE_2Psd42569125691eusmtip2H; Wed, 27 Apr 2022 16:03:01 +0000 (GMT) From: Pankaj Raghav To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com, sagi@grimberg.me, damien.lemoal@opensource.wdc.com, dsterba@suse.com, johannes.thumshirn@wdc.com Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, clm@fb.com, gost.dev@samsung.com, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com, jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org, kch@nvidia.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, linux-block@vger.kernel.org, Pankaj Raghav Subject: [PATCH 05/16] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size Date: Wed, 27 Apr 2022 18:02:44 +0200 Message-Id: <20220427160255.300418-6-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAA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cy+JKTOnV04GXTlZK569jsf35LoaPvNN7bRwZK6LOGwq2K82zhelC39O3js SOEGbY639dLuW/POowvFHclRe4INO/r99+/KHzo1vNTx0G3uC+NkHjhI7TshniheOa2rCq8O j7oXabFWOR8f7Dk8Q8D9NX7lWmWEceDBXmV9IseqftN+tjVt5VD+geBGv9rdm21We4wibmyr +ZgzZM45/+Pk80BCniwK347L5KL/ANv7M6o/BAAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPKsWRmVeSWpSXmKPExsVy+t/xe7qmmZlJBs/XilmsP3WM2WL13X42 i2kffjJbnJ56lsliUv8MdovfZ88zW+x9N5vV4sKPRiaLmwd2MlmsXH2UyeLJ+lnMFj0HPrBY /O26BxRrechs8eehocWkQ9cYLZ5encVksfeWtsWlxyvYLS4tcrfYs/cki8XlXXPYLOYve8pu MaHtK7PFjQlPGS0mHt/MavF5aQu7xbrX71ksTtySdpD1uHzF2+PfiTVsHhOb37F7nL+3kcXj 8tlSj02rOtk8FjZMZfbYvKTeY/eCz0weu282sHn0Nr9j89jZep/V4/2+q2wefVtWMXqs33KV xWPC5o2sAUJRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZGpkr6djYpqTmZZalF +nYJehktR1+wFTzmr3hxeDpLA+M03i5GTg4JAROJRb/Xs3QxcnEICSxllLg/cT8LREJC4vbC JkYIW1jiz7UuNoii54wSG6evZ+pi5OBgE9CSaOxkB4mLCDwBav75GGwSs0ADi8StibuYQLqF BUIlln9qYwexWQRUJdYf/cQGYvMKWEns+bcZapu8xMxL39lBhnIKWEtM+BQBEhYCKuledIsV olxQ4uTMJ2DlzEDlzVtnM09gFJiFJDULSWoBI9MqRpHU0uLc9NxiQ73ixNzi0rx0veT83E2M wJSy7djPzTsY5736qHeIkYmD8RCjBAezkgjvl90ZSUK8KYmVValF+fFFpTmpxYcYTYHOnsgs JZqcD0xqeSXxhmYGpoYmZpYGppZmxkrivJ4FHYlCAumJJanZqakFqUUwfUwcnFINTBt0uMpi LR7M/tjxO8sx2OtUwnq+RenK1fraUaZHbYKOSVomTnnVofXeZJHr4i2HThfGvpKdYN6c2ZDZ dE5gao+D/OSvXf3CMwq3vEhj1XvTPinwAlds/+3OWt0nLNG31dYU7eq8x7CcrUGScadnzBlr P4l779anlkaf/jo57oDM1MhPgtwsv/zOB8o2iB89t/2eVOdcZpHY3oK2+r8C1+8JJO7TNPA9 s12XeUecU3u/lI/OhpA13bqcv04WuEl7+Yh+m12o52AbJbH8UDTjCvmXvGe1W/75MIYumtYg ee7VpIW9T2+1/bZ8efTdEQGV9d33Qlep3re7dYXPJMq9Mf62H/s1NZ+TFunCbAlKLMUZiYZa zEXFiQBD5j4jsgMAAA== X-CMS-MailID: 20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224 References: <20220427160255.300418-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 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)); 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); -- 2.25.1