Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3656238rwb; Tue, 16 Aug 2022 06:51:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Tlb8eYIoelpcexERqPjBS+8ZUxerMc5KzipbVaTEPyypG7a7lFKdvPkwUwJi4Ee2/7dIe X-Received: by 2002:a17:907:75c1:b0:72f:248d:5259 with SMTP id jl1-20020a17090775c100b0072f248d5259mr13775685ejc.227.1660657902744; Tue, 16 Aug 2022 06:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660657902; cv=none; d=google.com; s=arc-20160816; b=CWybQgxq427MG1Yq7Tse7NpCjUUDZguk9OS+UbosOz54dRcDR6i/3G5tAAHHGDHt2+ li9jY38SdDOI+P4e7E4kyM4j1a7xiCdpWwQ7UDeO54n2/N4Ht+BAI6SCAzsl30hcMrqX gYQUpiVyzOaenjgYa41U8V3tfIBuKyNSS3OAOr/UCwXy0UQM1PMNeKJ8m9Z1giJSIUrv CUOGZJ/2FxlsTBjdZaOBt5qbBvzBH+c5I2zPVFFWk4E613qT6KZsaYSwrA1cS57kkzGs 4oGfuUahiSoK6pbGoaSlj0+78gi6FlAItV6Lox7gblgnvX+r08l2Y/v14H+ypOWemgwq h6dA== 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=zcE5Adn29ZMF++Fqw83SwV299p3M0hwBIu74IBaaXFqgQPvLVf39yXNHFDKgX3l9Vt u+D0zWDhZpIq/yXPHoLguC+kG7zN5M70kbpBiWM8zvkfVT5dW/FpvsqgDWtW3Dw8ioPw 71B9p4i8jDRZsnyJ5CR+8ouPpLyalcjx4Zl9aLeSwIm8nkcGLMMhgNiMj0ML/NdfkqZo vHHod2uSFQyL6GAK1uIbPlziLgblGsN57G0zvw58Fqs4EuBWpPQz9BuvMHIHHTnbc1MO iE6KeZMGJoNG1jmTedvLzxVlx/0ZCFqslCGc1CrZwM7Rfa9zGxN0paYW2HmL2TLw4J23 eQUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=OX6D6dlY; 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 cr14-20020a170906d54e00b007383988da8asi5537194ejc.586.2022.08.16.06.51.16; Tue, 16 Aug 2022 06:51: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=@samsung.com header.s=mail20170921 header.b=OX6D6dlY; 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 S235592AbiHPNQM (ORCPT + 99 others); Tue, 16 Aug 2022 09:16:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232922AbiHPNPt (ORCPT ); Tue, 16 Aug 2022 09:15:49 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 676E05F22A for ; Tue, 16 Aug 2022 06:15:45 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131544euoutp02a0d277971d97a25eb0b19a3b8b768876~L1ZnUCfNs2958029580euoutp02G for ; Tue, 16 Aug 2022 13:15:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220816131544euoutp02a0d277971d97a25eb0b19a3b8b768876~L1ZnUCfNs2958029580euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655744; bh=tGdXrZOo82rW1rnRJeQcvmwRabixUhHDV5CM9X+9nHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OX6D6dlYQbFMtbD2VhiTAiNsHUHXNSsSybLVZN/G8Ypg9oh/VdhQHbTcHpRPl+CMw G3lOhGkLMybeXNuUKX+8JYS6a/tiozMx2AhRCl/4Cd02JMm3HlpANKnhulOkN6kpyS nwX2cGbNm31MkUETavuA7tFCFOymOkknEOyIwXsg= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220816131542eucas1p25ea333b0145dc2db4bea93399819c075~L1ZliQojs0372203722eucas1p20; Tue, 16 Aug 2022 13:15:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id ED.65.09580.E789BF26; Tue, 16 Aug 2022 14:15:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032~L1ZlEiMOm0141101411eucas1p1a; Tue, 16 Aug 2022 13:15:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131541eusmtrp112f9ecb9c4ed041e0ee37c232919a072~L1ZlDriu-0149801498eusmtrp1C; Tue, 16 Aug 2022 13:15:41 +0000 (GMT) X-AuditID: cbfec7f5-9adff7000000256c-df-62fb987e6c6b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5C.A0.09095.D789BF26; Tue, 16 Aug 2022 14:15:41 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131541eusmtip183589bb30aa83ccac3b2bcf6852af3fe~L1ZkxXq_W2694326943eusmtip1A; Tue, 16 Aug 2022 13:15:41 +0000 (GMT) From: Pankaj Raghav To: damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, agk@redhat.com Cc: pankydev8@gmail.com, gost.dev@samsung.com, matias.bjorling@wdc.com, hare@suse.de, bvanassche@acm.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, Johannes.Thumshirn@wdc.com, linux-block@vger.kernel.org, Pankaj Raghav , Johannes Thumshirn , Luis Chamberlain Subject: [PATCH v11 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Tue, 16 Aug 2022 15:15:27 +0200 Message-Id: <20220816131536.189406-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220816131536.189406-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKKsWRmVeSWpSXmKPExsWy7djP87p1M34nGfQfE7RYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlTF7 0y2WglP8Fc9atrE2MC7h7WLk5J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i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCdKz6Yov7QkVSEjv7jEVina 0MJIz9DSQs/IxFLP0Ng81srIVEnfziYlNSezLLVI3y5BL2P2plssBaf4K561bGNtYFzC28XI ySEhYCJxc88s9i5GLg4hgaWMEs1bjzFCJCQkbi9sgrKFJf5c62IDsYUEnjFKvDkm38XIwcEm oCXR2MkOEhYRyJVYtKyDFWQOs8B8Zon5b5eygNQIC4RL9G+rBqlhEVCVaD67GGwkr4CVxPlZ 21ghxstLzLz0HWwOp4C1xL+GVSwQq6wk2o5dZoaoF5Q4OfMJWJwZqL5562zmCYwCs5CkZiFJ LWBkWsUoklpanJueW2yoV5yYW1yal66XnJ+7iREYuduO/dy8g3Heq496hxiZOBgPMUpwMCuJ 8Aq++JEkxJuSWFmVWpQfX1Sak1p8iNEU6O6JzFKiyfnA1JFXEm9oZmBqaGJmaWBqaWasJM7r WdCRKCSQnliSmp2aWpBaBNPHxMEp1cBU/rJnlXu8j7k438w9aRnWG9sqWvacPr22h/vK6r2W c9adLDq+hL+yhU+ShT3Oe/2CpG41u8kbVpse+8x3fIX65uC/TY9/uMbUL2jt3F956R3Pksva vmIyS9hObpsx1V6KI2CbPWPVbI0C4ctrVNrOMny0i75Vwvtm4bXulzzqK5re8HnlClvKmmyv m3K9MurjY60KTUn9rRoHsne31j54mbpkXZFP0t2L839t5zwdGdOxlE9CYAd7jNHutXdN3Zjt lLoYK6pcGvUtMx1PMx8wmfQ5eF9Iu5xNnHLqpD11zAwZvHOXfzJnLNj46JnG/Ykl2/b8uqr3 4TGzXFbR8VVqRWm/XwYrWgpO/XhcUVOJpTgj0VCLuag4EQBKYnwZZQMAAA== X-CMS-MailID: 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032 References: <20220816131536.189406-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.1 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=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 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