From patchwork Tue Jan 10 14:36:33 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 13095228
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 DA07BC63797
for ; Tue, 10 Jan 2023 14:36:48 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S231228AbjAJOgr (ORCPT );
Tue, 10 Jan 2023 09:36:47 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52330 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S238435AbjAJOgp (ORCPT
);
Tue, 10 Jan 2023 09:36:45 -0500
Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com
[210.118.77.12])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7744D431AB
for ;
Tue, 10 Jan 2023 06:36:42 -0800 (PST)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id
20230110143639euoutp027b84c3687c727964000d6a5f8c389ae9~4_VOZCsfH0464004640euoutp02Q
for ;
Tue, 10 Jan 2023 14:36:39 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com
20230110143639euoutp027b84c3687c727964000d6a5f8c389ae9~4_VOZCsfH0464004640euoutp02Q
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1673361399;
bh=SHvT0Iim03zZBGBqzNi6q7H4Efd4JG0NRYcOMqYqopo=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=OtbvNMUWx48FA3wzuBC/BXlVL9UhX2uZs/vLVVwGMFthhqvNzE3f5PEZrV1FLZP7G
pH2thY4TrA0f3irfyMTUDRC9elmOKG0lcT1eKg/oSjwKJhlCabUGqTu+lLeqWX5868
VhHjQLxYCAXcJf1D6gRZXr+MmcxlN1D74EHcJoe0=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20230110143638eucas1p263a3c1dfaa18b20444ab7589f281a81d~4_VNpIFwt0231602316eucas1p2k;
Tue, 10 Jan 2023 14:36:38 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id B6.A6.56180.6F77DB36;
Tue, 10
Jan 2023 14:36:38 +0000 (GMT)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20230110143637eucas1p1fa9ab24ea73f524dd3dcb11c10b5c11a~4_VNW5oXN2955929559eucas1p1s;
Tue, 10 Jan 2023 14:36:37 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20230110143637eusmtrp2099788fad2206056ff1a357ffc00c48c~4_VNV4q4T0701607016eusmtrp2V;
Tue, 10 Jan 2023 14:36:37 +0000 (GMT)
X-AuditID: cbfec7f2-ab5ff7000000db74-07-63bd77f6d085
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 63.1C.23420.5F77DB36;
Tue, 10
Jan 2023 14:36:37 +0000 (GMT)
Received: from localhost (unknown [106.210.248.241]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20230110143637eusmtip27e188158996471fbce28fafe158dc88f~4_VNKnuAw3006630066eusmtip2i;
Tue, 10 Jan 2023 14:36:37 +0000 (GMT)
From: Pankaj Raghav
To: axboe@kernel.dk
Cc: linux-nvme@lists.infradead.org, hch@lst.de, bvanassche@acm.org,
linux-block@vger.kernel.org, damien.lemoal@opensource.wdc.com,
gost.dev@samsung.com, snitzer@kernel.org,
Pankaj Raghav ,
Chaitanya Kulkarni ,
Johannes Thumshirn
Subject: [PATCH v2 1/3] block: remove superfluous check for request queue in
bdev_is_zoned()
Date: Tue, 10 Jan 2023 15:36:33 +0100
Message-Id: <20230110143635.77300-2-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20230110143635.77300-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA01Se0hTcRjtd+8276ar253kh0aj9aKHTinh2rtIuFlBJPSwsNa6aLWt2DLL
iFY+18NHoTkzl5Ll1kOcD1z5ykiLWi9rppCZbZBCZpnVECu3u6j/zvl95/udc+AjcKqeH0zs
1RxitRqFSiYQ8era3M9Cvyc3KsNb0gj6xtscAV0w5MbpUfsznO5qsWG0+cYDjB473YPRrtdF
GN3YPZ82XXP50cPlaX70w+6Qlf5Mx6t1TIc9ibFaDAKm+uoJ5m6XXsCcSx0UMLb0d3wmu8aC
mGHrNCaz5Qy2URQnWrqHVe09zGrly3eJEn+P6AUHXcSRkpFkPWrzO42EBJCLwJmTP45FBEVW
IPja8B7nyDcEvW0WxJFhBCUt5/h/VxzWXp/qOgJDhVHAkX4E6f0j44QgBOQ8OGnwegSSEmjO
Sud5NDhZicGHzjO4ZyAh4+GeyYl5MI+cBXk1Ri8Wk1FwPSML59ykYHz5w/uRkFwMz/NGEaeZ
DI+MTp4H4+Oa1NpL3kRADhEwOlbsi7oGfr4y8jgsgYH2Gl/rqfDbZsI4fAxcb0Z9y2kIcmyV
3gZALoHsJyoPxMm5UHlHzslXwad+p08xEd58msxFmAjn6y7i3LMYsjIoTi0Dm9vpMwXoOFXs
C8NAZfmYXy6aXvRfmaL/yhT9872CcAsKYpN06gRWF6Fhk8N0CrUuSZMQpjygtqLx43r8q/1r
Pbo88CWsFWEEakVA4LJAsVnYoKTEexRHU1jtgZ3aJBWra0UhBE8WJC6sNSkp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o5EIYH0xJLU7NTUgtQimD4mDk6pBibbrT9jZD7/u91/tb/FbI8Cd+pMYQHn6882WJcs
4tw99cpkZVm+dqV7kyNit9+8VLVm1t5iLsubsQ3L/nKvn+88TfXm7PUemlErvA8EShbOrrnL
O2dG4+6V52dFtoZtP/frwjvvgrJN8sE8S3wE2lJNm3aEWOixxTTGs0ezc+k4vboWs8HVLmzH
x/76dV0XhbM27vvg/XHjeaG+x8XuSxYrtIWv+mUVPlXu8l27OQtn/V159Vh0xTJT2/3ruJq0
bT+Y/ZykuKg51X75Q7MY1WUhbiLve46pF00W8Tig/8C4jv9z6rRi3wLl6m25z+XU1LabVznl
Mpzo+CaSPOfKHqkquRdTvXVq5m3f9M71hbkSS3FGoqEWc1FxIgDMdbZGOQMAAA==
X-CMS-MailID: 20230110143637eucas1p1fa9ab24ea73f524dd3dcb11c10b5c11a
X-Msg-Generator: CA
X-RootMTR: 20230110143637eucas1p1fa9ab24ea73f524dd3dcb11c10b5c11a
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20230110143637eucas1p1fa9ab24ea73f524dd3dcb11c10b5c11a
References: <20230110143635.77300-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Remove the superfluous request queue check in bdev_is_zoned() as
bdev_get_queue() can never return NULL.
Reviewed-by: Christoph Hellwig
Reviewed-by: Damien Le Moal
Reviewed-by: Bart Van Assche
Reviewed-by: Chaitanya Kulkarni
Reviewed-by: Johannes Thumshirn
Signed-off-by: Pankaj Raghav
---
include/linux/blkdev.h | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index b87ed829ab94..0956bc0fb5b0 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1285,12 +1285,7 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
static inline bool bdev_is_zoned(struct block_device *bdev)
{
- struct request_queue *q = bdev_get_queue(bdev);
-
- if (q)
- return blk_queue_is_zoned(q);
-
- return false;
+ return blk_queue_is_zoned(bdev_get_queue(bdev));
}
static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
From patchwork Tue Jan 10 14:36:34 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 13095225
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 E0B63C54EBC
for ; Tue, 10 Jan 2023 14:36:46 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S234273AbjAJOgp (ORCPT );
Tue, 10 Jan 2023 09:36:45 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52318 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S232301AbjAJOgo (ORCPT
);
Tue, 10 Jan 2023 09:36:44 -0500
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 775D443A26
for ;
Tue, 10 Jan 2023 06:36:42 -0800 (PST)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20230110143639euoutp01fc9a82b364b3f634594bab54bd64f800~4_VPAclvP3204332043euoutp017
for ;
Tue, 10 Jan 2023 14:36:39 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20230110143639euoutp01fc9a82b364b3f634594bab54bd64f800~4_VPAclvP3204332043euoutp017
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1673361399;
bh=G/NS82KayjnGwwjEEFhhHx3EPrjIVAhcZLJ4LNXd4zM=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=iMdvrEW7jcP+qwuS6nc0Jn+dzBDRkomY7hy3TU1NLjJWQW0GbH6uBBJWF4J5rwMBb
/xmon9NmJgYupcxuq/lDR7lO4rSe/0GjzHJLf6idikUC/crS+O3LJd1dS/mxm+eMw+
myQg5DYAzuctUIYI2i6aKq890cFBc7dDE22C+E+A=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20230110143638eucas1p29d4ef05afa377a30424445d5d08ceda7~4_VOS8wPO2559425594eucas1p27;
Tue, 10 Jan 2023 14:36:38 +0000 (GMT)
Received: from eucas1p2.samsung.com ( [182.198.249.207]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 18.A6.56180.6F77DB36;
Tue, 10
Jan 2023 14:36:38 +0000 (GMT)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20230110143638eucas1p1551ada551876f82df671162860f08d7d~4_VN9kV5o1940819408eucas1p1R;
Tue, 10 Jan 2023 14:36:38 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20230110143638eusmtrp2253f535994defd647ada71e3498fafc3~4_VN8zmqG0701607016eusmtrp2W;
Tue, 10 Jan 2023 14:36:38 +0000 (GMT)
X-AuditID: cbfec7f2-ab5ff7000000db74-09-63bd77f67d21
Received: from eusmtip1.samsung.com ( [203.254.199.221]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id D4.1C.23420.6F77DB36;
Tue, 10
Jan 2023 14:36:38 +0000 (GMT)
Received: from localhost (unknown [106.210.248.241]) by eusmtip1.samsung.com
(KnoxPortal) with ESMTPA id
20230110143638eusmtip1b69c7bedc2a1239472475578e3da8991~4_VNx7tui1830618306eusmtip1P;
Tue, 10 Jan 2023 14:36:38 +0000 (GMT)
From: Pankaj Raghav
To: axboe@kernel.dk
Cc: linux-nvme@lists.infradead.org, hch@lst.de, bvanassche@acm.org,
linux-block@vger.kernel.org, damien.lemoal@opensource.wdc.com,
gost.dev@samsung.com, snitzer@kernel.org,
Pankaj Raghav ,
Chaitanya Kulkarni
Subject: [PATCH v2 2/3] block: add a new helper bdev_{is_zone_start,
offset_from_zone_start}
Date: Tue, 10 Jan 2023 15:36:34 +0100
Message-Id: <20230110143635.77300-3-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20230110143635.77300-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA02SWUwTURiFvTPtdFqtjgXpH1HQJsSIASQxOgouGB8mIUYffBKt1HYEtRTs
Iq5YNhfQukRQEMUFZIupIigVECQoixAakYhWMNGiUnFBQK1sUqZG385//+/cc09ySVxi5s8m
d2r0rFajUMsIEe/eE2dbwI/4auXiImsQXdJ1mqAzvzlxeri1Dadf1lowuqjkMUb3dGRjdPWr
RXTuzR4BPZCfIqAbX3mvETHtz8OZ9lYDU1p8gmDu5h1hKl8aCeZU8heCsaS+4TOmsmLEDJT6
bBRuFoWqWPXOvaw2aFWkKNqYN4rizkv2fbthFRiRcUYaEpJALYH79TUoDYlICVWIoNr2g+CG
QQTOpH4+NwwgKB7qI/5aUqsKBdyiAMHp9D63vxfBp2tZExRJEpQ/JJ4QuAyelAfUHE/luRic
GkEw3tXEcy08KDm86+jAXZpH+cGzD98ntZhaDi+G6nlcmi9kPfs5eZGQWgHWs8OIY2ZCU5Z9
ksEnmOTyS7grAKiPJCSN1Ag48zoor8jhc9oDHA1l7vM5MG7JxTh9EHo6h93mlIk6FvNkA6BC
wNSidkmcWgjmB0EcHgamX/luYjp0fp7JPWE6nLt3AeeOxXD8qISjZWBx2t2hAO1JOe5WDFR3
nyTOoPnZ/5XJ/q9M9r/cqwgvRlLWoIuJYnXBGjY+UKeI0Rk0UYHK2JhSNPG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1JLT7EaAp09kRmKdHkfGBE55XEG5oZmBqamFkamFqaGSuJ83oWdCQK
CaQnlqRmp6YWpBbB9DFxcEo1MDUpznarndZ8eAUvXwrjoaZDP1Y1vHNZZrTo5vE5D1866god
zzm4/Z4mt3q1hsdCcfNU1+DNc/NXr3zB+zMkLGP69OXr9AqfSqmVZN5ytBec46qzjOclo/Tv
e1xzzfj0vlgo7uQWSfb//HdjVFqC7mslqYSm4FnmtQUTp++N4plfcsj2bd6uc031Gxvepzif
qp+2ZXqV2hGOz7s4/omsTVi0akmCh/86pecM2rMz70xbwvjYIrro9PYWj7MPeY/0ZTS+iLw7
T4ntxkdl3+NXGmPeJp2o3cv6IGWaopxHWmmhxedzv8SO9vgbOr4XnuDnL/nN9NQH3t3Tfy2Z
1pW4f3KGjKbEXSeNX1+l6o2M7iixFGckGmoxFxUnAgDMeJZgMAMAAA==
X-CMS-MailID: 20230110143638eucas1p1551ada551876f82df671162860f08d7d
X-Msg-Generator: CA
X-RootMTR: 20230110143638eucas1p1551ada551876f82df671162860f08d7d
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20230110143638eucas1p1551ada551876f82df671162860f08d7d
References: <20230110143635.77300-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Instead of open coding to check for zone start, add a helper to improve
readability and store the logic in one place.
Reviewed-by: Chaitanya Kulkarni
Reviewed-by: Christoph Hellwig
Signed-off-by: Pankaj Raghav
Reviewed-by: Bart Van Assche
---
block/blk-core.c | 2 +-
block/blk-zoned.c | 4 ++--
include/linux/blkdev.h | 12 ++++++++++++
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 9321767470dc..0405b3144e7a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -573,7 +573,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
return BLK_STS_NOTSUPP;
/* The bio sector must point to the start of a sequential zone */
- if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) ||
+ if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) ||
!bio_zone_is_seq(bio))
return BLK_STS_IOERR;
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index db829401d8d0..614b575be899 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -277,10 +277,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
return -EINVAL;
/* Check alignment (handle eventual smaller last zone) */
- if (sector & (zone_sectors - 1))
+ if (!bdev_is_zone_start(bdev, sector))
return -EINVAL;
- if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity)
+ if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity)
return -EINVAL;
/*
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0956bc0fb5b0..7822c6f4c7bd 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1306,6 +1306,18 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev)
return q->limits.chunk_sectors;
}
+static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev,
+ sector_t sector)
+{
+ return sector & (bdev_zone_sectors(bdev) - 1);
+}
+
+static inline bool bdev_is_zone_start(struct block_device *bdev,
+ sector_t sector)
+{
+ return bdev_offset_from_zone_start(bdev, sector) == 0;
+}
+
static inline int queue_dma_alignment(const struct request_queue *q)
{
return q ? q->limits.dma_alignment : 511;
From patchwork Tue Jan 10 14:36:35 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 13095227
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 5E0BBC54EBE
for ; Tue, 10 Jan 2023 14:36:48 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S238525AbjAJOgr (ORCPT );
Tue, 10 Jan 2023 09:36:47 -0500
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52328 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S231228AbjAJOgp (ORCPT
);
Tue, 10 Jan 2023 09:36:45 -0500
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7735742E36
for ;
Tue, 10 Jan 2023 06:36:42 -0800 (PST)
Received: from eucas1p1.samsung.com (unknown [182.198.249.206])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20230110143640euoutp0194158956b4db3ab7596b33015b16d1a2~4_VPpUeF-3100431004euoutp01V
for ;
Tue, 10 Jan 2023 14:36:40 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20230110143640euoutp0194158956b4db3ab7596b33015b16d1a2~4_VPpUeF-3100431004euoutp01V
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1673361400;
bh=2suXkH1KFPiYteZ9oMdTIvkNeSw64bwFwUVTSVjrGjs=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=XoKdh34Lp4UiSk+b9U9JIDNI5ksuBsYVeozgOmZCbr5yy/I25NxTMEKS5RvJY7GxV
67Bc6NZinA4Z0YSWdk3d49ZGBt3L8CRStTa5UEu5n3gQCZYPKe+KFF7GNs8ZHjOi7F
Edz4vYH+z1EvmUSjqWYEiweV7GgT4zlCp8dW1AJ4=
Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTP id
20230110143639eucas1p1a749f235b9f29daeed9db34f0c757cb9~4_VO6Ew9y0119001190eucas1p1M;
Tue, 10 Jan 2023 14:36:39 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges3new.samsung.com (EUCPMTA) with SMTP id D8.18.43884.7F77DB36;
Tue, 10
Jan 2023 14:36:39 +0000 (GMT)
Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by
eucas1p1.samsung.com (KnoxPortal) with ESMTPA id
20230110143639eucas1p1969276de5218d8e71dfb1ffe4b636574~4_VOqGmPB1433014330eucas1p1m;
Tue, 10 Jan 2023 14:36:39 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp2.samsung.com (KnoxPortal) with ESMTP id
20230110143639eusmtrp2545b3bcc97a80f81a850049e1aedf2b1~4_VOpZ_Z60701607016eusmtrp2Z;
Tue, 10 Jan 2023 14:36:39 +0000 (GMT)
X-AuditID: cbfec7f5-25bff7000000ab6c-20-63bd77f7a6f7
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 27.1C.23420.7F77DB36;
Tue, 10
Jan 2023 14:36:39 +0000 (GMT)
Received: from localhost (unknown [106.210.248.241]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20230110143639eusmtip26ac82f8edf03ff344e2c0aab1f8da50c~4_VOaEFVl2566725667eusmtip2v;
Tue, 10 Jan 2023 14:36:38 +0000 (GMT)
From: Pankaj Raghav
To: axboe@kernel.dk
Cc: linux-nvme@lists.infradead.org, hch@lst.de, bvanassche@acm.org,
linux-block@vger.kernel.org, damien.lemoal@opensource.wdc.com,
gost.dev@samsung.com, snitzer@kernel.org,
Pankaj Raghav ,
Chaitanya Kulkarni
Subject: [PATCH v2 3/3] block: introduce bdev_zone_no helper
Date: Tue, 10 Jan 2023 15:36:35 +0100
Message-Id: <20230110143635.77300-4-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20230110143635.77300-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAA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Zmuups8bx70fd/qBowcp/0fFGw453wrNmRleqTZ4rtvWup+0ZL
fOn+suYAPV2jf1GeUzk33ZfYr8RSnJFoqMVcVJwIALn/OEEvAwAA
X-CMS-MailID: 20230110143639eucas1p1969276de5218d8e71dfb1ffe4b636574
X-Msg-Generator: CA
X-RootMTR: 20230110143639eucas1p1969276de5218d8e71dfb1ffe4b636574
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20230110143639eucas1p1969276de5218d8e71dfb1ffe4b636574
References: <20230110143635.77300-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Add a generic bdev_zone_no() helper to calculate zone number for a
given sector in a block device. This helper internally uses disk_zone_no()
to find the zone number.
Use the helper bdev_zone_no() to calculate nr of zones. This lets us
make modifications to the math if needed in one place.
Reviewed-by: Christoph Hellwig
Reviewed-by: Chaitanya Kulkarni
Reviewed-by: Bart Van Assche
Reviewed-by: Damien Le Moal
Signed-off-by: Pankaj Raghav
---
drivers/nvme/target/zns.c | 3 +--
include/linux/blkdev.h | 5 +++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c
index 1254cf57e008..7e4292d88016 100644
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -254,8 +254,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req)
{
unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba);
- return bdev_nr_zones(req->ns->bdev) -
- (sect >> ilog2(bdev_zone_sectors(req->ns->bdev)));
+ return bdev_nr_zones(req->ns->bdev) - bdev_zone_no(req->ns->bdev, sect);
}
static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 7822c6f4c7bd..89f51d68c68a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1288,6 +1288,11 @@ static inline bool bdev_is_zoned(struct block_device *bdev)
return blk_queue_is_zoned(bdev_get_queue(bdev));
}
+static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
+{
+ return disk_zone_no(bdev->bd_disk, sec);
+}
+
static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
blk_opf_t op)
{