From patchwork Wed Aug 3 09:47:49 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935328
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 DCD82C19F28
for ; Wed, 3 Aug 2022 09:48:15 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237459AbiHCJsO (ORCPT );
Wed, 3 Aug 2022 05:48:14 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58978 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S236046AbiHCJsN (ORCPT
); Wed, 3 Aug 2022 05:48:13 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE6EA1F62F
for ;
Wed, 3 Aug 2022 02:48:09 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094806euoutp013d43473078640e30df5a2ac34636275a~HzLnN_JXJ3204232042euoutp01w
for ;
Wed, 3 Aug 2022 09:48:06 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094806euoutp013d43473078640e30df5a2ac34636275a~HzLnN_JXJ3204232042euoutp01w
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520086;
bh=AD8v/RK3vFIqsgabYiTtVZbPbcAOQ4zUOz/AmbfbvbE=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=iRXn0UmwY8hgWPVxsZu8A4quC3F9VbzMhhgCbJH3bi8sYQrS/a38E4joFjL2Sj98e
0eBSTpIQdpisjkixXy2QI+conYm5vRrmGFtEuMKDttQ3oflV0zmuy6UX0dC5TCSpia
WM7ITptkhlLkJzvwvmVL/VkVV6w6wbwaoV80V/kc=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094804eucas1p23f4f95acc37debaf32ebca7b7461228e~HzLlsvk8B2078320783eucas1p2-;
Wed, 3 Aug 2022 09:48:04 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 47.F2.09580.4544AE26;
Wed, 3
Aug 2022 10:48:04 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220803094803eucas1p2ee8d16f3b6e08203ac9b4e0df6f53d9d~HzLlKJBYJ2274622746eucas1p2y;
Wed, 3 Aug 2022 09:48:03 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220803094803eusmtrp29abd99fd25b82a7151d193ea5f023056~HzLlJU8T40985609856eusmtrp2q;
Wed, 3 Aug 2022 09:48:03 +0000 (GMT)
X-AuditID: cbfec7f5-9c3ff7000000256c-08-62ea44546ac3
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 9A.DB.09095.3544AE26;
Wed, 3
Aug 2022 10:48:03 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220803094803eusmtip28563b2ce9e5f1b5ca2b66ba8b64b2160~HzLkybMHr1682216822eusmtip2o;
Wed, 3 Aug 2022 09:48:03 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Luis Chamberlain ,
Adam Manzanares
Subject: [PATCH v9 01/13] block: make bdev_nr_zones and disk_zone_no generic
for npo2 zone size
Date: Wed, 3 Aug 2022 11:47:49 +0200
Message-Id: <20220803094801.177490-2-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrJKsWRmVeSWpSXmKPExsWy7djP87ohLq+SDC4sFrWYfljRYv2pY8wW
q+/2s1lM+/CT2eL32fPMFnvfzWa1uHlgJ5PFnkWTmCxWrj7KZPFk/Sxmi79d95gs9t7Stri8
aw6bxfxlT9ktJrR9Zba4MeEpo8XnpS3sFmtuPmWxOHFL2kHY4/IVb4+ds+6ye1w+W+qxaVUn
m8fmJfUeu282sHnsbL3P6vF+31U2j74tqxg9Np+u9vi8Sc6j/UA3UwBPFJdNSmpOZllqkb5d
AlfG36ntTAVXRSqeTXjF1sA4S7CLkZNDQsBE4vb5NcxdjFwcQgIrGCW2H3jFBuF8YZS4tLKP
CcL5zChx7cMe1i5GDrCW7mO6EPHljBL7b/+Dan/JKPFt2kI2kCI2AS2Jxk52kLiIQDOjxN2/
PawgDrPAGyaJZct/s4MsFxZIlNjV/ZwNxGYRUJVouPGCCcTmFbCSmHn4OwvEgfISMy99B6vn
FLCWmPIPZBtIjaDEyZlPwGqYgWqat84Gu0JC4DCnxIYbS1ghml0kLm89ywRhC0u8Or6FHcKW
kfi/cz5UvFri6Y3fUM0tjBL9O9ezQfxpLdF3JgfEZBbQlFi/Sx+i3FHiRtt7dogKPokbbwUh
TuCTmLRtOjNEmFeio00Iolp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S4fOYcK4jDLPCHSeLv0dMsIA3CAvESR0+3soLYLAKqEg03XoAt
4BWwkph5+DsLxAJ5iZmXvrOD2JwC1hJT/v1jhlhmJbHu7yxWiHpBiZMzn4DVMwPVN2+dzTyB
UWAWktQsJKkFjEyrGEVSS4tz03OLDfWKE3OLS/PS9ZLzczcxAmN427Gfm3cwznv1Ue8QIxMH
4yFGCQ5mJRHeOy7Pk4R4UxIrq1KL8uOLSnNSiw8xmgLdPZFZSjQ5H5hE8kriDc0MTA1NzCwN
TC3NjJXEeT0LOhKFBNITS1KzU1MLUotg+pg4OKUamPxrN894KbnldNZ3Ltf+tq3Wf4If6rB+
2flbIsxEsPpoUI/KNOMV0q171MMDT3iLbn3Ivia8wHvrqlV+M1xWLjtku/z0+VPBC5W4fPwm
1STvd1j+su5mReUF73X7l66tst3rm7dI/+1z1Q6W2T6bfm1ruc1skbV2S/PsRVsczr29ovpY
f4d+udXLTzs2fa/a2SJodV5HJmNjXLl6hOFiM+kKh0U5j18wb39rXNUSfnmywPaiCU+vc0+8
vfG8p9RM4cK5s5edEMg5sGbf2UO6O5R9lV5Y/NK9ucLen7cw4pIkM+/UQ+V7b/pl/JDfrxex
JY59yR41JT6WM49iDwfrSvfo/ZKfnL3yeNM5ybX8E1KUWIozEg21mIuKEwGNwBmyagMAAA==
X-CMS-MailID: 20220803094803eucas1p2ee8d16f3b6e08203ac9b4e0df6f53d9d
X-Msg-Generator: CA
X-RootMTR: 20220803094803eucas1p2ee8d16f3b6e08203ac9b4e0df6f53d9d
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094803eucas1p2ee8d16f3b6e08203ac9b4e0df6f53d9d
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Adapt bdev_nr_zones and disk_zone_no functions so that they can
also work for non-power-of-2 zone sizes.
As the existing deployments assume that a device zone size is a power of
2 number of sectors, power-of-2 optimized calculation is used for those
devices.
There are no direct hot paths modified and the changes just
introduce one new branch per call.
Reviewed-by: Luis Chamberlain
Reviewed-by: Adam Manzanares
Reviewed-by: Hannes Reinecke
Signed-off-by: Pankaj Raghav
Reviewed-by: Bart Van Assche
---
block/blk-zoned.c | 13 +++++++++----
include/linux/blkdev.h | 8 +++++++-
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index a264621d4905..dce9c95b4bcd 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -111,17 +111,22 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
* bdev_nr_zones - Get number of zones
* @bdev: Target device
*
- * Return the total number of zones of a zoned block device. For a block
- * device without zone capabilities, the number of zones is always 0.
+ * Return the total number of zones of a zoned block device, including the
+ * eventual small last zone if present. For a block device without zone
+ * capabilities, the number of zones is always 0.
*/
unsigned int bdev_nr_zones(struct block_device *bdev)
{
sector_t zone_sectors = bdev_zone_sectors(bdev);
+ sector_t capacity = bdev_nr_sectors(bdev);
if (!bdev_is_zoned(bdev))
return 0;
- return (bdev_nr_sectors(bdev) + zone_sectors - 1) >>
- ilog2(zone_sectors);
+
+ if (is_power_of_2(zone_sectors))
+ return (capacity + zone_sectors - 1) >> ilog2(zone_sectors);
+
+ return DIV_ROUND_UP_SECTOR_T(capacity, zone_sectors);
}
EXPORT_SYMBOL_GPL(bdev_nr_zones);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 84b13fdd34a7..ab82d1ff0cce 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -674,9 +674,15 @@ static inline unsigned int disk_nr_zones(struct gendisk *disk)
static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
{
+ sector_t zone_sectors = disk->queue->limits.chunk_sectors;
+
if (!blk_queue_is_zoned(disk->queue))
return 0;
- return sector >> ilog2(disk->queue->limits.chunk_sectors);
+
+ if (is_power_of_2(zone_sectors))
+ return sector >> ilog2(zone_sectors);
+
+ return div64_u64(sector, zone_sectors);
}
static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
From patchwork Wed Aug 3 09:47:50 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935329
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 7BCC3C3F6B0
for ; Wed, 3 Aug 2022 09:48:16 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237504AbiHCJsP (ORCPT );
Wed, 3 Aug 2022 05:48:15 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58986 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S236318AbiHCJsN (ORCPT
); Wed, 3 Aug 2022 05:48:13 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEC222181A
for ;
Wed, 3 Aug 2022 02:48:09 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094807euoutp015109200b4ec3b75b48c1d6f55bc133e0~HzLoHWKoR3021530215euoutp01U
for ;
Wed, 3 Aug 2022 09:48:07 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094807euoutp015109200b4ec3b75b48c1d6f55bc133e0~HzLoHWKoR3021530215euoutp01U
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520087;
bh=nWR/3EtmjCPRzM7IHtW3EB0aleuY4H+/CRFeCI52+CQ=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=vCNzAhNyp5IN+LRWzmAkmWK2SvtLCzPNiY9rgKn7pFVrk16GG5xJZdwFO8dDi7NyG
Wv/sNUp8PKByDCiN65g31fOP9WxN2fSiv4vLO/005mp85H68zmvr9OgXDoe4RqULhA
y5NWYjd0KCk/9nCCjbIgZ4ezVpxdss13OMMtI+iI=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094805eucas1p2fb2e6683b85d89ad1c79c6978055ad18~HzLmlH4_X1615116151eucas1p2u;
Wed, 3 Aug 2022 09:48:05 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id A0.FF.09664.5544AE26;
Wed, 3
Aug 2022 10:48:05 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220803094804eucas1p1feea4b1bdae819f4c8750994ddd94803~HzLmH9IqN1902519025eucas1p1H;
Wed, 3 Aug 2022 09:48:04 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220803094804eusmtrp28c08a2adda8796fdf9c233c636159095~HzLmHClmQ0972009720eusmtrp2Y;
Wed, 3 Aug 2022 09:48:04 +0000 (GMT)
X-AuditID: cbfec7f2-d97ff700000025c0-79-62ea44553828
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 40.9B.09038.4544AE26;
Wed, 3
Aug 2022 10:48:04 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220803094804eusmtip23b70977da7da3b653211630caa4bac3a~HzLlvVUMC1623516235eusmtip2k;
Wed, 3 Aug 2022 09:48:04 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav
Subject: [PATCH v9 02/13] block:rearrange
bdev_{is_zoned,zone_sectors,get_queue} helpers in blkdev.h
Date: Wed, 3 Aug 2022 11:47:50 +0200
Message-Id: <20220803094801.177490-3-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrPKsWRmVeSWpSXmKPExsWy7djPc7qhLq+SDBr2iVqsP3WM2WL13X42
i2kffjJb/D57ntli77vZrBY3D+xkstizaBKTxcrVR5ksnqyfxWzxt+sek8XeW9oWl3fNYbOY
v+wpu8WEtq/MFp+XtrBbrLn5lMXixC1pB0GPy1e8PXbOusvucflsqcemVZ1sHpuX1HvsvtnA
5rGz9T6rx/t9V9k8+rasYvTYfLra4/MmOY/2A91MATxRXDYpqTmZZalF+nYJXBnHH95nL9gu
WnHgyGb2Bsbngl2MnBwSAiYS+9ZdZASxhQRWMEps2B/VxcgFZH9hlJjdsIwdwvkM5PStZYHp
mLnsNhNEx3JGic4ZRRBFLxklVu1YATSKg4NNQEuisROsWUSgmVHi7t8eVhCHWWAGk0THxz6w
ScICaRLre16C2SwCqhKT9/0Es3kFrCRuvnnCDLFNXmLmpe/sIDangLXElH//mCFqBCVOznwC
Vs8MVNO8dTYzyAIJgc2cEj+XLYJqdpE49GwTE4QtLPHq+BZ2CFtG4v/O+VDxaomnN35DNbcw
SvTvXM8G8oIE0La+MzkgJrOApsT6XfoQ5Y4SH6ecZYao4JO48VYQ4gQ+iUnbpkOFeSU62o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VWJyft+soDYvAJWEjffPIHa
Ji8x89J3dhCbU8BaYsq/f2BxIaCadX9nsULUC0qcnPkErJcZqL5562zmCYwCs5CkZiFJLWBk
WsUoklpanJueW2ykV5yYW1yal66XnJ+7iREYtduO/dyyg3Hlq496hxiZOBgPMUpwMCuJ8N5x
eZ4kxJuSWFmVWpQfX1Sak1p8iNEU6O6JzFKiyfnAtJFXEm9oZmBqaGJmaWBqaWasJM7rWdCR
KCSQnliSmp2aWpBaBNPHxMEp1cAU9UA7NLPHUNj3zRotSYUTWikPxE2tTd78eldqJ3RFc8e2
RQ63rENfR5xZe+XOudUPameql7pHP90qq+UYJr4i46Da69k5xz5l/2t5G3jO/oOsvfiHjskL
Kv7qJ03g29z69pKkg439pgP7+ioybDdNW9Cp/bfMSFfRd8MidbbyNdOrqk+cUQlwzDB8d4vb
lS39gfrBJl9JtofnlO51TPkY8nOW4ME+fd3i1Nerij9KVb+08dnheOVym0veT467svpMvWx5
XlvuL9oc/Tb1lWen36Rdm7nmz9UqcNmkwLip88kPvcsR84siHvH2/WZjemm/bomEVmCFYGKv
lXfTXdFa9ZKLSgb/VCYaT2/d5avEUpyRaKjFXFScCAAG7hpFYwMAAA==
X-CMS-MailID: 20220803094804eucas1p1feea4b1bdae819f4c8750994ddd94803
X-Msg-Generator: CA
X-RootMTR: 20220803094804eucas1p1feea4b1bdae819f4c8750994ddd94803
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094804eucas1p1feea4b1bdae819f4c8750994ddd94803
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Define bdev_is_zoned(), bdev_zone_sectors() and bdev_get_queue() earlier
in the blkdev.h include file.
This commit has no functional change, and it is a prep patch for allowing
zoned devices with non-power-of-2 zone sizes in the block layer.
Signed-off-by: Pankaj Raghav
Suggested-by: Bart Van Assche
Reviewed-by: Bart Van Assche
---
include/linux/blkdev.h | 48 +++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ab82d1ff0cce..22f97427b60b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -635,6 +635,11 @@ static inline bool queue_is_mq(struct request_queue *q)
return q->mq_ops;
}
+static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
+{
+ return bdev->bd_queue; /* this is never NULL */
+}
+
#ifdef CONFIG_PM
static inline enum rpm_status queue_rpm_status(struct request_queue *q)
{
@@ -666,6 +671,25 @@ static inline bool blk_queue_is_zoned(struct request_queue *q)
}
}
+static inline bool bdev_is_zoned(struct block_device *bdev)
+{
+ struct request_queue *q = bdev_get_queue(bdev);
+
+ if (q)
+ return blk_queue_is_zoned(q);
+
+ return false;
+}
+
+static inline sector_t bdev_zone_sectors(struct block_device *bdev)
+{
+ struct request_queue *q = bdev_get_queue(bdev);
+
+ if (!blk_queue_is_zoned(q))
+ return 0;
+ return q->limits.chunk_sectors;
+}
+
#ifdef CONFIG_BLK_DEV_ZONED
static inline unsigned int disk_nr_zones(struct gendisk *disk)
{
@@ -892,11 +916,6 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags);
int iocb_bio_iopoll(struct kiocb *kiocb, struct io_comp_batch *iob,
unsigned int flags);
-static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
-{
- return bdev->bd_queue; /* this is never NULL */
-}
-
/* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
@@ -1296,25 +1315,6 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
return BLK_ZONED_NONE;
}
-static inline bool bdev_is_zoned(struct block_device *bdev)
-{
- struct request_queue *q = bdev_get_queue(bdev);
-
- if (q)
- return blk_queue_is_zoned(q);
-
- return false;
-}
-
-static inline sector_t bdev_zone_sectors(struct block_device *bdev)
-{
- struct request_queue *q = bdev_get_queue(bdev);
-
- if (!blk_queue_is_zoned(q))
- return 0;
- return q->limits.chunk_sectors;
-}
-
static inline int queue_dma_alignment(const struct request_queue *q)
{
return q ? q->dma_alignment : 511;
From patchwork Wed Aug 3 09:47:51 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935332
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 5C3E3C19F2C
for ; Wed, 3 Aug 2022 09:48:21 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237568AbiHCJsS (ORCPT );
Wed, 3 Aug 2022 05:48:18 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59024 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237511AbiHCJsP (ORCPT
); Wed, 3 Aug 2022 05:48:15 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35BE120F44
for ;
Wed, 3 Aug 2022 02:48:14 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094808euoutp01324a94b438101685d38a7a0bce953993~HzLpL5YbT3204232042euoutp010
for ;
Wed, 3 Aug 2022 09:48:08 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094808euoutp01324a94b438101685d38a7a0bce953993~HzLpL5YbT3204232042euoutp010
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520088;
bh=/lcXxddPODppydfVfNWVe2xGRFgwQKIkYPo+taXvQpg=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=UCAkVi0nKVBlWu9lc4hm61KIPTnstlqZLGqkoDDQvC29MNnm29VDawG1r8dTNuYkx
uR+r0vUkBN2PZrNx+LIz6mWX/rrpXZr1HlnwXrm6s6Qo4b6BKfpmNJfxwE+/zjaOs0
V9EbckTxdRC48Cw7wh6k4ebGGWusolpum4n8KftU=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094806eucas1p28e4acaa00f0bcede2828c6f7798de3ea~HzLnfy-8w3120331203eucas1p2s;
Wed, 3 Aug 2022 09:48:06 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 42.FF.09664.6544AE26;
Wed, 3
Aug 2022 10:48:06 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220803094805eucas1p1c68ba40d319331c2c34059f966ba2d83~HzLnD0WR_0754607546eucas1p16;
Wed, 3 Aug 2022 09:48:05 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220803094805eusmtrp25e56a76f66728139fcf1a55fd7baa169~HzLnC2gES0985609856eusmtrp2u;
Wed, 3 Aug 2022 09:48:05 +0000 (GMT)
X-AuditID: cbfec7f2-d97ff700000025c0-7f-62ea44563ea2
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id A1.9B.09038.5544AE26;
Wed, 3
Aug 2022 10:48:05 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220803094805eusmtip19192ed3b0cdfd5c11a6f449fcf12697b~HzLmtXW9L2551225512eusmtip1e;
Wed, 3 Aug 2022 09:48:05 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Luis Chamberlain
Subject: [PATCH v9 03/13] block: allow blk-zoned devices to have
non-power-of-2 zone size
Date: Wed, 3 Aug 2022 11:47:51 +0200
Message-Id: <20220803094801.177490-4-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7phLq+SDE7MErVYf+oYs8Xqu/1s
FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx
f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ
vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAldG/
7yt7wS71ioOnPjI2MPYqdDFyckgImEg09v9l72Lk4hASWMEoMXniOSjnC6PEv+5mJgjnM6PE
zNuzGWFaVnSvYwWxhQSWM0qs+1QOUfSSUeLP0QssXYwcHGwCWhKNnWCTRASaGSXu/u1hBXGY
BQ4wSdzccosJpFtYIFri96LnYJNYBFQlZn37BdbMK2Al8fBIFsQyeYmZl76zg9icAtYSU/79
YwaxeQUEJU7OfMICYjMD1TRvnc0MMl9CYDenxN99vcwQzS4S3283QtnCEq+Ob2GHsGUk/u+c
zwRhV0s8vfEbqrmFUaJ/53o2kCMkgLb1nckBMZkFN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Yuti5ELqOY5o0R/80WgBg4ONgEt
icZOdpC4iEA3o8TlM+dYQRxmgXNMEnOePmAD6RYWiJSYfLyJGcRmEVCVmPXtFwtIM6+AlcTD
I1kQC+QlZl76zg5icwpYS0z5948Z4iAriXV/Z4EdxysgKHFy5hMWEJsZqL5562zmCYwCs5Ck
ZiFJLWBkWsUoklpanJueW2ykV5yYW1yal66XnJ+7iREYu9uO/dyyg3Hlq496hxiZOBgPMUpw
MCuJ8N5xeZ4kxJuSWFmVWpQfX1Sak1p8iNEU6OyJzFKiyfnA5JFXEm9oZmBqaGJmaWBqaWas
JM7rWdCRKCSQnliSmp2aWpBaBNPHxMEp1cDkcG06p8ZbJ7nSSP0Z4S/XKAjzljiH8Xx2K7ZQ
Wq05a9LeO6dOrJJV3yMp770h8dPX7H8KfO0buCcyVdvnHLggqnQ++pPggsS1e6taec/eWbTn
8QyzzmIV15cJM8rMjoYd1bJozdFY+G1z4rdrgQxC07ZMvajx+9nh905tjRd15+pa6iumKqi8
mMR9+N78qUtUBE5IqPpnzOStmTx76T/39JU6gne/J2t6sX5MXm3+zvf5I11D5Y3f5zbZrZXd
uMhbZMqfSV8yqwoMeSZkHerXdtgsut3+n5f+4T82959ELAmavFLpF9dpvf+RHnvPTKt5xfuc
1fiBU9QjWav6Fx9Vmnm8/TvP1Aqfrf3IpmGpxFKckWioxVxUnAgAqxFEeGYDAAA=
X-CMS-MailID: 20220803094805eucas1p1c68ba40d319331c2c34059f966ba2d83
X-Msg-Generator: CA
X-RootMTR: 20220803094805eucas1p1c68ba40d319331c2c34059f966ba2d83
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094805eucas1p1c68ba40d319331c2c34059f966ba2d83
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Checking if a given sector is aligned to a zone is a common
operation that is performed for zoned devices. Add
bdev_is_zone_start helper to check for this instead of opencoding it
everywhere.
Convert the calculations on zone size to be generic instead of relying on
power-of-2(po2) based arithmetic in the block layer using the helpers
wherever possible.
The only hot path affected by this change for zoned devices with po2
zone size is in blk_check_zone_append() but bdev_is_zone_start() helper is
used to optimize the calculation for po2 zone sizes.
Finally, allow zoned devices with non po2 zone sizes provided that their
zone capacity and zone size are equal. The main motivation to allow zoned
devices with non po2 zone size is to remove the unmapped LBA between
zone capcity and zone size for devices that cannot have a po2 zone
capacity.
Reviewed-by: Luis Chamberlain
Reviewed-by: Hannes Reinecke
Signed-off-by: Pankaj Raghav
Reviewed-by: Bart Van Assche
---
block/blk-core.c | 2 +-
block/blk-zoned.c | 24 ++++++++++++++++++------
include/linux/blkdev.h | 30 ++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index a0d1104c5590..1cb519220ffb 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -563,7 +563,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
return BLK_STS_NOTSUPP;
/* The bio sector must point to the start of a sequential zone */
- if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
+ if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
!bio_zone_is_seq(bio))
return BLK_STS_IOERR;
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index dce9c95b4bcd..665b822d13f9 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -285,10 +285,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
return -EINVAL;
/* Check alignment (handle eventual smaller last zone) */
- if (sector & (zone_sectors - 1))
+ if (!bdev_is_zone_start(bdev, sector))
return -EINVAL;
- if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
+ if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity)
return -EINVAL;
/*
@@ -486,14 +486,26 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
* smaller last zone.
*/
if (zone->start == 0) {
- if (zone->len == 0 || !is_power_of_2(zone->len)) {
- pr_warn("%s: Invalid zoned device with non power of two zone size (%llu)\n",
- disk->disk_name, zone->len);
+ if (zone->len == 0) {
+ pr_warn("%s: Invalid zero zone size", disk->disk_name);
+ return -ENODEV;
+ }
+
+ /*
+ * Non power-of-2 zone size support was added to remove the
+ * gap between zone capacity and zone size. Though it is technically
+ * possible to have gaps in a non power-of-2 device, Linux requires
+ * the zone size to be equal to zone capacity for non power-of-2
+ * zoned devices.
+ */
+ if (!is_power_of_2(zone->len) && zone->capacity < zone->len) {
+ pr_err("%s: Invalid zone capacity: %lld with non power-of-2 zone size: %lld",
+ disk->disk_name, zone->capacity, zone->len);
return -ENODEV;
}
args->zone_sectors = zone->len;
- args->nr_zones = (capacity + zone->len - 1) >> ilog2(zone->len);
+ args->nr_zones = div64_u64(capacity + zone->len - 1, zone->len);
} else if (zone->start + args->zone_sectors < capacity) {
if (zone->len != args->zone_sectors) {
pr_warn("%s: Invalid zoned device with non constant zone size\n",
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 22f97427b60b..5aa15172299d 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -709,6 +709,30 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
return div64_u64(sector, zone_sectors);
}
+static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
+ sector_t sec)
+{
+ sector_t zone_sectors = bdev_zone_sectors(bdev);
+ u64 remainder = 0;
+
+ if (!bdev_is_zoned(bdev))
+ return 0;
+
+ if (is_power_of_2(zone_sectors))
+ return sec & (zone_sectors - 1);
+
+ div64_u64_rem(sec, zone_sectors, &remainder);
+ return remainder;
+}
+
+static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
+{
+ if (!bdev_is_zoned(bdev))
+ return false;
+
+ return bdev_offset_from_zone_start(bdev, sec) == 0;
+}
+
static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
{
if (!blk_queue_is_zoned(disk->queue))
@@ -753,6 +777,12 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
{
return 0;
}
+
+static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec)
+{
+ return false;
+}
+
static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
{
return 0;
From patchwork Wed Aug 3 09:47:52 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935331
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 6B9D3C25B0D
for ; Wed, 3 Aug 2022 09:48:20 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237563AbiHCJsR (ORCPT );
Wed, 3 Aug 2022 05:48:17 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59034 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237506AbiHCJsP (ORCPT
); Wed, 3 Aug 2022 05:48:15 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35AA21F62F
for ;
Wed, 3 Aug 2022 02:48:14 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094809euoutp01c33e5a4809214a096cee057e06e36156~HzLqGbfCH3021530215euoutp01Y
for ;
Wed, 3 Aug 2022 09:48:09 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094809euoutp01c33e5a4809214a096cee057e06e36156~HzLqGbfCH3021530215euoutp01Y
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520089;
bh=T6uTF12t86W2Ord6JkqRUxShPwTcKbnN1jJM5mS3HZw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=tj42y7q6xizQ6E2do1aoLsEu0hm33u3q5y6DgB32AqgF6DBCb1givbkyTCVD2hfAb
RZSF1tDFJMBNXzW0nZdSvNNFo3Z/YTcGIKZZd6W5FRiRqVstSvOdwUMqkw4UViuMr6
nGM0j8KaL4h7hEDumAszPJ3EfXOj8zNAGv1iPlec=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094807eucas1p224884eb226c7b424aed2ee5802687c73~HzLonXeKL2470524705eucas1p2m;
Wed, 3 Aug 2022 09:48:07 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id B3.FF.09664.7544AE26;
Wed, 3
Aug 2022 10:48:07 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220803094806eucas1p24e1fd0f3a595e050d79c4315559d97ae~HzLn-ja4E1528815288eucas1p2h;
Wed, 3 Aug 2022 09:48:06 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220803094806eusmtrp1f74e4c3e6a78656816aba9457baeed04~HzLn_o3YC2000320003eusmtrp1Q;
Wed, 3 Aug 2022 09:48:06 +0000 (GMT)
X-AuditID: cbfec7f2-d97ff700000025c0-81-62ea44573f19
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 53.9B.09038.6544AE26;
Wed, 3
Aug 2022 10:48:06 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220803094806eusmtip10b1dba597f608a76d1a515ca1f44a551~HzLnqIBVq2267222672eusmtip1h;
Wed, 3 Aug 2022 09:48:06 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Johannes Thumshirn ,
Luis Chamberlain
Subject: [PATCH v9 04/13] nvmet: Allow ZNS target to support non-power_of_2
zone sizes
Date: Wed, 3 Aug 2022 11:47:52 +0200
Message-Id: <20220803094801.177490-5-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrMKsWRmVeSWpSXmKPExsWy7djPc7rhLq+SDLr3K1qsP3WM2WL13X42
i2kffjJb/D57ntli77vZrBY3D+xkstizaBKTxcrVR5ksnqyfxWzxt+sek8XeW9oWl3fNYbOY
v+wpu8WEtq/MFjcmPGW0+Ly0hd1izc2nLBYnbkk7CHlcvuLtsXPWXXaPy2dLPTat6mTz2Lyk
3mP3zQY2j52t91k93u+7yubRt2UVo8fm09UenzfJebQf6GYK4InisklJzcksSy3St0vgyvg7
+zxzwSn+iobHF5kbGJfwdjFyckgImEh8XbeOrYuRi0NIYAWjRNvPqcwQzhdGiQXrJ7GCVAkJ
fGaUmPE3AKZjzaKpUB3LGSUuz//EDlH0klHiaaN9FyMHB5uAlkRjJztIjYhAM6PE3b89rCAO
s8BHJolH2zcygRQJC0RIfDkhBNLLIqAqsXHrbSYQm1fASuLKpW9sEMvkJWZe+g42n1PAWmLK
v3/MEDWCEidnPmEBsZmB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F5kbGJfwdjFy
ckgImEisWTSVrYuRi0NIYCmjxNwlDcwQCQmJ2wubGCFsYYk/17qgip4zSkxdfwWoiIODTUBL
orGTHSQuItDNKHH5zDlWkAZmgUZmiW+bSkFsYYEwic1bjoENZRFQldi49TYTiM0rYCVx5dI3
NogF8hIzL31nB7E5Bawlpvz7B1YvBFSz7u8sVoh6QYmTM5+wQMyXl2jeOpt5AqPALCSpWUhS
CxiZVjGKpJYW56bnFhvpFSfmFpfmpesl5+duYgRG77ZjP7fsYFz56qPeIUYmDsZDjBIczEoi
vHdcnicJ8aYkVlalFuXHF5XmpBYfYjQFunsis5Rocj4wfeSVxBuaGZgamphZGphamhkrifN6
FnQkCgmkJ5akZqemFqQWwfQxcXBKNTB53yqW52b7XGnK/jvFpjH79KblU49NqFkrd3sr/6fs
I3nbd3PGp8V59zFMscixCfrynydv+oHqqtfyS4/pPrrct2uOSM8Gh2f+vX8ui802nPl+XXt0
nxuT54/eW+xvGZ8l7Thm6lD2Sf4oW+Tn1en528QtKixj+tbn/OmZLRU3a+OBayE8i3ddinsr
envCyZrKF0LeDfarU3hbps472vJJX563vX9CiN+vdeHKDu+uGGi/ntapZVjiYNdVnt920PPb
BoGoXF3bRlbRX0mPBC3fH1y6xFvomPEEP+4NYnfXHzYrtjXoPvIh91/dFK8fYpVsjsWbfj48
f/DIzUVq6w07ihXK7dbVPtghfXS7IZMSS3FGoqEWc1FxIgAwwu7wZwMAAA==
X-CMS-MailID: 20220803094806eucas1p24e1fd0f3a595e050d79c4315559d97ae
X-Msg-Generator: CA
X-RootMTR: 20220803094806eucas1p24e1fd0f3a595e050d79c4315559d97ae
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094806eucas1p24e1fd0f3a595e050d79c4315559d97ae
References: <20220803094801.177490-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 5aa15172299d..ead848a15946 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1345,6 +1345,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;
From patchwork Wed Aug 3 09:47: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: 12935334
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 CFACCC19F28
for ; Wed, 3 Aug 2022 09:48:23 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237525AbiHCJsV (ORCPT );
Wed, 3 Aug 2022 05:48:21 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59038 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237514AbiHCJsP (ORCPT
); Wed, 3 Aug 2022 05:48:15 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A1802181A
for ;
Wed, 3 Aug 2022 02:48:14 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094810euoutp0140c23de6178101a66510362a2622c6e8~HzLrPSljq3128231282euoutp01C
for ;
Wed, 3 Aug 2022 09:48:10 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094810euoutp0140c23de6178101a66510362a2622c6e8~HzLrPSljq3128231282euoutp01C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520090;
bh=E+La7o2Zl30I/sNS3Lx2T739zrulxOvYuda5lE4fWfc=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=ikltu0wE24mOe3U3dKUOjvM4+VVsDaHNPMPPFGdsi/XXdOGku3WMzxwNQBQK3/S+H
gaHs8USGWaW7Qr0wHUrT2m0wKzd5+DT6zxxouGah3wZTusWjkUlcR2rkNT0Yz/Ctft
V24k7phUZEtT81XGVDBBbsLoVqI94ls1GTwTMeYY=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094808eucas1p20fccdbf39db130f1fcffa078d5c3ffd0~HzLpo-yKd1615116151eucas1p21;
Wed, 3 Aug 2022 09:48:08 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 2C.F2.09580.8544AE26;
Wed, 3
Aug 2022 10:48:08 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220803094808eucas1p1a6a800161d32fe4242d39e669e5f3527~HzLpBPANP1078810788eucas1p1N;
Wed, 3 Aug 2022 09:48:08 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220803094808eusmtrp111d241cef0397c0689130cd7d8eb2553~HzLpAXxR92000320003eusmtrp1R;
Wed, 3 Aug 2022 09:48:08 +0000 (GMT)
X-AuditID: cbfec7f5-9c3ff7000000256c-14-62ea4458fe5e
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 94.9B.09038.7544AE26;
Wed, 3
Aug 2022 10:48:07 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220803094807eusmtip2c69438db6f11c983d60b36accf56cbb4~HzLosQXnL1679416794eusmtip2n;
Wed, 3 Aug 2022 09:48:07 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Luis Chamberlain
Subject: [PATCH v9 05/13] nvme: zns: Allow ZNS drives that have
non-power_of_2 zone size
Date: Wed, 3 Aug 2022 11:47:53 +0200
Message-Id: <20220803094801.177490-6-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrGKsWRmVeSWpSXmKPExsWy7djPc7oRLq+SDFZu0LBYf+oYs8Xqu/1s
FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx
f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ
vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlbF5
/1b2gj6RiiOdk1kaGC8JdDFyckgImEjcOP6crYuRi0NIYAWjxIKDr1kgnC+MEv8m9jNDOJ8Z
Jfa9bWOCadmybQEjRGI5o8TsVxtZIZyXjBKtmxcAtXBwsAloSTR2soPERQSaGSXu/u0BK2IW
OMAkcXPLLbBRwgJREjvunWAGsVkEVCVOr5kCZvMKWElsvTCRHWKdvMTMS9/BbE4Ba4kp//5B
1QhKnJz5hAXEZgaqad46G+xWCYHtnBJ3l3SzQTS7SHxZuBJqkLDEq+NboGwZidOTe1gg7GqJ
pzd+QzW3MEr071zPBvKCBNC2vjM5ICazgKbE+l36EOWOEotnzmCFqOCTuPFWEOIEPolJ26Yz
Q4R5JTrahCCqlSR2/nwCtVRC4nLTHKilHhKXz35lm8CoOAvJM7OQPDMLYe8CRuZVjOKppcW5
6anFxnmp5XrFibnFpXnpesn5uZsYgUnx9L/jX3cwrnj1Ue8QIxMH4yFGCQ5mJRHeOy7Pk4R4
UxIrq1KL8uOLSnNSiw8xSnOwKInzJmduSBQSSE8sSc1OTS1ILYLJMnFwSjUwcfXt3pd77WJt
1Jk7hqvu9u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8aYkVlalFuXHF5XmpBYfYjQFunsis5Rocj4wgeSVxBuaGZgamphZGphamhkr
ifN6FnQkCgmkJ5akZqemFqQWwfQxcXBKNTAl+sp25f3lqDz+RSuO29Y9z3DFlsNdmnpzghR/
F1u98So+PoH7yo6M2jKWeQK5ObMXsFZx1lYx+BeIBRQZOqvne3LM+6i6iTUtk+H5LqYIhv+z
JV4qfeWwiNSzn3VH77SJRFTou/j0+PvPrj6SsuF8UqPwKPZ52EPnZJP0KysSPTyj8qbxXO/5
/6kg8PYqxXO5uoFtu+UZz04Oit02zWqGd9W/+Xuj03kn3UrVmzpX9I3LSc79u/qjozhsdq8t
WdL/me1q0epZK7Sac+/kXnr4Z47V7b8cRXNsGrw0kmZIrN6p8j6Z1WRjyvujqQbLL/ntiFjk
PEPlkM1emaiyxvmM3s9Ld245VdHvFXjSSYmlOCPRUIu5qDgRAAllp1doAwAA
X-CMS-MailID: 20220803094808eucas1p1a6a800161d32fe4242d39e669e5f3527
X-Msg-Generator: CA
X-RootMTR: 20220803094808eucas1p1a6a800161d32fe4242d39e669e5f3527
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094808eucas1p1a6a800161d32fe4242d39e669e5f3527
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Remove the condition which disallows non-power_of_2 zone size ZNS drive
to be updated and use generic method to calculate number of zones
instead of relying on log and shift based calculation on zone size.
The power_of_2 calculation has been replaced directly with generic
calculation without special handling. Both modified functions are not
used in hot paths, they are only used during initialization &
revalidation of the ZNS device.
As rounddown macro from math.h does not work for 32 bit architectures,
round down operation is open coded.
Reviewed-by: Luis Chamberlain
Reviewed by: Adam Manzanares
Reviewed-by: Hannes Reinecke
Signed-off-by: Pankaj Raghav
---
drivers/nvme/host/zns.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 12316ab51bda..73e4ad495ae8 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -101,13 +101,6 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
}
ns->zsze = nvme_lba_to_sect(ns, le64_to_cpu(id->lbafe[lbaf].zsze));
- if (!is_power_of_2(ns->zsze)) {
- dev_warn(ns->ctrl->device,
- "invalid zone size:%llu for namespace:%u\n",
- ns->zsze, ns->head->ns_id);
- status = -ENODEV;
- goto free_data;
- }
disk_set_zoned(ns->disk, BLK_ZONED_HM);
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
@@ -129,7 +122,7 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns,
sizeof(struct nvme_zone_descriptor);
nr_zones = min_t(unsigned int, nr_zones,
- get_capacity(ns->disk) >> ilog2(ns->zsze));
+ div64_u64(get_capacity(ns->disk), ns->zsze));
bufsize = sizeof(struct nvme_zone_report) +
nr_zones * sizeof(struct nvme_zone_descriptor);
@@ -182,6 +175,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
int ret, zone_idx = 0;
unsigned int nz, i;
size_t buflen;
+ u64 remainder = 0;
if (ns->head->ids.csi != NVME_CSI_ZNS)
return -EINVAL;
@@ -197,7 +191,11 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
c.zmr.zrasf = NVME_ZRASF_ZONE_REPORT_ALL;
c.zmr.pr = NVME_REPORT_ZONE_PARTIAL;
- sector &= ~(ns->zsze - 1);
+ /*
+ * Round down the sector value to the nearest zone start
+ */
+ div64_u64_rem(sector, ns->zsze, &remainder);
+ sector -= remainder;
while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) {
memset(report, 0, buflen);
From patchwork Wed Aug 3 09:47:54 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935330
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 D5251C25B06
for ; Wed, 3 Aug 2022 09:48:17 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237547AbiHCJsQ (ORCPT );
Wed, 3 Aug 2022 05:48:16 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59024 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237500AbiHCJsP (ORCPT
); Wed, 3 Aug 2022 05:48:15 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 788E928E1B
for ;
Wed, 3 Aug 2022 02:48:12 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094811euoutp027a112201d6456c59628f47f8cc1a46ea~HzLsGTqiI1921619216euoutp02J
for ;
Wed, 3 Aug 2022 09:48:11 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220803094811euoutp027a112201d6456c59628f47f8cc1a46ea~HzLsGTqiI1921619216euoutp02J
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520091;
bh=bYKKaKRKmRv+AlsOpjlNiS5TmS3H8P6AuWd0B5dlWjg=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=DOZLqQmzYe7WXI82OHiGlc7RJe5IHjymyK3wn8D3iGcG5cnIqUjv5b78xCMQvv/Nm
h36tugyo3QJj2lbQLo+6Tocv4a+J+4J/4R/1nWmbIFzgKJxPTU9PhorTRStgYeg8Bs
lPrugj9UC/lb3rwrIslye3U58C0D69ELXKeR/e14=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20220803094809eucas1p19bd8547e3fcb23e3f951c4f85f06f852~HzLqgfac10754107541eucas1p1_;
Wed, 3 Aug 2022 09:48:09 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 7D.F5.10067.9544AE26;
Wed, 3
Aug 2022 10:48:09 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220803094809eucas1p1e24ddc3076eaa05db0658b88fd34ffd4~HzLqABfkC1902519025eucas1p1K;
Wed, 3 Aug 2022 09:48:09 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220803094809eusmtrp261e43580a71933c10a45bfb080762358~HzLp_Bq0z0985609856eusmtrp2w;
Wed, 3 Aug 2022 09:48:09 +0000 (GMT)
X-AuditID: cbfec7f4-dd7ff70000002753-46-62ea4459ad8a
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 7E.DB.09095.8544AE26;
Wed, 3
Aug 2022 10:48:08 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220803094808eusmtip11dc1bc750fcb0c384f4ce3c02685227a~HzLppsgZ-2551225512eusmtip1f;
Wed, 3 Aug 2022 09:48:08 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Luis Chamberlain
Subject: [PATCH v9 06/13] null_blk: allow zoned devices with non power-of-2
zone sizes
Date: Wed, 3 Aug 2022 11:47:54 +0200
Message-Id: <20220803094801.177490-7-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrKKsWRmVeSWpSXmKPExsWy7djP87qRLq+SDI4sVLBYf+oYs8Xqu/1s
FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx
f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ
vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlbFs
XTt7wWXpit8XPjA2MG4U72Lk5JAQMJG49X0DaxcjF4eQwApGie4v39khnC+MEhv2b2KCcD4z
SuxetIwNpqX76UmoluWMEi9Ow1S9ZJQ4/mg5UD8HB5uAlkRjJ9goEYFmRom7f3vAOpgFDjBJ
3NxyiwlklLBAhMS6xzNZQWwWAVWJqcvusYA08wpYSTzqsobYJi8x8xLITZwcnALWElP+/WMG
sXkFBCVOznzCAmIzA9U0b53NDDJfQmA3p0TDrJNQp7pIbLw+nR3CFpZ4dXwLlC0j8X/nfCYI
u1ri6Y3fUM0tjBL9O9ezgRwhAbSt70wOiMksoCmxfpc+RLmjxPrHu6Eq+CRuvBWEOIFPYtK2
6cwQYV6JjjYhiGoliZ0/n0AtlZC43DSHBcL2kFjQ0802gVFxFpJnZiF5ZhbC3gWMzKsYxVNL
i3PTU4uN8lLL9YoTc4tL89L1kvNzNzECU+Lpf8e/7GBc/uqj3iFGJg7GQ4wSHMxKIrx3XJ4n
CfGmJFZWpRblxxeV5qQWH2K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zDsZ5rz7qHWJk4mA8xCjB
wawkwnvH5XmSEG9KYmVValF+fFFpTmrxIUZToLMnMkuJJucDk0deSbyhmYGpoYmZpYGppZmx
kjivZ0FHopBAemJJanZqakFqEUwfEwenVAOT0eYNAr1HLuSxVIg+7T4eo3fV3NLx1UHrOV57
bmzkv67jEBZ/ZFHv4n1PSg7qvxbiWO1XvG5ykpndnhMSM0q6lh0tLW5VOv2m9Lu+TvW/HXfy
dHWy+FKCFy8/Wfdp/mGf4xyNJ08sWX1NkEtG+qOib+QV27+sh02t+LKeGq/ZHP2uRl9+bu0e
jSuCL7Y89bd5mPNHbVbZG62Ytx/+Kz48Udy2dNW9dhXPMOtS9cRfOyRdZz8IXDRFovxUdeva
t8sWMzo/fLv+44cqz16WYr519x46vg21q3xi/v4y47bulTacX/JvNO20u6H8Vez0Ep5oQ0cP
nfaO1q6fjzzEgi+uDecvfHlw7QWVA/V1hgI1SizFGYmGWsxFxYkAB/+Yf2YDAAA=
X-CMS-MailID: 20220803094809eucas1p1e24ddc3076eaa05db0658b88fd34ffd4
X-Msg-Generator: CA
X-RootMTR: 20220803094809eucas1p1e24ddc3076eaa05db0658b88fd34ffd4
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094809eucas1p1e24ddc3076eaa05db0658b88fd34ffd4
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Convert the power-of-2(po2) based calculation with zone size to be generic
in null_zone_no with optimization for po2 based zone sizes.
The nr_zones calculation in null_init_zoned_dev has been replaced with a
division without special handling for po2 based zone sizes as
this function is called only during the initialization and will not be
invoked in the hot path.
Reviewed-by: Luis Chamberlain
Reviewed by: Adam Manzanares
Reviewed-by: Hannes Reinecke
Signed-off-by: Pankaj Raghav
---
drivers/block/null_blk/main.c | 5 ++---
drivers/block/null_blk/null_blk.h | 1 +
drivers/block/null_blk/zoned.c | 18 +++++++++++-------
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index c451c477978f..f1e0605dee94 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1976,9 +1976,8 @@ static int null_validate_conf(struct nullb_device *dev)
if (dev->queue_mode == NULL_Q_BIO)
dev->mbps = 0;
- if (dev->zoned &&
- (!dev->zone_size || !is_power_of_2(dev->zone_size))) {
- pr_err("zone_size must be power-of-two\n");
+ if (dev->zoned && !dev->zone_size) {
+ pr_err("Invalid zero zone size\n");
return -EINVAL;
}
diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h
index 94ff68052b1e..f63b6bed1bb3 100644
--- a/drivers/block/null_blk/null_blk.h
+++ b/drivers/block/null_blk/null_blk.h
@@ -83,6 +83,7 @@ struct nullb_device {
unsigned int imp_close_zone_no;
struct nullb_zone *zones;
sector_t zone_size_sects;
+ unsigned int zone_size_sects_shift;
bool need_zone_res_mgmt;
spinlock_t zone_res_lock;
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 55a69e48ef8b..015f6823706c 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -16,7 +16,10 @@ static inline sector_t mb_to_sects(unsigned long mb)
static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect)
{
- return sect >> ilog2(dev->zone_size_sects);
+ if (dev->zone_size_sects_shift)
+ return sect >> dev->zone_size_sects_shift;
+
+ return div64_u64(sect, dev->zone_size_sects);
}
static inline void null_lock_zone_res(struct nullb_device *dev)
@@ -65,10 +68,6 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
sector_t sector = 0;
unsigned int i;
- if (!is_power_of_2(dev->zone_size)) {
- pr_err("zone_size must be power-of-two\n");
- return -EINVAL;
- }
if (dev->zone_size > dev->size) {
pr_err("Zone size larger than device capacity\n");
return -EINVAL;
@@ -86,9 +85,14 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
zone_capacity_sects = mb_to_sects(dev->zone_capacity);
dev_capacity_sects = mb_to_sects(dev->size);
dev->zone_size_sects = mb_to_sects(dev->zone_size);
- dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects)
- >> ilog2(dev->zone_size_sects);
+ if (is_power_of_2(dev->zone_size_sects))
+ dev->zone_size_sects_shift = ilog2(dev->zone_size_sects);
+ else
+ dev->zone_size_sects_shift = 0;
+
+ dev->nr_zones = DIV_ROUND_UP_SECTOR_T(dev_capacity_sects,
+ dev->zone_size_sects);
dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone),
GFP_KERNEL | __GFP_ZERO);
if (!dev->zones)
From patchwork Wed Aug 3 09:47:55 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935333
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 BD702C25B07
for ; Wed, 3 Aug 2022 09:48:22 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237574AbiHCJsU (ORCPT );
Wed, 3 Aug 2022 05:48:20 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59022 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237525AbiHCJsP (ORCPT
); Wed, 3 Aug 2022 05:48:15 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF7371CB12
for ;
Wed, 3 Aug 2022 02:48:14 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094812euoutp015a55c77213e5de6d2db6e9ea67b3e676~HzLtcr1Nf3234332343euoutp01f
for ;
Wed, 3 Aug 2022 09:48:12 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094812euoutp015a55c77213e5de6d2db6e9ea67b3e676~HzLtcr1Nf3234332343euoutp01f
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520092;
bh=2l9t4o2MFdGXGYEr9szOD+OY2x6nysmCjdo7iJiFJ2A=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=oygDXWXdhS5//5n2wO4kaUTElYy+b38a8qHOU23nThmJMR9cq/3X8k1Kz57eWzmsW
iu+b9ApTpHw/EDpdjn4X5Z8HGHM/Zi+5a1F+UwU/TTj2D8UlhT87sVoZPEAQzVotw3
NJrLRn77cxVh2Rortwa4kZvN4/CTzQOnyuOB8W4g=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20220803094810eucas1p13ef520e51d3ca7b5822a11e2d1d1af1b~HzLrqKrSc1447714477eucas1p1G;
Wed, 3 Aug 2022 09:48:10 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 11.06.10067.A544AE26;
Wed, 3
Aug 2022 10:48:10 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220803094810eucas1p1304a82ba94d0265c3f6a8a371e5127a7~HzLq8-nPY3109731097eucas1p1S;
Wed, 3 Aug 2022 09:48:10 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220803094810eusmtrp2d87915093087080592522be7fa4346e1~HzLq8LrDT0972009720eusmtrp2d;
Wed, 3 Aug 2022 09:48:10 +0000 (GMT)
X-AuditID: cbfec7f4-dd7ff70000002753-4c-62ea445afc23
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 10.EB.09095.9544AE26;
Wed, 3
Aug 2022 10:48:09 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220803094809eusmtip1d73b9053f698e1f43a7bd40d4f7d177b~HzLqlR4Nk2555925559eusmtip1j;
Wed, 3 Aug 2022 09:48:09 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Luis Chamberlain
Subject: [PATCH v9 07/13] zonefs: allow non power of 2 zoned devices
Date: Wed, 3 Aug 2022 11:47:55 +0200
Message-Id: <20220803094801.177490-8-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrMKsWRmVeSWpSXmKPExsWy7djPc7pRLq+SDA6c0LVYf+oYs8Xqu/1s
FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx
f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ
vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlfFg
QmJBi2DFij/VDYyT+LoYOTkkBEwk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94d0265c3f6a8a371e5127a7
X-Msg-Generator: CA
X-RootMTR: 20220803094810eucas1p1304a82ba94d0265c3f6a8a371e5127a7
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094810eucas1p1304a82ba94d0265c3f6a8a371e5127a7
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
The zone size shift variable is useful only if the zone sizes are known
to be power of 2. Remove that variable and use generic helpers from
block layer to calculate zone index in zonefs.
Acked-by: Damien Le Moal
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/zonefs/super.c | 6 ++----
fs/zonefs/zonefs.h | 1 -
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 860f0b1032c6..e549ef16738c 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -476,10 +476,9 @@ static void __zonefs_io_error(struct inode *inode, bool write)
{
struct zonefs_inode_info *zi = ZONEFS_I(inode);
struct super_block *sb = inode->i_sb;
- struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
unsigned int noio_flag;
unsigned int nr_zones =
- zi->i_zone_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
+ bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT);
struct zonefs_ioerr_data err = {
.inode = inode,
.write = write,
@@ -1401,7 +1400,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
struct zonefs_inode_info *zi = ZONEFS_I(inode);
int ret = 0;
- inode->i_ino = zone->start >> sbi->s_zone_sectors_shift;
+ inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start);
inode->i_mode = S_IFREG | sbi->s_perm;
zi->i_ztype = type;
@@ -1776,7 +1775,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
* interface constraints.
*/
sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev));
- sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev));
sbi->s_uid = GLOBAL_ROOT_UID;
sbi->s_gid = GLOBAL_ROOT_GID;
sbi->s_perm = 0640;
diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
index 4b3de66c3233..39895195cda6 100644
--- a/fs/zonefs/zonefs.h
+++ b/fs/zonefs/zonefs.h
@@ -177,7 +177,6 @@ struct zonefs_sb_info {
kgid_t s_gid;
umode_t s_perm;
uuid_t s_uuid;
- unsigned int s_zone_sectors_shift;
unsigned int s_nr_files[ZONEFS_ZTYPE_MAX];
From patchwork Wed Aug 3 09:47:56 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935336
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 9E072C19F2A
for ; Wed, 3 Aug 2022 09:48:28 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237617AbiHCJs0 (ORCPT );
Wed, 3 Aug 2022 05:48:26 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59112 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S236046AbiHCJsR (ORCPT
); Wed, 3 Aug 2022 05:48:17 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2763C16E
for ;
Wed, 3 Aug 2022 02:48:15 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094813euoutp023df4f1d5644ec0003f33e8615c736fb6~HzLuhrIdC2038420384euoutp02c
for ;
Wed, 3 Aug 2022 09:48:13 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220803094813euoutp023df4f1d5644ec0003f33e8615c736fb6~HzLuhrIdC2038420384euoutp02c
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520093;
bh=YUh2zeQE2RmUBXA7/4tWmxObmeVjkyPLOxi8ex3NZxQ=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=CMw9zF1OjPwosTdt09H260Wpb9aFfbmmJqYCBGL6Pp296oxb4eaG4/MoTC7eBiIFd
w0jWf1XGKUmSBhW+LpOfpkJAPwGB9C19+gVKR81r8T8LyXN3iBUgJJ8gBRA38udPfx
DuhGA76zBCAkHg8cx2pV646ZXx7gFkBkou+36Rjg=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094811eucas1p28cd48175b9feac0080f9be506dd1b5b5~HzLspo2by1532415324eucas1p2S;
Wed, 3 Aug 2022 09:48:11 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 08.FF.09664.B544AE26;
Wed, 3
Aug 2022 10:48:11 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220803094811eucas1p17a2ac191899bba7938de6b9e3a55352f~HzLsBClpH3109631096eucas1p18;
Wed, 3 Aug 2022 09:48:11 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220803094811eusmtrp1ba4f7f94f43e6937f2a29d964ceaf11c~HzLr5us1F2000320003eusmtrp1Y;
Wed, 3 Aug 2022 09:48:11 +0000 (GMT)
X-AuditID: cbfec7f2-d81ff700000025c0-8e-62ea445bc010
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 07.9B.09038.A544AE26;
Wed, 3
Aug 2022 10:48:11 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220803094810eusmtip2b837e592c0d57ed90af9168ead84a75c~HzLrkbg3V1623616236eusmtip29;
Wed, 3 Aug 2022 09:48:10 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Luis Chamberlain ,
Pankaj Raghav
Subject: [PATCH v9 08/13] dm-zoned: ensure only power of 2 zone sizes are
allowed
Date: Wed, 3 Aug 2022 11:47:56 +0200
Message-Id: <20220803094801.177490-9-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7rRLq+SDM5+NrZYf+oYs8Xqu/1s
FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx
f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ
vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlXF8
+hmWgr3cFX/nvmdtYFzH2cXIySEhYCKxc9cV1i5GLg4hgRWMEpvO72OHcL4wSix9vxjK+cwo
8fT9RRaYl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9e3a55352f
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094811eucas1p17a2ac191899bba7938de6b9e3a55352f
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
From: Luis Chamberlain
dm-zoned relies on the assumption that the zone size is a
power-of-2(po2) and the zone capacity is same as the zone size.
Ensure only po2 devices can be used as dm-zoned target until a native
non po2 support is added.
Reviewed-by: Hannes Reinecke
Signed-off-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
Reviewed-by: Damien Le Moal
---
drivers/md/dm-zoned-target.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 95b132b52f33..9325bf5dee81 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -792,6 +792,10 @@ static int dmz_fixup_devices(struct dm_target *ti)
return -EINVAL;
}
zone_nr_sectors = bdev_zone_sectors(bdev);
+ if (!is_power_of_2(zone_nr_sectors)) {
+ ti->error = "Zone size is not a power-of-2 number of sectors";
+ return -EINVAL;
+ }
zoned_dev->zone_nr_sectors = zone_nr_sectors;
zoned_dev->nr_zones = bdev_nr_zones(bdev);
}
@@ -804,6 +808,10 @@ static int dmz_fixup_devices(struct dm_target *ti)
return -EINVAL;
}
zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev);
+ if (!is_power_of_2(zoned_dev->zone_nr_sectors)) {
+ ti->error = "Zone size is not a power-of-2 number of sectors";
+ return -EINVAL;
+ }
zoned_dev->nr_zones = bdev_nr_zones(bdev);
}
From patchwork Wed Aug 3 09:47:57 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935335
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 2FAC0C25B08
for ; Wed, 3 Aug 2022 09:48:25 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237514AbiHCJsW (ORCPT );
Wed, 3 Aug 2022 05:48:22 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59098 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S235061AbiHCJsR (ORCPT
); Wed, 3 Aug 2022 05:48:17 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA14D286FD
for ;
Wed, 3 Aug 2022 02:48:15 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094814euoutp012943ae63e02bc456d2be9fecf08ada25~HzLvBnul13139831398euoutp01M
for ;
Wed, 3 Aug 2022 09:48:14 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094814euoutp012943ae63e02bc456d2be9fecf08ada25~HzLvBnul13139831398euoutp01M
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520094;
bh=U+KX/7RkSecAPwIXzvtRwzm9pxQhhVpd7PMWcY0qTgw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=siqU5EGJaOXw8Z1NVqsiQzR5MZdcpT/P2zOKwTi249r3wjddiNJ9O2zkp6iHhfg5K
puF4MtpNJPIJQ7zYNyxlNgfBUTQjWQooUYa8B6zK1GLbNKgV93CfnI+xbx+XMpitnf
1zO8nvYHdlGBRLEUOxlNOGnSdWSx3bgcgTCkSUDY=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094812eucas1p2bd850e62b8b1e5b102ce5cf367481d37~HzLti7ILc2471124711eucas1p2q;
Wed, 3 Aug 2022 09:48:12 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id A3.03.09580.C544AE26;
Wed, 3
Aug 2022 10:48:12 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220803094812eucas1p271cea804453d9dd379b919067fe5b154~HzLs1fMOB1615116151eucas1p26;
Wed, 3 Aug 2022 09:48:12 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220803094812eusmtrp1a4c85857281fce3a66bd62cdfdd094cf~HzLs0miIg2000320003eusmtrp1c;
Wed, 3 Aug 2022 09:48:12 +0000 (GMT)
X-AuditID: cbfec7f5-9adff7000000256c-27-62ea445c55ce
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id A8.9B.09038.C544AE26;
Wed, 3
Aug 2022 10:48:12 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220803094811eusmtip2c6b37f361d28822a8c01f5e0fb4f3c34~HzLsg0_a31632116321eusmtip2w;
Wed, 3 Aug 2022 09:48:11 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Luis Chamberlain
Subject: [PATCH v9 09/13] dm-zone: use generic helpers to calculate offset
from zone start
Date: Wed, 3 Aug 2022 11:47:57 +0200
Message-Id: <20220803094801.177490-10-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrKKsWRmVeSWpSXmKPExsWy7djP87oxLq+SDI53GVusP3WM2WL13X42
i2kffjJb/D57ntli77vZrBY3D+xkstizaBKTxcrVR5ksnqyfxWzxt+sek8XeW9oWl3fNYbOY
v+wpu8WEtq/MFjcmPGW0+Ly0hd1izc2nLBYnbkk7CHlcvuLtsXPWXXaPy2dLPTat6mTz2Lyk
3mP3zQY2j52t91k93u+7yubRt2UVo8fm09UenzfJebQf6GYK4InisklJzcksSy3St0vgyph9
t42toJ+74vPL6cwNjBM5uxg5OSQETCQ+rW9l6mLk4hASWMEocWRTJyNIQkjgC6PEjH2xEInP
jBKT975mhelofnuUESKxnFFi87ImVgjnJaNE/4oWoAwHB5uAlkRjJztIXESgmVHi7t8esCJm
gQNMEje33GICGSUsECMx+dJJsH0sAqoSsx4vYwGxeQWsJa7Oa4daJy8x89J3dhCbEyg+5d8/
ZogaQYmTM5+A1TMD1TRvnc0MskBCYDenxPx1cxghml0kuq5dYIewhSVeHd8CZctInJ7cwwJh
V0s8vfEbqrkF6IWd69lAXpAA2tZ3JgfEZBbQlFi/Sx+i3FFi09kNTBAVfBI33gpCnMAnMWnb
dGaIMK9ER5sQRLWSxM6fT6CWSkhcbpoDtdRD4uP85SwTGBVnIXlmFpJnZiHsXcDIvIpRPLW0
ODc9tdg4L7Vcrzgxt7g0L10vOT93EyMwJZ7+d/zrDsYVrz7qHWJk4mA8xCjBwawkwnvH5XmS
EG9KYmVValF+fFFpTmrxIUZpDhYlcd7kzA2JQgLpiSWp2ampBalFMFkmDk6pBiY/y/o4kfrb
js2WsuJ8B4MfHfnr1F4vuTpSy+r62ffT1Tx6lzkZ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klqdmpqQWoRTB8TB6dUA5Pj+jXduyYqpYi5BFtr7Nted+21X57+xfnOpnpL
b02/sWnrAUfRaZcOM10V+HtAt/xpwcyEm1/5uCd/+i6j/bP09O070T/O1//b0XhaOG9FwsPo
TzlOmpd0L9ucCdOuF33Be3tbR+ryoD3827gvMqw3s+dd0zTr/IRrD9xP9llMUdDkjkm+VChe
WfJ4kfXSnkjxi8V+W4pM8z5d6Oi4Fel+vrXBI+L55+Xns+6pddff8lrPvfX/psVdPvO3rArf
d6xP227fNL92xyTfO47Pp6pEzpR+45N8afOdhavPTeh8fUYj/F6c6u2G0/cWulbzTE57ezv+
2EoJR8813l+tv6n+ONj57WvGOtV1vbxnTU6EKbEUZyQaajEXFScCAPgIuAloAwAA
X-CMS-MailID: 20220803094812eucas1p271cea804453d9dd379b919067fe5b154
X-Msg-Generator: CA
X-RootMTR: 20220803094812eucas1p271cea804453d9dd379b919067fe5b154
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094812eucas1p271cea804453d9dd379b919067fe5b154
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Use the bdev_offset_from_zone_start() helper function to calculate
the offset from zone start instead of using power of 2 based
calculation.
Signed-off-by: Pankaj Raghav
Reviewed-by: Luis Chamberlain
Reviewed-by: Damien Le Moal
---
drivers/md/dm-zone.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 3dafc0e8b7a9..31c16aafdbfc 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -390,7 +390,9 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
case REQ_OP_WRITE_ZEROES:
case REQ_OP_WRITE:
/* Writes must be aligned to the zone write pointer */
- if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
+ if ((bdev_offset_from_zone_start(md->disk->part0,
+ clone->bi_iter.bi_sector)) != zwp_offset)
+
return false;
break;
case REQ_OP_ZONE_APPEND:
@@ -602,11 +604,8 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
*/
if (clone->bi_status == BLK_STS_OK &&
bio_op(clone) == REQ_OP_ZONE_APPEND) {
- sector_t mask =
- (sector_t)bdev_zone_sectors(disk->part0) - 1;
-
orig_bio->bi_iter.bi_sector +=
- clone->bi_iter.bi_sector & mask;
+ bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);
}
return;
From patchwork Wed Aug 3 09:47:58 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935338
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 70DEFC19F28
for ; Wed, 3 Aug 2022 09:48:38 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237635AbiHCJsa (ORCPT );
Wed, 3 Aug 2022 05:48:30 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59414 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237589AbiHCJsY (ORCPT
); Wed, 3 Aug 2022 05:48:24 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C2B2A24F
for ;
Wed, 3 Aug 2022 02:48:17 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094815euoutp01c4da61a21829684f7398d704fc433f61~HzLwTGQ2J3207932079euoutp01s
for ;
Wed, 3 Aug 2022 09:48:15 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220803094815euoutp01c4da61a21829684f7398d704fc433f61~HzLwTGQ2J3207932079euoutp01s
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520095;
bh=LaB+Gcs0Fh5BCcbxlSsyrDjt3gzj6lS2/soveVJgI0s=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=a17qK5++bt00qdxR5RLJgG1drqy2pivmsMPUdcGHOgumS5VZNQB0XKUxDtW+DV6t3
I9d8lzI0YbjHNqwA3pH5mlo/RQ/PdXrhnykRmqZG++Q3STRJBgw4q96e9DSrNt8eTd
KhFZB2BVob2Y4x7o5PohQ27N/ElZlfYnubIrWUSI=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094813eucas1p298cfe017fbfdca6d5c606989f4a95a2e~HzLucPuni2470524705eucas1p2s;
Wed, 3 Aug 2022 09:48:13 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 37.03.09580.D544AE26;
Wed, 3
Aug 2022 10:48:13 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220803094813eucas1p2eab78901e97417ad52be1f8023db3d82~HzLt5TeNj2471024710eucas1p2t;
Wed, 3 Aug 2022 09:48:13 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220803094813eusmtrp236987c6f523104e1e5ca3c0b8fa8741c~HzLt4bV-v0985709857eusmtrp2v;
Wed, 3 Aug 2022 09:48:13 +0000 (GMT)
X-AuditID: cbfec7f5-9c3ff7000000256c-2a-62ea445daf58
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 93.EB.09095.D544AE26;
Wed, 3
Aug 2022 10:48:13 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220803094812eusmtip235cf51eca89103da97520a59ca801576~HzLtdCtG01623516235eusmtip2n;
Wed, 3 Aug 2022 09:48:12 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav
Subject: [PATCH v9 10/13] dm-table: allow zoned devices with non power-of-2
zone sizes
Date: Wed, 3 Aug 2022 11:47:58 +0200
Message-Id: <20220803094801.177490-11-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrIKsWRmVeSWpSXmKPExsWy7djPc7qxLq+SDNZ161isP3WM2WL13X42
i2kffjJb/D57ntli77vZrBY3D+xkstizaBKTxcrVR5ksnqyfxWzxt+sek8XeW9oWl3fNYbOY
v+wpu8WEtq/MFp+XtrBbrLn5lMXixC1pB0GPy1e8PXbOusvucflsqcemVZ1sHpuX1HvsvtnA
5rGz9T6rx/t9V9k8+rasYvTYfLra4/MmOY/2A91MATxRXDYpqTmZZalF+nYJXBlfjvSwFFzk
qXhw6SxbA2MnVxcjJ4eEgInEjnvN7F2MXBxCAisYJRZs74FyvjBKzLjWyArhfGaUWPTxFxNM
S/u9OUwQieWMEvuOr4aqeskocadtL1sXIwcHm4CWRGMn2CgRgWZGibt/e8CKmAVmMEl0fOxj
ARklLBAhceP8O7CxLA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Anii9GyK8ktLUhUy8otLbJWiDS2M9Awt
LfSMTCz1DI3NY62MTJX07WxSUnMyy1KL9O0S9DK+HOlhKbjIU/Hg0lm2BsZOri5GTg4JAROJ
9ntzmLoYuTiEBJYySsxau5gFIiEhcXthEyOELSzx51oXG0TRc0aJhjsHWLsYOTjYBLQkGjvZ
QeIiAt2MEpfPnGMFcZgFljFJNH25zgZSJCwQJrH4exXIIBYBVYmrMzcygdi8AtYSf6ZtY4NY
IC8x89J3dhCbEyg+5d8/ZhBbSMBKYt3fWawQ9YISJ2c+ATuOGai+eets5gmMArOQpGYhSS1g
ZFrFKJJaWpybnltsqFecmFtcmpeul5yfu4kRGLPbjv3cvINx3quPeocYmTgYDzFKcDArifDe
cXmeJMSbklhZlVqUH19UmpNafIjRFOjuicxSosn5wKSRVxJvaGZgamhiZmlgamlmrCTO61nQ
kSgkkJ5YkpqdmlqQWgTTx8TBKdXA1KNx4/0D7+4L58O0d9+y5FIq9Tdf0H5/Uh3XwZyyZ2q+
F+ytfaevTj0Q/+nofN2QFdK2EbvKpKaUdWh6eQUG6va4HPqylYlv0tsAYPqaf8BY4OX5aRcd
6hKsJnM9kOdPLjwpNvvoX0HNum3KZRPF63X3TOAM2LW/vO0pe6R46PHWoMdv01jK3OJuhiUk
SAZ+yz1qpT3BbL7XwnCBw3uO3vteffT++y9Hm+t/VUqvVTz4UfyE448oNg/T6n+czMFrGCKd
2L3/HnxjlPb18IXZH/IzH/X/W8L+QO3EweW8l48EO04tvGfINKNidtCMw0qbJ8Tvvax3b+5F
u6lSJRem/mLR/C0dfnlS7JwgRlFpJZbijERDLeai4kQAvr79AmIDAAA=
X-CMS-MailID: 20220803094813eucas1p2eab78901e97417ad52be1f8023db3d82
X-Msg-Generator: CA
X-RootMTR: 20220803094813eucas1p2eab78901e97417ad52be1f8023db3d82
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094813eucas1p2eab78901e97417ad52be1f8023db3d82
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Allow dm to support zoned devices with non power-of-2(po2) zone sizes as
the block layer now supports it.
Signed-off-by: Pankaj Raghav
Reviewed-by: Bart Van Assche
Reviewed-by: Damien Le Moal
---
drivers/md/dm-table.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 332f96b58252..31eb1d29d136 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -250,7 +250,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
if (bdev_is_zoned(bdev)) {
unsigned int zone_sectors = bdev_zone_sectors(bdev);
- if (start & (zone_sectors - 1)) {
+ if (!bdev_is_zone_start(bdev, start)) {
DMWARN("%s: start=%llu not aligned to h/w zone size %u of %pg",
dm_device_name(ti->table->md),
(unsigned long long)start,
@@ -267,7 +267,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
* devices do not end up with a smaller zone in the middle of
* the sector range.
*/
- if (len & (zone_sectors - 1)) {
+ if (!bdev_is_zone_start(bdev, len)) {
DMWARN("%s: len=%llu not aligned to h/w zone size %u of %pg",
dm_device_name(ti->table->md),
(unsigned long long)len,
@@ -1642,8 +1642,7 @@ static int validate_hardware_zoned_model(struct dm_table *t,
return -EINVAL;
}
- /* Check zone size validity and compatibility */
- if (!zone_sectors || !is_power_of_2(zone_sectors))
+ if (!zone_sectors)
return -EINVAL;
if (dm_table_any_dev_attr(t, device_not_matches_zone_sectors, &zone_sectors)) {
From patchwork Wed Aug 3 09:47:59 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935337
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 EE0BFC19F2C
for ; Wed, 3 Aug 2022 09:48:33 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237604AbiHCJs1 (ORCPT );
Wed, 3 Aug 2022 05:48:27 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59434 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237593AbiHCJsZ (ORCPT
); Wed, 3 Aug 2022 05:48:25 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD25D28703
for ;
Wed, 3 Aug 2022 02:48:17 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094816euoutp028ed9139b6e633ceda29a64d54be4ec1f~HzLwrhUm32085520855euoutp02F
for ;
Wed, 3 Aug 2022 09:48:16 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220803094816euoutp028ed9139b6e633ceda29a64d54be4ec1f~HzLwrhUm32085520855euoutp02F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520096;
bh=lA4ACIhgPS1mwgZjIDSka7RcIpNQB3Ybt1avCcUQ/Cs=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=Cb7tKxxadHNXkycJOuwBdAOSgjp02cXRJc856j5eOSXlHEgzQT7DyUPR0aJ1lLMg9
Xxro3Dje+CtTQ8CDHH2cEAfTqmvzxXSpoE/mYOXhSBunJhLUHDtT5CsHXOd27s1o+K
QfnagQ3obYJZWnA44z0y5SNdfysFdVWf0enhizDU=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220803094814eucas1p26e088e4d1902813c1d06ef0dd994f407~HzLvOmBkY2470524705eucas1p2x;
Wed, 3 Aug 2022 09:48:14 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id DB.FF.09664.E544AE26;
Wed, 3
Aug 2022 10:48:14 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220803094814eucas1p2789149466d095cc16710ee09a380cbdb~HzLuz7QyB1531915319eucas1p2L;
Wed, 3 Aug 2022 09:48:14 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220803094814eusmtrp1addc32d50c84a58b17d01be64653b93c~HzLuy7eRs2000320003eusmtrp1m;
Wed, 3 Aug 2022 09:48:14 +0000 (GMT)
X-AuditID: cbfec7f2-d97ff700000025c0-9f-62ea445e1e5a
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 9D.9B.09038.E544AE26;
Wed, 3
Aug 2022 10:48:14 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220803094813eusmtip148af0e15644aab588a871f6c749a8ca7~HzLudRlMc2554125541eusmtip1o;
Wed, 3 Aug 2022 09:48:13 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav
Subject: [PATCH v9 11/13] dm: call dm_zone_endio after the target endio
callback for zoned devices
Date: Wed, 3 Aug 2022 11:47:59 +0200
Message-Id: <20220803094801.177490-12-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrAKsWRmVeSWpSXmKPExsWy7djPc7pxLq+SDNY8UrdYf+oYs8Xqu/1s
FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx
f9lTdosJbV+ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB
zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDJWnlcteMtb
MetPL3sD41LuLkZODgkBE4mDL2cwdzFycQgJrGCU2PD1NhuE84VRYt3O4+wQzmdGida7k1lh
WtovPmGCSCxnlJi//h4LhPOSUaLx1EWgfg4ONgEticZOsG4RgWZGibt/e1hBHGaBGUwSHR/7
WEBGCQukSLy/PA3MZhFQlZh24yMjiM0rYC1xb+JPZoh18hIzL31nB7E5geJT/v1jhqgRlDg5
8wlYLzNQTfPW2WBfSAis55R4umMSO0Szi0Tb231sELawxKvjW6DiMhKnJ/ewQNjVEk9v/IZq
bmGU6N+5HuwFCaBtfWdyQExmAU2J9bv0IcodJdbfeM4IUcEnceOtIMQJfBKTtk1nhgjzSnS0
CUFUK0ns/PkEaqmExOWmOVBLPSRWv5vCMoFRcRaSZ2YheWYWwt4FjMyrGMVTS4tz01OLDfNS
y/WKE3OLS/PS9ZLzczcxAhPh6X/HP+1gnPvqo94hRiYOxkOMEhzMSiK8d1yeJwnxpiRWVqUW
5ccXleakFh9ilOZgURLnTc7ckCgkkJ5YkpqdmlqQWgSTZeLglGpgsn/3daHVR1/GBzL/l+8q
SNh/9qH8XaNlF1x+//FczeWvsjxx/xpd+7WrL0ozVDbNvmARr1Fjx8a7a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phakFsH0MXFwSjUwWViar29cW30op0pJn+/BunfmD0ykbxjc9mV8PWtm9R7e1y7T
RM8u/y/PJiXzofPjduYbXTGd6xOX6N0TWOmcNklUa+8nF7uVvhKvFWam19poiCuvipmrbfBA
IKLnypmVlzTTVhx4I5k4o2mv3Oy7b/rn289l/ndfR21lwL/iD1WyM6x6jG8c8H946/WyGW7x
BbXLyvNmGU+bdYPHeTfTj50/XkT8j9NbfHtT3DRt2dNPjpZd0Vjg9vWTxvbc6M8PtuzYJ669
RGR1g8bkufut1mRHxDJOVuz680iu6cC8FcvNLqf6+0x9GrC+c7a8vJHfRtvaPLvyf64Gsv51
GVNXuugZGKzc5ZWlud4qaQcntxJLcUaioRZzUXEiAIcg50liAwAA
X-CMS-MailID: 20220803094814eucas1p2789149466d095cc16710ee09a380cbdb
X-Msg-Generator: CA
X-RootMTR: 20220803094814eucas1p2789149466d095cc16710ee09a380cbdb
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094814eucas1p2789149466d095cc16710ee09a380cbdb
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
dm_zone_endio() updates the bi_sector of orig bio for zoned devices that
uses either native append or append emulation, and it is called before the
endio of the target. But target endio can still update the clone bio
after dm_zone_endio is called, thereby, the orig bio does not contain
the updated information anymore.
Currently, this is not a problem as the targets that support zoned devices
such as dm-zoned, dm-linear, and dm-crypt do not have an endio function,
and even if they do (such as dm-flakey), they don't modify the
bio->bi_iter.bi_sector of the cloned bio that is used to update the
orig_bio's bi_sector in dm_zone_endio function.
This is a prep patch for the new dm-po2zone target as it modifies
bi_sector in the endio callback.
Call dm_zone_endio for zoned devices after calling the target's endio
function.
Signed-off-by: Pankaj Raghav
---
drivers/md/dm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 60549b65c799..58b392c51d04 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1122,10 +1122,6 @@ static void clone_endio(struct bio *bio)
disable_write_zeroes(md);
}
- if (static_branch_unlikely(&zoned_enabled) &&
- unlikely(bdev_is_zoned(bio->bi_bdev)))
- dm_zone_endio(io, bio);
-
if (endio) {
int r = endio(ti, bio, &error);
switch (r) {
@@ -1154,6 +1150,10 @@ static void clone_endio(struct bio *bio)
}
}
+ if (static_branch_unlikely(&zoned_enabled) &&
+ unlikely(bdev_is_zoned(bio->bi_bdev)))
+ dm_zone_endio(io, bio);
+
if (static_branch_unlikely(&swap_bios_enabled) &&
unlikely(swap_bios_limit(ti, bio)))
up(&md->swap_bios_semaphore);
From patchwork Wed Aug 3 09:48:00 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935339
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 98BB6C19F2C
for ; Wed, 3 Aug 2022 09:48:38 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237637AbiHCJsd (ORCPT );
Wed, 3 Aug 2022 05:48:33 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59442 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237600AbiHCJsZ (ORCPT
); Wed, 3 Aug 2022 05:48:25 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4DEA5926A
for ;
Wed, 3 Aug 2022 02:48:18 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094817euoutp026218cd80e88d6aeaa7d4852b2792a22f~HzLx470OZ2085520855euoutp02H
for ;
Wed, 3 Aug 2022 09:48:17 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220803094817euoutp026218cd80e88d6aeaa7d4852b2792a22f~HzLx470OZ2085520855euoutp02H
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520097;
bh=aEZ9MVfXnixWs6H2frFA0ZxvwrL43KBWv8pJqvNry+8=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=SX6hi0cjpqpAsjLjSUz4UsZqYJ6G4DfLvJPSV+1Qb2wBrnvxwxA6i0h9cYlItEXxv
wPUV++0qXayyvUzuP+dloHz4HAA7e77pGbChcycHUpaPn0jP6LWW7KsCudmSY8iOaq
b0OehLT19PH51gu4SAT20h0eUc0U82UjuvBHi3E0=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20220803094815eucas1p1bd55c673d1b14f80f9ba075b862f4c30~HzLwNksfA3109731097eucas1p1c;
Wed, 3 Aug 2022 09:48:15 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 2D.06.10067.F544AE26;
Wed, 3
Aug 2022 10:48:15 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220803094815eucas1p2dfab477daf4f2eb05342d756fdf7f14d~HzLvvi38C1528815288eucas1p2r;
Wed, 3 Aug 2022 09:48:15 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220803094815eusmtrp12a4dd3bd318933996e4c815d9bdf1bd0~HzLvuqSpX2000320003eusmtrp1o;
Wed, 3 Aug 2022 09:48:15 +0000 (GMT)
X-AuditID: cbfec7f4-dc1ff70000002753-69-62ea445fd98a
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id EE.9B.09038.F544AE26;
Wed, 3
Aug 2022 10:48:15 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220803094814eusmtip145d6ac2a5c84936e935c88f18387aeec~HzLvY-4Yi2555925559eusmtip1m;
Wed, 3 Aug 2022 09:48:14 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav
Subject: [PATCH v9 12/13] dm: introduce DM_EMULATED_ZONES target type
Date: Wed, 3 Aug 2022 11:48:00 +0200
Message-Id: <20220803094801.177490-13-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrPKsWRmVeSWpSXmKPExsWy7djP87rxLq+SDD7f0LRYf+oYs8Xqu/1s
FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx
f9lTdosJbV+ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB
zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDK+vV7LUnBM
tOLWkQOsDYztQl2MHBwSAiYSt/7ldzFycQgJrGCU2PvvGjOE84VR4siDbWwQzmdGib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eb05342d756fdf7f14d
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094815eucas1p2dfab477daf4f2eb05342d756fdf7f14d
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Introduce a new target type DM_EMULATED_ZONES for targets with
a different zone number of sectors than the underlying device zone
number of sectors.
This target type is introduced as the existing zoned targets assume
that the target and the underlying device have the same zone
number of sectors. The new target: dm-po2zone will use this new target
type as it emulates the zone boundary that is different from the
underlying zoned device.
Signed-off-by: Pankaj Raghav
Reviewed-by: Damien Le Moal
---
drivers/md/dm-table.c | 13 ++++++++++---
include/linux/device-mapper.h | 9 +++++++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 31eb1d29d136..b37991ea3ffb 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1614,13 +1614,20 @@ static bool dm_table_supports_zoned_model(struct dm_table *t,
return true;
}
-static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
+/*
+ * Callback function to check for device zone sector across devices. If the
+ * DM_TARGET_EMULATED_ZONES target feature flag is not set, then the target
+ * should have the same zone sector as the underlying devices.
+ */
+static int check_valid_device_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
unsigned int *zone_sectors = data;
- if (!bdev_is_zoned(dev->bdev))
+ if (!bdev_is_zoned(dev->bdev) ||
+ dm_target_supports_emulated_zones(ti->type))
return 0;
+
return bdev_zone_sectors(dev->bdev) != *zone_sectors;
}
@@ -1645,7 +1652,7 @@ static int validate_hardware_zoned_model(struct dm_table *t,
if (!zone_sectors)
return -EINVAL;
- if (dm_table_any_dev_attr(t, device_not_matches_zone_sectors, &zone_sectors)) {
+ if (dm_table_any_dev_attr(t, check_valid_device_zone_sectors, &zone_sectors)) {
DMERR("%s: zone sectors is not consistent across all zoned devices",
dm_device_name(t->md));
return -EINVAL;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 04c6acf7faaa..83e20de264c9 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -294,6 +294,15 @@ struct target_type {
#define dm_target_supports_mixed_zoned_model(type) (false)
#endif
+#ifdef CONFIG_BLK_DEV_ZONED
+#define DM_TARGET_EMULATED_ZONES 0x00000400
+#define dm_target_supports_emulated_zones(type) \
+ ((type)->features & DM_TARGET_EMULATED_ZONES)
+#else
+#define DM_TARGET_EMULATED_ZONES 0x00000000
+#define dm_target_supports_emulated_zones(type) (false)
+#endif
+
struct dm_target {
struct dm_table *table;
struct target_type *type;
From patchwork Wed Aug 3 09:48:01 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12935340
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 6A40CC19F28
for ; Wed, 3 Aug 2022 09:49:07 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S237695AbiHCJtE (ORCPT );
Wed, 3 Aug 2022 05:49:04 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59432 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S237607AbiHCJsZ (ORCPT
); Wed, 3 Aug 2022 05:48:25 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B0B45A170
for ;
Wed, 3 Aug 2022 02:48:19 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220803094818euoutp0286c1f1e50b5f1d0181e5d30bdb4a45da~HzLy4-8-L1921619216euoutp02W
for ;
Wed, 3 Aug 2022 09:48:18 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220803094818euoutp0286c1f1e50b5f1d0181e5d30bdb4a45da~HzLy4-8-L1921619216euoutp02W
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1659520098;
bh=JRlwZvMkYHtnL6i9fUcNW6Rx0AlYf3L8pef0SqIDL+w=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=jpn7SprunHmvg0K2JkszwA8zERuPieu2z7YdfKpovUYMS4iGKCuRM7RDJKL/3iwPi
73sFpX5WpV93cWeiaMeNAKXylBT+WKlOiiyFODIMlA3popdh6ToWOepcnIFjdOBNCh
bRxqg+ogB4mY55Q0IQtQIlDXvaZxLERhR6rcuFAw=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20220803094816eucas1p1b2947b917caf6601922bdaac476f6824~HzLxRR4Ef3109731097eucas1p1g;
Wed, 3 Aug 2022 09:48:16 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 4F.06.10067.0644AE26;
Wed, 3
Aug 2022 10:48:16 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220803094816eucas1p1890ceb4faebaf4f0cdbc9581d1308672~HzLwzq_rx1902519025eucas1p1R;
Wed, 3 Aug 2022 09:48:16 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220803094816eusmtrp269f6b61586e288f08181b7c336900f37~HzLwy1l8g0972009720eusmtrp2i;
Wed, 3 Aug 2022 09:48:16 +0000 (GMT)
X-AuditID: cbfec7f4-dc1ff70000002753-6f-62ea446098ad
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 85.EB.09095.0644AE26;
Wed, 3
Aug 2022 10:48:16 +0100 (BST)
Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220803094816eusmtip261e6159d7d5bba642bb130f09846acf0~HzLwcNAPi1679316793eusmtip2f;
Wed, 3 Aug 2022 09:48:16 +0000 (GMT)
From: Pankaj Raghav
To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de
Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com,
linux-kernel@vger.kernel.org, pankydev8@gmail.com,
jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org,
linux-nvme@lists.infradead.org, bvanassche@acm.org,
Pankaj Raghav ,
Johannes Thumshirn ,
Damien Le Moal
Subject: [PATCH v9 13/13] dm: add power-of-2 target for zoned devices with
non power-of-2 zone sizes
Date: Wed, 3 Aug 2022 11:48:01 +0200
Message-Id: <20220803094801.177490-14-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djP87oJLq+SDN5M1LNYf+oYs8Xqu/1s
FtM+/GS2+H32PLNFa/s3Jou972azWtw8sJPJYs+iSUwWK1cfZbJ4sn4Ws8XfrntA2VvaFpd3
zWGzmL/sKbvFhLavzBafl7awW6y5+ZTF4sQtaQchj8tXvD12zrrL7nH5bKnHplWdbB6bl9R7
7L7ZwOaxs/U+q8f7fVfZPPq2rGL02Hy62uPzJjmP9gPdTAE8UVw2Kak5mWWpRfp2CVwZh3/u
YSw4V1hxveUHewPj5qguRk4OC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cdbc9581d1308672
X-Msg-Generator: CA
X-RootMTR: 20220803094816eucas1p1890ceb4faebaf4f0cdbc9581d1308672
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220803094816eucas1p1890ceb4faebaf4f0cdbc9581d1308672
References: <20220803094801.177490-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Only zoned devices with power-of-2(po2) zone sizes were supported in linux
but now non power-of-2(npo2) zone sizes support has been added to the
block layer.
Filesystems such as F2FS and btrfs have support for zoned devices with
po2 zone size assumption. Before adding native support for npo2 zone
sizes, it was suggested to create a dm target for npo2 zone size device to
appear as a po2 size zoned target so that file systems can initially work
without any explicit changes by using this target.
The design of this target is very simple: remap the device zone size to
the zone capacity and change the zone size to be the nearest power of 2
number of sectors.
For e.g., a device with a zone size/capacity of 3M will have an equivalent
target layout as follows:
Device layout :-
zone capacity = 3M
zone size = 3M
|--------------|-------------|
0 3M 6M
Target layout :-
zone capacity=3M
zone size = 4M
|--------------|---|--------------|---|
0 3M 4M 7M 8M
The area between target's zone capacity and zone size will be emulated
in the target.
The read IOs that fall in the emulated gap area will return 0 filled
bio and all the other IOs in that area will result in an error.
If a read IO span across the emulated area boundary, then the IOs are
split across them. All other IO operations that span across the emulated
area boundary will result in an error.
The target can be easily created as follows:
dmsetup create