From patchwork Tue Sep 20 09:11:15 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pankaj Raghav
X-Patchwork-Id: 12981708
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 4D645ECAAD8
for ; Tue, 20 Sep 2022 09:11:56 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S231657AbiITJLy (ORCPT );
Tue, 20 Sep 2022 05:11:54 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56310 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S231582AbiITJLh (ORCPT
);
Tue, 20 Sep 2022 05:11:37 -0400
Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com
[210.118.77.11])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 853B1606BC
for ;
Tue, 20 Sep 2022 02:11:34 -0700 (PDT)
Received: from eucas1p2.samsung.com (unknown [182.198.249.207])
by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id
20220920091133euoutp0164ceb6755d76dc7de3f01f582c400a40~WhpZvGMq61236612366euoutp01h
for ;
Tue, 20 Sep 2022 09:11:33 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com
20220920091133euoutp0164ceb6755d76dc7de3f01f582c400a40~WhpZvGMq61236612366euoutp01h
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com;
s=mail20170921; t=1663665093;
bh=uWKwk/Zw9bFSyQrcJcSCU7+huozs0FwbWylJN85xRgw=;
h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
b=REbfCwsfkouA72M5ZeCA+jHkey7EEBhUm9ivs3bUZ1uacGH1NhFW5VtSZsyMK+LDU
UfHHx2dzyIaSiFiIPJMTncNv4S70D+ioVRkZNZfchcehqvve6hHTuzjL64ogZSlAdt
FlP0DKDOupH+74q7iOhdQ8zkdLxcsQSAlC16D1/E=
Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTP id
20220920091130eucas1p2a0838123c18e4e17ea3e770248bdfbbf~WhpXhxK5M1326413264eucas1p2N;
Tue, 20 Sep 2022 09:11:30 +0000 (GMT)
Received: from eucas1p1.samsung.com ( [182.198.249.206]) by
eusmges1new.samsung.com (EUCPMTA) with SMTP id 1E.2E.29727.2C389236;
Tue, 20
Sep 2022 10:11:30 +0100 (BST)
Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by
eucas1p2.samsung.com (KnoxPortal) with ESMTPA id
20220920091129eucas1p26137d368bf7e2cfc2d585ce41f3cdc86~WhpW2ihrg3137931379eucas1p2G;
Tue, 20 Sep 2022 09:11:29 +0000 (GMT)
Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by
eusmtrp1.samsung.com (KnoxPortal) with ESMTP id
20220920091129eusmtrp119499d96c3e89392e5cec7a704d0ccbd~WhpW1uUQ30212802128eusmtrp1q;
Tue, 20 Sep 2022 09:11:29 +0000 (GMT)
X-AuditID: cbfec7f2-21dff7000001741f-47-632983c2ca6a
Received: from eusmtip2.samsung.com ( [203.254.199.222]) by
eusmgms1.samsung.com (EUCPMTA) with SMTP id 17.0E.07473.1C389236;
Tue, 20
Sep 2022 10:11:29 +0100 (BST)
Received: from localhost (unknown [106.210.248.192]) by eusmtip2.samsung.com
(KnoxPortal) with ESMTPA id
20220920091129eusmtip266122eeddf42e613961d590179a06c75~WhpWgYaD32182421824eusmtip2e;
Tue, 20 Sep 2022 09:11:29 +0000 (GMT)
From: Pankaj Raghav
To: agk@redhat.com, snitzer@kernel.org, axboe@kernel.dk,
damien.lemoal@opensource.wdc.com, hch@lst.de
Cc: gost.dev@samsung.com, jaegeuk@kernel.org,
Johannes.Thumshirn@wdc.com, hare@suse.de, bvanassche@acm.org,
dm-devel@redhat.com, matias.bjorling@wdc.com,
linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
pankydev8@gmail.com, linux-block@vger.kernel.org,
Pankaj Raghav ,
Luis Chamberlain ,
Johannes Thumshirn
Subject: [PATCH v14 09/13] dm-zone: use generic helpers to calculate offset
from zone start
Date: Tue, 20 Sep 2022 11:11:15 +0200
Message-Id: <20220920091119.115879-10-p.raghav@samsung.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220920091119.115879-1-p.raghav@samsung.com>
MIME-Version: 1.0
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7qHmjWTDfofy1usP3WM2WL13X42
i2kffjJb/D57ntli77vZrBY3D+xkstizaBKTxcrVR5ksnqyfxWzxt+sek8XeW9oWl3fNYbOY
v+wpu8WEtq/MFjcmPGW0+Ly0hd1izc2nLBYnbkk7CHlcvuLtsXPWXXaPy2dLPTat6mTz2Lyk
3mP3zQY2j52t91k93u+7yubRt2UVo8fm09UenzfJebQf6GYK4InisklJzcksSy3St0vgylh3
ZAlrwUqeit5Vb5kbGOdxdTFyckgImEhsu36OpYuRi0NIYAWjxP0rr9khnC+MEv1PvjFBOJ8Z
Jbq7p7HBtCz99oYZIrGcUeLkuStMIAkhgZeMEkdbRLsYOTjYBLQkGjvZQcIiAukSX79uYASp
ZxaYyCzxcPYnFpCEsECsxJmlK8BsFgFVibVfHzCC2LwC1hJbp09mhlgmLzHz0newQZxA8Tm7
W9ggagQlTs58AtbLDFTTvHU22EESAps5JV4e28cC0ewi0f99JiOELSzx6vgWdghbRuL05B6o
mmqJpzd+QzW3AP28cz0byAcSQNv6zuSAmMwCmhLrd+lDlDtKHOg7D1XBJ3HjrSDECXwSk7ZN
Z4YI80p0tAlBVCtJ7Pz5BGqphMTlpjlQSz0kvjTfY53AqDgLyTOzkDwzC2HvA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lbPCRSfs7uFDeIgK4mOWZvZIOoFJU7OfMICYjMD1Tdvnc08gVFgFpLULCSp
BYxMqxhFUkuLc9Nziw31ihNzi0vz0vWS83M3MQJjd9uxn5t3MM579VHvECMTB+MhRgkOZiUR
3hZ/zWQh3pTEyqrUovz4otKc1OJDjKZAd09klhJNzgcmj7ySeEMzA1NDEzNLA1NLM2MlcV7P
go5EIYH0xJLU7NTUgtQimD4mDk6pBqbl65Inbv8j+1rvj3e28t6PZny3fzj8lZLl97jmddvn
8PYVlw6+mpmakORT+bnEZqeafmCzwP7Q5XIpUg6zH4qFT9b0zJc5VvGryavH+bh0f9+X0y/9
JqYuLJH5z3Lkyza1J2f73Iy+O0tbr1xY3njru6NecDdHzdXnD+I+T+6Q1Yz2llvKVGPK8mHB
ybCLs7OLok8/aemzuaBvK2Zv7fiIX6Ak7+rZ2omtZfPkOmYKT/769n9lYfKKLPW2tuMrN6z3
6Vv2JHjhV6OahTb+V4oV+5RY1OTqtgm+L3R7s6B/dZmT88IPDg8XzVXOEPPMW/KCLyQkf02f
c1RLXtC9ZAOWviXdym93PbpgfFTQT4mlOCPRUIu5qDgRAM8iv9dmAwAA
X-CMS-MailID: 20220920091129eucas1p26137d368bf7e2cfc2d585ce41f3cdc86
X-Msg-Generator: CA
X-RootMTR: 20220920091129eucas1p26137d368bf7e2cfc2d585ce41f3cdc86
X-EPHeader: CA
CMS-TYPE: 201P
X-CMS-RootMailID: 20220920091129eucas1p26137d368bf7e2cfc2d585ce41f3cdc86
References: <20220920091119.115879-1-p.raghav@samsung.com>
Precedence: bulk
List-ID:
X-Mailing-List: linux-block@vger.kernel.org
Use the bdev_offset_from_zone_start() helper function to calculate
the offset from zone start instead of using power of 2 based
calculation.
Signed-off-by: Pankaj Raghav
Reviewed-by: Luis Chamberlain
Reviewed-by: Damien Le Moal
Reviewed-by: Bart Van Assche
Reviewed-by: Johannes Thumshirn
Reviewed-by: Mike Snitzer
---
drivers/md/dm-zone.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 3dafc0e8b7a9..ac6fc1293d41 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md,
case REQ_OP_WRITE_ZEROES:
case REQ_OP_WRITE:
/* Writes must be aligned to the zone write pointer */
- if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset)
+ if (bdev_offset_from_zone_start(md->disk->part0,
+ clone->bi_iter.bi_sector) != zwp_offset)
return false;
break;
case REQ_OP_ZONE_APPEND:
@@ -602,11 +603,8 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone)
*/
if (clone->bi_status == BLK_STS_OK &&
bio_op(clone) == REQ_OP_ZONE_APPEND) {
- sector_t mask =
- (sector_t)bdev_zone_sectors(disk->part0) - 1;
-
orig_bio->bi_iter.bi_sector +=
- clone->bi_iter.bi_sector & mask;
+ bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector);
}
return;