Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp638324rwb; Thu, 11 Aug 2022 07:33:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR65x5VHLLbDPj/qcRB4VRrBUj1ezPCSGOZuHrWtmRE3t3vxXmPT3Iwk+4BWvYTZtcoekXTu X-Received: by 2002:a05:6402:100e:b0:440:785c:20c9 with SMTP id c14-20020a056402100e00b00440785c20c9mr21248218edu.184.1660228436960; Thu, 11 Aug 2022 07:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660228436; cv=none; d=google.com; s=arc-20160816; b=Iu0A62y3SmHM0IzXHHzGlfSXVImYZ2AJUvy3mo+EMkW/ThwgUHLNaFzihEUDhxPS7+ /Vo/b/jVZsIRe5dd0SI2K8sV7fo3GFq/0Oosnsy262qJlNgV69SrmPbSmPkbutimjjmI nCC4se9w8NGg+NZPk/7s+JDBxAPdIx0iK2tawaY8I0off96x7qfXzVPhQ2+lJH4XdD/I 6/3X5HAP6k9NUA9NNRskTwbAm79Czco5tjTq2EjHIu8fyBczjtVkYpbimZ4ZP+x83IAo 9igfK3qiaQwAMn7IlYT7npjF2/1ZmXtByy2iZTa3LP5BO+G2Svs7G37wPpyi2kP6Z5Qu Hwng== 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=tGdXrZOo82rW1rnRJeQcvmwRabixUhHDV5CM9X+9nHY=; b=x/WFbVa4jC7d+34M9Tt/w8Vj3PAfvjV77q5099Krvfi4iLO7PY4P7ijCJGa7V/55Y2 PzzOEVVyqVTnygN1BkLx9N5aQcWfPEWHEywiUBcpn0HDHKe2QlebDRkLueR6do5F8Js1 jJrvd4/MVZhZxWsfChJL3axhSdJYCaB4TEe7tN6zUkZiGo4hH8CyPZVsbZ4V3O9DPEIg +ZAN4fQNLbesRceO51xjTZpPEXavAOZWnkQ/tcYV4tYtACnZjr0ML5UESYG8jpfs57sf wIajrBM9X2omvOMQRO338XjUJkDHfP1mMAc26zS3liOpo+dQlQueV5HBwuHGM4A+8tfH hyVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rIIVgrmd; 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 q1-20020a056402248100b0044217256e13si2059909eda.441.2022.08.11.07.33.27; Thu, 11 Aug 2022 07:33:56 -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=rIIVgrmd; 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 S235573AbiHKObZ (ORCPT + 99 others); Thu, 11 Aug 2022 10:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235484AbiHKOa5 (ORCPT ); Thu, 11 Aug 2022 10:30:57 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC99E647FA for ; Thu, 11 Aug 2022 07:30:55 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143051euoutp01de47badcaba00ba8521f5428582e4ed8~KUMxsXJx92164821648euoutp01M for ; Thu, 11 Aug 2022 14:30:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143051euoutp01de47badcaba00ba8521f5428582e4ed8~KUMxsXJx92164821648euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228251; bh=tGdXrZOo82rW1rnRJeQcvmwRabixUhHDV5CM9X+9nHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIIVgrmdDjVY7c6oUankpYVIjETFb1jFWYQyCvWLeMj8aHxZBr++3Pu5U3A7LbLdb lT7GQJjgYhlpAuMrvH3Y427Z7xiEuAVwsqDoyQLEiHQUiUlu1lMx20HKy48c0fVhFN Os7p2qwwfb3WWQVzL0EtAayOFht3NatXh5861rbM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143049eucas1p27cb8b7758e8a5e7b59456f22fb326720~KUMwHY_MB1006810068eucas1p2M; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 92.3A.09664.99215F26; Thu, 11 Aug 2022 15:30:49 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204~KUMvfQPuc0779607796eucas1p1j; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143049eusmtrp1e3aae0de0e516634df21100a3c33ba88~KUMvdqMez2320623206eusmtrp1b; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-ee-62f51299c5cc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D2.10.09038.99215F26; Thu, 11 Aug 2022 15:30:49 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143048eusmtip11fa620b806bf661c7086d78210f8c4d5~KUMvLFObd3242632426eusmtip1D; Thu, 11 Aug 2022 14:30:48 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Johannes Thumshirn , Luis Chamberlain Subject: [PATCH v10 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Thu, 11 Aug 2022 16:30:34 +0200 Message-Id: <20220811143043.126029-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7ozhb4mGfzYYmix/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2P2 plssBaf4K561bGNtYFzC28XIySEhYCLxfO8mNhBbSGAFo8SZOfpdjFxA9hdG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T2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCdKz6Yov7QkVSEjv7jEVina 0MJIz9DSQs/IxFLP0Ng81srIVEnfziYlNSezLLVI3y5BL2P2plssBaf4K561bGNtYFzC28XI ySEhYCLRdGcpI4gtJLCUUeJzTxxEXELi9sImRghbWOLPtS62LkYuoJpnjBLH22azdjFycLAJ aEk0drKDmCICuRIHjwSClDALzGeWeNn/HKxEWCBc4sCueJAxLAKqElO3bGIHsXkFrCSm7r/I DDFeXmLmpe9gcU4Ba4kJiy4yQZxjJTGh4xhUvaDEyZlPWEBsZqD65q2zmScwCsxCkpqFJLWA kWkVo0hqaXFuem6xkV5xYm5xaV66XnJ+7iZGYNxuO/Zzyw7Gla8+6h1iZOJgPMQowcGsJMJb tuhzkhBvSmJlVWpRfnxRaU5q8SFGU6C7JzJLiSbnAxNHXkm8oZmBqaGJmaWBqaWZsZI4r2dB R6KQQHpiSWp2ampBahFMHxMHp1QDk1VZ0G9JZS2XSSqGCXv91oRXZTmEivcFnt4U7p/2fubE E/tUNr2JXz7B/alLs7bWHaevQtyXT7Hfa4jp/Tr3LUcwq+uFHe5JF+PX7k54qrVj1srju6+9 jMoyuKN6OmOByQ6P/XeU3uzL+bj+1p8Oh1vvV9+NVd8x5WjJsgnqF9jOX43SmuW6p3p7nQt7 9FPhjaL1qmUKb3adjOHS/pD6/7ULj9Ky+tgki/2x3CqWom+77vzQMrYwlz6vXfPE9cVxLc/d 5coPpjoI7Xi0fev08xnHJ2+b1bqReYaZ/qc9H1WPPfnTw3Z2rv9Upo+uWakvWrJf7fvSUPxn 7aRG+3snru5VvRD5fjPDRrsbl9KDp3QqsRRnJBpqMRcVJwIASf8/ImQDAAA= X-CMS-MailID: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204 References: <20220811143043.126029-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.7 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 disk_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 zoned devices with non po2 zone size. Reviewed by: Adam Manzanares Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/nvme/target/zns.c | 3 +-- include/linux/blkdev.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c index c7ef69f29fe4..662f1a92f39b 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -241,8 +241,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 bdev_nr_zones(req->ns->bdev) - - (sect >> ilog2(bdev_zone_sectors(req->ns->bdev))); + return bdev_nr_zones(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 d0d66a0db224..b2636dcca105 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1340,6 +1340,11 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) return BLK_ZONED_NONE; } +static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec) +{ + return disk_zone_no(bdev->bd_disk, sec); +} + static inline int queue_dma_alignment(const struct request_queue *q) { return q ? q->dma_alignment : 511; -- 2.25.1