Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3138537iob; Mon, 16 May 2022 14:07:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxbngylmQ7v5HNOaulCYgLpndI1Sgvj1BN0remjxUyhEYgNEBvCrVYRB9FVO/zspxAUH92 X-Received: by 2002:a17:906:60cd:b0:6fd:d95c:3e34 with SMTP id f13-20020a17090660cd00b006fdd95c3e34mr17167184ejk.250.1652735250576; Mon, 16 May 2022 14:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652735250; cv=none; d=google.com; s=arc-20160816; b=CQLCvynDBmUgN2dNE9nY8Glim5oUXTlLOVP7fCcnWYrxWGLDAOJAfrRpqO+r9NQu6f og2VNngXXav36mMPkQCvqUQte8H+r4wtH5mc4fV/vmKCRTKQCF0+949IfwA8JBcDJZuH bsPqHn1eE4ysUDcB98eob9btSZG+WWOfPmWMXsiqCqatCRWoYCUzAFC8plMEfJ7myd6J NzN2uC2eEndmTQ+B6IUE1Ck2k8Q7qL1gG85Fwifk77ZaGkD3ryo5hYqDqMkTkl0Ut7CR 2bjVD61cXwCE3L8tkROoPXE3B35lJ6FzKRN11KqedqkZiUgSY1s2zahfxxT/G3K4vGWv wOnA== 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=vrYMM/cTOrW0/UYYWyRRUQC9LsDHx9p6dz/qEYyG7Ug=; b=RNCartd3d4+zbdvhmvt8RLDxOi19nNDMScrxbLrkZqh5kyvN5/AYr7kgC7A6NJqRTw HPIC/ITTYn7RCMogBotX8cT1EPPRCMcXD0M0ZAh4YpZKcES7Zi71f3W8njOphgGJ+1HK JY36dsk4L9r8OFoEvy7xKpehprelAjliClS/zCA06DNdDeX0R3J1PletjyWpoierVYnb waP7ovOr5C6ig8ZGxi6ICSAqH9k+YjLE0ufXjjAWoyDb9Oof/4Cm5+qIS59VNesHiFit HTKBrOe8kg/fEvuLhpkngtwxNRn2XX97y8egEZCqYpezq44XZ4ibN6LGHzWwB9OsLRUt 52WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=lGtjbgmG; 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=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a056402511100b00425ed902ba4si12635584edd.373.2022.05.16.14.07.05; Mon, 16 May 2022 14:07:30 -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=@samsung.com header.s=mail20170921 header.b=lGtjbgmG; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240711AbiEPNkB (ORCPT + 99 others); Mon, 16 May 2022 09:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243421AbiEPNji (ORCPT ); Mon, 16 May 2022 09:39:38 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E80AD2ED64 for ; Mon, 16 May 2022 06:39:36 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220516133928euoutp02f05b279049e521e3539218a628a68337~vmYFKPPE51726517265euoutp02N for ; Mon, 16 May 2022 13:39:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220516133928euoutp02f05b279049e521e3539218a628a68337~vmYFKPPE51726517265euoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1652708368; bh=vrYMM/cTOrW0/UYYWyRRUQC9LsDHx9p6dz/qEYyG7Ug=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=lGtjbgmGFr2YxtOx2xcRZIY2OWyIRIMYbS01ZS/PpxA5hEcY6pd459l6tvH1g2IKO HHV7XOx9/DrTxYMCaw4T+JoDU1M//BSmRxI3i+cPqR2kAqsLFKfxHwLijj71J0NVSv /VBh0BxZWe4HpmRa8WpBTQI8jo1RSJY31FvBrZAo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220516133928eucas1p17f913d0f1876cd98dcc58f76f736ade6~vmYEsE7iP0943109431eucas1p1M; Mon, 16 May 2022 13:39:28 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FF.8D.09887.01452826; Mon, 16 May 2022 14:39:28 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220516133927eucas1p1bab57e07c14c1194705e254afdd5d346~vmYEMRaTH0242102421eucas1p1n; Mon, 16 May 2022 13:39:27 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220516133927eusmtrp20361a1951764c888368339cde1da5799~vmYELPEDL2486924869eusmtrp2W; Mon, 16 May 2022 13:39:27 +0000 (GMT) X-AuditID: cbfec7f4-471ff7000000269f-64-62825410e4a6 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 02.09.09404.F0452826; Mon, 16 May 2022 14:39:27 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220516133927eusmtip18398a47cd4b3d6f2c96039f7a1ceee72~vmYEAZeBt0855508555eusmtip1b; Mon, 16 May 2022 13:39:27 +0000 (GMT) Received: from localhost (106.110.32.130) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 16 May 2022 14:39:26 +0100 From: Pankaj Raghav To: , , , , , , , CC: , , , , Keith Busch , , , Johannes Thumshirn , "Josef Bacik" , , Alasdair Kergon , , Jens Axboe , "Sagi Grimberg" , , , Chaitanya Kulkarni , , Chris Mason , Pankaj Raghav , Hannes Reinecke , Luis Chamberlain Subject: [PATCH v4 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Mon, 16 May 2022 15:39:12 +0200 Message-ID: <20220516133921.126925-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516133921.126925-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [106.110.32.130] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0xTZxjG851zenraWXZanH6pZGaVjSiReWHuy0SciX8cd0WyZYubcS0e LuNS1lpUDLFy2yBgodtUKEzYrdh2dlBgoIUIxBbFAqFDoWMQgs0Qxr1kEgaMcnDhv+d939/7 fM+bfBQuuUFKqYSUM6wqRZ4kI4VEvWOhczf9QaZij76ORtb7Dhyt2B0kMv+pI9GV6QUc6XXX +GjR1YWjpkkDD3U/vYQh+/d6DN0w38XQY2spjgruTBNoKX9wt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Dn8lPX8je31 ns8eSr+ODHgtLnhZi6eSf5G2p5b+hWUT5mqkCj91O65ycrda5s65yf6B5eHffc1Vbt4WCN2d GfKh+XNB/fOHDd90Xy8JPRe3L6a3SbUgVvi1E+Pxtqft8YE196LLfew0Pl1YPvmfqZTtDZYn S0JDueY386pVfNDPaOYV/xPOr9hw+IgSS3FGoqEWc1FxIgCY9rvo5QMAAA== X-CMS-MailID: 20220516133927eucas1p1bab57e07c14c1194705e254afdd5d346 X-Msg-Generator: CA X-RootMTR: 20220516133927eucas1p1bab57e07c14c1194705e254afdd5d346 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220516133927eucas1p1bab57e07c14c1194705e254afdd5d346 References: <20220516133921.126925-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 A generic bdev_zone_no helper is added to calculate zone number for a given sector in a block device. This helper internally uses blk_queue_zone_no to find the zone number. Use the helper bdev_zone_no() to calculate nr of zones. This let's us make modifications to the math if needed in one place and adds now support for npo2 zone devices. Reviewed by: Adam Manzanares Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/nvme/target/zns.c | 2 +- include/linux/blkdev.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c index 82b61acf7..5516dd6cc 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -242,7 +242,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req) unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba); return blkdev_nr_zones(req->ns->bdev->bd_disk) - - (sect >> ilog2(bdev_zone_sectors(req->ns->bdev))); + bdev_zone_no(req->ns->bdev, sect); } static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 32d7bd7b1..967790f51 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1370,6 +1370,13 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev) return 0; } +static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec) +{ + struct request_queue *q = bdev_get_queue(bdev); + + return blk_queue_zone_no(q, sec); +} + static inline unsigned int bdev_max_open_zones(struct block_device *bdev) { struct request_queue *q = bdev_get_queue(bdev); -- 2.25.1