From patchwork Wed May 25 15:49:53 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12861399
Return-Path:
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
Received: from vger.kernel.org (vger.kernel.org [23.128.96.18])
by smtp.lore.kernel.org (Postfix) with ESMTP id 068BAC433F5
for ; Wed, 25 May 2022 15:50:33 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S238860AbiEYPu1 (ORCPT );
Wed, 25 May 2022 11:50:27 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40102 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S245369AbiEYPuI (ORCPT
);
Wed, 25 May 2022 11:50:08 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ADE3B0A56
for ;
Wed, 25 May 2022 08:50:07 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220525155006euoutp01619608b3ab55e373ea35e0e454db17ab~yY9ssI5NR0415204152euoutp019
for ;
Wed, 25 May 2022 15:50:06 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220525155006euoutp01619608b3ab55e373ea35e0e454db17ab~yY9ssI5NR0415204152euoutp019
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1653493806;
bh=9W1pLbbKKEsanlon70WFxiL7DVRrcoEEPxlxXdEW3tc=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=EUtqN6UoLdNj6uWhYdhS76kwjBfchXAD6tXcjKypXGQ5Zor9Uv0/pySK48uRJXz2Q
Mxjpz9wLtPAQAt3vBJyqK5aFYKN+YiBxC47cgh17iOxGWX9J+/YAmUi3SuV0Tl01RD
OEM7kEUVkpnnfgszDWcWjmmLA/FzWiceeimxHmRk=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220525155004eucas1p2dfa1a7a6b945f9b09d92979e69409947~yY9rKj9GH0574305743eucas1p2V;
Wed, 25 May 2022 15:50:04 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id D8.43.09887.C205E826;
Wed, 25
May 2022 16:50:04 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220525155004eucas1p162c6f43536424f93800ba788ed045363~yY9qwmLNY1064710647eucas1p1p;
Wed, 25 May 2022 15:50:04 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220525155004eusmtrp26fd7b673c6e99ce337989ba209192d6f~yY9qvwSZQ0177001770eusmtrp2Z;
Wed, 25 May 2022 15:50:04 +0000 (GMT)
X-AuditID: cbfec7f4-45bff7000000269f-6c-628e502c8c17
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id A0.9E.09404.B205E826;
Wed, 25
May 2022 16:50:03 +0100 (BST)
Received: from localhost (unknown [106.210.248.20]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220525155003eusmtip11ab0a9c1aac41be6c73f997f027f7090~yY9qdZ3lV1835018350eusmtip1C;
Wed, 25 May 2022 15:50:03 +0000 (GMT)
From: Pankaj Raghav
To: axboe@kernel.dk, damien.lemoal@opensource.wdc.com,
snitzer@redhat.com, Johannes.Thumshirn@wdc.com, hch@lst.de,
hare@suse.de
Cc: dsterba@suse.com, dm-devel@redhat.com, jiangbo.365@bytedance.com,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nvme@lists.infradead.org, jaegeuk@kernel.org,
gost.dev@samsung.com, Pankaj Raghav ,
Bart Van Assche ,
Johannes Thumshirn ,
Luis Chamberlain
Subject: [PATCH v6 4/8] nvmet: Allow ZNS target to support non-power_of_2
zone sizes
Date: Wed, 25 May 2022 17:49:53 +0200
Message-Id: <20220525154957.393656-5-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220525154957.393656-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrKKsWRmVeSWpSXmKPExsWy7djP87o6AX1JBgcOy1isvtvPZjHtw09m
i99nzzNb7H03m9Xiwo9GJoubB3YyWexZNInJYuXqo0wWT9bPYrboOfCBxeJv1z0mi723tC0u
75rDZjF/2VN2ixsTnjJafF7awm7RtvEro4Ogx+Ur3h7/Tqxh87h8ttRj06pONo/NS+o9dt9s
YPPY2Xqf1eP9vqtsHn1bVjF6rN9ylcVj8+lqj8+b5DzaD3QzBfBGcdmkpOZklqUW6dslcGWc
XGNZcJK/Yte5x+wNjPN4uxg5OSQETCS+7VjN3sXIxSEksIJRYu+u86wQzhdGiWNrGpkhnM+M
EksvdrHDtOxeepcNIrGcUeLhrP2MEM4LRom+DXOYuhg5ONgEtCQaO8Hmigg0MkpMfXkCrIhZ
4BuTxJI53Uwgo4QFwiS+vl0DNpZFQFXi6MWP7CDNvAJWEvPnREFsk5eYeek7WAmngLXE/P2f
mUFsXgFBiZMzn7CA2MxANc1bZ4OdKiGwnVNiydU9bBDNLhIn9m+EsoUlXh3fAvWCjMT/nfOZ
IOxqiac3fkM1tzBK9O9czwZyhATQtr4zOSAms4CmxPpd+hDljkD3fGCHqOCTuPFWEOIEPolJ
26YzQ4R5JTrahCCqlSR2/nwCtVRC4nLTHBYI20Pix6OJTBMYFWcheWYWkmdmIexdwMi8ilE8
tbQ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8zf/5kZ4h4ria93vrKC2LwCghInZz5hAbGZgeqbt85mnsAoMAtJahaS
1AJGplWMIqmlxbnpucVGesWJucWleel6yfm5mxiBkbvt2M8tOxhXvvqod4iRiYPxEKMEB7OS
CO+Fp71JQrwpiZVVqUX58UWlOanFhxhNgc6eyCwlmpwPTB15JfGGZgamhiZmlgamlmbGSuK8
ngUdiUIC6YklqdmpqQWpRTB9TBycUg1M3JOrAro0JyveN36aE7Q8uXR/7N4vigU7mxfWMifo
8r8PZFLqeBS8VmmefMwJM80HkkbLtigt8uQvyD/9bWuLKO9mLzHpxq2MnKeFXEv2CKjb/wj+
tmT2nLDoRxceKlWVXJn7ZL/vZGOf7gp/EVH5lksN/cqPXXZOritM1HjEU2j+o0Y1S3JvfuT5
qDef77y+M3vmry1lphNNfhcsc9n2/yXfrNPP4rMChefc/CeSLKMwY/muZ1xHzoa+msRTtcVl
a/n/vXWGGdPaJPQ0hbWu1l5YaLn99L27CgI+LTXf2Gc7nNhfs32S0Vu5ZxXvO57FZczdvv8u
Y25qV/wLmwdX/z33LPv+azO3g5aRdliMEktxRqKhFnNRcSIANKoc7WUDAAA=
X-CMS-MailID: 20220525155004eucas1p162c6f43536424f93800ba788ed045363
X-Msg-Generator: CA
X-RootMTR: 20220525155004eucas1p162c6f43536424f93800ba788ed045363
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220525155004eucas1p162c6f43536424f93800ba788ed045363
References: <20220525154957.393656-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@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
Reviewed-by: Johannes Thumshirn
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 e34718b09550..e41b6a6ef048 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -243,7 +243,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 f5c7a41032ba..ed8742a72dcb 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1382,6 +1382,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);