From patchwork Thu Aug 11 14:30:34 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12941476
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 E7BB4C25B0D
for ; Thu, 11 Aug 2022 14:31:06 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S235005AbiHKObF (ORCPT );
Thu, 11 Aug 2022 10:31:05 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43874 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S235351AbiHKOa4 (ORCPT
);
Thu, 11 Aug 2022 10:30:56 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2996BD48
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
20220811143051euoutp0174cbfb93f57a06379a01b870095b0ba7~KUMxqK2fE2136521365euoutp01b
for ;
Thu, 11 Aug 2022 14:30:51 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220811143051euoutp0174cbfb93f57a06379a01b870095b0ba7~KUMxqK2fE2136521365euoutp01b
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
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7ozhb4mGfzYYmix/tQxZovVd/vZ
LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i
/rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS
eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2P2
plssBaf4K561bGNtYFzC28XIySEhYCLxfO8mNhBbSGAFo8SZOfpdjFxA9hdGiQfb/rFBOJ8Z
JS69+scG09F0ZykjRGI5o8TJu1uhnBeMEv0//7B0MXJwsAloSTR2soM0iAikS6xfsJwFpIZZ
oJ9ZYsG/5WCThAUiJc5NuA1WxCKgKjF1yyYwm1fASmLq/ovMENvkJWZe+g4W5xSwlpiw6CIT
RI2gxMmZT1hAbGagmuats5lBFkgIbOeU+HXmK9SpLhKvljYzQtjCEq+Ob2GHsGUkTk/uYYGw
qyWe3vgN1dwC9MHO9WwgH0gAbes7kwNiMgtoSqzfpQ9R7ijR1DKDCaKCT+LGW0GIE/gkJm2b
zgwR5pXoaBOCqFaS2PnzCdRSCYnLTXOglnpI3Pr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r/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
X-RootMTR: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204
References: <20220811143043.126029-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 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;