From patchwork Fri Jan 6 08:33:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 39997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp713425wrt; Fri, 6 Jan 2023 00:36:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXtoJ938NoV670e2Fjuj/Ku1ANzc4vPuOq2EMjS7RhNP/wHO0vbsqa4/8JfWWnMlSqzvcu5W X-Received: by 2002:aa7:cf94:0:b0:46b:6214:44c8 with SMTP id z20-20020aa7cf94000000b0046b621444c8mr45061591edx.39.1672994184057; Fri, 06 Jan 2023 00:36:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672994184; cv=none; d=google.com; s=arc-20160816; b=Ku7ITwBaUsFu84E/etSb8MEUIoQMTOqr8gex1U7H0H4XzB8mTcHbYVnoR+G8ipiXsP FsLCzqhnV0eOSNV36XFYbcFcDjOENPG7Pv6nzYgegfFvdBgpxqNZl/hbz3WNuZ1GpIx6 eBj8gK3KvHTZlQk0/VX/OcFd3VncAtMeAXh0Y+ZjDr8iE1Ug6EU/9Mi99xyGmzuCPoyB Jzmwor44LtQ9S/z8ta2bBZTvT4yXcYSMm5/p9RC0coT8AmHGRcjATrIsLG+Eg9O1SIcw zxIy/dMlQDkggGkZKagftYe+Z9lWWFpAneG0lrY+0jU1gVfUKvEYkT/RTBuxkHcor/P7 m2SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=VLRJd/g9zW/ZTmb/70CCbE3iGbRVLutU6c9iT4cK22Q=; b=YxIdrPMbWc8sKbUF2irP+iKlLuy99hcVWZWRerohO74Gi9M04QN0ojv0oJuPILdXrg T5ePBV8Oho/dEcWRIDAZkSTafNjFbEvtJHuXTrySi+JGmJmunl1wp75gLKNEpfhirog1 IPA1YPzyhfI2acJsB8pqozhN9RV59S6Xqh7EF1g2XJ8uLHwODVSMaEHQSx5QNEQenGWU tG6J/2ZJTJL4Gy+rOgMXGyqxs3vuJMxhew5SxIYqq0bnpjQ5Fh835O4B0jwNrZb5jQA9 cfRGUD4U9Z8049PcNwqyckYqFuDQbb8DtbLdtdtGCHgbyLk9MZzX4aeGXQ9EJiQOZ7/c BNeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=c9qafOCd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a50fb0b000000b0046a09ce4d12si901748edq.339.2023.01.06.00.36.00; Fri, 06 Jan 2023 00:36:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=c9qafOCd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231831AbjAFIeL (ORCPT + 99 others); Fri, 6 Jan 2023 03:34:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232437AbjAFId2 (ORCPT ); Fri, 6 Jan 2023 03:33:28 -0500 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6567A938 for ; Fri, 6 Jan 2023 00:33:27 -0800 (PST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083324euoutp019eff452955e6da789dab97861d40e099~3qy7u9Hj41990519905euoutp01_ for ; Fri, 6 Jan 2023 08:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230106083324euoutp019eff452955e6da789dab97861d40e099~3qy7u9Hj41990519905euoutp01_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994004; bh=VLRJd/g9zW/ZTmb/70CCbE3iGbRVLutU6c9iT4cK22Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9qafOCdbAJ7L0vtSLa2LQ7W3Ukf2Hi+mHXzG7ZYz4Zc6SaL+IoF9oAdgS3uWatzn wiTMdjuJDgocD81JFFpBD6i49C8UtM6WvLYWnpdHht8RBh8VhG9Hub9Gd3+HHNVHoB qkmzEGjGTTCTzsTLLScTOabHi33N1OpJxrWaEItY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230106083323eucas1p1a65f5682e8176e747042a06939916e1c~3qy6Zaafa1079910799eucas1p1N; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 50.A3.56180.3DCD7B36; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338~3qy6AgovI1079910799eucas1p1M; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230106083322eusmtrp2ce6bf037b828e56c769e14ab7c11768d~3qy5-wgci1128211282eusmtrp2E; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) X-AuditID: cbfec7f2-ab5ff7000000db74-a2-63b7dcd32d2f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FD.AB.52424.2DCD7B36; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230106083322eusmtip1c280cca29120352af56f70ae80405570~3qy50uWRv0965409654eusmtip1b; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Pankaj Raghav , Luis Chamberlain , Johannes Thumshirn Subject: [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start Date: Fri, 6 Jan 2023 09:33:16 +0100 Message-Id: <20230106083317.93938-7-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMKsWRmVeSWpSXmKPExsWy7djPc7qX72xPNvjwidNi9d1+NotpH34y W/w+e57ZYu+72awWNw/sZLLYs2gSk8XK1UeZLP523WOyOPPyM4vF3lvaFpd3zWGzmL/sKbvF jQlPGS0+L21htzhxS9qB3+PyFW+Py2dLPTat6mTz2Lyk3mP3zQY2j52t91k9zq509Hi/7yqb R9+WVYwem09Xe3zeJOfRfqCbKYAnissmJTUnsyy1SN8ugSvj+Z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CA X-RootMTR: 20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338 References: <20230106083317.93938-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754261549589577248?= X-GMAIL-MSGID: =?utf-8?q?1754261549589577248?= Use the bdev_offset_from_zone_start() helper function to calculate the offset from zone start instead of open coding. 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;