Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp474212imn; Wed, 27 Jul 2022 11:12:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t0M/iDpu8z36s5nLACvFlU+bW2/VrkfzgeFZQ2o6tk9+zS/nrRmytOxLl5pcO+uZKi7jGW X-Received: by 2002:a05:6402:194d:b0:43b:f21b:e9f4 with SMTP id f13-20020a056402194d00b0043bf21be9f4mr18039510edz.180.1658945552275; Wed, 27 Jul 2022 11:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658945552; cv=none; d=google.com; s=arc-20160816; b=Uqsr1Aa2CGGWmR5hfO/9C80UiYqYyDVr7y4UGoKzJL9Lb6QV/gTGx/DgkK2BozI0Uh bX18cGYtb1wiu6lP3zOt9kTGBGMxuELI2upSCsQxd1fmyuulLVGxhCtGKvBornttLkwU zi+/BtMBwQgFL6nUlyb5Pm5cK+C0uVp0QvUUxjevOV38J3Ie5uLkzvxC7kUJ3TQUn+rz clXjM30SSTJX6duu7iP131peukJiJ+4HoMuxoNWedlfekP8mCYPRBp06Fwu6NspKSgK7 kM6huPB00lr+B57ukOTskEXUiGAamS3/IQGxj3AB/ggCWitfQTjHzaCxdILkYQInC0De 4BsA== 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=w5O8BVNbekPWS0uTFULfAlhiPgH30QywlTHY/GvNI4U=; b=KqYjWxVZt9cJXpDqaRVFuc7hejfzkaPib68mno8PawpadaxqVl3z05NQVoiukUqPTX cDjbTDOVYxB6oAidvWodrcEeDI5h+E899drD31OV3uMzj/zTQruhHGWDgL+TlkubI4DH +iby900v8P2xLQ29ePchvLJBcdZyIK1FK7QyJ5AzhsDwidtw677vPpiOZLfONgrDdY60 jTwOWXeM0gzwdgCS9aWT2qq1ViIhQQYeFZBbPzwaplV7nGf/R2u3vWkN/yWwEm74c5d4 HxMV47YAAFJeiDL+F6bdJgGcdOpKQPtCS8vMVQInuAJoXnlkjkfOe3/hxYiVZcNH2Sgp dWIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=cA3D1ANX; 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 m13-20020a170906848d00b0072b13fa7314si12645335ejx.439.2022.07.27.11.12.05; Wed, 27 Jul 2022 11:12:32 -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=cA3D1ANX; 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 S235972AbiG0QZM (ORCPT + 99 others); Wed, 27 Jul 2022 12:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236252AbiG0QYT (ORCPT ); Wed, 27 Jul 2022 12:24:19 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62D094E614 for ; Wed, 27 Jul 2022 09:23:14 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220727162256euoutp012b48621e8c9ba27010ef5ed877196938~FvDW1rwlF2487524875euoutp01w for ; Wed, 27 Jul 2022 16:22:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220727162256euoutp012b48621e8c9ba27010ef5ed877196938~FvDW1rwlF2487524875euoutp01w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658938976; bh=w5O8BVNbekPWS0uTFULfAlhiPgH30QywlTHY/GvNI4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cA3D1ANXcWA/rH5h2KjUSuHkVXTo/XeE9N9GDtTqRgvDpdJhytcc3g0b/g5LQEWdu k7VCRjMZDtr2JDr0durIrT3c8kETMYngI+T3o7Z+dy8gcQwJxYfZFLHBZEpSZj/iC/ s85tBllNt5V7zzKkmObvEJd/DFWcet2AIUfhf+5s= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220727162255eucas1p270f1762da9a9d8a41d40bde0664f9b65~FvDVcfZl82220522205eucas1p28; Wed, 27 Jul 2022 16:22:55 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 28.E8.09580.F5661E26; Wed, 27 Jul 2022 17:22:55 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220727162254eucas1p1fd990f746d9f9870b8d58ee0bd01fedd~FvDVEOET21345313453eucas1p1m; Wed, 27 Jul 2022 16:22:54 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220727162254eusmtrp1ea1f3eb33ea28187ca0b488efe6d40d1~FvDVCBW6T0298902989eusmtrp1P; Wed, 27 Jul 2022 16:22:54 +0000 (GMT) X-AuditID: cbfec7f5-9adff7000000256c-e7-62e1665f73bc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 99.8D.09038.E5661E26; Wed, 27 Jul 2022 17:22:54 +0100 (BST) Received: from localhost (unknown [106.210.248.8]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220727162254eusmtip16a6354516571bc22aef68af1faaca7ef~FvDUtVvM_0065000650eusmtip1G; Wed, 27 Jul 2022 16:22:54 +0000 (GMT) From: Pankaj Raghav To: damien.lemoal@opensource.wdc.com, hch@lst.de, axboe@kernel.dk, snitzer@kernel.org, Johannes.Thumshirn@wdc.com Cc: matias.bjorling@wdc.com, gost.dev@samsung.com, linux-kernel@vger.kernel.org, hare@suse.de, linux-block@vger.kernel.org, pankydev8@gmail.com, bvanassche@acm.org, jaegeuk@kernel.org, dm-devel@redhat.com, linux-nvme@lists.infradead.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v8 08/11] dm-zone: use generic helpers to calculate offset from zone start Date: Wed, 27 Jul 2022 18:22:42 +0200 Message-Id: <20220727162245.209794-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220727162245.209794-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLKsWRmVeSWpSXmKPExsWy7djPc7rxaQ+TDFZuZrZYfbefzWLah5/M Fr/Pnme22PtuNqvFzQM7mSz2LJrEZLFy9VEmiyfrZzFb/O26x2Sx95a2xeVdc9gs5i97ym4x oe0rs8WNCU8ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDLeXzzNWnCe q2L+j80sDYzXOboYOTkkBEwkLrcsYQexhQRWMEpMnSLWxcgFZH9hlJh46TAbhPOZUeJQ+1lm mI4PtyaxQiSW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qzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAnii9GyK8ktLUhUy8otLbJWiDS2M9Awt LfSMTCz1DI3NY62MTJX07WxSUnMyy1KL9O0S9DLeXzzNWnCeq2L+j80sDYzXOboYOTkkBEwk PtyaxApiCwksZZS4s8wUIi4hcXthEyOELSzx51oXWxcjF1DNU0aJP3O3sXcxcnCwCWhJNHaC mSIClRJnv8iClDALnGOSuHnxGhtIr7BAlMSmL/eZQGwWAVWJpm03wXbxClhJ7Nj7iRlivrzE zEvf2UFsTgFric1T5jFB3GMl8ezBRzaIekGJkzOfsIDYzED1zVtnM09gFJiFJDULSWoBI9Mq RpHU0uLc9NxiI73ixNzi0rx0veT83E2MwHjdduznlh2MK1991DvEyMTBeIhRgoNZSYQ3Ifp+ khBvSmJlVWpRfnxRaU5q8SFGU6C7JzJLiSbnAxNGXkm8oZmBqaGJmaWBqaWZsZI4r2dBR6KQ QHpiSWp2ampBahFMHxMHp1QDk0331ldGj1tDHp2wZy2qWFu/4cXNjveJF0vkP7NMY1H85pnH dLzr6ZvWrAvq9yMjZvffZytx8H/h475VmTfq/nRd2X+PEiS++vcYGp1Wv5EYd9lMZ3u306u5 S+8EvFFe5eE21fHbSZZ9WvuDd08vPNA4O/DUhDxdzcSlbOEXJrmnZP85UVi4da0Dq+G9Nao7 QoytN3339kta7979jeNTvz9PV5Xlzakiv4/VeiSKvJew5/vEc2DFK3flVRf4v4emXRFL2pny JbeWa1U4Vx6zmJq32EbNtYu1Ih8X7xXKSczukFCqbF3rNfGs3vo3TteC586/tnXZNQPfC84b d4p9+rTEQcdk4f8jvducBK2YlFiKMxINtZiLihMBaWW7FWADAAA= X-CMS-MailID: 20220727162254eucas1p1fd990f746d9f9870b8d58ee0bd01fedd X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220727162254eucas1p1fd990f746d9f9870b8d58ee0bd01fedd X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220727162254eucas1p1fd990f746d9f9870b8d58ee0bd01fedd References: <20220727162245.209794-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.7 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 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 --- drivers/md/dm-zone.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 3dafc0e8b7a9..31c16aafdbfc 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -390,7 +390,9 @@ 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 +604,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