From patchwork Tue Mar 8 16:53:44 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12774057
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 396EDC433FE
for ; Tue, 8 Mar 2022 16:54:28 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1345068AbiCHQzV (ORCPT );
Tue, 8 Mar 2022 11:55:21 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37852 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S238663AbiCHQzU (ORCPT
); Tue, 8 Mar 2022 11:55:20 -0500
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 962684EA31
for ;
Tue, 8 Mar 2022 08:54:23 -0800 (PST)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220308165422euoutp0241c67d709cc51440c7fdc9632b92d8af~adhixliNx1845618456euoutp02H
for ;
Tue, 8 Mar 2022 16:54:22 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220308165422euoutp0241c67d709cc51440c7fdc9632b92d8af~adhixliNx1845618456euoutp02H
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1646758462;
bh=TPUaZzbXqWKNL5NK3tHyPNndlEeKhHRqKKMcymvnEMw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=ELlwquSipcHFH7woU1a1qEceNMFUIpRAo2p4pantT4OXqjBOHWQdbyhTifczzSfTK
xtXzfu3Sa0a5fBYBGw+u8kffZ+E3ri9qVNUMn2BceqxjMMUJrUDCUzJbkIq6XXshaQ
nvPTQNcZ6jarEtta1/vAi50KRL5e3R3tV7YuOqbw=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220308165421eucas1p2d7e3afd6d010d9272674f1082b9cdc7f~adhiZ_tpP2398623986eucas1p2X;
Tue, 8 Mar 2022 16:54:21 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 69.3B.10009.D3A87226;
Tue, 8
Mar 2022 16:54:21 +0000 (GMT)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220308165421eucas1p20575444f59702cd5478cb35fce8b72cd~adhhtgbkY2414524145eucas1p2V;
Tue, 8 Mar 2022 16:54:21 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220308165421eusmtrp196690df24c43b52d7b47ce9b95f35190~adhhshRtE0526005260eusmtrp1L;
Tue, 8 Mar 2022 16:54:21 +0000 (GMT)
X-AuditID: cbfec7f2-e7fff70000002719-af-62278a3d5bfc
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 47.73.09522.C3A87226;
Tue, 8
Mar 2022 16:54:20 +0000 (GMT)
Received: from localhost (unknown [106.210.248.181]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220308165420eusmtip27049d06298085b75b096df4273286dbd~adhhW6HS30867508675eusmtip2N;
Tue, 8 Mar 2022 16:54:20 +0000 (GMT)
From: Pankaj Raghav
To: Luis Chamberlain ,
Adam Manzanares ,
=?utf-8?q?Javier_Gonz=C3=A1lez?= ,
kanchan Joshi , Jens Axboe ,
Keith Busch , Christoph Hellwig ,
Sagi Grimberg ,
Damien Le Moal , =?utf-8?q?Matias_Bj?=
=?utf-8?q?=C3=B8rling?= , jiangbo.365@bytedance.com
Cc: Pankaj Raghav ,
Kanchan Joshi ,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Pankaj Raghav
Subject: [PATCH 1/6] nvme: zns: Allow ZNS drives that have non-power_of_2
zone size
Date: Tue, 8 Mar 2022 17:53:44 +0100
Message-Id: <20220308165349.231320-2-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220308165349.231320-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrKKsWRmVeSWpSXmKPExsWy7djP87q2XepJBos/qllMP6xosfpuP5vF
77PnmS1Wrj7KZPH4zmd2i54DH1gsjv5/y2Zx/u1hJotJh64xWuy9pW0xf9lTdosJbV+ZLW5M
eMpo8XlpC7vFmptPWSzWvX7P4iDg8e/EGjaPnbPusnucv7eRxePy2VKPTas62Tw2L6n32H2z
ASjXep/Vo2/LKkaPz5vkPNoPdDMFcEdx2aSk5mSWpRbp2yVwZbQumcpecJer4u38iawNjD85
uhg5OSQETCTOTV/I0sXIxSEksIJR4uekB6wQzhdGiYnHzzKDVAkJfGaU2NKb2sXIAdbRc6II
omY5o8Te5jeMEM5LRon/fWtZQYrYBLQkGjvZQXpFBC4wS/y4qQhSwyywmVHiw6QVrCAJYYFQ
iRlr57KB2CwCqhI7nm5iAbF5Bawkbm25zghxnrzEzEvfwQZxClhLPO2cyQZRIyhxcuYTsHpm
oJrmrbOZIeoXc0o8WFQAYbtItJ9ZBBUXlnh1fAs7hC0jcXpyD9jLEgL9jBJTW/4wQTgzGCV6
Dm9mgnjTWqLvTA6IySygKbF+lz5E1FHi5kEzCJNP4sZbQYgL+CQmbZvODBHmlehoE4JYpCSx
8+cTqKUSEpeb5rBA2B4SPbOWsk9gVJyF5JdZSH6ZhbB2ASPzKkbx1NLi3PTUYsO81HK94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iSWlqcm55b
bKhXnJhbXJqXrpecn7uJERij24793LyDcd6rj3qHGJk4GA8xSnAwK4nw3j+vkiTEm5JYWZVa
lB9fVJqTWnyI0RTo7onMUqLJ+cAkkVcSb2hmYGpoYmZpYGppZqwkzutZ0JEoJJCeWJKanZpa
kFoE08fEwSnVwMSx5H2N8MkYLv91fEV55xuzf5as/nZzS/TUGJaQs+sy1hdt99OynfJyhVeU
5aKICWLhyX23XzJUvy2dvsb4fpWrpeynfnvHe1Z5jrd2bGec8aKlYOvbx7ue7eo8ED6V87/n
g8vBpS9vVZ3O4fEK4/lkIM/sxOTe/rBEL/VlgY2lerLW9KDFkvU299aut2JuZy2w1HB8fDAy
tvXZT3ne+DiHEy7FElb9/zKeBcSw9Eze9adSj2+Oks2/jJioH4qsqy7qq6R+7u7er/Ery21/
vMjZFzwFFhs+B58+om+RFbQtU3mdJdchu+th++3Efv4UVoreGzh7963YmTNza04+m7hdxfqO
wf/mpibBELUvSizFGYmGWsxFxYkA1+uce1oDAAA=
X-CMS-MailID: 20220308165421eucas1p20575444f59702cd5478cb35fce8b72cd
X-Msg-Generator: CA
X-RootMTR: 20220308165421eucas1p20575444f59702cd5478cb35fce8b72cd
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220308165421eucas1p20575444f59702cd5478cb35fce8b72cd
References: <20220308165349.231320-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.
Signed-off-by: Pankaj Raghav
---
drivers/nvme/host/zns.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 9f81beb4df4e..ad02c61c0b52 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;
- }
blk_queue_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));
+ get_capacity(ns->disk) / ns->zsze);
bufsize = sizeof(struct nvme_zone_report) +
nr_zones * sizeof(struct nvme_zone_descriptor);
From patchwork Tue Mar 8 16:53:45 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12774058
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 4D36DC433FE
for ; Tue, 8 Mar 2022 16:54:34 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S238663AbiCHQz3 (ORCPT );
Tue, 8 Mar 2022 11:55:29 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37972 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1346381AbiCHQz2 (ORCPT
); Tue, 8 Mar 2022 11:55:28 -0500
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F234ECFE
for ;
Tue, 8 Mar 2022 08:54:31 -0800 (PST)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220308165429euoutp02c41eb24f8431e23326236e2839ff9445~adhqDJbTu1860718607euoutp02N
for ;
Tue, 8 Mar 2022 16:54:29 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220308165429euoutp02c41eb24f8431e23326236e2839ff9445~adhqDJbTu1860718607euoutp02N
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1646758470;
bh=EVDf6R84igtJ/y3qEBnMjQVZ6aHLsjiJLYrL/j3arWY=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=qi/hu/CVraA9IG7h/lSGqPgic3BhuK5edr/24K6jV58mOiW2J3ECAfqx5yfyseMzH
v1IXlIPTXWSTXVY8Yrp1brL72rBGZHXjgZsfG56TZg42l2L5Wk5ov8H8TFrKZJgOmJ
9GYsoZSTVYsdaU1/q7qFTUcximPGu/znNzEflzIs=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220308165429eucas1p211fb120efe0efa0a2a27a3ea3a400ff9~adhph4M3Q2912829128eucas1p2F;
Tue, 8 Mar 2022 16:54:29 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 23.4B.10009.54A87226;
Tue, 8
Mar 2022 16:54:29 +0000 (GMT)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220308165428eucas1p14ea0a38eef47055c4fa41d695c5a249d~adhohIFSy0406404064eucas1p1l;
Tue, 8 Mar 2022 16:54:28 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220308165428eusmtrp17c3bb4cc2490d53f3a86cad323a434ae~adhogYd9f0526005260eusmtrp1S;
Tue, 8 Mar 2022 16:54:28 +0000 (GMT)
X-AuditID: cbfec7f2-e7fff70000002719-cd-62278a457bf8
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 0B.73.09522.44A87226;
Tue, 8
Mar 2022 16:54:28 +0000 (GMT)
Received: from localhost (unknown [106.210.248.181]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220308165428eusmtip140f2ab8c2fedd3e5358318dcff5517a4~adhoODwyn0418504185eusmtip1V;
Tue, 8 Mar 2022 16:54:28 +0000 (GMT)
From: Pankaj Raghav
To: Luis Chamberlain ,
Adam Manzanares ,
=?utf-8?q?Javier_Gonz=C3=A1lez?= ,
kanchan Joshi , Jens Axboe ,
Keith Busch , Christoph Hellwig ,
Sagi Grimberg ,
Damien Le Moal , =?utf-8?q?Matias_Bj?=
=?utf-8?q?=C3=B8rling?= , jiangbo.365@bytedance.com
Cc: Pankaj Raghav ,
Kanchan Joshi ,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Pankaj Raghav
Subject: [PATCH 2/6] block: Add npo2_zone_setup callback to block device
fops
Date: Tue, 8 Mar 2022 17:53:45 +0100
Message-Id: <20220308165349.231320-3-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220308165349.231320-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrOKsWRmVeSWpSXmKPExsWy7djP87quXepJBlu7RC2mH1a0WH23n83i
99nzzBYrVx9lsnh85zO7Rc+BDywWR/+/ZbM4//Ywk8WkQ9cYLfbe0raYv+wpu8WEtq/MFjcm
PGW0+Ly0hd1izc2nLBbrXr9ncRDw+HdiDZvHzll32T3O39vI4nH5bKnHplWdbB6bl9R77L7Z
AJRrvc/q0bdlFaPH501yHu0HupkCuKO4bFJSczLLUov07RK4Mm68XsRc0M1XsWn5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ator: CA
X-RootMTR: 20220308165428eucas1p14ea0a38eef47055c4fa41d695c5a249d
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220308165428eucas1p14ea0a38eef47055c4fa41d695c5a249d
References: <20220308165349.231320-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
A new fops is added to block device which will be used to setup the
necessary hooks when a non-power_of_2 zone size is detected in a zoned
device.
This fops will be called as a part of blk_revalidate_disk_zones.
The primary use case for this callback is to deal with zoned devices
that does not have a power_of_2 zone size such as ZNS drives.For e.g,
the current NVMe ZNS specification does not require zone size to be
power_of_2 but the linux block layer still expects a all zoned device to
have a power_of_2 zone size.
Signed-off-by: Pankaj Raghav
---
block/blk-zoned.c | 3 +++
include/linux/blkdev.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 602bef54c813..d3d821797559 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -575,6 +575,9 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
if (!get_capacity(disk))
return -EIO;
+ if (disk->fops->npo2_zone_setup)
+ disk->fops->npo2_zone_setup(disk);
+
/*
* Ensure that all memory allocations in this context are done as if
* GFP_NOIO was specified.
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index a12c031af887..08cf039c1622 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1472,6 +1472,7 @@ struct block_device_operations {
void (*swap_slot_free_notify) (struct block_device *, unsigned long);
int (*report_zones)(struct gendisk *, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data);
+ void (*npo2_zone_setup)(struct gendisk *disk);
char *(*devnode)(struct gendisk *disk, umode_t *mode);
/* returns the length of the identifier or a negative errno: */
int (*get_unique_id)(struct gendisk *disk, u8 id[16],
From patchwork Tue Mar 8 16:53:46 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12774059
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 B15EDC433F5
for ; Tue, 8 Mar 2022 16:54:37 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1345293AbiCHQzc (ORCPT );
Tue, 8 Mar 2022 11:55:32 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38052 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1345309AbiCHQzb (ORCPT
); Tue, 8 Mar 2022 11:55:31 -0500
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FD994ECF9
for ;
Tue, 8 Mar 2022 08:54:34 -0800 (PST)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220308165433euoutp02bec9c59850fbd52207a9d20d7bf4c1c7~adhs3JPQJ1883018830euoutp02F
for ;
Tue, 8 Mar 2022 16:54:33 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220308165433euoutp02bec9c59850fbd52207a9d20d7bf4c1c7~adhs3JPQJ1883018830euoutp02F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1646758473;
bh=I35qQFK0enOoaV9/O3Pbc4mWuZUa1zao+8/QBtn9w8A=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=tS2QzxCbenrohW91Vt5PBO91IWlurRUhBBJHm0SeCHDqoxIWObeyYycHk9fylPWJI
eqOBgKKjneMo7neFln4GPjDrV5WIRt5qr1BnFQWhHnpEUCSwMfKesm+BeeZP/dsIJe
uuggzS8wQTrNb5a/thrz3c58KFHrWrLc8oZ5eTm8=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20220308165432eucas1p11f851543691ef1e2b239a4c5aaeff1e3~adhsZzV3k0127001270eucas1p1I;
Tue, 8 Mar 2022 16:54:32 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id FA.AD.09887.84A87226;
Tue, 8
Mar 2022 16:54:32 +0000 (GMT)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220308165432eucas1p18b36a238ef3f5a812ee7f9b0e52599a5~adhr9ejQ63038730387eucas1p1C;
Tue, 8 Mar 2022 16:54:32 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220308165432eusmtrp2f1a11e8a3571b9775004065a77e7715e~adhr8aCbQ0464104641eusmtrp2Z;
Tue, 8 Mar 2022 16:54:32 +0000 (GMT)
X-AuditID: cbfec7f4-471ff7000000269f-26-62278a48454f
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id A8.96.09404.74A87226;
Tue, 8
Mar 2022 16:54:31 +0000 (GMT)
Received: from localhost (unknown [106.210.248.181]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220308165431eusmtip2b29f05515e91ee479562ae7c726e6a1e~adhrl2rHe1222112221eusmtip2-;
Tue, 8 Mar 2022 16:54:31 +0000 (GMT)
From: Pankaj Raghav
To: Luis Chamberlain ,
Adam Manzanares ,
=?utf-8?q?Javier_Gonz=C3=A1lez?= ,
kanchan Joshi , Jens Axboe ,
Keith Busch , Christoph Hellwig ,
Sagi Grimberg ,
Damien Le Moal , =?utf-8?q?Matias_Bj?=
=?utf-8?q?=C3=B8rling?= , jiangbo.365@bytedance.com
Cc: Pankaj Raghav ,
Kanchan Joshi ,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Pankaj Raghav
Subject: [PATCH 3/6] block: add a bool member to request_queue for
power_of_2 emulation
Date: Tue, 8 Mar 2022 17:53:46 +0100
Message-Id: <20220308165349.231320-4-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220308165349.231320-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrGKsWRmVeSWpSXmKPExsWy7djP87oeXepJBucXSFpMP6xosfpuP5vF
77PnmS1Wrj7KZPH4zmd2i54DH1gsjv5/y2Zx/u1hJotJh64xWuy9pW0xf9lTdosJbV+ZLW5M
eMpo8XlpC7vFmptPWSzWvX7P4iDg8e/EGjaPnbPusnucv7eRxePy2VKPTas62Tw2L6n32H2z
ASjXep/Vo2/LKkaPz5vkPNoPdDMFcEdx2aSk5mSWpRbp2yVwZdzskC5o5K34unwDawPjda4u
Rk4OCQETiR//TjCB2EICKxglTkxm6WLkArK/MErMnjiHFcL5zCjx/+Z7FpiOxW+XsUEkljNK
/O1Yzg7R/pJRYuUT9y5GDg42AS2Jxk6wsIjABWaJHzcVQeqZBTYzSnyYtIIVJCEsECmx8/ht
sCIWAVWJc/PWgcV5Bawk3nX+YIdYJi8x89J3MJtTwFriaedMNogaQYmTM5+AHcQMVNO8dTYz
yAIJgcWcEhuOHmCGaHaRWPb5CRuELSzx6vgWqKEyEv93zmeCaOhnlJja8gfKmcEo0XN4MxPI
CxJA6/rO5ICYzAKaEut36UP0Okq8fb2eBaKCT+LGW0GIG/gkJm2bzgwR5pXoaBOCqFaS2Pnz
CdRWCYnLTXOgYeghcfz1E9YJjIqzkHwzC8k3sxD2LmBkXsUonlpanJueWmyUl1quV5yYW1ya
l66XnJ+7iRGY9E7/O/5lB+PyVx/1DjEycTAeYpTgYFYS4b1/XiVJiDclsbIqt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iJGJg/EQowQHs5II7/3zKklCvCmJlVWpRfnx
RaU5qcWHGE2B7p7ILCWanA9MEnkl8YZmBqaGJmaWBqaWZsZK4ryeBR2JQgLpiSWp2ampBalF
MH1MHJxSDUyuh7lEV7++32nKd7fju4RF/CuXk0yKGivuci8u27lYOTQpq/rIvwd3ZLP/Sq6+
cHLO0ivGK5sutGoXPz409f+jgAD2FptekZM93f0bHdKucU+6E2JdFXTuhtq3tHpOVtVtr7Z7
3pU4rPVzCk/MhmMLBdVP88mePqy9x/HlswJ9xo6zxpM31kv4T/iR0+68N1jsz20RA4fvBgsj
0q0r3dvdlrat0bxs37N7skaKmM/H/B1b+3+vevPUVr1V1UVt64G5a+e+L3Y5tnmHT8nmqZcY
RO9UN7dsFa6LavVTCY1w73WSDzdqZxL5E7d8QcOs26xRnaZtun9urrplpPwhLNP7jqHqyyzO
sKuMTzctWqnEUpyRaKjFXFScCADx9YTAWgMAAA==
X-CMS-MailID: 20220308165432eucas1p18b36a238ef3f5a812ee7f9b0e52599a5
X-Msg-Generator: CA
X-RootMTR: 20220308165432eucas1p18b36a238ef3f5a812ee7f9b0e52599a5
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220308165432eucas1p18b36a238ef3f5a812ee7f9b0e52599a5
References: <20220308165349.231320-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
A new member is added to request_queue struct to indicate if power_of_2
emulation is enabled. Helpers are also added to get and set that member.
Signed-off-by: Pankaj Raghav
---
include/linux/blkdev.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 08cf039c1622..3a5d5ddc779c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -463,6 +463,7 @@ struct request_queue {
unsigned long *seq_zones_wlock;
unsigned int max_open_zones;
unsigned int max_active_zones;
+ bool po2_zone_emu;
#endif /* CONFIG_BLK_DEV_ZONED */
int node;
@@ -705,6 +706,18 @@ static inline unsigned int queue_max_active_zones(const struct request_queue *q)
{
return q->max_active_zones;
}
+
+static inline void blk_queue_po2_zone_emu(struct request_queue *q,
+ bool po2_zone_emu)
+{
+ q->po2_zone_emu = po2_zone_emu;
+}
+
+static inline bool blk_queue_is_po2_zone_emu(struct request_queue *q)
+{
+ return q->po2_zone_emu;
+}
+
#else /* CONFIG_BLK_DEV_ZONED */
static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
{
@@ -728,6 +741,17 @@ static inline unsigned int queue_max_active_zones(const struct request_queue *q)
{
return 0;
}
+
+static inline bool blk_queue_is_po2_zone_emu(struct request_queue *q)
+{
+ return false;
+}
+
+static inline void blk_queue_po2_zone_emu(struct request_queue *q,
+ unsigned int po2_zone_emu)
+{
+}
+
#endif /* CONFIG_BLK_DEV_ZONED */
static inline unsigned int blk_queue_depth(struct request_queue *q)
From patchwork Tue Mar 8 16:53:47 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12774060
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 45F51C433F5
for ; Tue, 8 Mar 2022 16:54:44 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1346020AbiCHQzh (ORCPT );
Tue, 8 Mar 2022 11:55:37 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38166 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1345576AbiCHQzg (ORCPT
); Tue, 8 Mar 2022 11:55:36 -0500
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A414EF4F
for ;
Tue, 8 Mar 2022 08:54:39 -0800 (PST)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220308165438euoutp01e69bb84fa05d964df171853a44209b70~adhxiBZoL0386603866euoutp01G
for ;
Tue, 8 Mar 2022 16:54:38 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220308165438euoutp01e69bb84fa05d964df171853a44209b70~adhxiBZoL0386603866euoutp01G
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1646758478;
bh=1YzBI3QOSlc4vPAYHgBOHlD+7Cnh780oelqWpe0CZLA=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=qiVrbmqb2B02iEBlaeQJFTCKPvOlam3LT2rjEc80myIaI+UP6JXdhPzLtv3OkLQa6
J2kOeto6JOBPRJu6Zknc0zJbov9WyDxQO3ChvCNbbcYscOXhpJqWuWQkZ8YB885EXz
H833vC6WLXcAlGMlEoAQKoJhGJQKcKkVb1topilw=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20220308165437eucas1p14fa8fd82729768844de4893ee65e8abc~adhxJ-35N0451504515eucas1p1s;
Tue, 8 Mar 2022 16:54:37 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 5D.AD.09887.D4A87226;
Tue, 8
Mar 2022 16:54:37 +0000 (GMT)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220308165436eucas1p1b76f3cb5b4fa1f7d78b51a3b1b44d160~adhwilQOX0435704357eucas1p1s;
Tue, 8 Mar 2022 16:54:36 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220308165436eusmtrp180830eb17cf9b45f8c930b427af213f6~adhwh1WUh0499204992eusmtrp1u;
Tue, 8 Mar 2022 16:54:36 +0000 (GMT)
X-AuditID: cbfec7f4-471ff7000000269f-32-62278a4d1d44
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id FE.73.09522.C4A87226;
Tue, 8
Mar 2022 16:54:36 +0000 (GMT)
Received: from localhost (unknown [106.210.248.181]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220308165436eusmtip1107f453e4fcdf8dc5ce8e2ba013b6b07~adhwNRgXf0238202382eusmtip1g;
Tue, 8 Mar 2022 16:54:36 +0000 (GMT)
From: Pankaj Raghav
To: Luis Chamberlain ,
Adam Manzanares ,
=?utf-8?q?Javier_Gonz=C3=A1lez?= ,
kanchan Joshi , Jens Axboe ,
Keith Busch , Christoph Hellwig ,
Sagi Grimberg ,
Damien Le Moal , =?utf-8?q?Matias_Bj?=
=?utf-8?q?=C3=B8rling?= , jiangbo.365@bytedance.com
Cc: Pankaj Raghav ,
Kanchan Joshi ,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Pankaj Raghav
Subject: [PATCH 4/6] nvme: zns: Add support for power_of_2 emulation to NVMe
ZNS devices
Date: Tue, 8 Mar 2022 17:53:47 +0100
Message-Id: <20220308165349.231320-5-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220308165349.231320-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrOKsWRmVeSWpSXmKPExsWy7djP87q+XepJBm9eyFtMP6xosfpuP5vF
77PnmS1Wrj7KZPH4zmd2i54DH1gsjv5/y2Zx/u1hJotJh64xWuy9pW0xf9lTdosJbV+ZLW5M
eMpo8XlpC7vFmptPWSzWvX7P4iDg8e/EGjaPnbPusnucv7eRxePy2VKPTas62Tw2L6n32H2z
ASjXep/V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1p1b76f3cb5b4fa1f7d78b51a3b1b44d160
X-Msg-Generator: CA
X-RootMTR: 20220308165436eucas1p1b76f3cb5b4fa1f7d78b51a3b1b44d160
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220308165436eucas1p1b76f3cb5b4fa1f7d78b51a3b1b44d160
References: <20220308165349.231320-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
power_of_2(PO2) is not a requirement as per the NVMe ZNSspecification,
however we still have in place a lot of assumptions
for PO2 in the block layer, in FS such as F2FS, btrfs and userspace
applications.
So in keeping with these requirements, provide an emulation layer to
non-power_of_2 zone devices and which does not create a performance
regression to existing zone storage devices which have PO2 zone sizes.
Callbacks are provided where needed in the hot paths to reduce the
impact of performance regression.
Signed-off-by: Pankaj Raghav
---
drivers/nvme/host/core.c | 28 +++++++----
drivers/nvme/host/nvme.h | 100 ++++++++++++++++++++++++++++++++++++++-
drivers/nvme/host/pci.c | 4 ++
drivers/nvme/host/zns.c | 79 +++++++++++++++++++++++++++++--
include/linux/blk-mq.h | 2 +
5 files changed, 200 insertions(+), 13 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index fd4720d37cc0..c7180d512b08 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -327,14 +327,6 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
return RETRY;
}
-static inline void nvme_end_req_zoned(struct request *req)
-{
- if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
- req_op(req) == REQ_OP_ZONE_APPEND)
- req->__sector = nvme_lba_to_sect(req->q->queuedata,
- le64_to_cpu(nvme_req(req)->result.u64));
-}
-
static inline void nvme_end_req(struct request *req)
{
blk_status_t status = nvme_error_status(nvme_req(req)->status);
@@ -676,6 +668,12 @@ blk_status_t nvme_fail_nonready_command(struct nvme_ctrl *ctrl,
}
EXPORT_SYMBOL_GPL(nvme_fail_nonready_command);
+blk_status_t nvme_fail_po2_zone_emu_violation(struct request *req)
+{
+ return nvme_zone_handle_po2_emu_violation(req);
+}
+EXPORT_SYMBOL_GPL(nvme_fail_po2_zone_emu_violation);
+
bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
bool queue_live)
{
@@ -879,6 +877,7 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req,
req->special_vec.bv_offset = offset_in_page(range);
req->special_vec.bv_len = alloc_size;
req->rq_flags |= RQF_SPECIAL_PAYLOAD;
+ nvme_verify_sector_value(ns, req);
return BLK_STS_OK;
}
@@ -909,6 +908,7 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns,
break;
}
}
+ nvme_verify_sector_value(ns, req);
return BLK_STS_OK;
}
@@ -973,6 +973,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
cmnd->rw.control = cpu_to_le16(control);
cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
+ nvme_verify_sector_value(ns, req);
return 0;
}
@@ -2105,8 +2106,14 @@ static int nvme_report_zones(struct gendisk *disk, sector_t sector,
return nvme_ns_report_zones(disk->private_data, sector, nr_zones, cb,
data);
}
+
+static void nvme_npo2_zone_setup(struct gendisk *disk)
+{
+ nvme_ns_po2_zone_emu_setup(disk->private_data);
+}
#else
#define nvme_report_zones NULL
+#define nvme_npo2_zone_setup NULL
#endif /* CONFIG_BLK_DEV_ZONED */
static const struct block_device_operations nvme_bdev_ops = {
@@ -2116,6 +2123,7 @@ static const struct block_device_operations nvme_bdev_ops = {
.release = nvme_release,
.getgeo = nvme_getgeo,
.report_zones = nvme_report_zones,
+ .npo2_zone_setup = nvme_npo2_zone_setup,
.pr_ops = &nvme_pr_ops,
};
@@ -3844,6 +3852,10 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
ns->disk = disk;
ns->queue = disk->queue;
+#ifdef CONFIG_BLK_DEV_ZONED
+ ns->sect_to_lba = __nvme_sect_to_lba;
+ ns->update_sector_append = nvme_update_sector_append_noop;
+#endif
if (ctrl->opts && ctrl->opts->data_digest)
blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, ns->queue);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index a162f6c6da6e..f584f760e8cc 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -457,6 +457,10 @@ struct nvme_ns {
u8 pi_type;
#ifdef CONFIG_BLK_DEV_ZONED
u64 zsze;
+ u64 zsze_po2;
+ u32 zsze_diff;
+ u64 (*sect_to_lba)(struct nvme_ns *ns, sector_t sector);
+ sector_t (*update_sector_append)(struct nvme_ns *ns, sector_t sector);
#endif
unsigned long features;
unsigned long flags;
@@ -562,12 +566,21 @@ static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl)
return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65);
}
+static inline u64 __nvme_sect_to_lba(struct nvme_ns *ns, sector_t sector)
+{
+ return sector >> (ns->lba_shift - SECTOR_SHIFT);
+}
+
/*
* Convert a 512B sector number to a device logical block number.
*/
static inline u64 nvme_sect_to_lba(struct nvme_ns *ns, sector_t sector)
{
- return sector >> (ns->lba_shift - SECTOR_SHIFT);
+#ifdef CONFIG_BLK_DEV_ZONED
+ return ns->sect_to_lba(ns, sector);
+#else
+ return __nvme_sect_to_lba(ns, sector);
+#endif
}
/*
@@ -578,6 +591,83 @@ static inline sector_t nvme_lba_to_sect(struct nvme_ns *ns, u64 lba)
return lba << (ns->lba_shift - SECTOR_SHIFT);
}
+#ifdef CONFIG_BLK_DEV_ZONED
+static inline u64 __nvme_sect_to_lba_po2(struct nvme_ns *ns, sector_t sector)
+{
+ sector_t zone_idx = sector >> ilog2(ns->zsze_po2);
+
+ sector = sector - (zone_idx * ns->zsze_diff);
+
+ return sector >> (ns->lba_shift - SECTOR_SHIFT);
+}
+
+static inline sector_t
+nvme_update_sector_append_po2_zone_emu(struct nvme_ns *ns, sector_t sector)
+{
+ /* The sector value passed by the drive after a append operation is the
+ * based on the actual zone layout in the device, hence, use the actual
+ * zone_size to calculate the zone number from the sector.
+ */
+ u32 zone_no = sector / ns->zsze;
+
+ sector += ns->zsze_diff * zone_no;
+ return sector;
+}
+
+static inline sector_t nvme_update_sector_append_noop(struct nvme_ns *ns,
+ sector_t sector)
+{
+ return sector;
+}
+
+static inline void nvme_end_req_zoned(struct request *req)
+{
+ if (req_op(req) == REQ_OP_ZONE_APPEND) {
+ struct nvme_ns *ns = req->q->queuedata;
+ sector_t sector;
+
+ sector = nvme_lba_to_sect(ns,
+ le64_to_cpu(nvme_req(req)->result.u64));
+
+ sector = ns->update_sector_append(ns, sector);
+
+ req->__sector = sector;
+ }
+}
+
+static inline void nvme_verify_sector_value(struct nvme_ns *ns, struct request *req)
+{
+ if (unlikely(blk_queue_is_po2_zone_emu(ns->queue))) {
+ sector_t sector = blk_rq_pos(req);
+ sector_t zone_idx = sector >> ilog2(ns->zsze_po2);
+ sector_t device_sector = sector - (zone_idx * ns->zsze_diff);
+
+ /* Check if the IO is in the emulated area */
+ if (device_sector - (zone_idx * ns->zsze) > ns->zsze)
+ req->rq_flags |= RQF_ZONE_EMU_VIOLATION;
+ }
+}
+
+static inline bool nvme_po2_zone_emu_violation(struct request *req)
+{
+ return req->rq_flags & RQF_ZONE_EMU_VIOLATION;
+}
+#else
+static inline void nvme_end_req_zoned(struct request *req)
+{
+}
+
+static inline void nvme_verify_sector_value(struct nvme_ns *ns, struct request *req)
+{
+}
+
+static inline bool nvme_po2_zone_emu_violation(struct request *req)
+{
+ return false;
+}
+
+#endif
+
/*
* Convert byte length to nvme's 0-based num dwords
*/
@@ -752,6 +842,7 @@ long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd,
long nvme_dev_ioctl(struct file *file, unsigned int cmd,
unsigned long arg);
int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo);
+blk_status_t nvme_fail_po2_zone_emu_violation(struct request *req);
extern const struct attribute_group *nvme_ns_id_attr_groups[];
extern const struct pr_ops nvme_pr_ops;
@@ -873,11 +964,13 @@ static inline void nvme_mpath_default_iopolicy(struct nvme_subsystem *subsys)
int nvme_revalidate_zones(struct nvme_ns *ns);
int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data);
+void nvme_ns_po2_zone_emu_setup(struct nvme_ns *ns);
#ifdef CONFIG_BLK_DEV_ZONED
int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf);
blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req,
struct nvme_command *cmnd,
enum nvme_zone_mgmt_action action);
+blk_status_t nvme_zone_handle_po2_emu_violation(struct request *req);
#else
static inline blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns,
struct request *req, struct nvme_command *cmnd,
@@ -892,6 +985,11 @@ static inline int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
"Please enable CONFIG_BLK_DEV_ZONED to support ZNS devices\n");
return -EPROTONOSUPPORT;
}
+
+static inline blk_status_t nvme_zone_handle_po2_emu_violation(struct request *req)
+{
+ return BLK_STS_OK;
+}
#endif
static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 6a99ed680915..fc022df3f98e 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -960,6 +960,10 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
return nvme_fail_nonready_command(&dev->ctrl, req);
ret = nvme_prep_rq(dev, req);
+
+ if (unlikely(nvme_po2_zone_emu_violation(req)))
+ return nvme_fail_po2_zone_emu_violation(req);
+
if (unlikely(ret))
return ret;
spin_lock(&nvmeq->sq_lock);
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index ad02c61c0b52..25516a5ae7e2 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -3,7 +3,9 @@
* Copyright (C) 2020 Western Digital Corporation or its affiliates.
*/
+#include
#include
+#include
#include
#include "nvme.h"
@@ -46,6 +48,18 @@ static int nvme_set_max_append(struct nvme_ctrl *ctrl)
return 0;
}
+static sector_t nvme_zone_size(struct nvme_ns *ns)
+{
+ sector_t zone_size;
+
+ if (blk_queue_is_po2_zone_emu(ns->queue))
+ zone_size = ns->zsze_po2;
+ else
+ zone_size = ns->zsze;
+
+ return zone_size;
+}
+
int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
{
struct nvme_effects_log *log = ns->head->effects;
@@ -122,7 +136,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) / ns->zsze);
+ get_capacity(ns->disk) / nvme_zone_size(ns));
bufsize = sizeof(struct nvme_zone_report) +
nr_zones * sizeof(struct nvme_zone_descriptor);
@@ -147,6 +161,8 @@ static int nvme_zone_parse_entry(struct nvme_ns *ns,
void *data)
{
struct blk_zone zone = { };
+ u64 zone_gap = 0;
+ u32 zone_idx;
if ((entry->zt & 0xf) != NVME_ZONE_TYPE_SEQWRITE_REQ) {
dev_err(ns->ctrl->device, "invalid zone type %#x\n",
@@ -159,10 +175,19 @@ static int nvme_zone_parse_entry(struct nvme_ns *ns,
zone.len = ns->zsze;
zone.capacity = nvme_lba_to_sect(ns, le64_to_cpu(entry->zcap));
zone.start = nvme_lba_to_sect(ns, le64_to_cpu(entry->zslba));
+
+ if (blk_queue_is_po2_zone_emu(ns->queue)) {
+ zone_idx = zone.start / zone.len;
+ zone_gap = zone_idx * ns->zsze_diff;
+ zone.start += zone_gap;
+ zone.len = ns->zsze_po2;
+ }
+
if (zone.cond == BLK_ZONE_COND_FULL)
zone.wp = zone.start + zone.len;
else
- zone.wp = nvme_lba_to_sect(ns, le64_to_cpu(entry->wp));
+ zone.wp =
+ nvme_lba_to_sect(ns, le64_to_cpu(entry->wp)) + zone_gap;
return cb(&zone, idx, data);
}
@@ -173,6 +198,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
struct nvme_zone_report *report;
struct nvme_command c = { };
int ret, zone_idx = 0;
+ u64 zone_size = nvme_zone_size(ns);
unsigned int nz, i;
size_t buflen;
@@ -190,7 +216,7 @@ 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);
+ sector = rounddown(sector, zone_size);
while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) {
memset(report, 0, buflen);
@@ -214,7 +240,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
zone_idx++;
}
- sector += ns->zsze * nz;
+ sector += zone_size * nz;
}
if (zone_idx > 0)
@@ -226,6 +252,32 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
return ret;
}
+void nvme_ns_po2_zone_emu_setup(struct nvme_ns *ns)
+{
+ u32 nr_zones;
+ sector_t capacity;
+
+ if (is_power_of_2(ns->zsze))
+ return;
+
+ if (!get_capacity(ns->disk))
+ return;
+
+ blk_mq_freeze_queue(ns->disk->queue);
+
+ blk_queue_po2_zone_emu(ns->queue, 1);
+ ns->zsze_po2 = 1 << get_count_order_long(ns->zsze);
+ ns->zsze_diff = ns->zsze_po2 - ns->zsze;
+
+ nr_zones = get_capacity(ns->disk) / ns->zsze;
+ capacity = nr_zones * ns->zsze_po2;
+ set_capacity_and_notify(ns->disk, capacity);
+ ns->sect_to_lba = __nvme_sect_to_lba_po2;
+ ns->update_sector_append = nvme_update_sector_append_po2_zone_emu;
+
+ blk_mq_unfreeze_queue(ns->disk->queue);
+}
+
blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req,
struct nvme_command *c, enum nvme_zone_mgmt_action action)
{
@@ -239,5 +291,24 @@ blk_status_t nvme_setup_zone_mgmt_send(struct nvme_ns *ns, struct request *req,
if (req_op(req) == REQ_OP_ZONE_RESET_ALL)
c->zms.select_all = 1;
+ nvme_verify_sector_value(ns, req);
+ return BLK_STS_OK;
+}
+
+blk_status_t nvme_zone_handle_po2_emu_violation(struct request *req)
+{
+ /* The spec mentions that read from ZCAP until ZSZE shall behave
+ * like a deallocated block. Deallocated block reads are
+ * deterministic, hence we fill zero.
+ * The spec does not clearly define the result for other opreation.
+ */
+ if (req_op(req) == REQ_OP_READ) {
+ zero_fill_bio(req->bio);
+ nvme_req(req)->status = NVME_SC_SUCCESS;
+ } else {
+ nvme_req(req)->status = NVME_SC_WRITE_FAULT;
+ }
+ blk_mq_set_request_complete(req);
+ nvme_complete_rq(req);
return BLK_STS_OK;
}
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 3a41d50b85d3..9ec59183efcd 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -57,6 +57,8 @@ typedef __u32 __bitwise req_flags_t;
#define RQF_TIMED_OUT ((__force req_flags_t)(1 << 21))
/* queue has elevator attached */
#define RQF_ELV ((__force req_flags_t)(1 << 22))
+/* request to do IO in the emulated area with po2 zone emulation */
+#define RQF_ZONE_EMU_VIOLATION ((__force req_flags_t)(1 << 23))
/* flags that prevent us from merging requests: */
#define RQF_NOMERGE_FLAGS \
From patchwork Tue Mar 8 16:53:48 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12774061
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 71C6AC433F5
for ; Tue, 8 Mar 2022 16:54:48 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S232531AbiCHQzn (ORCPT );
Tue, 8 Mar 2022 11:55:43 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38246 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1348038AbiCHQzm (ORCPT
); Tue, 8 Mar 2022 11:55:42 -0500
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB78D4EF56
for ;
Tue, 8 Mar 2022 08:54:45 -0800 (PST)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220308165444euoutp016c904ec0013a4e678be6b32761ea50cc~adh3pJcRT3241132411euoutp01M
for ;
Tue, 8 Mar 2022 16:54:44 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220308165444euoutp016c904ec0013a4e678be6b32761ea50cc~adh3pJcRT3241132411euoutp01M
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1646758484;
bh=H53xp6yeGBlTuoGeu8BDVoyhOFj9m5618FQoTrdC9pQ=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=BQ1ndsTEal0EQVH1QKa750Kwu3/+ZGAobYTIZtSdStjcNFGqwbF2meimoWHdDEiG2
CuPQcdPw7cpF5G1xP0gkBGPENHFW0B3V6i2JWVcZKj3NRDqpOUdFG6RnCp2VHp6JCP
2dqEiD1Oic8XWhHbOpKN1nGbtc1MxyKwdyDEKUiI=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20220308165444eucas1p1dc6f150ebe97c32b17af0c232b120eec~adh3TqMe00406404064eucas1p12;
Tue, 8 Mar 2022 16:54:44 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 80.BD.09887.45A87226;
Tue, 8
Mar 2022 16:54:44 +0000 (GMT)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220308165443eucas1p17e61670a5057f21a6c073711b284bfeb~adh20X0_30374103741eucas1p1A;
Tue, 8 Mar 2022 16:54:43 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220308165443eusmtrp22016d5d24eb1bec006c0eb956c4f0969~adh2zoTfc0464104641eusmtrp2k;
Tue, 8 Mar 2022 16:54:43 +0000 (GMT)
X-AuditID: cbfec7f4-45bff7000000269f-43-62278a5498c3
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id BF.96.09404.35A87226;
Tue, 8
Mar 2022 16:54:43 +0000 (GMT)
Received: from localhost (unknown [106.210.248.181]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220308165443eusmtip2d2d4bc26adfa27ddce92481060f6f699~adh2iffUO1078010780eusmtip2c;
Tue, 8 Mar 2022 16:54:43 +0000 (GMT)
From: Pankaj Raghav
To: Luis Chamberlain ,
Adam Manzanares ,
=?utf-8?q?Javier_Gonz=C3=A1lez?= ,
kanchan Joshi , Jens Axboe ,
Keith Busch , Christoph Hellwig ,
Sagi Grimberg ,
Damien Le Moal , =?utf-8?q?Matias_Bj?=
=?utf-8?q?=C3=B8rling?= , jiangbo.365@bytedance.com
Cc: Pankaj Raghav ,
Kanchan Joshi ,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Pankaj Raghav
Subject: [PATCH 5/6] null_blk: forward the sector value from
null_handle_memory_backend
Date: Tue, 8 Mar 2022 17:53:48 +0100
Message-Id: <20220308165349.231320-6-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220308165349.231320-1-p.raghav@samsung.com>
MIME-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aoO92q6dMqKX67etsi5vvj5Fn/FS
d3zTgt2paqdkL8TWzUvccuTzgekXw/1m/noRkSTPKDt5TqvGrejnRpePT5dn3XPMp6fssFaZ
W+oM/z95U8pvVOl0lxkn73UvSF3b9d7N4lLP3Himn6f+16mV5DJ/suS6ctz8UcDhKwefzPP5
L5p89dWXWQt3KbEUZyQaajEXFScCAFyGh6lYAwAA
X-CMS-MailID: 20220308165443eucas1p17e61670a5057f21a6c073711b284bfeb
X-Msg-Generator: CA
X-RootMTR: 20220308165443eucas1p17e61670a5057f21a6c073711b284bfeb
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220308165443eucas1p17e61670a5057f21a6c073711b284bfeb
References: <20220308165349.231320-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
This is a preparation patch to add support for power_of_2 emulation in
the null_blk driver.
Currently, the sector value from null_handle_memory_backend is not
forwarded to the lower layer functions such as null_handle_rq and
null_handle_bio but instead they are fetched again from the request or
the bio respectively. This behaviour will not work when zone size
emulation is enabled.
Instead of fetching the sector value again from the request or bio, pass
down the sector value from null_handle_memory_backend to
null_handle_rq/bio.
Signed-off-by: Pankaj Raghav
---
drivers/block/null_blk/main.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 05b1120e6623..625a06bfa5ad 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1204,13 +1204,12 @@ static int null_transfer(struct nullb *nullb, struct page *page,
return err;
}
-static int null_handle_rq(struct nullb_cmd *cmd)
+static int null_handle_rq(struct nullb_cmd *cmd, sector_t sector)
{
struct request *rq = cmd->rq;
struct nullb *nullb = cmd->nq->dev->nullb;
int err;
unsigned int len;
- sector_t sector = blk_rq_pos(rq);
struct req_iterator iter;
struct bio_vec bvec;
@@ -1231,13 +1230,12 @@ static int null_handle_rq(struct nullb_cmd *cmd)
return 0;
}
-static int null_handle_bio(struct nullb_cmd *cmd)
+static int null_handle_bio(struct nullb_cmd *cmd, sector_t sector)
{
struct bio *bio = cmd->bio;
struct nullb *nullb = cmd->nq->dev->nullb;
int err;
unsigned int len;
- sector_t sector = bio->bi_iter.bi_sector;
struct bio_vec bvec;
struct bvec_iter iter;
@@ -1320,9 +1318,9 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd,
return null_handle_discard(dev, sector, nr_sectors);
if (dev->queue_mode == NULL_Q_BIO)
- err = null_handle_bio(cmd);
+ err = null_handle_bio(cmd, sector);
else
- err = null_handle_rq(cmd);
+ err = null_handle_rq(cmd, sector);
return errno_to_blk_status(err);
}
From patchwork Tue Mar 8 16:53: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: 12774062
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 D9269C433EF
for ; Tue, 8 Mar 2022 16:54:53 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241287AbiCHQzt (ORCPT );
Tue, 8 Mar 2022 11:55:49 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38322 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S243190AbiCHQzr (ORCPT
); Tue, 8 Mar 2022 11:55:47 -0500
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EDEA4ECF9
for ;
Tue, 8 Mar 2022 08:54:50 -0800 (PST)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220308165449euoutp025a7ac19ed8e765f4609b0668df265c26~adh75WYcZ1933719337euoutp024
for ;
Tue, 8 Mar 2022 16:54:49 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220308165449euoutp025a7ac19ed8e765f4609b0668df265c26~adh75WYcZ1933719337euoutp024
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1646758489;
bh=HGaWcY8n+4ocfWs62bYgL+CzDOaHpoifmYU74lyi9D0=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=JY+6bAwFmV7aQTkV1RzxWG2DYvZPwucXN1CviwF4wn5x6sHhZH7Ofv0xWTxitsgsu
i5kq6z139csbCJmZMGhwq+OyW0wYmADYpqJLfoiey+kQyH9g2HRU12GTqrj7TePN7j
y2oZ61CKzzIiyx5MX2p9VTrEAMjrcCuZpvit7j5A=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220308165448eucas1p28317b6a694ac6d07bc5062ad11143436~adh7igDYk2414524145eucas1p2n;
Tue, 8 Mar 2022 16:54:48 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 6C.4B.10009.85A87226;
Tue, 8
Mar 2022 16:54:48 +0000 (GMT)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220308165448eucas1p12c7c302a4b239db64b49d54cc3c1f0ac~adh67nP7W1394013940eucas1p1X;
Tue, 8 Mar 2022 16:54:48 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220308165448eusmtrp2cfde600da3c75354119e07c3717512ea~adh663xTC0537605376eusmtrp2R;
Tue, 8 Mar 2022 16:54:48 +0000 (GMT)
X-AuditID: cbfec7f2-e95ff70000002719-fa-62278a58eba5
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id D2.A6.09404.75A87226;
Tue, 8
Mar 2022 16:54:48 +0000 (GMT)
Received: from localhost (unknown [106.210.248.181]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220308165447eusmtip18f7edb07ec6dbb6febe5b28345ee9648~adh6lo8Rn3181531815eusmtip1Y;
Tue, 8 Mar 2022 16:54:47 +0000 (GMT)
From: Pankaj Raghav
To: Luis Chamberlain ,
Adam Manzanares ,
=?utf-8?q?Javier_Gonz=C3=A1lez?= ,
kanchan Joshi , Jens Axboe ,
Keith Busch , Christoph Hellwig ,
Sagi Grimberg ,
Damien Le Moal , =?utf-8?q?Matias_Bj?=
=?utf-8?q?=C3=B8rling?= , jiangbo.365@bytedance.com
Cc: Pankaj Raghav ,
Kanchan Joshi ,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
Pankaj Raghav
Subject: [PATCH 6/6] null_blk: Add support for power_of_2 emulation to the
null blk device
Date: Tue, 8 Mar 2022 17:53:49 +0100
Message-Id: <20220308165349.231320-7-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220308165349.231320-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFrrJKsWRmVeSWpSXmKPExsWy7djPc7oRXepJBlNPqFtMP6xosfpuP5vF
77PnmS1Wrj7KZPH4zmd2i54DH1gsjv5/y2Zx/u1hJotJh64xWuy9pW0xf9lTdosJbV+ZLW5M
eMpo8XlpC7vFmptPWSzWvX7P4iDg8e/EGjaPnbPusnucv7eRxePy2VKPTas62Tw2L6n32H2z
ASjXep/Vo2/LKkaPz5vkPNoPdDMFcEdx2aSk5mSWpRbp2yVwZfxr7WMrWJhV8eHoXZYGxgXh
XYycHBICJhLnpq5j6mLk4hASWMEoMfPVKnYI5wujRPPEV4wQzmdGidWTlrL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2nLBbrXr9ncRDw+HdiDZvHzll32T3O39vI4nH5bKnHplWdbB6bl9R77L7Z
AJRrvc/q0bdlFaPH501yHu0HupkCuKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1j
rYxMlfTtbFJSczLLUov07RL0Mv619rEVLMyq+HD0LksD44LwLkZODgkBE4mf284wgthCAksZ
JXbfF4KIS0jcXtjECGELS/y51sXWxcgFVPOcUeL0z1Ygh4ODTUBLorGTHSQuInCDWWLZ1DZG
EIdZYDujxIaVc9hAuoUFoiQOt/1jBrFZBFQlnhw5xwRi8wpYSUxsOA+1QV5i5qXv7CA2p4C1
xNPOmWwQF1lJ/DrQClUvKHFy5hMWEJsZqL5562zmCYwCs5CkZiFJLWBkWsUoklpanJueW2yk
V5yYW1yal66XnJ+7iREYo9uO/dyyg3Hlq496hxiZOBgPMUpwMCuJ8N4/r5IkxJuSWFmVWpQf
X1Sak1p8iNEU6O6JzFKiyfnAJJFXEm9oZmBqaGJmaWBqaWasJM7rWdCRKCSQnliSmp2aWpBa
BNPHxMEp1cC0/onO7orq3qRjWU+LZqxiaF+S1r/wtC1D4Z5VwpKTEj0vqCxhujFzdeMHFsVE
vogZP/Z0fVYrOnzE2ubq9CXtFpNY33fPX2Qovfv+sdtiO6s29VVGbq+a+2Zh46wWtXOTG5cK
vvQxfr/lWVLSBytmUR6X6O0+R0V+7XuwR/PmI+euDds+n3TN11qdrZh967cAvzPr0+uvP3hG
xvidSbNgWfxW5i3TMtlH+Qf+/77nN1NweWPhjamXFZ1m+kybVxccK2fMp14/86Ni4WNbx95n
J7euccucfvqcJN/8qEnNid4buAS0Fr6zUJb/NFVjx2TutOyUewKnrzX/V3O/srb1uuG35ftu
vfKqU9E3nbTHV4mlOCPRUIu5qDgRAKO4UtdaAwAA
X-CMS-MailID: 20220308165448eucas1p12c7c302a4b239db64b49d54cc3c1f0ac
X-Msg-Generator: CA
X-RootMTR: 20220308165448eucas1p12c7c302a4b239db64b49d54cc3c1f0ac
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220308165448eucas1p12c7c302a4b239db64b49d54cc3c1f0ac
References: <20220308165349.231320-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
power_of_2(PO2) emulation support is added to the null blk device to
measure performance.
Callbacks are added in the hotpaths that require PO2 emulation specific
behaviour to reduce the impact on exisiting path.
The power_of_2 emulation support is wired up for both the request and
the bio queue mode and it is automatically enabled when the given zone
size is non-power_of_2.
Signed-off-by: Pankaj Raghav
---
drivers/block/null_blk/main.c | 8 +-
drivers/block/null_blk/null_blk.h | 12 ++
drivers/block/null_blk/zoned.c | 203 ++++++++++++++++++++++++++----
3 files changed, 196 insertions(+), 27 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 625a06bfa5ad..c926b59f2b17 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -210,7 +210,7 @@ MODULE_PARM_DESC(zoned, "Make device as a host-managed zoned block device. Defau
static unsigned long g_zone_size = 256;
module_param_named(zone_size, g_zone_size, ulong, S_IRUGO);
-MODULE_PARM_DESC(zone_size, "Zone size in MB when block device is zoned. Must be power-of-two: Default: 256");
+MODULE_PARM_DESC(zone_size, "Zone size in MB when block device is zoned. Default: 256");
static unsigned long g_zone_capacity;
module_param_named(zone_capacity, g_zone_capacity, ulong, 0444);
@@ -1772,11 +1772,13 @@ static const struct block_device_operations null_bio_ops = {
.owner = THIS_MODULE,
.submit_bio = null_submit_bio,
.report_zones = null_report_zones,
+ .npo2_zone_setup = null_po2_zone_emu_setup,
};
static const struct block_device_operations null_rq_ops = {
.owner = THIS_MODULE,
.report_zones = null_report_zones,
+ .npo2_zone_setup = null_po2_zone_emu_setup,
};
static int setup_commands(struct nullb_queue *nq)
@@ -1929,8 +1931,8 @@ static int null_validate_conf(struct nullb_device *dev)
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");
+ (!dev->zone_size)) {
+ pr_err("zone_size must be zero\n");
return -EINVAL;
}
diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h
index 78eb56b0ca55..34c1b7b2546b 100644
--- a/drivers/block/null_blk/null_blk.h
+++ b/drivers/block/null_blk/null_blk.h
@@ -74,6 +74,16 @@ struct nullb_device {
unsigned int imp_close_zone_no;
struct nullb_zone *zones;
sector_t zone_size_sects;
+ sector_t zone_size_po2_sects;
+ sector_t zone_size_diff_sects;
+ /* The callbacks below are used as hook to perform po2 emulation for a
+ * zoned device.
+ */
+ unsigned int (*zone_no)(struct nullb_device *dev,
+ sector_t sect);
+ sector_t (*zone_update_sector)(struct nullb_device *dev, sector_t sect);
+ sector_t (*zone_update_sector_append)(struct nullb_device *dev,
+ sector_t sect);
bool need_zone_res_mgmt;
spinlock_t zone_res_lock;
@@ -137,6 +147,7 @@ int null_register_zoned_dev(struct nullb *nullb);
void null_free_zoned_dev(struct nullb_device *dev);
int null_report_zones(struct gendisk *disk, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data);
+void null_po2_zone_emu_setup(struct gendisk *disk);
blk_status_t null_process_zoned_cmd(struct nullb_cmd *cmd,
enum req_opf op, sector_t sector,
sector_t nr_sectors);
@@ -166,5 +177,6 @@ static inline size_t null_zone_valid_read_len(struct nullb *nullb,
return len;
}
#define null_report_zones NULL
+#define null_po2_zone_emu_setup NULL
#endif /* CONFIG_BLK_DEV_ZONED */
#endif /* __NULL_BLK_H */
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index dae54dd1aeac..3bb63c170149 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -16,6 +16,44 @@ static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect)
return sect >> ilog2(dev->zone_size_sects);
}
+static inline unsigned int null_npo2_zone_no(struct nullb_device *dev,
+ sector_t sect)
+{
+ return sect / dev->zone_size_sects;
+}
+
+static inline bool null_is_po2_zone_emu(struct nullb_device *dev)
+{
+ return !!dev->zone_size_diff_sects;
+}
+
+static inline sector_t null_zone_update_sector_noop(struct nullb_device *dev,
+ sector_t sect)
+{
+ return sect;
+}
+
+static inline sector_t null_zone_update_sector_po2_emu(struct nullb_device *dev,
+ sector_t sect)
+{
+ sector_t zsze_po2 = dev->zone_size_po2_sects;
+ sector_t zsze_diff = dev->zone_size_diff_sects;
+ u32 zone_idx = sect >> ilog2(zsze_po2);
+
+ sect = sect - (zone_idx * zsze_diff);
+ return sect;
+}
+
+static inline sector_t
+null_zone_update_sector_append_po2_emu(struct nullb_device *dev, sector_t sect)
+{
+ /* Need to readjust the sector if po2 emulation is used. */
+ u32 zone_no = dev->zone_no(dev, sect);
+
+ sect += dev->zone_size_diff_sects * zone_no;
+ return sect;
+}
+
static inline void null_lock_zone_res(struct nullb_device *dev)
{
if (dev->need_zone_res_mgmt)
@@ -62,15 +100,14 @@ 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;
}
+ if (!is_power_of_2(dev->zone_size))
+ pr_info("zone_size is not power-of-two. power-of-two emulation is enabled");
+
if (!dev->zone_capacity)
dev->zone_capacity = dev->zone_size;
@@ -83,8 +120,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);
+
+ dev->nr_zones = roundup(dev_capacity_sects, dev->zone_size_sects) /
+ dev->zone_size_sects;
+
+ dev->zone_no = null_zone_no;
+ dev->zone_update_sector = null_zone_update_sector_noop;
+ dev->zone_update_sector_append = null_zone_update_sector_noop;
+
dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone),
GFP_KERNEL | __GFP_ZERO);
@@ -166,7 +209,13 @@ int null_register_zoned_dev(struct nullb *nullb)
if (ret)
return ret;
} else {
- blk_queue_chunk_sectors(q, dev->zone_size_sects);
+ nullb->disk->fops->npo2_zone_setup(nullb->disk);
+
+ if (null_is_po2_zone_emu(dev))
+ blk_queue_chunk_sectors(q, dev->zone_size_po2_sects);
+ else
+ blk_queue_chunk_sectors(q, dev->zone_size_sects);
+
q->nr_zones = blkdev_nr_zones(nullb->disk);
}
@@ -183,17 +232,49 @@ void null_free_zoned_dev(struct nullb_device *dev)
dev->zones = NULL;
}
+static void null_update_zone_info(struct nullb *nullb, struct blk_zone *blkz,
+ struct nullb_zone *zone)
+{
+ unsigned int zone_idx;
+ u64 zone_gap;
+ struct nullb_device *dev = nullb->dev;
+
+ if (null_is_po2_zone_emu(dev)) {
+ zone_idx = zone->start / zone->len;
+ zone_gap = zone_idx * dev->zone_size_diff_sects;
+
+ blkz->start = zone->start + zone_gap;
+ blkz->len = dev->zone_size_po2_sects;
+ blkz->wp = zone->wp + zone_gap;
+ } else {
+ blkz->start = zone->start;
+ blkz->len = zone->len;
+ blkz->wp = zone->wp;
+ }
+
+ blkz->type = zone->type;
+ blkz->cond = zone->cond;
+ blkz->capacity = zone->capacity;
+}
+
int null_report_zones(struct gendisk *disk, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data)
{
struct nullb *nullb = disk->private_data;
struct nullb_device *dev = nullb->dev;
unsigned int first_zone, i;
+ sector_t zone_size;
struct nullb_zone *zone;
struct blk_zone blkz;
int error;
- first_zone = null_zone_no(dev, sector);
+ if (null_is_po2_zone_emu(dev))
+ zone_size = dev->zone_size_po2_sects;
+ else
+ zone_size = dev->zone_size_sects;
+
+ first_zone = sector / zone_size;
+
if (first_zone >= dev->nr_zones)
return 0;
@@ -210,12 +291,7 @@ int null_report_zones(struct gendisk *disk, sector_t sector,
* array.
*/
null_lock_zone(dev, zone);
- blkz.start = zone->start;
- blkz.len = zone->len;
- blkz.wp = zone->wp;
- blkz.type = zone->type;
- blkz.cond = zone->cond;
- blkz.capacity = zone->capacity;
+ null_update_zone_info(nullb, &blkz, zone);
null_unlock_zone(dev, zone);
error = cb(&blkz, i, data);
@@ -226,6 +302,35 @@ int null_report_zones(struct gendisk *disk, sector_t sector,
return nr_zones;
}
+void null_po2_zone_emu_setup(struct gendisk *disk)
+{
+ struct nullb *nullb = disk->private_data;
+ struct nullb_device *dev = nullb->dev;
+ sector_t capacity;
+
+ if (is_power_of_2(dev->zone_size_sects))
+ return;
+
+ if (!get_capacity(disk))
+ return;
+
+ blk_mq_freeze_queue(disk->queue);
+
+ blk_queue_po2_zone_emu(disk->queue, 1);
+ dev->zone_size_po2_sects =
+ 1 << get_count_order_long(dev->zone_size_sects);
+ dev->zone_size_diff_sects =
+ dev->zone_size_po2_sects - dev->zone_size_sects;
+ dev->zone_no = null_npo2_zone_no;
+ dev->zone_update_sector = null_zone_update_sector_po2_emu;
+ dev->zone_update_sector_append = null_zone_update_sector_append_po2_emu;
+
+ capacity = dev->nr_zones * dev->zone_size_po2_sects;
+ set_capacity(disk, capacity);
+
+ blk_mq_unfreeze_queue(disk->queue);
+}
+
/*
* This is called in the case of memory backing from null_process_cmd()
* with the target zone already locked.
@@ -234,7 +339,7 @@ size_t null_zone_valid_read_len(struct nullb *nullb,
sector_t sector, unsigned int len)
{
struct nullb_device *dev = nullb->dev;
- struct nullb_zone *zone = &dev->zones[null_zone_no(dev, sector)];
+ struct nullb_zone *zone = &dev->zones[dev->zone_no(dev, sector)];
unsigned int nr_sectors = len >> SECTOR_SHIFT;
/* Read must be below the write pointer position */
@@ -363,11 +468,24 @@ static blk_status_t null_check_zone_resources(struct nullb_device *dev,
}
}
+static void null_update_sector_append(struct nullb_cmd *cmd, sector_t sector)
+{
+ struct nullb_device *dev = cmd->nq->dev;
+
+ sector = dev->zone_update_sector_append(dev, sector);
+
+ if (cmd->bio) {
+ cmd->bio->bi_iter.bi_sector = sector;
+ } else {
+ cmd->rq->__sector = sector;
+ }
+}
+
static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
unsigned int nr_sectors, bool append)
{
struct nullb_device *dev = cmd->nq->dev;
- unsigned int zno = null_zone_no(dev, sector);
+ unsigned int zno = dev->zone_no(dev, sector);
struct nullb_zone *zone = &dev->zones[zno];
blk_status_t ret;
@@ -395,10 +513,7 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
*/
if (append) {
sector = zone->wp;
- if (cmd->bio)
- cmd->bio->bi_iter.bi_sector = sector;
- else
- cmd->rq->__sector = sector;
+ null_update_sector_append(cmd, sector);
} else if (sector != zone->wp) {
ret = BLK_STS_IOERR;
goto unlock;
@@ -619,7 +734,7 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,
return BLK_STS_OK;
}
- zone_no = null_zone_no(dev, sector);
+ zone_no = dev->zone_no(dev, sector);
zone = &dev->zones[zone_no];
null_lock_zone(dev, zone);
@@ -650,13 +765,54 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,
return ret;
}
+static blk_status_t null_handle_po2_zone_emu_violation(struct nullb_cmd *cmd,
+ enum req_opf op)
+{
+ if (op == REQ_OP_READ) {
+ if (cmd->bio)
+ zero_fill_bio(cmd->bio);
+ else
+ zero_fill_bio(cmd->rq->bio);
+
+ return BLK_STS_OK;
+ } else {
+ return BLK_STS_IOERR;
+ }
+}
+
+static bool null_verify_sector_violation(struct nullb_device *dev,
+ sector_t sector)
+{
+ if (unlikely(null_is_po2_zone_emu(dev))) {
+ /* The zone idx should be calculated based on the emulated
+ * layout
+ */
+ u32 zone_idx = sector >> ilog2(dev->zone_size_po2_sects);
+ sector_t zsze = dev->zone_size_sects;
+ sector_t sect = null_zone_update_sector_po2_emu(dev, sector);
+
+ if (sect - (zone_idx * zsze) > zsze)
+ return true;
+ }
+ return false;
+}
+
blk_status_t null_process_zoned_cmd(struct nullb_cmd *cmd, enum req_opf op,
sector_t sector, sector_t nr_sectors)
{
- struct nullb_device *dev;
+ struct nullb_device *dev = cmd->nq->dev;
struct nullb_zone *zone;
blk_status_t sts;
+ /* Handle when the sector falls in the emulated area */
+ if (unlikely(null_verify_sector_violation(dev, sector)))
+ return null_handle_po2_zone_emu_violation(cmd, op);
+
+ /* The sector value is updated if po2 emulation is enabled, else it
+ * will have no effect on the value
+ */
+ sector = dev->zone_update_sector(dev, sector);
+
switch (op) {
case REQ_OP_WRITE:
return null_zone_write(cmd, sector, nr_sectors, false);
@@ -669,8 +825,7 @@ blk_status_t null_process_zoned_cmd(struct nullb_cmd *cmd, enum req_opf op,
case REQ_OP_ZONE_FINISH:
return null_zone_mgmt(cmd, op, sector);
default:
- dev = cmd->nq->dev;
- zone = &dev->zones[null_zone_no(dev, sector)];
+ zone = &dev->zones[dev->zone_no(dev, sector)];
null_lock_zone(dev, zone);
sts = null_process_cmd(cmd, op, sector, nr_sectors);