Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3771551rwa; Tue, 23 Aug 2022 09:51:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6E7W5f+QwyCdapUQKxn+T+eOaWfswrBM1H1vdR/B3vnq8GSGK/htXt4Z0amUrdvdB+qFgB X-Received: by 2002:a17:902:bd96:b0:172:e973:82af with SMTP id q22-20020a170902bd9600b00172e97382afmr10649450pls.126.1661273497701; Tue, 23 Aug 2022 09:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661273497; cv=none; d=google.com; s=arc-20160816; b=VbMk68DclZ8mtwzz3aF2WAvPPSqVXcbEl9aFc/HUynjMfs21ruO/7vHNMIfh6zww4S yy+7qUyeenCbqAbPqTodpLDfw2ZKVHiNWvmOWKpSEtsnDEtQotc1pkFI5bYXaxuUrhWS IoomnEGZ4nmdQOHrhNAa9V2x+u7n94Iwd7gEpabvj6d7apMVrQ78BarcaPGd56pBR2Yv BbOefwzyIPrcytBTup3y2++IdoaGXa+fZffPZdAay7GNTYcsYa2b5mkabDcsoePHslRW VKy5gMGSsg3bhsOPEkoQ5nkSNjtuy8DI4UuD/QI/2x4oJBaPzc/2HRr3U6sWYVPZxCw/ rRsA== 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=rIbhfxDBpj+Ii51tIIt4kTVb6ZA8NV8eQeaNrvmy2UQ=; b=nKq9sGiX4E2ZkzUV4MqIHcq5FE2pYkWtXh5fFtrkRWVhaYsuN7pXYspHQNP9QVJpCL aWSVgubGAAeZ5nCntlgD4jxFbus6Ir0vYh4DHgzP2lFDwOTB9mdPM71GRuylRsQ+/30y hsbO/Gu1si6NzffPQpoKnuL8I5Zj5mVQWPtOhgmRIJKqEYxvwojxrwRJPxfu2JdLJFMR NDfCdVx2R/3w8vcs44IuLzGjtRz6y/Sbch1UPIEJzRRwLEE/AT69K3Ggy9+1AZvD0LUB 737lDs/GxjmkjyMHZ287NbitVpuqF8+432e93Trm2QCJlLsBkc4xzN6YuTKwVFNP+sII BrIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QDYBnL0I; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a170902e88800b00164179b39acsi17704469plg.556.2022.08.23.09.51.26; Tue, 23 Aug 2022 09:51:37 -0700 (PDT) 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=QDYBnL0I; 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 S244663AbiHWQRJ (ORCPT + 99 others); Tue, 23 Aug 2022 12:17:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244519AbiHWQQX (ORCPT ); Tue, 23 Aug 2022 12:16:23 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1DC932E0AC for ; Tue, 23 Aug 2022 05:37:44 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220823121913euoutp02a5c15fb22a1295c2aa4ea2f4c78d9f03~N_JRpwPTj2196021960euoutp02U for ; Tue, 23 Aug 2022 12:19:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220823121913euoutp02a5c15fb22a1295c2aa4ea2f4c78d9f03~N_JRpwPTj2196021960euoutp02U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661257153; bh=rIbhfxDBpj+Ii51tIIt4kTVb6ZA8NV8eQeaNrvmy2UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QDYBnL0I55ydiY9ytKg4wIQEGbO7TOIAPlS4EMJ/3NOGYKVFP1Syf6RzD3CRBucZ8 +1FY74lj3xHIPFGlkYwTXf4uuMbfu50tZOw2idqKB7P3k/1VvTWG0HEWVIKGEDpjrF NyppSzCJiWFdgjWuDkN5TP/kewZ2s2jxQKRuV7yE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220823121911eucas1p26e219dbed47a96dc011f86fd44abc605~N_JPm1vMJ2020620206eucas1p2X; Tue, 23 Aug 2022 12:19:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 00.81.07817.FB5C4036; Tue, 23 Aug 2022 13:19:11 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220823121911eucas1p2a55dec72a6d780123e6c7655aee72457~N_JPEV8ZX2414724147eucas1p2S; Tue, 23 Aug 2022 12:19:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220823121911eusmtrp2afea96fe5b8dcf30d79ea00d23578530~N_JPDk_xU2723427234eusmtrp2i; Tue, 23 Aug 2022 12:19:11 +0000 (GMT) X-AuditID: cbfec7f4-8abff70000011e89-6c-6304c5bfed2e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B8.12.07473.EB5C4036; Tue, 23 Aug 2022 13:19:10 +0100 (BST) Received: from localhost (unknown [106.210.248.52]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220823121910eusmtip123314f6a15e89198c1d6e2955b763163~N_JOvE2mn0871108711eusmtip1s; Tue, 23 Aug 2022 12:19:10 +0000 (GMT) From: Pankaj Raghav To: agk@redhat.com, snitzer@kernel.org, axboe@kernel.dk, damien.lemoal@opensource.wdc.com, hch@lst.de Cc: pankydev8@gmail.com, Johannes.Thumshirn@wdc.com, linux-block@vger.kernel.org, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, linux-kernel@vger.kernel.org, matias.bjorling@wdc.com, gost.dev@samsung.com, bvanassche@acm.org, linux-nvme@lists.infradead.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v12 09/13] dm-zone: use generic helpers to calculate offset from zone start Date: Tue, 23 Aug 2022 14:18:55 +0200 Message-Id: <20220823121859.163903-10-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220823121859.163903-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAKsWRmVeSWpSXmKPExsWy7djPc7r7j7IkG0yepmax/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2PZ 4W/MBR3cFVffKzUw9nJ2MXJwSAiYSOxeyN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w2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBOlZ1OUX1qSqpCRX1xiqxRt aGGkZ2hpoWdkYqlnaGwea2VkqqRvZ5OSmpNZllqkb5egl7Hs8Dfmgg7uiqvvlRoYezm7GDk5 JARMJHreHGTtYuTiEBJYyijx+HIHI0RCQuL2wiYoW1jiz7UuNoiiZ4wS+w7sYepi5OBgE9CS aOxkB6kREciVOLx5AhNIDbPAGyaJo/9aWEESwgLREl9fX2UBsVkEVCWunLnDBtLLK2At8eue DMR8eYmZl76DzeEECs9begpsr5CAlcT8W5/YQGxeAUGJkzOfgI1hBqpv3jqbeQKjwCwkqVlI UgsYmVYxiqSWFuem5xYb6hUn5haX5qXrJefnbmIERu62Yz8372Cc9+qj3iFGJg7GQ4wSHMxK IrzVFxmShXhTEiurUovy44tKc1KLDzGaAp09kVlKNDkfmDrySuINzQxMDU3MLA1MLc2MlcR5 PQs6EoUE0hNLUrNTUwtSi2D6mDg4pRqY1BvPSf2NmpW9buOHB/tX9Wg9tTbf8Wsx16SOjJiX LRdOK3P8KHX+7/9gIdtVxxBuV/1Q/oI7DzeGxgTfWK6t90nTgFuomzPeZEGUzYMjFx+GuYqt clpYW+mmtE6SZZuIQFppzkuVqRVXWYp+v7/KlHeyT4lt35Y1AR82Fq1jc/+3IvvY7+nLnp1u fpDI2cWtPXX16vAjcw8lXstQKXi8/Lze18h/7qXpHBn3HT1rloU8/HTc3+1+O8PSfWXnLi1J 46yqSzt3lv3i5p7nndNL5ja9ljCrWR060yZx35a2XafXG4j9vFM/P1TuUPTyt2eU6xfaLw++ 1Gs4ZcsOTY339vvWdHpPnfihVUfXv3p1mxJLcUaioRZzUXEiADrLlrllAwAA X-CMS-MailID: 20220823121911eucas1p2a55dec72a6d780123e6c7655aee72457 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220823121911eucas1p2a55dec72a6d780123e6c7655aee72457 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220823121911eucas1p2a55dec72a6d780123e6c7655aee72457 References: <20220823121859.163903-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, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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; -- 2.25.1