From patchwork Wed Apr 27 16:02:40 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12829055
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 4C75FC43219
for ; Wed, 27 Apr 2022 16:03:47 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241689AbiD0QGz (ORCPT );
Wed, 27 Apr 2022 12:06:55 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49066 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241578AbiD0QGw (ORCPT
);
Wed, 27 Apr 2022 12:06:52 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E19A3CAAC2
for ;
Wed, 27 Apr 2022 09:03:01 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160259euoutp026841ecc997dbbb5fc0667c79582062c3~pzE9SbciJ1060610606euoutp02b
for ;
Wed, 27 Apr 2022 16:02:59 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220427160259euoutp026841ecc997dbbb5fc0667c79582062c3~pzE9SbciJ1060610606euoutp02b
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075379;
bh=kk01EsRG9bOHVzhx2cg7vI10rthuoQfVL8TCej8gbAs=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=FqFqteqGXSEnxZPhnX9rym6n42YAt++KmTUYH1akFOm0A7L9YLhwHpvVJ5z+0TJl9
A71EFZm4I1wTNw7c+GIBonIM8041uzM6cxt8uvhd7XeS0ftGXi1kqVecDOT0q+lFCo
xeb6kGclgglBpZfHmT9Vj1NgpQ/SIdZW/rLg5myE=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160257eucas1p248f9fb67b38f65e92cd401d8333f1f48~pzE7tOLRh2334023340eucas1p2g;
Wed, 27 Apr 2022 16:02:57 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 40.0A.10260.13969626;
Wed, 27
Apr 2022 17:02:57 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220427160257eucas1p21fb58d0129376a135fdf0b9c2fe88895~pzE7TkyRS2335223352eucas1p2Z;
Wed, 27 Apr 2022 16:02:57 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220427160257eusmtrp29abf9fbaa39f05eb9b4bd28a52f41a07~pzE7Sr62r2598325983eusmtrp2c;
Wed, 27 Apr 2022 16:02:57 +0000 (GMT)
X-AuditID: cbfec7f5-bddff70000002814-7e-62696931489b
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 9B.71.09522.13969626;
Wed, 27
Apr 2022 17:02:57 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160256eusmtip1cbd768be896ffc9fa5c108cd32dcf1a6~pzE67wefT0884308843eusmtip1h;
Wed, 27 Apr 2022 16:02:56 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 01/16] block: make blkdev_nr_zones and blk_queue_zone_no
generic for npo2 zsze
Date: Wed, 27 Apr 2022 18:02:40 +0200
Message-Id: <20220427160255.300418-2-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02Se1BUZRjG+8539pzDjmuH1dEv6ebOaGGGMEZ+E0YxOniwGeCf2GiYkQVO
sAWr7Epg6bTcDFaTywTCAgNYEFeXe1xEaUEuIcGwYMAQRrKjILAYEpctjOXQ5H/P+36/533f
Z+ZjoPQ6tYdRqs7yapUiXEaJyYbO1f43XZTKIOdLeY7Y8HMnxOW/pVA4c2EV4t6MPgKnp2TR
2NrXD3HrfI4ID6zEEni0rYnApeW3CTxl0EN8uW2BxP/oJjZ6CZMQ/z3pgtONdwE2D+sJ3Dr2
Bh68X0LjwWsn8I3WHhKbmnMpnF9spnHqxSWIR1LNAKd11YrwYlECja8/spC4e8zh/Zc409AH
3Hp3BcWlxc/TXP9ENcmZ+qK4mrJkiivUZkCu9vuvuJaCRYJrGdVS3Dfx8xTXlHhPxFluDlPc
lboywBnqhkkutbZa5Cv9WHw0hA9Xfs6rD7kHisMst/afSWJjLGurQAsaJTpgxyD2LZRQnAJ1
QMxI2RKAEjtnCaF4AtB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F5aQu7xbrX71ksTtySdpD1uHzF2+PfiTVsHhOb37F7nL+3kcXj
8tlSj02rOtk8FjZMZfbYvKTeY/eCz0weu282sHn0Nr9j89jZep/V4/2+q2wefVtWMXqs33KV
xWPC5o2sAUJRejZF+aUlqQoZ+cUltkrRhhZGeoaWFnpGJpZ6hsbmsVZGpkr6djYpqTmZZalF
+nYJehnv96sVdAhUvP/1k7GBcQdvFyMHh4SAicTnrbldjFwcQgJLGSV+PNjF2MXICRSXkLi9
sAnKFpb4c62LDaLoOaPEll2TmECa2QS0JBo72UHiIgJPGCXu/3zMAuIwCzSwSNyauIsJpFtY
IE5i5rFDzCA2i4CqxNun38FsXgEriYPvt7JAbJCXmHnpOzvIUE4Ba4kJnyJAwkJAJd2LbrFC
lAtKnJz5BKycGai8eets5gmMArOQpGYhSS1gZFrFKJJaWpybnltsqFecmFtcmpeul5yfu4kR
mE62Hfu5eQfjvFcf9Q4xMnEwHmKU4GBWEuH9sjsjSYg3JbGyKrUoP76oNCe1+BCjKdDZE5ml
RJPzgQktryTe0MzA1NDEzNLA1NLMWEmc17OgI1FIID2xJDU7NbUgtQimj4mDU6qBidvFgLde
KU2Y82fPlJdpbQYOeVKdrT8nT3Zp9Pj6z2de32p1k57g7xxG05c4HVkckRoT84zVlGX/068R
548EqHmt61bz5bh/wTjjCUfeQ4bqHexaC7W2bOSLuPV7i+rMeyH8OUptHw5s2bp94dn6fd48
xw08429uNq5fmZm7q8uq/KTxmvVfZy5uYXjf25yisU2u2EFIbncqy0K7WYa9j2bz3DRWNlwc
/0XLevpHofcCOleeiO5kuMZeM2mD2aZzB1k4tN5POijOtaC4/L/gnT1nPbS5plTdKfk1cZv4
KyPNxzP+OphweMVyeCp8dXoVczXr7Lbu0mUBOSv/Oa3N3OHt8YV/9cX87Pf163yclFiKMxIN
tZiLihMBAepjMLADAAA=
X-CMS-MailID: 20220427160257eucas1p21fb58d0129376a135fdf0b9c2fe88895
X-Msg-Generator: CA
X-RootMTR: 20220427160257eucas1p21fb58d0129376a135fdf0b9c2fe88895
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160257eucas1p21fb58d0129376a135fdf0b9c2fe88895
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Adapt blkdev_nr_zones and blk_queue_zone_no function so that it can
also work for non-power-of-2 zone sizes.
As the existing deployments of zoned devices had power-of-2
assumption, power-of-2 optimized calculation is kept for those devices.
There are no direct hot paths modified and the changes just
introduce one new branch per call.
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
Reviewed-by: Hannes Reinecke
---
block/blk-zoned.c | 8 +++++++-
include/linux/blkdev.h | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 38cd840d8838..1dff4a8bd51d 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -117,10 +117,16 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
unsigned int blkdev_nr_zones(struct gendisk *disk)
{
sector_t zone_sectors = blk_queue_zone_sectors(disk->queue);
+ sector_t capacity = get_capacity(disk);
if (!blk_queue_is_zoned(disk->queue))
return 0;
- return (get_capacity(disk) + zone_sectors - 1) >> ilog2(zone_sectors);
+
+ if (is_power_of_2(zone_sectors))
+ return (capacity + zone_sectors - 1) >>
+ ilog2(zone_sectors);
+
+ return div64_u64(capacity + zone_sectors - 1, zone_sectors);
}
EXPORT_SYMBOL_GPL(blkdev_nr_zones);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 60d016138997..c4e4c7071b7b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -665,9 +665,15 @@ static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
static inline unsigned int blk_queue_zone_no(struct request_queue *q,
sector_t sector)
{
+ sector_t zone_sectors = blk_queue_zone_sectors(q);
+
if (!blk_queue_is_zoned(q))
return 0;
- return sector >> ilog2(q->limits.chunk_sectors);
+
+ if (is_power_of_2(zone_sectors))
+ return sector >> ilog2(zone_sectors);
+
+ return div64_u64(sector, zone_sectors);
}
static inline bool blk_queue_zone_is_seq(struct request_queue *q,
From patchwork Wed Apr 27 16:02:41 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12829059
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 D24A4C4332F
for ; Wed, 27 Apr 2022 16:03:55 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241611AbiD0QHC (ORCPT );
Wed, 27 Apr 2022 12:07:02 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49194 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241619AbiD0QGx (ORCPT
);
Wed, 27 Apr 2022 12:06:53 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 149CA3CD5B4
for ;
Wed, 27 Apr 2022 09:03:06 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160300euoutp01f6208ba8ab41cef8020102d3e0b10767~pzE_WMHqs0745007450euoutp01T
for ;
Wed, 27 Apr 2022 16:03:00 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160300euoutp01f6208ba8ab41cef8020102d3e0b10767~pzE_WMHqs0745007450euoutp01T
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075380;
bh=RJVMrlQpvMBXokOVGO8QBkDOO+u9KZOAxDi7xzIPKXQ=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=Hm/DOeyCcaKdDk9xu6hdF6129Z33BVsqljAvLdYQOq4TXbF86UxKVp4//UAYM1JWb
ZMLN0ZHtnzpC3du0x1jTRHI9nhHOp8VFEjt2LCcBy6Sl7f4scRPldoQnFGcsaXOY+J
6eYqmxgN6KDAf93zrKzPXCr/9iFVZ2HYmQ1+OJM8=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160258eucas1p252cb6872c7cc20eea327c199f8e2aec9~pzE8vLb-p1589415894eucas1p2E;
Wed, 27 Apr 2022 16:02:58 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id C2.0A.10260.23969626;
Wed, 27
Apr 2022 17:02:58 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160258eucas1p19548a7094f67b4c9f340add776f60082~pzE8W8LWT0330603306eucas1p1Q;
Wed, 27 Apr 2022 16:02:58 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220427160258eusmtrp2f76aadf93653911fc7f556ba6f0a2efb~pzE8ULUY32598325983eusmtrp2d;
Wed, 27 Apr 2022 16:02:58 +0000 (GMT)
X-AuditID: cbfec7f5-bf3ff70000002814-81-6269693261bd
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 7D.71.09522.23969626;
Wed, 27
Apr 2022 17:02:58 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160258eusmtip2b1f69ceee95e1cec081198bf82161f87~pzE79CnAQ2569125691eusmtip2E;
Wed, 27 Apr 2022 16:02:58 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 02/16] block: add blk_queue_zone_aligned and
bdev_zone_aligned helper
Date: Wed, 27 Apr 2022 18:02:41 +0200
Message-Id: <20220427160255.300418-3-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02Sf0xTVxTHd999fX1tUvYoBO8E3Og0UwZYQLcbWHQGM1/CFlmyxGW6YYEn
MMuPtLJN3GYdSJQILThwVBg/FShCEUoBkUWbDWTalBYYKBNHhDHAAQoyQCejPMz873vu+Xy/
55zk0lBaR62n4xOPcKpEhVJGiUlzx6LNPyg+PkpemBeIjb92QFxzV0vh/JlFiG/mWQmcq/1B
iJ9YbRC3T50X4O6FEwS+fa2VwNU1vxB4xKiH+My1GRL/mzm08pY+DPHT4UCca/kN4NE+PYHb
77yJHferhNhRtgdfbe8icc+VQgoXXxwVYl3GY4gHdKMA53Q2CvDshXQhrpucJvGNO57verM9
veHssxuXKDYnbUrI2oYuk2yPNYVtMJym2FJNHmQbK46zbSWzBNt2W0O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VyWW4oxE
Qy3mouJEAGOYaxeyAwAA
X-CMS-MailID: 20220427160258eucas1p19548a7094f67b4c9f340add776f60082
X-Msg-Generator: CA
X-RootMTR: 20220427160258eucas1p19548a7094f67b4c9f340add776f60082
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160258eucas1p19548a7094f67b4c9f340add776f60082
References: <20220427160255.300418-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 very common
operation that is performed for zoned devices. Add
blk_queue_zone_aligned helper to check for this instead of opencoding it
everywhere.
The helper is made to be generic so that it can also check for alignment
for non non-power-of-2 zone size devices.
As the existing deployments of zoned devices had power-of-2
assumption, power-of-2 optimized calculation is done for devices with
power-of-2 zone size
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
Reviewed-by: Hannes Reinecke
---
include/linux/blkdev.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c4e4c7071b7b..f8f2d2998afb 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -676,6 +676,22 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q,
return div64_u64(sector, zone_sectors);
}
+static inline bool blk_queue_zone_aligned(struct request_queue *q, sector_t sec)
+{
+ sector_t zone_sectors = blk_queue_zone_sectors(q);
+ u64 remainder = 0;
+
+ if (!blk_queue_is_zoned(q))
+ return false;
+
+ if (is_power_of_2(zone_sectors))
+ return IS_ALIGNED(sec, zone_sectors);
+
+ div64_u64_rem(sec, zone_sectors, &remainder);
+ /* if there is a remainder, then the sector is not aligned */
+ return remainder == 0;
+}
+
static inline bool blk_queue_zone_is_seq(struct request_queue *q,
sector_t sector)
{
@@ -722,6 +738,12 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q,
{
return 0;
}
+
+static inline bool blk_queue_zone_aligned(struct request_queue *q, sector_t sec)
+{
+ return false;
+}
+
static inline unsigned int queue_max_open_zones(const struct request_queue *q)
{
return 0;
@@ -1361,6 +1383,15 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
return 0;
}
+static inline bool bdev_zone_aligned(struct block_device *bdev, sector_t sec)
+{
+ struct request_queue *q = bdev_get_queue(bdev);
+
+ if (q)
+ return blk_queue_zone_aligned(q, sec);
+ return false;
+}
+
static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
{
struct request_queue *q = bdev_get_queue(bdev);
From patchwork Wed Apr 27 16:02:42 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12829056
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 8D8A0C43219
for ; Wed, 27 Apr 2022 16:03:50 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241730AbiD0QG6 (ORCPT );
Wed, 27 Apr 2022 12:06:58 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49122 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241419AbiD0QGy (ORCPT
);
Wed, 27 Apr 2022 12:06:54 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD6973C9BBF
for ;
Wed, 27 Apr 2022 09:03:06 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160301euoutp02ffd0074fd93873fbc40c026d758f501f~pzE-UHb-y1400814008euoutp02t
for ;
Wed, 27 Apr 2022 16:03:01 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220427160301euoutp02ffd0074fd93873fbc40c026d758f501f~pzE-UHb-y1400814008euoutp02t
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075381;
bh=BWD7vHeyj4CQ5Yi8P8N3Y/UNmrAcLUZCdK4xuanhqxM=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=GjtnpqS6TFmG2lS3q3AvbSUlERHkrFUlQO9oURtx63Y8neTC073fmMr39BfnCvCBw
DTvzJ0X8IPJMoeRECHcpODziirNBHPHsusQTuxwb6EylE22GYnBKu6saD8rcytElZS
FMexbXBDvDOgUTbirA0LbgEUR7hJIW8gG1tIYbU8=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160300eucas1p2fc7475012e90a1a33a382c42587b4446~pzE9zxJ3a2333423334eucas1p2i;
Wed, 27 Apr 2022 16:03:00 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 48.D7.10009.33969626;
Wed, 27
Apr 2022 17:02:59 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220427160259eucas1p25aab0637fec229cd1140e6aa08678f38~pzE9RHMr30646906469eucas1p2D;
Wed, 27 Apr 2022 16:02:59 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220427160259eusmtrp23acd8a811248a150d7112d6be62c6f22~pzE9QGU2h2598325983eusmtrp2e;
Wed, 27 Apr 2022 16:02:59 +0000 (GMT)
X-AuditID: cbfec7f2-e95ff70000002719-74-6269693374d0
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 5F.71.09522.33969626;
Wed, 27
Apr 2022 17:02:59 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160259eusmtip2e40409a4ed4d05babb2748470116c200~pzE85iTMw3126231262eusmtip23;
Wed, 27 Apr 2022 16:02:59 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 03/16] block: add bdev_zone_no helper
Date: Wed, 27 Apr 2022 18:02:42 +0200
Message-Id: <20220427160255.300418-4-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02Sf1CTdRzH7/t8H549rOY9bBTfUDN3l1eoEAceX9PrSkue8vJE7Yf5B0x4
hOkYuDGjqGsEIySRwSUojvxR5JzhgBE1kY6gGAgEMWf8/nGwUgqGsJkcCTGeefnf+/P5vj7v
9+dz96Wh+CoVTMuVaZxKKVNIKSFZ2zz368YIufzgC5MjUdh8oxniK4MFFC6enoO47VQHgYsK
TgvwfEcnxPVTZ/1w1/1MAvc2WAl8+covBB43l0J8omGaxA/yhpZ62aMQ/zsajosabwHsdJQS
uL5vPe4eMwpw98V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zZXlMvfYLiZJRJmvYG2K8bwxo/1e5OTK9evt/bOm3Jit5CH4+o78hvNM964s
SWa92MliZFcX9Oqdzbwvem15DxN4zxxjvCvwR9j3zGNjUZG7WgErmRpLu0pXxgVkKrEUZyQa
ajEXFScCAJFoJ62yAwAA
X-CMS-MailID: 20220427160259eucas1p25aab0637fec229cd1140e6aa08678f38
X-Msg-Generator: CA
X-RootMTR: 20220427160259eucas1p25aab0637fec229cd1140e6aa08678f38
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160259eucas1p25aab0637fec229cd1140e6aa08678f38
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Many places in the filesystem for zoned devices open code this function
to find the zone number for a given sector with power of 2 assumption.
This generic helper can be used to calculate zone number for a given
sector in a block device
This helper internally uses blk_queue_zone_no to find the zone number.
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
Reviewed-by: Hannes Reinecke
---
include/linux/blkdev.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f8f2d2998afb..55293e0a8702 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1392,6 +1392,15 @@ static inline bool bdev_zone_aligned(struct block_device *bdev, sector_t sec)
return false;
}
+static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
+{
+ struct request_queue *q = bdev_get_queue(bdev);
+
+ if (q)
+ return blk_queue_zone_no(q, sec);
+ return 0;
+}
+
static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
{
struct request_queue *q = bdev_get_queue(bdev);
From patchwork Wed Apr 27 16:02:43 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12829057
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 C8763C433EF
for ; Wed, 27 Apr 2022 16:03:50 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241735AbiD0QG7 (ORCPT );
Wed, 27 Apr 2022 12:06:59 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49004 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241548AbiD0QGx (ORCPT
);
Wed, 27 Apr 2022 12:06:53 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF3D33CE99F
for ;
Wed, 27 Apr 2022 09:03:07 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160302euoutp028aa2f95732a9210820e06caf0483347d~pzFAkUJDV1441914419euoutp02u
for ;
Wed, 27 Apr 2022 16:03:02 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220427160302euoutp028aa2f95732a9210820e06caf0483347d~pzFAkUJDV1441914419euoutp02u
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075383;
bh=hUBpZxkDXTvCbRzniY5oQe/mcS4maRVWN0mf8iYt6nk=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=nUD3Zlljb1W0hKuro0V+VuS6AzNwVXo2IEBdL3HytZKp+pf4rjul8PwzEA8TIpSkW
7nJJ26TxElUXLp2CtpMD3NhzFJm4XRSCZtZ8SLFKMrDjwWSNHWQG3aYZcTV1wLjxje
ypI6XKbLcp0CGsseTYr04mRkmN9XIp9n3ttp424c=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160300eucas1p2820b4ac90e9eb0636191f5d6b6009ac5~pzE_szwrg2336123361eucas1p2k;
Wed, 27 Apr 2022 16:03:00 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id D4.0A.10260.43969626;
Wed, 27
Apr 2022 17:03:00 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a~pzE_QB5uM0602706027eucas1p1M;
Wed, 27 Apr 2022 16:03:00 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160300eusmtrp11a05ef21462b132cd88f3aeacf09747f~pzE_N2fo72077420774eusmtrp1H;
Wed, 27 Apr 2022 16:03:00 +0000 (GMT)
X-AuditID: cbfec7f5-bf3ff70000002814-85-626969340c0e
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id CC.97.09404.43969626;
Wed, 27
Apr 2022 17:03:00 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160300eusmtip201f34f7356e5fa50793f41df667dbd86~pzE93FBDa0262002620eusmtip2N;
Wed, 27 Apr 2022 16:03:00 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 04/16] block: allow blk-zoned devices to have non-power-of-2
zone size
Date: Wed, 27 Apr 2022 18:02:43 +0200
Message-Id: <20220427160255.300418-5-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02SfUxTVxjGOffc3luq1duKcoZDA3GZ6AA/WHYG09Fs2a66LOr8w5EsrsAN
EFsgLR0CWyjCXGGMQpkyCjJQRD62tUgVscUwIl8ilBUrYBiECcvEUBigjoFs7Voz/3ve9/ze
5znvyeFDsZHy4yckpnCKRKkskBKQ1zqXrMFhCQnRuzpb92LD7U6IG37VUvjc3BLEvWf7CKzT
fkfj5T4rxK2OMh4e+CuLwCNtLQSua+gg8KRBD3F+2xyJn+WNOXs5ExCvTOzGuvZ7AE/Z9QRu
vb8T2x7U0th24X1sae0h8eCNcgp/XzNF48IzjyEeLpwCuKiriYcXLuXQ+KdHsyTuvr850p8d
vHuIXe3+gWKLsh00ax1rJNnBPhV7pT6XYqvUZyHbVJ3JmisXCNY8oqbYb7IdFNvy5TiPnb1p
p9gCUz1gDSY7yRY2NfIOi6MEb8VysoTPOEXo/k8F8Y1VD+jk3o2nzFoLrQa3RXnAm4+YMPR1
7yWQBwR8MVMLkLZ5zlMsAnTBbCPcxQJA/6ibqecj7W0mD3UZoDvTpR7qIUCdZQPOgs+nmB0o
K5d29X2YYYCKjMb/IMhMQzRgGiJcVhuY4+jb0XHo0iTzCsr/e4jn0kImHFXUnOe547aiUttT
2mXqzUSgwvnjbkSEekonSZeGTiT7ahl0+SOmToB0agdwz76Lhn6f8fhsQNNdJtqtX0a9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nYJehkbFz5mLzgtWrG7fw97A+MpwS5GTg4JAROJQwe2MHYxcnEICSxllFi/fj8rREJC4vbC
JkYIW1jiz7UuNoii54wS9w7uB3I4ONgEtCQaO9lB4iICTxgl7v98zALiMAs0sEjcmriLCaRb
WCBMYtGrScwgNouAqkTPr+tgG3gFrCTmLZsLtU1eYual7+wgQzkFrCUmfIoACQsBlXQvugVV
LihxcuYTFhCbGai8eets5gmMArOQpGYhSS1gZFrFKJJaWpybnltspFecmFtcmpeul5yfu4kR
mFK2Hfu5ZQfjylcf9Q4xMnEwHmKU4GBWEuH9sjsjSYg3JbGyKrUoP76oNCe1+BCjKdDZE5ml
RJPzgUktryTe0MzA1NDEzNLA1NLMWEmc17OgI1FIID2xJDU7NbUgtQimj4mDU6qBKU0o8r2c
c0vGDb+Q+80WSYcz9VMqFQJXmlr3rDjkvSuF6+j/Llk+9atRm7jPldSJbjlj8zXssc7Li6rc
zI9Zfz2vemEqe/lL4M4V8y7O3sGeVlD3c1/SyWMh+6fv2iavcjNQTPpmROjh7Nq1T65JWh64
qcdQ77JNV/DM6hn3pzQs0lDmEHL2vX3280kOownb3x/vnDRjVva6xaqyTzdHfqy/s+6Ktk9T
pO/R7x3+PVfOqG2Z+jdbbTLnprD3AQ1q7wXMvc9POl6rMJFZ+XCW2ffljOKruvI1Us5+Zn63
zvts5/bb59ledTZtEoxalqum/V0s+hVb8CG2swu3K/ZoXVwlVmcjEfzgz4t/O1c+P6zEUpyR
aKjFXFScCAAgq28nsgMAAA==
X-CMS-MailID: 20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a
X-Msg-Generator: CA
X-RootMTR: 20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160300eucas1p1470fe30535849de6204bb78d7083cb3a
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Convert the calculations on zone size to be generic instead of relying on
power_of_2 based logic in the block layer using the helpers wherever
possible.
The only hot path affected by this change for power_of_2 zoned devices
is in blk_check_zone_append() but the effects should be negligible as the
helper blk_queue_zone_aligned() optimizes the calculation for those
devices. Note that the append path cannot be accessed by direct raw access
to the block device but only through a filesystem abstraction.
Finally, remove the check for power_of_2 zone size requirement in
blk-zoned.c
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
block/blk-core.c | 3 +--
block/blk-zoned.c | 12 ++++++------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 937bb6b86331..850caf311064 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -634,8 +634,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 (pos & (blk_queue_zone_sectors(q) - 1) ||
- !blk_queue_zone_is_seq(q, pos))
+ if (!blk_queue_zone_aligned(q, pos) || !blk_queue_zone_is_seq(q, pos))
return BLK_STS_IOERR;
/*
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 1dff4a8bd51d..f7c7c3bd148d 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -288,10 +288,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
return -EINVAL;
/* Check alignment (handle eventual smaller last zone) */
- if (sector & (zone_sectors - 1))
+ if (!blk_queue_zone_aligned(q, sector))
return -EINVAL;
- if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
+ if (!blk_queue_zone_aligned(q, nr_sectors) && end_sector != capacity)
return -EINVAL;
/*
@@ -489,14 +489,14 @@ 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 zoned device size",
+ disk->disk_name);
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",
From patchwork Wed Apr 27 16:02: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: 12829061
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 6C9C6C433FE
for ; Wed, 27 Apr 2022 16:04:14 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241627AbiD0QHX (ORCPT );
Wed, 27 Apr 2022 12:07:23 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49356 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241649AbiD0QGy (ORCPT
);
Wed, 27 Apr 2022 12:06:54 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 195373CD5BB
for ;
Wed, 27 Apr 2022 09:03:06 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160304euoutp015bee1ad7fb664b2394bebe49b2886c1b~pzFBpinTe0745607456euoutp01X
for ;
Wed, 27 Apr 2022 16:03:04 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160304euoutp015bee1ad7fb664b2394bebe49b2886c1b~pzFBpinTe0745607456euoutp01X
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075384;
bh=K2H4xPkIz91YDFdyCv2zwfrxVTdulhy1N1SKCVAIbPs=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=Sp9VM4Td3vG0k/ykXWvXxR97Y5i8f0rspVz80mZPqaOhHumhgp4oLd1W8BLafa8E2
3RbXSp50mXqyaR3MMrmEGSO7olnmxv+LbJjrs7YBgPFTVwViPj6MLFBnkolTteuyzm
0rqWeHE7dXk8asdvUZUddbVpo2lcA9uM/SY+7G6c=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160302eucas1p21c415084c0ee2461ca1f2112d95ba2cb~pzFAAgkwA2336123361eucas1p2m;
Wed, 27 Apr 2022 16:03:02 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 27.0A.10260.63969626;
Wed, 27
Apr 2022 17:03:02 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224~pzE-LcsQc0330603306eucas1p1R;
Wed, 27 Apr 2022 16:03:01 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220427160301eusmtrp22fb9b18976fb07e36270ff54bf0dfad9~pzE-HzO9m2598325983eusmtrp2i;
Wed, 27 Apr 2022 16:03:01 +0000 (GMT)
X-AuditID: cbfec7f5-bf3ff70000002814-87-62696936abd5
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id D1.81.09522.53969626;
Wed, 27
Apr 2022 17:03:01 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160301eusmtip23507d9cdffdd2cc397776ec30d69ca54~pzE_2Psd42569125691eusmtip2H;
Wed, 27 Apr 2022 16:03:01 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 05/16] nvme: zns: Allow ZNS drives that have non-power_of_2
zone size
Date: Wed, 27 Apr 2022 18:02:44 +0200
Message-Id: <20220427160255.300418-6-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02SfUxTVxjGd+69vS11xWvBcCKbG+DG0AgjM/MElM2FjJssUWKmQ7PICl6h
WaGshYEQGUhh2AmULoBUFosKdshWbMGs0C6ujs9SISACOkQ+GrHGIgJRwiijXsz87znv+T3P
c97k8HBhI7mFJ05NZ2SpIkkgySeudyzd2vmxWJzwYUu1D9L3dODo6lgZiSqfLuHIVmHHkLrs
HBct2/twZHGd56D+F/kYGr1hwtCvV9sxNK3X4OjsjacEWlHeX5spJnD070Q4UlvvAOQY0mDI
cncHGpjScdHAxRhktnQTaLC1hkQX6h1cpCpaxNGIygFQeaeRg+brFFz0++NZAnXd9f/0bXrw
9he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V9d33Qlep3re7dYXPJMq9Mf62H/s1NZ+TFunCbAlKLMUZiYZa
zEXFiQBD5j4jsgMAAA==
X-CMS-MailID: 20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224
X-Msg-Generator: CA
X-RootMTR: 20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160301eucas1p147d0dced70946e20dd2dd046b94b8224
References: <20220427160255.300418-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.
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
drivers/nvme/host/zns.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 9f81beb4df4e..2087de0768ee 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));
+ div64_u64(get_capacity(ns->disk), ns->zsze));
bufsize = sizeof(struct nvme_zone_report) +
nr_zones * sizeof(struct nvme_zone_descriptor);
@@ -197,7 +190,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, ns->zsze);
while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) {
memset(report, 0, buflen);
From patchwork Wed Apr 27 16:02: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: 12829058
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 422B8C433F5
for ; Wed, 27 Apr 2022 16:03:53 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241736AbiD0QHB (ORCPT );
Wed, 27 Apr 2022 12:07:01 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49232 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241545AbiD0QGx (ORCPT
);
Wed, 27 Apr 2022 12:06:53 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F8D63CDE0D
for ;
Wed, 27 Apr 2022 09:03:06 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160304euoutp0190bda6f586456eff1f2add3faf7250b6~pzFCcI4ka0318203182euoutp01T
for ;
Wed, 27 Apr 2022 16:03:04 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160304euoutp0190bda6f586456eff1f2add3faf7250b6~pzFCcI4ka0318203182euoutp01T
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075385;
bh=O6Jd6Tzouqxtj71a1kvN5ymqEncAInPsXdGxEKyRKOk=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=okYuDVNPLpKu25k82IIBR2oTDHR0888dZWh3c1jeYaTMFBDt2IO8QEVtCx3v2lDmK
yfWMlDv9zYdpwoY4LLo0nkP7WjHCXvfZT3lcxai6MXVc7sk905ppJb+LUB/Tu73gZC
bYIDJfbqunpzA60pr9KdNMuH19jY4npb3f1CnbpU=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160303eucas1p22d7897065d614fc598a2b9280bec4adb~pzFA9zWA62335623356eucas1p2b;
Wed, 27 Apr 2022 16:03:03 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id BE.04.09887.73969626;
Wed, 27
Apr 2022 17:03:03 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160302eucas1p1aaba7a309778d3440c3315ad899e4035~pzFAbPWo12290322903eucas1p1u;
Wed, 27 Apr 2022 16:03:02 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160302eusmtrp1f372a17275b8fcf9c53a511412b0283f~pzFAYod592077420774eusmtrp1N;
Wed, 27 Apr 2022 16:03:02 +0000 (GMT)
X-AuditID: cbfec7f4-45bff7000000269f-52-62696937cddc
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id FF.97.09404.63969626;
Wed, 27
Apr 2022 17:03:02 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160302eusmtip1f317e24df26397b4f560f917fa75f11b~pzE-yyoKH1317113171eusmtip1K;
Wed, 27 Apr 2022 16:03:02 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 06/16] nvmet: use blk_queue_zone_no()
Date: Wed, 27 Apr 2022 18:02:45 +0200
Message-Id: <20220427160255.300418-7-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02SfUxTZxTG8957e++lse5aNL4ggqCOAYEicdkrELdlEu9gcctwUfZpwRs+
VkBbO9Ftsa7gpGNQMEwoLIJRUWBrKYxYGIThBsi3LSiosCDgBoSP8RGtBbaWWzP/e857fs95
zkleGhfrSXc6MeUEJ0+RynxIIVHbYu0OfC0xMTa41/oS0re34KhiKIdEP8xZcdSR34WhvJwC
Ctm6enDUMFMkQL1Pz2JosMmEoRsVf2BoTK/DUVbTHIFWNMP2t/QRHC2P7EJ5zXcBGu/XYajh
fgAyj16nkPnyfvRrw20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B4cyy/WGy+hKfllx5NT0on0FWjFX+V6+Ewl+jI7NqjavYJ3VNXJyUadFqZqDs
sXPKBsmt988Ur1ip9Fdo9RU7+16Gi61C0wrvBv5anWXTt9+17ZyIitD6L0zvSpVYijMSDbWY
i4oTAU7HChCxAwAA
X-CMS-MailID: 20220427160302eucas1p1aaba7a309778d3440c3315ad899e4035
X-Msg-Generator: CA
X-RootMTR: 20220427160302eucas1p1aaba7a309778d3440c3315ad899e4035
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160302eucas1p1aaba7a309778d3440c3315ad899e4035
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
From: Luis Chamberlain
Instead of open coding the number of zones given a sector, use the helper
blk_queue_zone_no(). This let's us make modifications to the math if
needed in one place and adds now support for npo2 zone devices.
Signed-off-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
Reviewed-by: Bart Van Assche
Reviewed-by: Hannes Reinecke
---
drivers/nvme/target/zns.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index e34718b09550..e41b6a6ef048 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -243,7 +243,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req)
unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba);
return blkdev_nr_zones(req->ns->bdev->bd_disk) -
- (sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
+ bdev_zone_no(req->ns->bdev, sect);
}
static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize)
From patchwork Wed Apr 27 16:02: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: 12829070
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 40CA1C433F5
for ; Wed, 27 Apr 2022 16:04:48 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241677AbiD0QH4 (ORCPT );
Wed, 27 Apr 2022 12:07:56 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49096 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241533AbiD0QGz (ORCPT
);
Wed, 27 Apr 2022 12:06:55 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA05A3D1267
for ;
Wed, 27 Apr 2022 09:03:13 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160306euoutp020f6f236b0f3e00a35c55a3f28d16ccdd~pzFDcJW4N1442014420euoutp02o
for ;
Wed, 27 Apr 2022 16:03:06 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220427160306euoutp020f6f236b0f3e00a35c55a3f28d16ccdd~pzFDcJW4N1442014420euoutp02o
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075386;
bh=QWDCdGpeRI5X2tzwrJf3syqVSb5HHkyW+8hRafR+UIA=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=bPfWJzsBS6dlxu5+0QG6kEPvIkakPBIJcV0eK7Dt7oryxSX+rkbg+BLhaDe5I+EnY
kTRFGlDb1aQFefVPO/k4npsq0Z/Wuwx/7ApWyR5I54THKstGf6iaW7qUlcLtKsZPlx
QYDssMhTFROO7osDbmOUA8u4rJS4rLUsnoqlUrHI=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160304eucas1p2132f5d8996bb4be8c720545503199880~pzFBzwJqs2337723377eucas1p2a;
Wed, 27 Apr 2022 16:03:04 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 90.14.09887.83969626;
Wed, 27
Apr 2022 17:03:04 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e~pzFBSE8tz0330203302eucas1p1Q;
Wed, 27 Apr 2022 16:03:03 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220427160303eusmtrp242409ff9824954bbde9684e0ce2d4e12~pzFBRNRlD2598325983eusmtrp2l;
Wed, 27 Apr 2022 16:03:03 +0000 (GMT)
X-AuditID: cbfec7f4-471ff7000000269f-55-62696938c9ff
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 74.81.09522.73969626;
Wed, 27
Apr 2022 17:03:03 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160303eusmtip204431c6f8fcfa88dcd1d0a173a580914~pzFA_seRx2538025380eusmtip2M;
Wed, 27 Apr 2022 16:03:03 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 07/16] btrfs: zoned: Cache superblock location in
btrfs_zoned_device_info
Date: Wed, 27 Apr 2022 18:02:46 +0200
Message-Id: <20220427160255.300418-8-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02SfUxbVRjGc+65vS1EyKVUOYxNZ6NOZujEoDk6JSxMvdEEv5Y5HX4UdqUN
tGBLZWNL5NuBEwoKa8ukbHED2Ur5GrR06KwyYMDWUHAFEYdShOooCA6xgtJdFvff733f53mf
8yZHAIVmapNArsxkVUppmpgKJNsvrVyJwnJ50qO6c3dh8+VLEJ/9sYzCVfMrEPdXDhK4okzH
x77BqxB3zVXzsOOvXAKPXrQS+Muz3QSeMhsgPnZxnsSrJRPrvYJJiP+ZjMYV9u8Bdo8YCNw1
9gge+qWej4dOPY8vdPWR2Nl5gsLGM24+1hb9CbFL6wa4vKeVhxdPF/Bx429eEveORcRtYZzD
LzJrvecopjx/js9cnWgmGeeghmlpKKaYkzmVkGn94kPGVrtIMLbRHIr5JH+OYqyFP/EY71cj
FFPa1gAYc9sIyWhbm3kvC98MfPoAmyb/gFXtiH03UNb5rQ5mDIQdNOm/JnOAObQEBAgQHYMs
Cw5eCQgUCOl6gJqMrYR/IKSXALrRLOEGiwDNnO/l3XZ4b9ZuOOoA+qHQQXHFLEBzM3p+CRAI
KHo7yi3m+/si2gVQeVMT4S8g7YHI0XbtVkYovR9NdPdTfibpB5F++XPo5yD6KTRW5duIuw/p
h5ZvLQ2gdyLtH/s4SQj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RhhZGeoaWFnpGJpZ6hsbmsVZGpkr6djYpqTmZZalF
+nYJehm7Ds9gLjgjXrF25n6WBsb1wl2MnBwSAiYS778tYO1i5OIQEljKKLGg5QEzREJC4vbC
JkYIW1jiz7UuNhBbSOA5o8Tpc1xdjBwcbAJaEo2d7CC9IgJPGCXu/3zMAuIwCzSwSNyauIsJ
pEFYIFKi++dWdhCbRUBVYub3uWALeAWsJG5N+80KsUBeYual7+wgQzkFrCUmfIqA2GUl0b3o
FitEuaDEyZlPWEBsZqDy5q2zmScwCsxCkpqFJLWAkWkVo0hqaXFuem6xoV5xYm5xaV66XnJ+
7iZGYELZduzn5h2M81591DvEyMTBeIhRgoNZSYT3y+6MJCHelMTKqtSi/Pii0pzU4kOMpkBn
T2SWEk3OB6a0vJJ4QzMDU0MTM0sDU0szYyVxXs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGJs6X
V9cdyO1yCFG+ufLA+h/ijtW79e3tag/yHDpgLaCcMU9d69uH/PudEdIv469UB/ed6N1bdeIm
c+6MBbWvNWqtusRMGFQ25H+/n3tG2Lhto+SU3bP3e72SfiHhvfDc27TJhrVfZjVKLczw++LA
WSG1NfPitQXOu/v5q6Z3dvuHeh5569pebMrAX3qbWcuprrVqef4PS3/T/r9ZjT8jpWcuYVo+
y/b07V/Pfk+IFTtwv69g9z6r3tepy0+U6dhX/lreVzvB1e6Vz9KJLKKzqq5POs121tKvrPyF
dMXtBz8fXYuas0ZMX3Vi8MXr0z+m8NjfCDo752qoienP+wyPOk1urNkzu3nzqUUf9i21MlBi
Kc5INNRiLipOBABGrugrsQMAAA==
X-CMS-MailID: 20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e
X-Msg-Generator: CA
X-RootMTR: 20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Instead of calculating the superblock location every time, cache the
superblock zone location in btrfs_zoned_device_info struct and use it to
locate the zone index.
The functions such as btrfs_sb_log_location_bdev() and
btrfs_reset_sb_log_zones() which work directly on block_device shall
continue to use the sb_zone_number because btrfs_zoned_device_info
struct might not have been initialized at that point.
This patch will enable non power-of-2 zoned devices to not perform
division to lookup superblock and its mirror location.
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/btrfs/zoned.c | 13 +++++++++----
fs/btrfs/zoned.h | 1 +
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 1b1b310c3c51..6f76942d0ea5 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -512,6 +512,11 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
max_active_zones - nactive);
}
+ /* Cache the sb zone number */
+ for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; ++i) {
+ zone_info->sb_zone_location[i] =
+ sb_zone_number(zone_info->zone_size_shift, i);
+ }
/* Validate superblock log */
nr_zones = BTRFS_NR_SB_LOG_ZONES;
for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
@@ -519,7 +524,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
u64 sb_wp;
int sb_pos = BTRFS_NR_SB_LOG_ZONES * i;
- sb_zone = sb_zone_number(zone_info->zone_size_shift, i);
+ sb_zone = zone_info->sb_zone_location[i];
if (sb_zone + 1 >= zone_info->nr_zones)
continue;
@@ -867,7 +872,7 @@ int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,
return 0;
}
- zone_num = sb_zone_number(zinfo->zone_size_shift, mirror);
+ zone_num = zinfo->sb_zone_location[mirror];
if (zone_num + 1 >= zinfo->nr_zones)
return -ENOENT;
@@ -884,7 +889,7 @@ static inline bool is_sb_log_zone(struct btrfs_zoned_device_info *zinfo,
if (!zinfo)
return false;
- zone_num = sb_zone_number(zinfo->zone_size_shift, mirror);
+ zone_num = zinfo->sb_zone_location[mirror];
if (zone_num + 1 >= zinfo->nr_zones)
return false;
@@ -1012,7 +1017,7 @@ u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start,
u32 sb_zone;
u64 sb_pos;
- sb_zone = sb_zone_number(shift, i);
+ sb_zone = zinfo->sb_zone_location[i];
if (!(end <= sb_zone ||
sb_zone + BTRFS_NR_SB_LOG_ZONES <= begin)) {
have_sb = true;
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index cbf016a7bb5d..49317524e9a6 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h
@@ -31,6 +31,7 @@ struct btrfs_zoned_device_info {
unsigned long *active_zones;
struct blk_zone *zone_cache;
struct blk_zone sb_zones[2 * BTRFS_SUPER_MIRROR_MAX];
+ u32 sb_zone_location[BTRFS_SUPER_MIRROR_MAX];
};
#ifdef CONFIG_BLK_DEV_ZONED
From patchwork Wed Apr 27 16:02: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: 12829063
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 0D153C4321E
for ; Wed, 27 Apr 2022 16:04:28 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241710AbiD0QHh (ORCPT );
Wed, 27 Apr 2022 12:07:37 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49002 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241691AbiD0QG4 (ORCPT
);
Wed, 27 Apr 2022 12:06:56 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4583D1BF4
for ;
Wed, 27 Apr 2022 09:03:14 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160306euoutp0265d02cdcaa48af3849e3abe896320e42~pzFEK95Nl1441914419euoutp023
for ;
Wed, 27 Apr 2022 16:03:06 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220427160306euoutp0265d02cdcaa48af3849e3abe896320e42~pzFEK95Nl1441914419euoutp023
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075386;
bh=6yQzfClVhDZ6n4jKfgnEonLdHdedN/dO+ui2CUTxKaw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=cKE+vL/OPgHNA5HyEuoppvKdFOS+gwWs/XPu9wKdHeQVDpM9bVGUGuGH4Cz1Ot2nV
mwZW75NlBDHpbmp3EMaq6ci6eCl8znZzFGLCjeqC8bf+AzrosLVKEJGzyhJO56tHro
xWC6wXNFsIlB0LEPDkuJgM7n+T08AdvuEPooYFV8=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160305eucas1p23f1ca6b3cc5d07b7197b62455d839133~pzFCtQUuI1589415894eucas1p2K;
Wed, 27 Apr 2022 16:03:05 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 7B.D7.10009.93969626;
Wed, 27
Apr 2022 17:03:05 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160304eucas1p1a0080df82f76c39882c4298c3c3d99fd~pzFCRIwGd2685626856eucas1p1p;
Wed, 27 Apr 2022 16:03:04 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220427160304eusmtrp21dbea116401f4753609014b6527a5210~pzFCQGpO42598325983eusmtrp2o;
Wed, 27 Apr 2022 16:03:04 +0000 (GMT)
X-AuditID: cbfec7f2-e7fff70000002719-7f-626969390a70
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id C6.81.09522.83969626;
Wed, 27
Apr 2022 17:03:04 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160304eusmtip21ef5128fdd0e92e860a902eb43177b8d~pzFB5d6OL3126231262eusmtip26;
Wed, 27 Apr 2022 16:03:04 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 08/16] btrfs: zoned: add generic btrfs helpers for zoned
devices
Date: Wed, 27 Apr 2022 18:02:47 +0200
Message-Id: <20220427160255.300418-9-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 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fGmJFZWpRblxxeV5qQWH2I0Bbp6IrOU
aHI+MKXllcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJpCeWpGanphakFsH0MXFwSjUwbXh0sFYx
ffez0B6x6u98avHVshcbxYx9PuuKqC2oyAzgu+CwtoUpebr1lrPqWgqLljxszKicc6BGQ13I
6evUJ+ebNSwcVrf4uN4X2H9p0b79p9z1jxvH3u/mepvZFyL1epHRTbW0Za4/4t5/vhSaYfbe
Nv/OIaHcQy/5yxZ8X/bHpEG2/YBd47UCT6FTu35+ccguYrMy7AvSi0xYfvGwTtrMxss3rzr+
fb/IzDvo9PeqkBVWQo8tRKNua6l/rP7w3DF31qFTMVd5171Zv+Y374rm8BKVtJ2Xjq9u9Yj8
yrfkL4+Dq8uUw98/2STONzv8qsZ57wfTRxHFkjMF416p3f6VVTG7S19jdfC2JWpySizFGYmG
WsxFxYkABPmx3bEDAAA=
X-CMS-MailID: 20220427160304eucas1p1a0080df82f76c39882c4298c3c3d99fd
X-Msg-Generator: CA
X-RootMTR: 20220427160304eucas1p1a0080df82f76c39882c4298c3c3d99fd
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160304eucas1p1a0080df82f76c39882c4298c3c3d99fd
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Add helpers to calculate alignment, round up and round down
for zoned devices. These helpers encapsulates the necessary handling for
power_of_2 and non-power_of_2 zone sizes. Optimized calculations are
performed for zone sizes that are power_of_2 with log and shifts.
btrfs_zoned_is_aligned() is added instead of reusing bdev_zone_aligned()
helper is due to some use cases in btrfs where zone alignment is checked
before having access to the underlying block device such as in this
function: btrfs_load_block_group_zone_info().
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/btrfs/zoned.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index 49317524e9a6..b9c435961361 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h
@@ -9,6 +9,7 @@
#include "disk-io.h"
#include "block-group.h"
#include "btrfs_inode.h"
+#include "misc.h"
/*
* Block groups with more than this value (percents) of unusable space will be
@@ -34,6 +35,33 @@ struct btrfs_zoned_device_info {
u32 sb_zone_location[BTRFS_SUPER_MIRROR_MAX];
};
+static inline bool btrfs_zoned_is_aligned(u64 pos, u64 zone_size)
+{
+ u64 remainder = 0;
+
+ if (is_power_of_two_u64(zone_size))
+ return IS_ALIGNED(pos, zone_size);
+
+ div64_u64_rem(pos, zone_size, &remainder);
+ return remainder == 0;
+}
+
+static inline u64 btrfs_zoned_roundup(u64 pos, u64 zone_size)
+{
+ if (is_power_of_two_u64(zone_size))
+ return ALIGN(pos, zone_size);
+
+ return roundup(pos, zone_size);
+}
+
+static inline u64 btrfs_zoned_rounddown(u64 pos, u64 zone_size)
+{
+ if (is_power_of_two_u64(zone_size))
+ return round_down(pos, zone_size);
+
+ return rounddown(pos, zone_size);
+}
+
#ifdef CONFIG_BLK_DEV_ZONED
int btrfs_get_dev_zone(struct btrfs_device *device, u64 pos,
struct blk_zone *zone);
From patchwork Wed Apr 27 16:02: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: 12829060
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 85E21C433EF
for ; Wed, 27 Apr 2022 16:04:13 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241797AbiD0QHW (ORCPT );
Wed, 27 Apr 2022 12:07:22 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49276 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241627AbiD0QGy (ORCPT
);
Wed, 27 Apr 2022 12:06:54 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56D1B3CF554
for ;
Wed, 27 Apr 2022 09:03:09 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160308euoutp01036764fdd2cd782ec11cf8466abbe967~pzFFZgvG50745007450euoutp01g
for ;
Wed, 27 Apr 2022 16:03:08 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160308euoutp01036764fdd2cd782ec11cf8466abbe967~pzFFZgvG50745007450euoutp01g
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075388;
bh=ffM16ryPWJ6fYXTfy7LXC81hPnUdkDXlmIiQv6XuFeE=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=czoz1DZUIJLQgdra6izfn4a61lOGG0j0S0wfOzB8x8exfU2X28fKGL4qHJ39d5VY+
WUWf6Ztcs04m1E8JqK34dwgeFD3FR5hg2Gn9H9P3VqQgSn+f+UY+tgMYC/+lovSBtC
XAT+CPidHuIqFVx2zfla6R15Zl23cUuwQEDlt4o8=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160306eucas1p2e570e1b4e34a5067bb507ed05d2d73a6~pzFDvZ7kA0627806278eucas1p29;
Wed, 27 Apr 2022 16:03:06 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 5A.0A.10260.A3969626;
Wed, 27
Apr 2022 17:03:06 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220427160305eucas1p26831c19df0b2097e42209edcf73526b7~pzFDM2UI22337723377eucas1p2c;
Wed, 27 Apr 2022 16:03:05 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160305eusmtrp1235314abc78e18282c5dc2e5777199f2~pzFDL4Ere2077420774eusmtrp1T;
Wed, 27 Apr 2022 16:03:05 +0000 (GMT)
X-AuditID: cbfec7f5-bddff70000002814-92-6269693aae9b
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 13.A7.09404.93969626;
Wed, 27
Apr 2022 17:03:05 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160305eusmtip22f05675131d051368efed5b5a469ebf6~pzFC4wzQ40262002620eusmtip2Q;
Wed, 27 Apr 2022 16:03:05 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 09/16] btrfs: zoned: Make sb_zone_number function non power
of 2 compatible
Date: Wed, 27 Apr 2022 18:02:48 +0200
Message-Id: <20220427160255.300418-10-p.raghav@samsung.com>
X-M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9IoTc4tL89L1kvNzNzEC
U8q2Yz+37GBc+eqj3iFGJg7GQ4wSHMxKIrxfdmckCfGmJFZWpRblxxeV5qQWH2I0BTp7IrOU
aHI+MKnllcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJpCeWpGanphakFsH0MXFwSjUwSeoz9Aau
c5v8yPPef/mGLUcSK5P+ZIqqOZWK3bvHsspW/llBw4I/NU99v5rwSnCbvDs9UV4ibv1S1RY+
0QuzAmcu+rxcbfJKpbAjr1dFPnF0/e/3KGt67q6Lh6ed1o7PbfBsu6UcGCr/57r8tDk9ftfU
05LtZqixcLE8ZeAx5p3ztszaP27ijf3Ce701NbNVH+WcnCBwumHJvebD5cd7Za+rRe94yyZ5
Jef8T+F0+2rR3Kkq/y6fPnlZe5OMUd6yB3t5up4mFNhO6l9Zp2K3iFmj+qXcFRVdZom5qrf0
FWX3MEgtv/4j1/cEv/n5Q6mMd8w7T7CyH+XpuzUpTcxTtWwlx8xUEZ6pk6r3rZyhxFKckWio
xVxUnAgAjuFRN7IDAAA=
X-CMS-MailID: 20220427160305eucas1p26831c19df0b2097e42209edcf73526b7
X-Msg-Generator: CA
X-RootMTR: 20220427160305eucas1p26831c19df0b2097e42209edcf73526b7
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160305eucas1p26831c19df0b2097e42209edcf73526b7
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Make the calculation in sb_zone_number function to be generic and work
for both power-of-2 and non power-of-2 zone sizes.
The function signature has been modified to take block device and mirror
as input as this function is only invoked from callers that have access
to the block device. This enables to use the generic bdev_zone_no
function provided by the block layer to calculate the zone number.
Even though division is used to calculate the zone index for non
power-of-2 zone sizes, this function will not be used in the fast path as
the sb_zone_location cache is used for the superblock zone location.
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/btrfs/zoned.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 6f76942d0ea5..8f574a474420 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -34,9 +34,6 @@
#define BTRFS_SB_LOG_FIRST_OFFSET (512ULL * SZ_1G)
#define BTRFS_SB_LOG_SECOND_OFFSET (4096ULL * SZ_1G)
-#define BTRFS_SB_LOG_FIRST_SHIFT const_ilog2(BTRFS_SB_LOG_FIRST_OFFSET)
-#define BTRFS_SB_LOG_SECOND_SHIFT const_ilog2(BTRFS_SB_LOG_SECOND_OFFSET)
-
/* Number of superblock log zones */
#define BTRFS_NR_SB_LOG_ZONES 2
@@ -153,15 +150,23 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
/*
* Get the first zone number of the superblock mirror
*/
-static inline u32 sb_zone_number(int shift, int mirror)
+static inline u32 sb_zone_number(struct block_device *bdev, int mirror)
{
u64 zone;
ASSERT(mirror < BTRFS_SUPER_MIRROR_MAX);
switch (mirror) {
- case 0: zone = 0; break;
- case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break;
- case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break;
+ case 0:
+ zone = 0;
+ break;
+ case 1:
+ zone = bdev_zone_no(bdev,
+ BTRFS_SB_LOG_FIRST_OFFSET >> SECTOR_SHIFT);
+ break;
+ case 2:
+ zone = bdev_zone_no(bdev,
+ BTRFS_SB_LOG_SECOND_OFFSET >> SECTOR_SHIFT);
+ break;
}
ASSERT(zone <= U32_MAX);
@@ -515,7 +520,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
/* Cache the sb zone number */
for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; ++i) {
zone_info->sb_zone_location[i] =
- sb_zone_number(zone_info->zone_size_shift, i);
+ sb_zone_number(bdev, i);
}
/* Validate superblock log */
nr_zones = BTRFS_NR_SB_LOG_ZONES;
@@ -840,7 +845,7 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,
nr_sectors = bdev_nr_sectors(bdev);
nr_zones = nr_sectors >> zone_sectors_shift;
- sb_zone = sb_zone_number(zone_sectors_shift + SECTOR_SHIFT, mirror);
+ sb_zone = sb_zone_number(bdev, mirror);
if (sb_zone + 1 >= nr_zones)
return -ENOENT;
@@ -964,7 +969,7 @@ int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror)
nr_sectors = bdev_nr_sectors(bdev);
nr_zones = nr_sectors >> zone_sectors_shift;
- sb_zone = sb_zone_number(zone_sectors_shift + SECTOR_SHIFT, mirror);
+ sb_zone = sb_zone_number(bdev, mirror);
if (sb_zone + 1 >= nr_zones)
return -ENOENT;
From patchwork Wed Apr 27 16:02: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: 12829064
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 35DF0C433FE
for ; Wed, 27 Apr 2022 16:04:27 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241690AbiD0QHf (ORCPT );
Wed, 27 Apr 2022 12:07:35 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49538 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241710AbiD0QG4 (ORCPT
);
Wed, 27 Apr 2022 12:06:56 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 126A63D2808
for ;
Wed, 27 Apr 2022 09:03:14 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160309euoutp02b386d1b64d9566f976c0a0b51fcb1ee0~pzFGSOmEz1479314793euoutp02t
for ;
Wed, 27 Apr 2022 16:03:09 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220427160309euoutp02b386d1b64d9566f976c0a0b51fcb1ee0~pzFGSOmEz1479314793euoutp02t
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075389;
bh=6KheWDMJayGgUZm5cX5ypXhrxLVS/z/lNlxWvV+S3gU=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=oKOOQqTnkgA+xeL9Ueo04TncfX7Jj0pgrtxJ+dsDvidU5zp4F1u/lfQok9JQZ4C0y
F3vWHpa9oZGTkPzDl6FVIFs/Sg3By261hHNiSR/LR+HrH/0/EwNPPNC2hfsAIab3FK
7RD4s6RpeXAoeTV1XdTvWOWV7lMsFZVdKsnrb+Dk=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160307eucas1p20ea3feb33adf91cfc3dd4f8fbf324a82~pzFE2r7sG0614706147eucas1p2s;
Wed, 27 Apr 2022 16:03:07 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id FD.D7.10009.B3969626;
Wed, 27
Apr 2022 17:03:07 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160306eucas1p10514a8597007ed9d5e269d659df58d35~pzFENQHEv2685626856eucas1p1q;
Wed, 27 Apr 2022 16:03:06 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160306eusmtrp1bd41f0ccc94ff2757a2c5d1040c9a38c~pzFEMD4Fz2142221422eusmtrp1C;
Wed, 27 Apr 2022 16:03:06 +0000 (GMT)
X-AuditID: cbfec7f2-e7fff70000002719-85-6269693b25f4
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id C8.81.09522.A3969626;
Wed, 27
Apr 2022 17:03:06 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160306eusmtip12de3b05594fbd8d62abc7abc3a75390e~pzFDyTcRQ0836008360eusmtip1j;
Wed, 27 Apr 2022 16:03:06 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 10/16] btrfs: zoned: use btrfs zone helpers to support non
po2 zoned devices
Date: Wed, 27 Apr 2022 18:02:49 +0200
Message-Id: <20220427160255.300418-11-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02SfUxTVxjGc+69vb10KVwKCQctYXRbomyDdZvzZGzKFpbdDYwz6TZjtknF
y8eEIq0w2TIpUMns+GhBNykyO4QNaUORVl35smIQELvWFhwQkaH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2Q/PlHkM82U9Dt5YKrCg6/ZvF7vLswzF7uy6Vvq/rHGh5kbmZYpvvvtb
9CvontrGnCUhc+Ny5OtZbfNVW4rKODsnij2SN3fbU/Ev1/3+9L+iPRMerVhz8vYrpuvxSm6r
Jru8eHTXiyl8xeeW46vKqi358haJ2gaW7/k4x0pDJXx2tmDaK/Xrs+XSJCMCdmkv69lScfoX
f9arWge1vd7fKvY9PpL/ScPG+9Jie5YNB49eVmaytz0eJvr50J/T0ntlOf5OOPPhBcNS85yd
W0LjitZeXH92pt88D9NF3dEPmrlPNTktuxZa4tdXJvnMkVVkbtyllCtH/aW5pU8xfO5WYinO
SDTUYi4qTgQAfrbHbrADAAA=
X-CMS-MailID: 20220427160306eucas1p10514a8597007ed9d5e269d659df58d35
X-Msg-Generator: CA
X-RootMTR: 20220427160306eucas1p10514a8597007ed9d5e269d659df58d35
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160306eucas1p10514a8597007ed9d5e269d659df58d35
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Use the generic btrfs zone helpers to calculate zone index, check zone
alignment, round up and round down operations.
The zone_size_shift field is not needed anymore as generic helpers are
used for calculation.
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/btrfs/volumes.c | 24 +++++++++-------
fs/btrfs/zoned.c | 72 ++++++++++++++++++++++------------------------
fs/btrfs/zoned.h | 12 ++++----
3 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index a8cc736731fd..0c6d1600d8b3 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1421,7 +1421,7 @@ static u64 dev_extent_search_start(struct btrfs_device *device, u64 start)
* allocator, because we anyway use/reserve the first two zones
* for superblock logging.
*/
- return ALIGN(start, device->zone_info->zone_size);
+ return btrfs_zoned_roundup(start, device->zone_info->zone_size);
default:
BUG();
}
@@ -1436,7 +1436,7 @@ static bool dev_extent_hole_check_zoned(struct btrfs_device *device,
int ret;
bool changed = false;
- ASSERT(IS_ALIGNED(*hole_start, zone_size));
+ ASSERT(btrfs_zoned_is_aligned(*hole_start, zone_size));
while (*hole_size > 0) {
pos = btrfs_find_allocatable_zones(device, *hole_start,
@@ -1573,7 +1573,7 @@ static int find_free_dev_extent_start(struct btrfs_device *device,
search_start = dev_extent_search_start(device, search_start);
WARN_ON(device->zone_info &&
- !IS_ALIGNED(num_bytes, device->zone_info->zone_size));
+ !btrfs_zoned_is_aligned(num_bytes, device->zone_info->zone_size));
path = btrfs_alloc_path();
if (!path)
@@ -5131,8 +5131,8 @@ static void init_alloc_chunk_ctl_policy_zoned(
ctl->max_stripe_size = zone_size;
if (type & BTRFS_BLOCK_GROUP_DATA) {
- ctl->max_chunk_size = round_down(BTRFS_MAX_DATA_CHUNK_SIZE,
- zone_size);
+ ctl->max_chunk_size = btrfs_zoned_rounddown(
+ BTRFS_MAX_DATA_CHUNK_SIZE, zone_size);
} else if (type & BTRFS_BLOCK_GROUP_METADATA) {
ctl->max_chunk_size = ctl->max_stripe_size;
} else if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
@@ -5144,9 +5144,10 @@ static void init_alloc_chunk_ctl_policy_zoned(
}
/* We don't want a chunk larger than 10% of writable space */
- limit = max(round_down(div_factor(fs_devices->total_rw_bytes, 1),
- zone_size),
- min_chunk_size);
+ limit = max(
+ btrfs_zoned_rounddown(div_factor(fs_devices->total_rw_bytes, 1),
+ zone_size),
+ min_chunk_size);
ctl->max_chunk_size = min(limit, ctl->max_chunk_size);
ctl->dev_extent_min = zone_size * ctl->dev_stripes;
}
@@ -6725,7 +6726,8 @@ static void submit_stripe_bio(struct btrfs_io_context *bioc, struct bio *bio,
*/
if (bio_op(bio) == REQ_OP_ZONE_APPEND) {
if (btrfs_dev_is_sequential(dev, physical)) {
- u64 zone_start = round_down(physical, fs_info->zone_size);
+ u64 zone_start = btrfs_zoned_rounddown(physical,
+ fs_info->zone_size);
bio->bi_iter.bi_sector = zone_start >> SECTOR_SHIFT;
} else {
@@ -8119,8 +8121,8 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
if (dev->zone_info) {
u64 zone_size = dev->zone_info->zone_size;
- if (!IS_ALIGNED(physical_offset, zone_size) ||
- !IS_ALIGNED(physical_len, zone_size)) {
+ if (!btrfs_zoned_is_aligned(physical_offset, zone_size) ||
+ !btrfs_zoned_is_aligned(physical_len, zone_size)) {
btrfs_err(fs_info,
"zoned: dev extent devid %llu physical offset %llu len %llu is not aligned to device zone",
devid, physical_offset, physical_len);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 8f574a474420..8f3f542e174c 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -177,13 +177,13 @@ static inline u32 sb_zone_number(struct block_device *bdev, int mirror)
static inline sector_t zone_start_sector(u32 zone_number,
struct block_device *bdev)
{
- return (sector_t)zone_number << ilog2(bdev_zone_sectors(bdev));
+ return zone_number * bdev_zone_sectors(bdev);
}
static inline u64 zone_start_physical(u32 zone_number,
struct btrfs_zoned_device_info *zone_info)
{
- return (u64)zone_number << zone_info->zone_size_shift;
+ return zone_number * zone_info->zone_size;
}
/*
@@ -236,8 +236,8 @@ static int btrfs_get_dev_zones(struct btrfs_device *device, u64 pos,
if (zinfo->zone_cache) {
unsigned int i;
- ASSERT(IS_ALIGNED(pos, zinfo->zone_size));
- zno = pos >> zinfo->zone_size_shift;
+ ASSERT(btrfs_zoned_is_aligned(pos, zinfo->zone_size));
+ zno = bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT);
/*
* We cannot report zones beyond the zone end. So, it is OK to
* cap *nr_zones to at the end.
@@ -410,9 +410,8 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
}
nr_sectors = bdev_nr_sectors(bdev);
- zone_info->zone_size_shift = ilog2(zone_info->zone_size);
- zone_info->nr_zones = nr_sectors >> ilog2(zone_sectors);
- if (!IS_ALIGNED(nr_sectors, zone_sectors))
+ zone_info->nr_zones = bdev_zone_no(bdev, nr_sectors);
+ if (!btrfs_zoned_is_aligned(nr_sectors, zone_sectors))
zone_info->nr_zones++;
max_active_zones = queue_max_active_zones(queue);
@@ -824,10 +823,8 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,
u64 *bytenr_ret)
{
struct blk_zone zones[BTRFS_NR_SB_LOG_ZONES];
- sector_t zone_sectors;
u32 sb_zone;
int ret;
- u8 zone_sectors_shift;
sector_t nr_sectors;
u32 nr_zones;
@@ -838,12 +835,10 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,
ASSERT(rw == READ || rw == WRITE);
- zone_sectors = bdev_zone_sectors(bdev);
- if (!is_power_of_2(zone_sectors))
+ if (!is_power_of_2(bdev_zone_sectors(bdev)))
return -EINVAL;
- zone_sectors_shift = ilog2(zone_sectors);
nr_sectors = bdev_nr_sectors(bdev);
- nr_zones = nr_sectors >> zone_sectors_shift;
+ nr_zones = bdev_zone_no(bdev, nr_sectors);
sb_zone = sb_zone_number(bdev, mirror);
if (sb_zone + 1 >= nr_zones)
@@ -960,14 +955,12 @@ int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror)
{
sector_t zone_sectors;
sector_t nr_sectors;
- u8 zone_sectors_shift;
u32 sb_zone;
u32 nr_zones;
zone_sectors = bdev_zone_sectors(bdev);
- zone_sectors_shift = ilog2(zone_sectors);
nr_sectors = bdev_nr_sectors(bdev);
- nr_zones = nr_sectors >> zone_sectors_shift;
+ nr_zones = bdev_zone_no(bdev, nr_sectors);
sb_zone = sb_zone_number(bdev, mirror);
if (sb_zone + 1 >= nr_zones)
@@ -993,18 +986,17 @@ u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start,
u64 hole_end, u64 num_bytes)
{
struct btrfs_zoned_device_info *zinfo = device->zone_info;
- const u8 shift = zinfo->zone_size_shift;
- u64 nzones = num_bytes >> shift;
+ u64 nzones = bdev_zone_no(device->bdev, num_bytes >> SECTOR_SHIFT);
u64 pos = hole_start;
u64 begin, end;
bool have_sb;
int i;
- ASSERT(IS_ALIGNED(hole_start, zinfo->zone_size));
- ASSERT(IS_ALIGNED(num_bytes, zinfo->zone_size));
+ ASSERT(btrfs_zoned_is_aligned(hole_start, zinfo->zone_size));
+ ASSERT(btrfs_zoned_is_aligned(num_bytes, zinfo->zone_size));
while (pos < hole_end) {
- begin = pos >> shift;
+ begin = bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT);
end = begin + nzones;
if (end > zinfo->nr_zones)
@@ -1036,8 +1028,9 @@ u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start,
if (!(pos + num_bytes <= sb_pos ||
sb_pos + BTRFS_SUPER_INFO_SIZE <= pos)) {
have_sb = true;
- pos = ALIGN(sb_pos + BTRFS_SUPER_INFO_SIZE,
- zinfo->zone_size);
+ pos = btrfs_zoned_roundup(
+ sb_pos + BTRFS_SUPER_INFO_SIZE,
+ zinfo->zone_size);
break;
}
}
@@ -1051,7 +1044,7 @@ u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start,
static bool btrfs_dev_set_active_zone(struct btrfs_device *device, u64 pos)
{
struct btrfs_zoned_device_info *zone_info = device->zone_info;
- unsigned int zno = (pos >> zone_info->zone_size_shift);
+ unsigned int zno = bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT);
/* We can use any number of zones */
if (zone_info->max_active_zones == 0)
@@ -1073,7 +1066,7 @@ static bool btrfs_dev_set_active_zone(struct btrfs_device *device, u64 pos)
static void btrfs_dev_clear_active_zone(struct btrfs_device *device, u64 pos)
{
struct btrfs_zoned_device_info *zone_info = device->zone_info;
- unsigned int zno = (pos >> zone_info->zone_size_shift);
+ unsigned int zno = bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT);
/* We can use any number of zones */
if (zone_info->max_active_zones == 0)
@@ -1109,14 +1102,14 @@ int btrfs_reset_device_zone(struct btrfs_device *device, u64 physical,
int btrfs_ensure_empty_zones(struct btrfs_device *device, u64 start, u64 size)
{
struct btrfs_zoned_device_info *zinfo = device->zone_info;
- const u8 shift = zinfo->zone_size_shift;
- unsigned long begin = start >> shift;
- unsigned long end = (start + size) >> shift;
+ unsigned long begin = bdev_zone_no(device->bdev, start >> SECTOR_SHIFT);
+ unsigned long end =
+ bdev_zone_no(device->bdev, (start + size) >> SECTOR_SHIFT);
u64 pos;
int ret;
- ASSERT(IS_ALIGNED(start, zinfo->zone_size));
- ASSERT(IS_ALIGNED(size, zinfo->zone_size));
+ ASSERT(btrfs_zoned_is_aligned(start, zinfo->zone_size));
+ ASSERT(btrfs_zoned_is_aligned(size, zinfo->zone_size));
if (end > zinfo->nr_zones)
return -ERANGE;
@@ -1140,8 +1133,9 @@ int btrfs_ensure_empty_zones(struct btrfs_device *device, u64 start, u64 size)
/* Free regions should be empty */
btrfs_warn_in_rcu(
device->fs_info,
- "zoned: resetting device %s (devid %llu) zone %llu for allocation",
- rcu_str_deref(device->name), device->devid, pos >> shift);
+ "zoned: resetting device %s (devid %llu) zone %u for allocation",
+ rcu_str_deref(device->name), device->devid,
+ bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT));
WARN_ON_ONCE(1);
ret = btrfs_reset_device_zone(device, pos, zinfo->zone_size,
@@ -1238,7 +1232,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
return 0;
/* Sanity check */
- if (!IS_ALIGNED(length, fs_info->zone_size)) {
+ if (!btrfs_zoned_is_aligned(length, fs_info->zone_size)) {
btrfs_err(fs_info,
"zoned: block group %llu len %llu unaligned to zone size %llu",
logical, length, fs_info->zone_size);
@@ -1326,7 +1320,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
* The group is mapped to a sequential zone. Get the zone write
* pointer to determine the allocation offset within the zone.
*/
- WARN_ON(!IS_ALIGNED(physical[i], fs_info->zone_size));
+ WARN_ON(!btrfs_zoned_is_aligned(physical[i], fs_info->zone_size));
nofs_flag = memalloc_nofs_save();
ret = btrfs_get_dev_zone(device, physical[i], &zone);
memalloc_nofs_restore(nofs_flag);
@@ -1352,10 +1346,12 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
switch (zone.cond) {
case BLK_ZONE_COND_OFFLINE:
case BLK_ZONE_COND_READONLY:
- btrfs_err(fs_info,
- "zoned: offline/readonly zone %llu on device %s (devid %llu)",
- physical[i] >> device->zone_info->zone_size_shift,
- rcu_str_deref(device->name), device->devid);
+ btrfs_err(
+ fs_info,
+ "zoned: offline/readonly zone %u on device %s (devid %llu)",
+ bdev_zone_no(device->bdev,
+ physical[i] >> SECTOR_SHIFT),
+ rcu_str_deref(device->name), device->devid);
alloc_offsets[i] = WP_MISSING_DEV;
break;
case BLK_ZONE_COND_EMPTY:
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index b9c435961361..c578bdb6bf2f 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h
@@ -23,7 +23,6 @@ struct btrfs_zoned_device_info {
* zoned block device.
*/
u64 zone_size;
- u8 zone_size_shift;
u32 nr_zones;
unsigned int max_active_zones;
atomic_t active_zones_left;
@@ -274,7 +273,8 @@ static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)
if (!zone_info)
return false;
- return test_bit(pos >> zone_info->zone_size_shift, zone_info->seq_zones);
+ return test_bit(bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT),
+ zone_info->seq_zones);
}
static inline bool btrfs_dev_is_empty_zone(struct btrfs_device *device, u64 pos)
@@ -284,7 +284,8 @@ static inline bool btrfs_dev_is_empty_zone(struct btrfs_device *device, u64 pos)
if (!zone_info)
return true;
- return test_bit(pos >> zone_info->zone_size_shift, zone_info->empty_zones);
+ return test_bit(bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT),
+ zone_info->empty_zones);
}
static inline void btrfs_dev_set_empty_zone_bit(struct btrfs_device *device,
@@ -296,7 +297,7 @@ static inline void btrfs_dev_set_empty_zone_bit(struct btrfs_device *device,
if (!zone_info)
return;
- zno = pos >> zone_info->zone_size_shift;
+ zno = bdev_zone_no(device->bdev, pos >> SECTOR_SHIFT);
if (set)
set_bit(zno, zone_info->empty_zones);
else
@@ -350,7 +351,8 @@ static inline bool btrfs_can_zone_reset(struct btrfs_device *device,
return false;
zone_size = device->zone_info->zone_size;
- if (!IS_ALIGNED(physical, zone_size) || !IS_ALIGNED(length, zone_size))
+ if (!btrfs_zoned_is_aligned(physical, zone_size) ||
+ !btrfs_zoned_is_aligned(length, zone_size))
return false;
return true;
From patchwork Wed Apr 27 16:02: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: 12829062
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 61430C433EF
for ; Wed, 27 Apr 2022 16:04:26 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241897AbiD0QHd (ORCPT );
Wed, 27 Apr 2022 12:07:33 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49232 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241690AbiD0QG4 (ORCPT
);
Wed, 27 Apr 2022 12:06:56 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8264A3D1255
for ;
Wed, 27 Apr 2022 09:03:13 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160310euoutp0113c30f3c95f49be1760df85d6732b48e~pzFHNA3Tx0745007450euoutp01k
for ;
Wed, 27 Apr 2022 16:03:10 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160310euoutp0113c30f3c95f49be1760df85d6732b48e~pzFHNA3Tx0745007450euoutp01k
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075390;
bh=Z59AramoBMIFuOXUYYH05DZBLjfbCNMGUst3i9j3Z7Q=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=W7RCwmZtNSpvqE8y4evit2Zuyld27ntnSWb6JvmMVBxMaxqsV2CNMLB1BGalJnTQP
YU0C/GItlU594cRcvi1Dbxne/WVtaDdWMEvWlL9JbbHa5tK/3iAwedjLyWAn8J47KM
uIoIWOO+pVS0kGYKL9LDlUfRYQeyBV2VT2nUvGbg=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160308eucas1p29e66b3685c84483f3fdd5a90299d93e1~pzFFvrXVn2333623336eucas1p2p;
Wed, 27 Apr 2022 16:03:08 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 8C.0A.10260.C3969626;
Wed, 27
Apr 2022 17:03:08 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220427160307eucas1p229f9ebae38fcca9974909799e5e63ccf~pzFFKDoBX2335623356eucas1p2h;
Wed, 27 Apr 2022 16:03:07 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160307eusmtrp194cac78e29ca037961137d3a49caf9ec~pzFFDipZN2142221422eusmtrp1D;
Wed, 27 Apr 2022 16:03:07 +0000 (GMT)
X-AuditID: cbfec7f5-bddff70000002814-96-6269693c7e10
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 85.A7.09404.B3969626;
Wed, 27
Apr 2022 17:03:07 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160307eusmtip1fe2208eed35a4c2cc164aecccf9c648a~pzFEt7JbD1109611096eusmtip1x;
Wed, 27 Apr 2022 16:03:07 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 11/16] btrfs: zoned: relax the alignment constraint for
zoned devices
Date: Wed, 27 Apr 2022 18:02:50 +0200
Message-Id: <20220427160255.300418-12-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA01Se0xTZxzNd+/t7S2z7lpd+CLdiFWmuPAQMPvG2MIWs924p7pMMNmwwOWR
8XAt4BAX64oOOnlVUB5uQh2TAqGUh1lBSIMCMoa6YkeBDOKEqSCt8kjpEFjLrZn/nXN+5/zO
70s+ChfpyM1UYkoaK0uRJklID+JKj+OmX1hiYnTgco8Y6X7rwVH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vy
mlri9jQ9lBUtLUw71Ht/Pu/8Sx8y+xa/z3qlkhm3PE9bSebp4+RTjpGcG7Rv817UnFhZHV72
4sg0++ZHk1j8eddUrNkx64SjxfM/27/d+Mxw52zurrkCx825z/sceibeyelzr+vJC48DMxy0
3zutXD6Fa2E1z7w1r6a1PD37+/TBpn/VXgebj/CvDIt2udqfe01MzXFXetXfVRx1z3r8lViK
MxINtZiLihMBMHgdG7EDAAA=
X-CMS-MailID: 20220427160307eucas1p229f9ebae38fcca9974909799e5e63ccf
X-Msg-Generator: CA
X-RootMTR: 20220427160307eucas1p229f9ebae38fcca9974909799e5e63ccf
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160307eucas1p229f9ebae38fcca9974909799e5e63ccf
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Checks were in place to return error when a non power-of-2 zoned devices
is detected. Remove those checks as non power-of-2 zoned devices are
now supported.
Relax the zone size constraint to align with the BTRFS_STRIPE_LEN(64k)
so that block groups are aligned to the BTRFS_STRIPE_LEN.
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/btrfs/zoned.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 8f3f542e174c..3ed085762f14 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -395,8 +395,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
zone_sectors = bdev_zone_sectors(bdev);
}
- /* Check if it's power of 2 (see is_power_of_2) */
- ASSERT(zone_sectors != 0 && (zone_sectors & (zone_sectors - 1)) == 0);
+ ASSERT(zone_sectors != 0 && IS_ALIGNED(zone_sectors, BTRFS_STRIPE_LEN));
zone_info->zone_size = zone_sectors << SECTOR_SHIFT;
/* We reject devices with a zone size larger than 8GB */
@@ -835,9 +834,11 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw,
ASSERT(rw == READ || rw == WRITE);
- if (!is_power_of_2(bdev_zone_sectors(bdev)))
- return -EINVAL;
nr_sectors = bdev_nr_sectors(bdev);
+
+ if (!IS_ALIGNED(nr_sectors, BTRFS_STRIPE_LEN))
+ return -EINVAL;
+
nr_zones = bdev_zone_no(bdev, nr_sectors);
sb_zone = sb_zone_number(bdev, mirror);
From patchwork Wed Apr 27 16:02: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: 12829068
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 238C5C433F5
for ; Wed, 27 Apr 2022 16:04:43 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241682AbiD0QHt (ORCPT );
Wed, 27 Apr 2022 12:07:49 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49194 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241576AbiD0QGz (ORCPT
);
Wed, 27 Apr 2022 12:06:55 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716E13D1245
for ;
Wed, 27 Apr 2022 09:03:13 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160311euoutp016772cd42e8364d15a2d42ff446bef604~pzFIKAD6q0745007450euoutp01m
for ;
Wed, 27 Apr 2022 16:03:11 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160311euoutp016772cd42e8364d15a2d42ff446bef604~pzFIKAD6q0745007450euoutp01m
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075391;
bh=OB9p6vdF6aM/UyeT3F5OA9umYZjZTrGgOlJ+GHn3kUA=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=kGdmxQVCPIEUcIy67ATpNKAJmKtjsChem/btPjcOfh2L+Z25V4jeg06ggTEEbXwpO
TJfyn1uc84TZecH5/VCcts+KMZLb3ffxFHUgbdekzZnPwWoyOLfelIgRJET/F69Jry
xH2vBbDHUypUhefqSgN5msgNSFj/UVxQYBBTh0Gc=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160309eucas1p25764fd1df9f26db4844fda3c1f148051~pzFGlnhYj1589415894eucas1p2P;
Wed, 27 Apr 2022 16:03:09 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id 8E.0A.10260.D3969626;
Wed, 27
Apr 2022 17:03:09 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220427160309eucas1p2f677c8db581616f994473f17c4a5bd44~pzFGL5Kmx2335223352eucas1p2d;
Wed, 27 Apr 2022 16:03:09 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160308eusmtrp18af0ed37110fa9c75771e3484c9f838a~pzFGJpnvr2142221422eusmtrp1F;
Wed, 27 Apr 2022 16:03:08 +0000 (GMT)
X-AuditID: cbfec7f5-bf3ff70000002814-99-6269693d1883
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 87.A7.09404.C3969626;
Wed, 27
Apr 2022 17:03:08 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160308eusmtip112cb60e69e75f4067509f9e1ad8af9ac~pzFFx3uD50884308843eusmtip1k;
Wed, 27 Apr 2022 16:03:08 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 12/16] zonefs: allow non power of 2 zoned devices
Date: Wed, 27 Apr 2022 18:02:51 +0200
Message-Id: <20220427160255.300418-13-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02SfUxTZxTGfe+93F5IipfCyjuqYVTRoBuMiMu7bDhxW7zBZX5szkX+0Fav
pcqHttRNtswiHQgoFJQyqk7ZwFUclkJlVD5knYKIIAIdBSbEjRphE0QgiJ2yllsz/3vOOb/n
fc5JXgoXVJBBlDwphVUkSRLEpA9R0zzb8Ua0XC5909AqRMabzTi6eDePRLpHszhqK2zHUEHe
dzzkbL+No4axU16o80kahvqaLBi6cPE6hoaNehwda3pEoGfZg66e5h6O/r0XiQqsvwPksOkx
1NC/EnX9ZeChrh/Wo/qGVgJ1XzlNorPnHTykzZjGkV3rACi/pdoLTZZ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kvZFWeco7WYXwiS9/SlxJ9E3dn5L9
o+3Vi6zk3RycSt/c5pt0b6ifMb2Mx2LmjCrdh44dsaVycybU+2RZLfO2EfZWYinOSDTUYi4q
TgQABxgFrq8DAAA=
X-CMS-MailID: 20220427160309eucas1p2f677c8db581616f994473f17c4a5bd44
X-Msg-Generator: CA
X-RootMTR: 20220427160309eucas1p2f677c8db581616f994473f17c4a5bd44
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160309eucas1p2f677c8db581616f994473f17c4a5bd44
References: <20220427160255.300418-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
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 3614c7834007..5422be2ca570 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -401,10 +401,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,
@@ -1300,7 +1299,7 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
struct zonefs_inode_info *zi = ZONEFS_I(inode);
- 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;
@@ -1647,7 +1646,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 7b147907c328..2d5ea3be3a8e 100644
--- a/fs/zonefs/zonefs.h
+++ b/fs/zonefs/zonefs.h
@@ -175,7 +175,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 Apr 27 16:02: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: 12829067
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 A1ED4C433EF
for ; Wed, 27 Apr 2022 16:04:38 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241558AbiD0QHp (ORCPT );
Wed, 27 Apr 2022 12:07:45 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52204 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241812AbiD0QH3 (ORCPT
);
Wed, 27 Apr 2022 12:07:29 -0400
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F24CB3D2830
for ;
Wed, 27 Apr 2022 09:03:16 -0700 (PDT)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160312euoutp0298682bd4ed6378d68f6735bc99cf069c~pzFJkFLi51442014420euoutp02z
for ;
Wed, 27 Apr 2022 16:03:12 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20220427160312euoutp0298682bd4ed6378d68f6735bc99cf069c~pzFJkFLi51442014420euoutp02z
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075392;
bh=epmGeWlUg0sk1ymD8aKTHa+TpgtMEyeF9rDL5knBwqw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=O1B+j/eS+FAhKO55gxGTSOXqmIXYgt9rOunF5AtiN+EgolHYWyqnHFZICEd76fw0Q
pICj5XVecpnpOl3dd6/zPcqBDH401BRYF4C9WFh7ZxVUNEi9jyq5Zn1fDuaya3HWLe
YReGlE4H46Th3X+/JAZzE24GELaWet6aVi7q99PQ=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160310eucas1p2f26bfea8215bfd277e0dea375708d596~pzFH3ddlk2333623336eucas1p2t;
Wed, 27 Apr 2022 16:03:10 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 24.14.09887.E3969626;
Wed, 27
Apr 2022 17:03:10 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220427160310eucas1p28cd3c5ff4fb7a04bc77c4c0b9d96bb74~pzFHH_jlH1480614806eucas1p2y;
Wed, 27 Apr 2022 16:03:10 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160309eusmtrp1f63202f28b5d3c5f17e52fea4e3ccc83~pzFHFJ3Nm2077420774eusmtrp1Y;
Wed, 27 Apr 2022 16:03:09 +0000 (GMT)
X-AuditID: cbfec7f4-45bff7000000269f-64-6269693e7212
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 4B.81.09522.D3969626;
Wed, 27
Apr 2022 17:03:09 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160309eusmtip10bafb514eb5df875b8fe2d26100f2413~pzFGuYNlG1783517835eusmtip1N;
Wed, 27 Apr 2022 16:03:09 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 13/16] null_blk: allow non power of 2 zoned devices
Date: Wed, 27 Apr 2022 18:02:52 +0200
Message-Id: <20220427160255.300418-14-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA01Sa1ATVxidu7vZXTITukZbbpHaIa1toQJV++O2MDzGpl2lr7EvcEZtDFvI
EB5NoI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qoHJfmuR3JS9
wd12bwW2Xy7z49n4lM9k/e36g+9+35z6aInLXouvByXCph4U/1vHO4EvideZUU+/YHl9FtfL
fIlHZ+/u2Bka/n3GrPILLpV/ivoy+1ewBRXP5p7+f4+LWYz/+UsyJ/nZYpWFFPfx/BRlLrJY
VNm9bLlzeGnXr6Wisq/2Xar8qhOyNWuJRNWeu8cjtQPO3N/9T7Fv3brvE2ZPKI9Y6+HkpnT3
2s4Tc5iC/y72yXv6ZWuk/TGGp2eEOF8Ji308LcSpmL6nUap2cYxEy64nk6ftrV4k2NLCYPL4
zrWG859ZutoZTgqvY4hZuPLX00Pzf8jpGReI6HVd7jvkOLVdUrX8CMfrL5/XeU7dqsRSnJFo
qMVcVJwIAMW3jdqxAwAA
X-CMS-MailID: 20220427160310eucas1p28cd3c5ff4fb7a04bc77c4c0b9d96bb74
X-Msg-Generator: CA
X-RootMTR: 20220427160310eucas1p28cd3c5ff4fb7a04bc77c4c0b9d96bb74
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160310eucas1p28cd3c5ff4fb7a04bc77c4c0b9d96bb74
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Convert the power of 2 based calculation with zone size to be generic in
null_zone_no with optimization for power of 2 based zone sizes.
The nr_zones calculation in null_init_zoned_dev has been replaced with a
division without special handling for power of 2 based zone sizes as
this function is called only during the initialization and will not
invoked in the hot path.
Performance Measurement:
Device:
zone size = 128M, blocksize=4k
FIO cmd:
fio --name=zbc --filename=/dev/nullb0 --direct=1 --zonemode=zbd --size=23G
--io_size= --ioengine=io_uring --iodepth= --rw= --bs=4k
--loops=4
The following results are an average of 4 runs on AMD Ryzen 5 5600X with
32GB of RAM:
Sequential Write:
x-----------------x---------------------------------x---------------------------------x
| IOdepth | 8 | 16 |
x-----------------x---------------------------------x---------------------------------x
| | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) |
x-----------------x---------------------------------x---------------------------------x
| Without patch | 578 | 2257 | 12.80 | 576 | 2248 | 25.78 |
x-----------------x---------------------------------x---------------------------------x
| With patch | 581 | 2268 | 12.74 | 576 | 2248 | 25.85 |
x-----------------x---------------------------------x---------------------------------x
Sequential read:
x-----------------x---------------------------------x---------------------------------x
| IOdepth | 8 | 16 |
x-----------------x---------------------------------x---------------------------------x
| | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) |
x-----------------x---------------------------------x---------------------------------x
| Without patch | 667 | 2605 | 11.79 | 675 | 2637 | 23.49 |
x-----------------x---------------------------------x---------------------------------x
| With patch | 667 | 2605 | 11.79 | 675 | 2638 | 23.48 |
x-----------------x---------------------------------x---------------------------------x
Random read:
x-----------------x---------------------------------x---------------------------------x
| IOdepth | 8 | 16 |
x-----------------x---------------------------------x---------------------------------x
| | KIOPS |BW(MiB/s) | Lat(usec) | KIOPS |BW(MiB/s) | Lat(usec) |
x-----------------x---------------------------------x---------------------------------x
| Without patch | 522 | 2038 | 15.05 | 514 | 2006 | 30.87 |
x-----------------x---------------------------------x---------------------------------x
| With patch | 522 | 2039 | 15.04 | 523 | 2042 | 30.33 |
x-----------------x---------------------------------x---------------------------------x
Minor variations are noticed in Sequential write with io depth 8 and
in random read with io depth 16. But overall no noticeable differences
were noticed
Reviewed-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
Reviewed-by: Hannes Reinecke
---
drivers/block/null_blk/main.c | 4 ++--
drivers/block/null_blk/zoned.c | 14 +++++++-------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index c441a4972064..82a62b543782 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1931,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 not be zero\n");
return -EINVAL;
}
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index dae54dd1aeac..00c34e65ef0a 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -13,7 +13,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 (is_power_of_2(dev->zone_size_sects))
+ return sect >> ilog2(dev->zone_size_sects);
+
+ return div64_u64(sect, dev->zone_size_sects);
}
static inline void null_lock_zone_res(struct nullb_device *dev)
@@ -62,10 +65,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;
@@ -83,8 +82,9 @@ 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 =
+ div64_u64(roundup(dev_capacity_sects, dev->zone_size_sects),
+ dev->zone_size_sects);
dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone),
GFP_KERNEL | __GFP_ZERO);
From patchwork Wed Apr 27 16:02: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: 12829069
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 535FDC433F5
for ; Wed, 27 Apr 2022 16:04:46 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241387AbiD0QHy (ORCPT );
Wed, 27 Apr 2022 12:07:54 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49098 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241677AbiD0QGz (ORCPT
);
Wed, 27 Apr 2022 12:06:55 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F6813D2821
for ;
Wed, 27 Apr 2022 09:03:15 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160313euoutp01bcf43535ba282cfbd3e2a22e91be1230~pzFKMjFqh0743407434euoutp010
for ;
Wed, 27 Apr 2022 16:03:13 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160313euoutp01bcf43535ba282cfbd3e2a22e91be1230~pzFKMjFqh0743407434euoutp010
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075393;
bh=a76qyKknkM0wvqdFNEHw+s8BT16u2uGhpV7aO9NKOYY=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=uTmyJt/Fj7B4+/K/zKEUMK6Ipat+TX8HPxfYnEo40bgAUnZbIsbpsqzG5w9+P2wVG
TRJQ+J0CtnKw4bAxDzstGzuT7ljO7vhp4g1vXOvaydPr2cFfbL34VktgitNST7VJd0
0cjytuutkeUKGQMoeGLw6Zp66yTyHmeihbn02hnY=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160311eucas1p292a05a97a5799178d307b83156d7614c~pzFInhDTQ0627806278eucas1p2B;
Wed, 27 Apr 2022 16:03:11 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id 46.14.09887.F3969626;
Wed, 27
Apr 2022 17:03:11 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160311eucas1p151141fc73adc590b40ad6f935b1ac214~pzFIDq05j2685026850eucas1p1l;
Wed, 27 Apr 2022 16:03:11 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160311eusmtrp19ad138dbf7fe61a8204739883754e403~pzFICnC7Y2142221422eusmtrp1I;
Wed, 27 Apr 2022 16:03:11 +0000 (GMT)
X-AuditID: cbfec7f4-45bff7000000269f-66-6269693f394f
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id F9.A7.09404.E3969626;
Wed, 27
Apr 2022 17:03:10 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160310eusmtip1f0d4275814b6fa6855728a90524835ba~pzFHtPgBm1783517835eusmtip1O;
Wed, 27 Apr 2022 16:03:10 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 14/16] f2fs: call bdev_zone_sectors() only once on
init_blkz_info()
Date: Wed, 27 Apr 2022 18:02:53 +0200
Message-Id: <20220427160255.300418-15-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA01Se0xTVxzOuef2tnSrXKqZZ8iyUbYs8hIfM2dCxtgjXjcz56Jm0S1Q4QKd
BVkLc5vJVsZjwoA+HKhtNx3hJTBbaWGWVwhDqmCl4yEgAeRRHciACXsQpq7drZn/fd/3+77f
d37JEUDxBcpfIEtNZxWpUrmEEpINnSvXw6JlssMRhrsB2NTVCXHNqJrCJYsrEHcXOwisU5/m
41VHD8Qt8wYedv6dSeDhNhuBz9dcJvC0SQ9xQdsiie/nj7m17AmI/5nYjHXtNwB2DegJ3HIz
BPdOVfFxb+lO3NxylcR9jUYKn61w8bEm9w+IhzQugLV2Cw8vlWfz8YW7CyS+cnPDq88wff1v
Mw+u1FKMNmuez/SMXSSZPkcGU1edRzE/qIohYyn7kmk6t0QwTcMqiinMmqcYW844j1loHaCY
Ims1YEzWAZLRWC7y3hUfFEYlsHLZJ6xi0ytxwmR9jgGmTT/5af7iHhW4JcwHPgJEb0P25hGQ
D4QCMV0F0NySy0uWAbpudvI4sgRQ22A/9SgyMvo9xQ0qAWpwLXrJDECFtTX8fCAQUHQwyszj
e/R19BBAWrOZ8BBIz0LktA4SnlVr6f1IvWDkezBJv4AmS8ZJT1hER6LVzBiu7Vl0pvev/3b6
uGXNvfc9soj2Q1fPTJMeDN2WrHoD9KxHdLkQdU1e5nHZN5C6fgxyeC2atVv5HA5A3ScLSA4f
R66hVW84GyC1zUR5yp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G9gfMDVxcjJISFgInH77jy2LkYuDiGBpYwSJ7tmM0EkJCRuL2xi
hLCFJf5c64Iqes4osb/5KVARBwebgJZEYyc7SFxE4AmjxP2fj1lAHGaBBhaJWxN3gU0SFgiW
+LPzKBuIzSKgKvFo2n0WkGZeAWuJ342OEAvkJWZe+s4OEuYECk/4FAESFhKwkuhedIsVxOYV
EJQ4OfMJC4jNDFTevHU28wRGgVlIUrOQpBYwMq1iFEktLc5Nzy020itOzC0uzUvXS87P3cQI
TCfbjv3csoNx5auPeocYmTgYDzFKcDArifB+2Z2RJMSbklhZlVqUH19UmpNafIjRFOjqicxS
osn5wISWVxJvaGZgamhiZmlgamlmrCTO61nQkSgkkJ5YkpqdmlqQWgTTx8TBKdXAtKfn//y8
/uJTqw+fsrirF7fqvdE3B42bVc5X82SyOFT4M+SP8m91/mrY9/Op6sbdO7sm9t4Qil4s5l64
UmnjntXTbM+9vnze5eQnkfKyjZe3WIQ6uu6W7n5zuWRW6Zk/0yY1/dzU4c2w3CHMiE9swo5M
qbDrLy683XZWfZnuqSkfFjPfbdsX9UdRRcGIX0/0BluZX/cZH44VwilTVV/8XL2uMrruopIx
n5SOldf0VV4NNxPT5N8uMLtUGvdAZV7Q5CXmL5tqtI4FxFZkXdozjeHW1Ec9ezUOf5y1xlgn
oszwi7JpXoxPnErd79RHPCqd9y6Ub47n91vsUL9gT9S9tpsMUVwXt6vuE+jTrzslqcRSnJFo
qMVcVJwIAAeEaE6wAwAA
X-CMS-MailID: 20220427160311eucas1p151141fc73adc590b40ad6f935b1ac214
X-Msg-Generator: CA
X-RootMTR: 20220427160311eucas1p151141fc73adc590b40ad6f935b1ac214
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160311eucas1p151141fc73adc590b40ad6f935b1ac214
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
From: Luis Chamberlain
Instead of calling bdev_zone_sectors() multiple times, call
it once and cache the value locally. This will make the
subsequent change easier to read.
Signed-off-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/f2fs/super.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ea939db18f88..f64761a15df7 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3678,22 +3678,25 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
struct block_device *bdev = FDEV(devi).bdev;
sector_t nr_sectors = bdev_nr_sectors(bdev);
struct f2fs_report_zones_args rep_zone_arg;
+ u64 zone_sectors;
int ret;
if (!f2fs_sb_has_blkzoned(sbi))
return 0;
+ zone_sectors = bdev_zone_sectors(bdev);
+
if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
- SECTOR_TO_BLOCK(bdev_zone_sectors(bdev)))
+ SECTOR_TO_BLOCK(zone_sectors))
return -EINVAL;
- sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_sectors(bdev));
+ sbi->blocks_per_blkz = SECTOR_TO_BLOCK(zone_sectors);
if (sbi->log_blocks_per_blkz && sbi->log_blocks_per_blkz !=
__ilog2_u32(sbi->blocks_per_blkz))
return -EINVAL;
sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz);
FDEV(devi).nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >>
sbi->log_blocks_per_blkz;
- if (nr_sectors & (bdev_zone_sectors(bdev) - 1))
+ if (nr_sectors & (zone_sectors - 1))
FDEV(devi).nr_blkz++;
FDEV(devi).blkz_seq = f2fs_kvzalloc(sbi,
From patchwork Wed Apr 27 16:02: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: 12829065
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 7E716C43219
for ; Wed, 27 Apr 2022 16:04:32 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241946AbiD0QHj (ORCPT );
Wed, 27 Apr 2022 12:07:39 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49116 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241779AbiD0QHV (ORCPT
);
Wed, 27 Apr 2022 12:07:21 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A9773D388A
for ;
Wed, 27 Apr 2022 09:03:17 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160314euoutp01815b47e397f45c96f77fbdf15af99205~pzFK3rw1z0743407434euoutp012
for ;
Wed, 27 Apr 2022 16:03:14 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160314euoutp01815b47e397f45c96f77fbdf15af99205~pzFK3rw1z0743407434euoutp012
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075394;
bh=jd72J8M0neFFhUOwxsHNzjGfA1o+HHRAGh31eMkc+aw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=Q920AbObxfqW9FIerFZcnqN7I6yNd1imxWw7I+M8TEElhoIfb2iG6fm8wdi+HJExu
ucaVVJdYgZuLkMfK+gZBm4pGde8yRGeFjrNm3O2oxsTvlUpP4pK4kVFqIzK/w2qZN4
J9JJMizDk9uU1BXHuBLCYOPDBnV3EBIHkO+bqeGk=
Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160312eucas1p287fed8f498db8495d7a0e270dbca8ab1~pzFJXt9m32337223372eucas1p28;
Wed, 27 Apr 2022 16:03:12 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges2new.samsung.com (EUCPMTA) with SMTP id C8.14.09887.04969626;
Wed, 27
Apr 2022 17:03:12 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220427160312eucas1p279bcffd97ef83bd3617a38b80d979746~pzFJABirU0627806278eucas1p2D;
Wed, 27 Apr 2022 16:03:12 +0000 (GMT)
Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220427160312eusmtrp1554db7f7acd8df39fab8ccb76d9490ec~pzFI-Cgfl2077420774eusmtrp1d;
Wed, 27 Apr 2022 16:03:12 +0000 (GMT)
X-AuditID: cbfec7f4-471ff7000000269f-6b-62696940e55b
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms2.samsung.com (EUCPMTA) with SMTP id 6C.A7.09404.F3969626;
Wed, 27
Apr 2022 17:03:11 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220427160311eusmtip2e43e337671f79300cb30594cd877a901~pzFIsidNe2538025380eusmtip2Q;
Wed, 27 Apr 2022 16:03:11 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 15/16] f2fs: ensure only power of 2 zone sizes are allowed
Date: Wed, 27 Apr 2022 18:02:54 +0200
Message-Id: <20220427160255.300418-16-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA01SbUxTZxTee+/t7aWm5FJEXmCb0MkiMEDZou8CYywjcjf4sfhjIW7GFbkC
o0VoQTdMNgRk0jBoMUgpDNGNiaAWBMn4qCuED1lt6ujK+NgYxjYqc4C2bKsgWcvtNv895znP
c55zkkPhok4ymMrJK2TleRKpmBQQvWMuc3RSTk7GrtNrAUj3wxiOOn6tIdHZFReOjHUmDNXW
aPhozWTGkX6pkYdu/30SQzOGPgxd6hjFkE2nxVGVYYVAT5Xzbq78Do7W7+xGtcNTANmtWgzp
Z6PQ5N02Ppq8kIIG9RMEsvQ3kejct3Y+UlWs4mhaZQdIPd7NQ47Wcj66+vsygW7OhiS9wFh+
SmU2bl4mGXXZEp8xz3cRjMVUxFxrrySZ8yV1ONP9zefMQIsDYwZmSkjmy7Ilkuk79RuPWb5h
JZnqnnbA6HqsBKPq7uK9JzogSMhkpTnHWHls4keCbIezGctfoD5Zt3RjJUDDVwIfCtKvQdPG
VzwlEFAiug1A+5VLBFc4AVzve4xzhQNAx+zqf5bZqTaMa1wEsHRoAXDFAwBHTz1yD6Moko6E
Jyv5Hn4rPQ2gurNz04HTizi83fMz5hnlT78LR75f2MQEHQ6t5QbSg4V0PLzcYAVc3HbYMPkX
3zPUx82rHqdzEj840WAjPBh3S8quN26uCulWAWy4v8rjvMnQMTfixf5wcbzHe8Lz0HimiuDw
CWifXvOaywGs6dORnjDoDqu+JfVAnI6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ZXsVqre4X/ngAIaYEY0EKRmBak73k/S5jBT92/7wSrkH/I
alL3H6eLl5avwCUTxEfr/lbYAF3CTVAcQZEiKjjcAJugeIJL1kPUSMCKbhkUNVpXBm3hRGp9
2IRthaYh6vzD2ighCIxMoUor8JieRE5B1PjaJBojCGlAqWB1BxybTiRfp3w/TzzGKJlMBYzd
WAwnkHup6zWB/y48T9UMhfHY0riobn5YEJO5ZBZVaQ9ytuLbqf6aqcfPIdF4edtlxAyR1ics
6xOWDYIdUBKr1yplSq2Q1kqVWr1KRheplTegaFN+6llztUONM4u0F4IJyAtRBMJPSlj2FBdy
E05IT33MatTHNHoFq/VCGdG3qxHe00XqaNVUumOCzLQMgShTnJYhzkzn70g4VHJWyiVlUh17
kmVLWM3/czARxzPAZ+05myblmVzLiqD/SFVu6sY7rj3PuJYVi55ZRUGf2mP+Qd9eMatjtvEi
Xy0eAhLblI1ePeVh8t+cgc2EM0/y2mnxG6cnPT63qO1B4ODOHqf8UY6zKO+piG7VeLj0QO4H
e4saZJ27scbCFhN7lHO3IGKf9l2xVW778+Taixu5vXfqk3cL372Z80V4tExcsNDlvzA/uOJT
ybYHb9Xhlk/Ibx51hUqc6ZWJK+ObKflJ+sMtevdB+4Mfuc+29YRnhqxHLWHjXyOjv8ddM8SH
Jh3nVBNN/Gzam+2byREt71jcJU6W5Kvdx/+5Y3jhu7LpFd63dyUyx9sHIu1n/OHaDiMf1RZL
BSmIRiv9F9LcNg2yAwAA
X-CMS-MailID: 20220427160312eucas1p279bcffd97ef83bd3617a38b80d979746
X-Msg-Generator: CA
X-RootMTR: 20220427160312eucas1p279bcffd97ef83bd3617a38b80d979746
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160312eucas1p279bcffd97ef83bd3617a38b80d979746
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
From: Luis Chamberlain
F2FS zoned support has power of 2 zone size assumption in many places
such as in __f2fs_issue_discard_zone, init_blkz_info. As the power of 2
requirement has been removed from the block layer, explicitly add a
condition in f2fs to allow only power of 2 zone size devices.
This condition will be relaxed once those calculation based on power of
2 is made generic.
Signed-off-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
---
fs/f2fs/super.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index f64761a15df7..db79abf30002 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3685,6 +3685,10 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
return 0;
zone_sectors = bdev_zone_sectors(bdev);
+ if (!is_power_of_2(zone_sectors)) {
+ f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");
+ return -EINVAL;
+ }
if (sbi->blocks_per_blkz && sbi->blocks_per_blkz !=
SECTOR_TO_BLOCK(zone_sectors))
From patchwork Wed Apr 27 16:02: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: 12829066
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 BD07AC4332F
for ; Wed, 27 Apr 2022 16:04:31 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S241931AbiD0QHi (ORCPT );
Wed, 27 Apr 2022 12:07:38 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49524 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S241695AbiD0QG4 (ORCPT
);
Wed, 27 Apr 2022 12:06:56 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B68A53D491E
for ;
Wed, 27 Apr 2022 09:03:20 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220427160315euoutp01720327af1582550978158cff1b5e9ae8~pzFL6nWsM0745007450euoutp01v
for ;
Wed, 27 Apr 2022 16:03:15 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220427160315euoutp01720327af1582550978158cff1b5e9ae8~pzFL6nWsM0745007450euoutp01v
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1651075395;
bh=T09TdKd+PKEo6/XUyeNORY3qJAIzmSkSW/V2uBW8/x8=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=XvvkE/3L93M0ztjxYphRVPfQl3magsan30V9vvdhTP7mRxFlNLj1mjzC6AlyeLw9D
egBm9E1bwBN3Fpab3MnE8f1gc9fX+pdSSLpj/wkCXRe98K+GYu5s6ONn8p1sbDP6PN
t4b79Il3zRxkovf/IvCAhnueJaHPdSjBfydterzw=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220427160313eucas1p28f302518de9cf124f9194cc8d376fd43~pzFKbY0Jn2334023340eucas1p2s;
Wed, 27 Apr 2022 16:03:13 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id C1.E7.10009.14969626;
Wed, 27
Apr 2022 17:03:13 +0100 (BST)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676~pzFJ-Gzll2489024890eucas1p1n;
Wed, 27 Apr 2022 16:03:13 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20220427160313eusmtrp2cea78a3137da11659e89a20f8b5be479~pzFJ_NFx82598325983eusmtrp2p;
Wed, 27 Apr 2022 16:03:13 +0000 (GMT)
X-AuditID: cbfec7f2-e7fff70000002719-93-62696941346b
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 5E.81.09522.04969626;
Wed, 27
Apr 2022 17:03:12 +0100 (BST)
Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20220427160312eusmtip1ae2f42acfa009ab15e75927ef0532d22~pzFJnZ99a1317113171eusmtip1M;
Wed, 27 Apr 2022 16:03:12 +0000 (GMT)
From: Pankaj Raghav
To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org,
hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com,
sagi@grimberg.me, damien.lemoal@opensource.wdc.com,
dsterba@suse.com, johannes.thumshirn@wdc.com
Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org,
clm@fb.com, gost.dev@samsung.com, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com,
jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org,
kch@nvidia.com, linux-nvme@lists.infradead.org,
dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com,
linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com,
linux-block@vger.kernel.org, Pankaj Raghav
Subject: [PATCH 16/16] dm-zoned: ensure only power of 2 zone sizes are
allowed
Date: Wed, 27 Apr 2022 18:02:55 +0200
Message-Id: <20220427160255.300418-17-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02Se0xTVxzHc+69vb3tVrgUI2e1Y1pn5tDx2Ng8CQtItmRXpwvGLTJxj4J3
hQ0KawEH/kF5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+pg4OKUamOoNztk7
676Vqz9ou6rw0tv1akJitqWbtj5JydrfKbNS7pTm13VZmWtnX80QzUgviwhx+f3njLLFRY4H
jus3m76TDZhgq6r+UPdQkuSxF7I3Zcwf3M17EnTt2zJPO9mQLFPZw3oZlwr7ZVi6uDnXvMs2
Wxa0IffyTJUuqaayzraXsiaq269fZ/inmPLOu8n/eTr7t097n/vxftx9T0v1LJf242WN58+m
SjQ7Nd7scpjsoOQ7WZ9dwfHHeqO3cY1nzVYZ5T+dK6I3ycX+YP08SYNW7d7iz4xzeOabMp/t
jprluMSX1+T2XuHk96+iPz+a3B5yquyNt/+Xusthrvxz76zynMgj9TUtJHbX1z1NSizFGYmG
WsxFxYkA506w3bEDAAA=
X-CMS-MailID: 20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676
X-Msg-Generator: CA
X-RootMTR: 20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676
References: <20220427160255.300418-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
From: Luis Chamberlain
Today dm-zoned relies on the assumption that you have a zone size
with a power of 2. Even though the block layer today enforces this
requirement, these devices do exist and so provide a stop-gap measure
to ensure these devices cannot be used by mistake
Signed-off-by: Luis Chamberlain
Signed-off-by: Pankaj Raghav
Reviewed-by: Hannes Reinecke
---
drivers/md/dm-zone.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 57daa86c19cf..221e0aa0f1a7 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -231,6 +231,18 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t)
struct request_queue *q = md->queue;
unsigned int noio_flag;
int ret;
+ struct block_device *bdev = md->disk->part0;
+ sector_t zone_sectors;
+ char bname[BDEVNAME_SIZE];
+
+ zone_sectors = bdev_zone_sectors(bdev);
+
+ if (!is_power_of_2(zone_sectors)) {
+ DMWARN("%s: %s only power of two zone size supported\n",
+ dm_device_name(md),
+ bdevname(bdev, bname));
+ return 1;
+ }
/*
* Check if something changed. If yes, cleanup the current resources