From patchwork Tue Aug 16 13:15:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944920 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 2C70CC2BB41 for ; Tue, 16 Aug 2022 13:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235608AbiHPNQB (ORCPT ); Tue, 16 Aug 2022 09:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235436AbiHPNPw (ORCPT ); Tue, 16 Aug 2022 09:15:52 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E38545A82B for ; Tue, 16 Aug 2022 06:15:50 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131549euoutp02045fc7a265a0077b501e7b5217aa4400~L1ZscAFPc2682126821euoutp02K for ; Tue, 16 Aug 2022 13:15:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220816131549euoutp02045fc7a265a0077b501e7b5217aa4400~L1ZscAFPc2682126821euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655749; bh=rIbhfxDBpj+Ii51tIIt4kTVb6ZA8NV8eQeaNrvmy2UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFHmCgW3scAwFETWgtohASUPy96lLu279gtR4xXWKKnOc2aAvfbb1Xwx+anLwtQ5p cUSJDJ7b2AZLQJCw4T2EwznPWbT0esV5ONj6njbS/+oODe5CtkIvmoQDYgR/27pS12 M37na7QEV1qHMAkb++L+0/+k0QsS1QKJHwlSJGWw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131547eucas1p117ca36a8d41704af1b16d1b46b5efa8e~L1ZqrC7Nm0139001390eucas1p1O; Tue, 16 Aug 2022 13:15:47 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 62.C7.10067.3889BF26; Tue, 16 Aug 2022 14:15:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131547eucas1p1b38862475577332351efe91e5428e295~L1ZqCucnG0139001390eucas1p1N; Tue, 16 Aug 2022 13:15:47 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131547eusmtrp1e5ef2ac3da3c85514713642b4ff8e425~L1ZqBB7Ss0149801498eusmtrp1M; Tue, 16 Aug 2022 13:15:47 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-24-62fb9883d59f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 23.B0.09095.3889BF26; Tue, 16 Aug 2022 14:15:47 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131546eusmtip1b8b1d7f74048b66552e093a2a310cee5~L1ZpvD_qw2676726767eusmtip1X; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) From: Pankaj Raghav To: damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, agk@redhat.com Cc: pankydev8@gmail.com, gost.dev@samsung.com, matias.bjorling@wdc.com, hare@suse.de, bvanassche@acm.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, Johannes.Thumshirn@wdc.com, linux-block@vger.kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v11 09/13] dm-zone: use generic helpers to calculate offset from zone start Date: Tue, 16 Aug 2022 15:15:32 +0200 Message-Id: <20220816131536.189406-10-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220816131536.189406-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIKsWRmVeSWpSXmKPExsWy7djP87rNM34nGWz9qGux/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2PZ 4W/MBR3cFVffKzUw9nJ2MXJySAiYSOx6O425i5GLQ0hgBaPE2dYrTBDOF0aJl82dbBDOZ0aJ jqWvWWFaJk2/zwxiCwksZ5TYt9gWougFo8Tuk89Yuhg5ONgEtCQaO9lBakQE0iWmtLxkAalh FrjDJHHq3VZ2kBphgViJhvM5IDUsAqoS65dfZwMJ8wpYSzS+yYRYJS8x89J3sDGcQOF/DatY QGxeAUGJkzOfgNnMQDXNW2eDfSAhsJ1T4mzXN6g7XSQO/2hng7CFJV4d38IOYctInJ7cwwJh V0s8vfEbqrmFUaJ/53qwIySAtvWdyQExmQU0Jdbv0ocod5Ro+beeCaKCT+LGW0GIE/gkJm2b zgwR5pXoaBOCqFaS2PnzCdRSCYnLTXOglnpI/Nz3k2UCo+IsJM/MQvLMLIS9CxiZVzGKp5YW 56anFhvlpZbrFSfmFpfmpesl5+duYgSmwtP/jn/Zwbj81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ck FjAyrWIUSS0tzk3PLTbUK07MLS7NS9dLzs/dxAiM3G3Hfm7ewTjv1Ue9Q4xMHIyHGCU4mJVE eAVf/EgS4k1JrKxKLcqPLyrNSS0+xGgKdPZEZinR5Hxg6sgriTc0MzA1NDGzNDC1NDNWEuf1 LOhIFBJITyxJzU5NLUgtgulj4uCUamBaUyflGGLNmJvIsPwMlxqPmajmL2ZfJpm8U2W+Z5Ou vFnYfjFFuCKOXeyT5cKJSwsi7SJ5d26+HaAsMaPD3cTzZ+uv/QEv6+aKG70MnXihiqHvUMgn o0495Xe7t387vXdTkm3O630T17X9ElqqodW/TM3rhLuBpPJmSaHsO++vczR/Z1PONuN6dDT6 csqDG+dtlYsfvL9+4xRvyFvn6IQrnmbHRe8LXvu237zv4NQHn73S9ycbsz41tvB+557/8F3+ pIXhn2e7BHHM0ecWK1rN9OV65bXbJ2v8dX4s1/v64r3PluCt9s9WW/BcDLihKM/083y2xJTL cz8c9915Y12NyPb/lrPnzeP/Uubm9u68EktxRqKhFnNRcSIA2wH34GUDAAA= X-CMS-MailID: 20220816131547eucas1p1b38862475577332351efe91e5428e295 X-Msg-Generator: CA X-RootMTR: 20220816131547eucas1p1b38862475577332351efe91e5428e295 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131547eucas1p1b38862475577332351efe91e5428e295 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use the bdev_offset_from_zone_start() helper function to calculate the offset from zone start instead of using power of 2 based calculation. Signed-off-by: Pankaj Raghav Reviewed-by: Luis Chamberlain Reviewed-by: Damien Le Moal --- drivers/md/dm-zone.c | 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;