From patchwork Tue Aug 16 13:15:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944911 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 A68CCC25B0E for ; Tue, 16 Aug 2022 13:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234022AbiHPNPt (ORCPT ); Tue, 16 Aug 2022 09:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231960AbiHPNPp (ORCPT ); Tue, 16 Aug 2022 09:15:45 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 116705A82B for ; Tue, 16 Aug 2022 06:15:42 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131540euoutp024b3b72f74b076d46af8280970e058e55~L1ZkQbwzK2470324703euoutp02h for ; Tue, 16 Aug 2022 13:15:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220816131540euoutp024b3b72f74b076d46af8280970e058e55~L1ZkQbwzK2470324703euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655741; bh=AD8v/RK3vFIqsgabYiTtVZbPbcAOQ4zUOz/AmbfbvbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dYyKZA123aDKiTjZZO+uI37rOfEKyULct3Zl6s9XnlhQlb3/lN5lcEhAER3/roNBg fMiTKMZAynq6Xf2XhVsDLtZ6+V5xXwWOJeYuEebr0KvGiJU9lKC8gSu3Cn3T5lerjQ v6kKmqoyYG/knT+dY62H1nd2dOukeH0b3660ZwI0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220816131539eucas1p26d86a5a1304108a25edff82219a984be~L1ZiaG4wu1906819068eucas1p2w; Tue, 16 Aug 2022 13:15:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 5F.93.09664.A789BF26; Tue, 16 Aug 2022 14:15:38 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131538eucas1p173e1c91bada451ae8a37d5b4ba3550b0~L1Zh8-0O_0140201402eucas1p1T; Tue, 16 Aug 2022 13:15:38 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131538eusmtrp1dfb31e16cfbde621e18d525b910130f4~L1Zh8CkPw0149801498eusmtrp19; Tue, 16 Aug 2022 13:15:38 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-ff-62fb987ae852 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 99.A0.09095.A789BF26; Tue, 16 Aug 2022 14:15:38 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220816131538eusmtip2f55ebca3bea1379ed12c7563f930fe9d~L1ZhpwYZX1242312423eusmtip2t; Tue, 16 Aug 2022 13:15:38 +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 , Adam Manzanares Subject: [PATCH v11 01/13] block: make bdev_nr_zones and disk_zone_no generic for npo2 zone size Date: Tue, 16 Aug 2022 15:15:24 +0200 Message-Id: <20220816131536.189406-2-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+NgFnrBKsWRmVeSWpSXmKPExsWy7djPc7pVM34nGdzYb24x/bCixfpTx5gt Vt/tZ7OY9uEns8Xvs+eZLfa+m81qcfPATiaLPYsmMVmsXH2UyeLJ+lnMFn+77jFZ7L2lbXF5 1xw2i/nLnrJbTGj7ymxxY8JTRovPS1vYLdbcfMpiceKWtIOwx+Ur3h47Z91l97h8ttRj06pO No/NS+o9dt9sYPPY2Xqf1eP9vqtsHn1bVjF6bD5d7fF5k5xH+4FupgCeKC6blNSczLLUIn27 BK6Mv1PbmQquilQ8m/CKrYFxlmAXIyeHhICJxJwXL5m6GLk4hARWMErMvXOcDcL5wiixf/5h FgjnM6PEusOLWWBabj/8wwqRWM4oMWfmGqiWF4wS8z9+BnI4ONgEtCQaO9lBGkQE0iWmtLwE m8Qs0MUscffmcbCEsECSxNsbB5lBbBYBVYmFHUvZQXp5Bawk2ve5QiyTl5h56TtYOaeAtcS/ hlVgR/AKCEqcnPkEzGYGqmneOpsZZL6EwG5OiQ2XJjBCNLtIrLl9nQnCFpZ4dXwLO4QtI3F6 cg/UN9UST2/8hmpuYZTo37ke7AEJoG19Z3JATGYBTYn1u/Qhyh0luvYtYoGo4JO48VYQ4gQ+ iUnbpjNDhHklOtqEIKqVJHb+fAK1VELictMcqKUeEtsf3GKZwKg4C8kzs5A8Mwth7wJG5lWM 4qmlxbnpqcWGeanlesWJucWleel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 SFKzkKQWMDKtYhRJLS3OTc8tNtQrTswtLs1L10vOz93ECIzhbcd+bt7BOO/VR71DjEwcjIcY JTiYlUR4BV/8SBLiTUmsrEotyo8vKs1JLT7EaAp09kRmKdHkfGASySuJNzQzMDU0MbM0MLU0 M1YS5/Us6EgUEkhPLEnNTk0tSC2C6WPi4JRqYDKVOCt+IvKjxbubL7tXMXBf3RXzKXORndlD +YCfRWW/X3v7BbO83/OXwSKtU+tG19asLIc9LBN+76lLeCDqtX+JVbBs+3z+JW0fbJfo1e+M mnTA+Cn/2d3R999KmFl9s3Hg0D3RJXvv8isZ/c86fL0yy7PW2QRsmzDHuFNu1q0zjzcq5y7R EdkgpiB79utSh/huy6UN6iu8tX/Wtf8JfNx3cu/tHUFOGu+mWsewBbDo/0jrDly69O7K9suv 3T4WBtQuMHghzMS94SvvlUb1itQTbx74FscISHNfLctcZbZOiL8/9XpIx1YLu/jzVV8TMoL0 tgdqPawzlV7z2/HI3cgYtyi1h7o7A165L7lVqcRSnJFoqMVcVJwIALROnPtqAwAA X-CMS-MailID: 20220816131538eucas1p173e1c91bada451ae8a37d5b4ba3550b0 X-Msg-Generator: CA X-RootMTR: 20220816131538eucas1p173e1c91bada451ae8a37d5b4ba3550b0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131538eucas1p173e1c91bada451ae8a37d5b4ba3550b0 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Adapt bdev_nr_zones and disk_zone_no functions so that they can also work for non-power-of-2 zone sizes. As the existing deployments assume that a device zone size is a power of 2 number of sectors, power-of-2 optimized calculation is used for those devices. There are no direct hot paths modified and the changes just introduce one new branch per call. Reviewed-by: Luis Chamberlain Reviewed-by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav Reviewed-by: Bart Van Assche --- block/blk-zoned.c | 13 +++++++++---- include/linux/blkdev.h | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/block/blk-zoned.c b/block/blk-zoned.c index a264621d4905..dce9c95b4bcd 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -111,17 +111,22 @@ EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock); * bdev_nr_zones - Get number of zones * @bdev: Target device * - * Return the total number of zones of a zoned block device. For a block - * device without zone capabilities, the number of zones is always 0. + * Return the total number of zones of a zoned block device, including the + * eventual small last zone if present. For a block device without zone + * capabilities, the number of zones is always 0. */ unsigned int bdev_nr_zones(struct block_device *bdev) { sector_t zone_sectors = bdev_zone_sectors(bdev); + sector_t capacity = bdev_nr_sectors(bdev); if (!bdev_is_zoned(bdev)) return 0; - return (bdev_nr_sectors(bdev) + zone_sectors - 1) >> - ilog2(zone_sectors); + + if (is_power_of_2(zone_sectors)) + return (capacity + zone_sectors - 1) >> ilog2(zone_sectors); + + return DIV_ROUND_UP_SECTOR_T(capacity, zone_sectors); } EXPORT_SYMBOL_GPL(bdev_nr_zones); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 84b13fdd34a7..ab82d1ff0cce 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -674,9 +674,15 @@ static inline unsigned int disk_nr_zones(struct gendisk *disk) static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) { + sector_t zone_sectors = disk->queue->limits.chunk_sectors; + if (!blk_queue_is_zoned(disk->queue)) return 0; - return sector >> ilog2(disk->queue->limits.chunk_sectors); + + if (is_power_of_2(zone_sectors)) + return sector >> ilog2(zone_sectors); + + return div64_u64(sector, zone_sectors); } static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector) From patchwork Tue Aug 16 13:15:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944912 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 2CE9BC3F6B0 for ; Tue, 16 Aug 2022 13:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232707AbiHPNPv (ORCPT ); Tue, 16 Aug 2022 09:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231701AbiHPNPp (ORCPT ); Tue, 16 Aug 2022 09:15:45 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC0065A3E3 for ; Tue, 16 Aug 2022 06:15:43 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131542euoutp01fe9ac6ed1cbbc3cfabb25bb197520ac4~L1ZlhMmlk0135401354euoutp01E for ; Tue, 16 Aug 2022 13:15:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131542euoutp01fe9ac6ed1cbbc3cfabb25bb197520ac4~L1ZlhMmlk0135401354euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655742; bh=6P1R/E9YGiOBn04IzPo5prb2SpaL2SRQk5AKU4iXtGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rxgJrkYmDNav+8n2hLlQSMbGqvsoS5yLZ7lvDF37BQmATyOjPJvL4foUtDzFWipuT 62pm3nFi2KJnBNHA/sPQOieqcBc9vm1IJPUiOcajbr7B1K2IdtKO0cINXhSRUqZrAA xTDj7NJ5kq+e1WqF1EQ8q4Q7XmUV4Gy2ml87SsQU= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220816131540eucas1p226ff379faf0d84c5021a3cd93e20489c~L1Zjq9F3J3098130981eucas1p2A; Tue, 16 Aug 2022 13:15:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 7B.65.09580.C789BF26; Tue, 16 Aug 2022 14:15:40 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131539eucas1p171840f8cb3a2983274fce0322c0f4901~L1Zi8uyZc0141901419eucas1p1P; Tue, 16 Aug 2022 13:15:39 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220816131539eusmtrp2842c1f8d2fd4e4b1b2aa3d3368f5a790~L1Zi7syvS0621306213eusmtrp2B; Tue, 16 Aug 2022 13:15:39 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-da-62fb987ccf45 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DB.21.09038.B789BF26; Tue, 16 Aug 2022 14:15:39 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220816131539eusmtip24b3a859c602c2943e28d2ca0379f9d29~L1Ziif3yT1196811968eusmtip2Z; Tue, 16 Aug 2022 13:15:39 +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 Subject: [PATCH v11 02/13] block:rearrange bdev_{is_zoned,zone_sectors,get_queue} helpers in blkdev.h Date: Tue, 16 Aug 2022 15:15:25 +0200 Message-Id: <20220816131536.189406-3-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+NgFrrPKsWRmVeSWpSXmKPExsWy7djP87o1M34nGXzbzWex/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW3xe2sJusebmUxaLE7ekHQQ9Ll/x9tg56y67x+WzpR6bVnWyeWxeUu+x+2YD m8fO1vusHu/3XWXz6NuyitFj8+lqj8+b5DzaD3QzBfBEcdmkpOZklqUW6dslcGWsPHKJpeCF aMWT05fYGhhnC3UxcnBICJhINB4s7WLk4hASWMEoMfFGNyuE84VR4sikz0wQzmdGia2v7zB2 MXKCdZxb28AOkVjOKLF+1VI2COcFUP/p60wgc9kEtCQaO9lBGkQE0iWmtLxkAalhFtjGJPHm 0gSwScJAic+HT7KA2CwCqhJfL20Bs3kFrCQmbnzOBLFNXmLmpe9ggzgFrCX+NayCqhGUODnz CZjNDFTTvHU2M8gCCYH1nBJre5YyQzS7SMx/PYkFwhaWeHV8CzuELSPxf+d8qAXVEk9v/IZq bmGU6N+5ng0SMtYSfWdyQExmAU2J9bv0IcodJdbc3s0MUcEnceOtIMQJfBKTtk2HCvNKdLQJ QVQrSez8+QRqqYTE5aY5UMd4SHzdfoFlAqPiLCTPzELyzCyEvQsYmVcxiqeWFuempxYb56WW 6xUn5haX5qXrJefnbmIEpsHT/45/3cG44tVHvUOMTByMhxglOJiVRHgFX/xIEuJNSaysSi3K jy8qzUktPsQozcGiJM6bnLkhUUggPbEkNTs1tSC1CCbLxMEp1cBU9GuJ8ZnCSW0vfyxwPDN1 pthcjp+W/Jf7/zLJrMq03cd8PGxdfH3Ik92R069MP786dZ3694v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91i/GtVFwy29mDvG5v/7FeC14rHJDL+w2 X8mKNSVtG/VuXNQxyOwMXluuVqG/eX3BNvN7e+Zunm3jtbM56VrR2Z3t9/pV1zw/+eFq0V4b o8KeNceVzIU+fZ90Lrn45INjzYpr10yx7sjjzwrp0M/tXl7f1H76S/ikS46Rb/+GinqdZXfJ 3m0za4/p2iNanHO7RTezLRFZvOO4yuZNhffKJk0qNAo4dqLwZ4W5QuHf+UZtsXlnxAw3Kh48 fymVheN51p9rtd6d3ifkins3Vn7J1TANVmvO/5igNbUg8lRITc1ykZLHDX+tvcO/ysgczbuc d93q97tZ7Yw/5qcUXPl3YUvCViWW4oxEQy3mouJEANnt15lhAwAA X-CMS-MailID: 20220816131539eucas1p171840f8cb3a2983274fce0322c0f4901 X-Msg-Generator: CA X-RootMTR: 20220816131539eucas1p171840f8cb3a2983274fce0322c0f4901 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131539eucas1p171840f8cb3a2983274fce0322c0f4901 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Define bdev_is_zoned(), bdev_zone_sectors() and bdev_get_queue() earlier in the blkdev.h include file. Simplify bdev_is_zoned() by removing the superfluous NULL check for request queue while we are at it. This commit has no functional change, and it is a prep patch for allowing zoned devices with non-power-of-2 zone sizes in the block layer. Signed-off-by: Pankaj Raghav Reviewed-by: Damien Le Moal --- include/linux/blkdev.h | 43 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ab82d1ff0cce..84e7881262e3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -635,6 +635,11 @@ static inline bool queue_is_mq(struct request_queue *q) return q->mq_ops; } +static inline struct request_queue *bdev_get_queue(struct block_device *bdev) +{ + return bdev->bd_queue; /* this is never NULL */ +} + #ifdef CONFIG_PM static inline enum rpm_status queue_rpm_status(struct request_queue *q) { @@ -666,6 +671,20 @@ static inline bool blk_queue_is_zoned(struct request_queue *q) } } +static inline bool bdev_is_zoned(struct block_device *bdev) +{ + return blk_queue_is_zoned(bdev_get_queue(bdev)); +} + +static inline sector_t bdev_zone_sectors(struct block_device *bdev) +{ + struct request_queue *q = bdev_get_queue(bdev); + + if (!blk_queue_is_zoned(q)) + return 0; + return q->limits.chunk_sectors; +} + #ifdef CONFIG_BLK_DEV_ZONED static inline unsigned int disk_nr_zones(struct gendisk *disk) { @@ -892,11 +911,6 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags); int iocb_bio_iopoll(struct kiocb *kiocb, struct io_comp_batch *iob, unsigned int flags); -static inline struct request_queue *bdev_get_queue(struct block_device *bdev) -{ - return bdev->bd_queue; /* this is never NULL */ -} - /* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond); @@ -1296,25 +1310,6 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) return BLK_ZONED_NONE; } -static inline bool bdev_is_zoned(struct block_device *bdev) -{ - struct request_queue *q = bdev_get_queue(bdev); - - if (q) - return blk_queue_is_zoned(q); - - return false; -} - -static inline sector_t bdev_zone_sectors(struct block_device *bdev) -{ - struct request_queue *q = bdev_get_queue(bdev); - - if (!blk_queue_is_zoned(q)) - return 0; - return q->limits.chunk_sectors; -} - static inline int queue_dma_alignment(const struct request_queue *q) { return q ? q->dma_alignment : 511; From patchwork Tue Aug 16 13:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944914 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 314F2C2BB41 for ; Tue, 16 Aug 2022 13:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232357AbiHPNPw (ORCPT ); Tue, 16 Aug 2022 09:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232696AbiHPNPt (ORCPT ); Tue, 16 Aug 2022 09:15:49 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEDEE5A2F7 for ; Tue, 16 Aug 2022 06:15:44 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131543euoutp01e7685faed0e8a7bfc09d1705ab73c483~L1ZmcbKZ80139901399euoutp01B for ; Tue, 16 Aug 2022 13:15:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131543euoutp01e7685faed0e8a7bfc09d1705ab73c483~L1ZmcbKZ80139901399euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655743; bh=OX60KjudRLvNZCiTdE3cUfkGk6srYbDq6kJdBqLbD0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uU1GTasffkW5v4q0SUtLabNzjfCdmTP9DxvPnnHDR8LKFvl622BbY7M+Xfabgr/pA 8/yhfbjv+k+oBaqpCsQg7Ix1IEP7nGWYeOgsyVtf+yO5fVNxKnbiWDmCzQk25cA2m+ JQualadWQzpyxv1OJZ7jOlZInPta8xAopMYlef4g= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220816131541eucas1p2aff989b25c95badd2db9213297931e91~L1Zk4YiuE0840008400eucas1p2-; Tue, 16 Aug 2022 13:15:41 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 9C.65.09580.D789BF26; Tue, 16 Aug 2022 14:15:41 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220816131540eucas1p2f8d8579f4050da3257ee0150c194e0af~L1ZkKcmr00994909949eucas1p2R; Tue, 16 Aug 2022 13:15:40 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220816131540eusmtrp2819aada079e9a6630d3566cedda642fe~L1ZkJjO1F0621306213eusmtrp2F; Tue, 16 Aug 2022 13:15:40 +0000 (GMT) X-AuditID: cbfec7f5-9adff7000000256c-dd-62fb987d91d4 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 8D.21.09038.C789BF26; Tue, 16 Aug 2022 14:15:40 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220816131540eusmtip20d307f27b4dd6b50de556d5484750539~L1ZjzaQhb1363513635eusmtip2g; Tue, 16 Aug 2022 13:15:40 +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 03/13] block: allow blk-zoned devices to have non-power-of-2 zone size Date: Tue, 16 Aug 2022 15:15:26 +0200 Message-Id: <20220816131536.189406-4-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220816131536.189406-1-p.raghav@sams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OvTs nSkd4ufOL7FZXnNx+sTlOSVmz29IOTN9ubLi/d+rNen5wn9LA9xZ3t9n28CaMfGMiFd0B/um ffN+XGvzndx44+aCSd0ykb+fXTy0OHaHCdMPndoVzlkvdrxOYus7sdZr3UGP3gmXRF1KZ3T1 BHz6WFg4PTOh+5fdjejKFInnvzuPe6+P+VZ0ft6PrbGOUmKT7L8oVq/QyfU4Em36wdi5nXOq 1Opwm3bnif1TrRyyPTJ/T+SseP2t/Y3Wzk4lluKMREMt5qLiRAC1x/4eZgMAAA== X-CMS-MailID: 20220816131540eucas1p2f8d8579f4050da3257ee0150c194e0af X-Msg-Generator: CA X-RootMTR: 20220816131540eucas1p2f8d8579f4050da3257ee0150c194e0af X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131540eucas1p2f8d8579f4050da3257ee0150c194e0af References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Checking if a given sector is aligned to a zone is a common operation that is performed for zoned devices. Add bdev_is_zone_start helper to check for this instead of opencoding it everywhere. Convert the calculations on zone size to be generic instead of relying on power-of-2(po2) based arithmetic in the block layer using the helpers wherever possible. The only hot path affected by this change for zoned devices with po2 zone size is in blk_check_zone_append() but bdev_is_zone_start() helper is used to optimize the calculation for po2 zone sizes. Finally, allow zoned devices with non po2 zone sizes provided that their zone capacity and zone size are equal. The main motivation to allow zoned devices with non po2 zone size is to remove the unmapped LBA between zone capcity and zone size for devices that cannot have a po2 zone capacity. Reviewed-by: Luis Chamberlain Reviewed-by: Hannes Reinecke Reviewed-by: Bart Van Assche Signed-off-by: Pankaj Raghav --- block/blk-core.c | 2 +- block/blk-zoned.c | 24 ++++++++++++++++++------ include/linux/blkdev.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index a0d1104c5590..1cb519220ffb 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -563,7 +563,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q, return BLK_STS_NOTSUPP; /* The bio sector must point to the start of a sequential zone */ - if (bio->bi_iter.bi_sector & (bdev_zone_sectors(bio->bi_bdev) - 1) || + if (!bdev_is_zone_start(bio->bi_bdev, bio->bi_iter.bi_sector) || !bio_zone_is_seq(bio)) return BLK_STS_IOERR; diff --git a/block/blk-zoned.c b/block/blk-zoned.c index dce9c95b4bcd..6806c69c81dc 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -285,10 +285,10 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op, return -EINVAL; /* Check alignment (handle eventual smaller last zone) */ - if (sector & (zone_sectors - 1)) + if (!bdev_is_zone_start(bdev, sector)) return -EINVAL; - if ((nr_sectors & (zone_sectors - 1)) && end_sector != capacity) + if (!bdev_is_zone_start(bdev, nr_sectors) && end_sector != capacity) return -EINVAL; /* @@ -486,14 +486,26 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx, * smaller last zone. */ if (zone->start == 0) { - if (zone->len == 0 || !is_power_of_2(zone->len)) { - pr_warn("%s: Invalid zoned device with non power of two zone size (%llu)\n", - disk->disk_name, zone->len); + if (zone->len == 0) { + pr_warn("%s: Invalid zero zone size", disk->disk_name); + return -ENODEV; + } + + /* + * Non power-of-2 zone size support was added to remove the + * gap between zone capacity and zone size. Though it is technically + * possible to have gaps in a non power-of-2 device, Linux requires + * the zone size to be equal to zone capacity for non power-of-2 + * zoned devices. + */ + if (!is_power_of_2(zone->len) && zone->capacity < zone->len) { + pr_err("%s: Invalid zone capacity %lld with non power-of-2 zone size %lld", + disk->disk_name, zone->capacity, zone->len); return -ENODEV; } args->zone_sectors = zone->len; - args->nr_zones = (capacity + zone->len - 1) >> ilog2(zone->len); + args->nr_zones = div64_u64(capacity + zone->len - 1, zone->len); } else if (zone->start + args->zone_sectors < capacity) { if (zone->len != args->zone_sectors) { pr_warn("%s: Invalid zoned device with non constant zone size\n", diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 84e7881262e3..d0d66a0db224 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -704,6 +704,30 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) return div64_u64(sector, zone_sectors); } +static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev, + sector_t sec) +{ + sector_t zone_sectors = bdev_zone_sectors(bdev); + u64 remainder = 0; + + if (!bdev_is_zoned(bdev)) + return 0; + + if (is_power_of_2(zone_sectors)) + return sec & (zone_sectors - 1); + + div64_u64_rem(sec, zone_sectors, &remainder); + return remainder; +} + +static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec) +{ + if (!bdev_is_zoned(bdev)) + return false; + + return bdev_offset_from_zone_start(bdev, sec) == 0; +} + static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector) { if (!blk_queue_is_zoned(disk->queue)) @@ -748,6 +772,12 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) { return 0; } + +static inline bool bdev_is_zone_start(struct block_device *bdev, sector_t sec) +{ + return false; +} + static inline unsigned int bdev_max_open_zones(struct block_device *bdev) { return 0; From patchwork Tue Aug 16 13:15:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944915 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 27BBDC32774 for ; Tue, 16 Aug 2022 13:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232782AbiHPNPx (ORCPT ); Tue, 16 Aug 2022 09:15:53 -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 S233175AbiHPNPt (ORCPT ); Tue, 16 Aug 2022 09:15:49 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615F45F213 for ; Tue, 16 Aug 2022 06:15:45 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131544euoutp02f91f0f4cdca8c94ae20d556942f953d8~L1ZnN5npA2682526825euoutp02G for ; Tue, 16 Aug 2022 13:15:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220816131544euoutp02f91f0f4cdca8c94ae20d556942f953d8~L1ZnN5npA2682526825euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655744; bh=tGdXrZOo82rW1rnRJeQcvmwRabixUhHDV5CM9X+9nHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OX6D6dlYQbFMtbD2VhiTAiNsHUHXNSsSybLVZN/G8Ypg9oh/VdhQHbTcHpRPl+CMw G3lOhGkLMybeXNuUKX+8JYS6a/tiozMx2AhRCl/4Cd02JMm3HlpANKnhulOkN6kpyS nwX2cGbNm31MkUETavuA7tFCFOymOkknEOyIwXsg= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220816131542eucas1p25ea333b0145dc2db4bea93399819c075~L1ZliQojs0372203722eucas1p20; Tue, 16 Aug 2022 13:15:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id ED.65.09580.E789BF26; Tue, 16 Aug 2022 14:15:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032~L1ZlEiMOm0141101411eucas1p1a; Tue, 16 Aug 2022 13:15:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131541eusmtrp112f9ecb9c4ed041e0ee37c232919a072~L1ZlDriu-0149801498eusmtrp1C; Tue, 16 Aug 2022 13:15:41 +0000 (GMT) X-AuditID: cbfec7f5-9adff7000000256c-df-62fb987e6c6b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5C.A0.09095.D789BF26; Tue, 16 Aug 2022 14:15:41 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131541eusmtip183589bb30aa83ccac3b2bcf6852af3fe~L1ZkxXq_W2694326943eusmtip1A; Tue, 16 Aug 2022 13:15:41 +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 , Johannes Thumshirn , Luis Chamberlain Subject: [PATCH v11 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Tue, 16 Aug 2022 15:15:27 +0200 Message-Id: <20220816131536.189406-5-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+NgFnrKKsWRmVeSWpSXmKPExsWy7djP87p1M34nGfQfE7RYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/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fQ5eF9Iu5xNnHLqpD11zAwZvHOXfzJnLNj46JnG/Ykl2/b8uqr3 4TGzXFbR8VVqRWm/XwYrWgpO/XhcUVOJpTgj0VCLuag4EQBKYnwZZQMAAA== X-CMS-MailID: 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032 X-Msg-Generator: CA X-RootMTR: 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131541eucas1p1a025fa0b664cb89a5c3f513863f69032 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org A generic bdev_zone_no() helper is added to calculate zone number for a given sector in a block device. This helper internally uses disk_zone_no() to find the zone number. Use the helper bdev_zone_no() to calculate nr of zones. This let's us make modifications to the math if needed in one place and adds now support for zoned devices with non po2 zone size. Reviewed by: Adam Manzanares Reviewed-by: Bart Van Assche Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/nvme/target/zns.c | 3 +-- include/linux/blkdev.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c index c7ef69f29fe4..662f1a92f39b 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -241,8 +241,7 @@ static unsigned long nvmet_req_nr_zones_from_slba(struct nvmet_req *req) { unsigned int sect = nvmet_lba_to_sect(req->ns, req->cmd->zmr.slba); - return bdev_nr_zones(req->ns->bdev) - - (sect >> ilog2(bdev_zone_sectors(req->ns->bdev))); + return bdev_nr_zones(req->ns->bdev) - bdev_zone_no(req->ns->bdev, sect); } static unsigned long get_nr_zones_from_buf(struct nvmet_req *req, u32 bufsize) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d0d66a0db224..b2636dcca105 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1340,6 +1340,11 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) return BLK_ZONED_NONE; } +static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec) +{ + return disk_zone_no(bdev->bd_disk, sec); +} + static inline int queue_dma_alignment(const struct request_queue *q) { return q ? q->dma_alignment : 511; From patchwork Tue Aug 16 13:15:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944918 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 0A409C28B2B for ; Tue, 16 Aug 2022 13:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234231AbiHPNPz (ORCPT ); Tue, 16 Aug 2022 09:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233412AbiHPNPt (ORCPT ); Tue, 16 Aug 2022 09:15:49 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDA0C5FF75 for ; Tue, 16 Aug 2022 06:15:46 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131545euoutp013975b485a7270542005550d7d2c5cdb9~L1ZowSwyI0139901399euoutp01F for ; Tue, 16 Aug 2022 13:15:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131545euoutp013975b485a7270542005550d7d2c5cdb9~L1ZowSwyI0139901399euoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655745; bh=EO928PFpmrq5sHaWlnNhp7CZXI/51IcH8DoHTWAcRM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+LjqtUaKQJ3mJLaXx06eFzSyrMT+xxCcdQ9SNPrLQQfy2OXCz4XaAdy9ix/Stsgt Cs9VxAdNg+viOpydOZh2z7t808qlySuEDUtgm85iS8gM4z0IMz26MPK4awM6gS6uQQ +THHJ02wNl1cr4AULcyhdCKipQsv1n8f4vT0FSdA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131544eucas1p13471fe76b92999809feb4dc6e73873ce~L1ZnEDab70549005490eucas1p19; Tue, 16 Aug 2022 13:15:44 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 2C.B7.10067.F789BF26; Tue, 16 Aug 2022 14:15:43 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131543eucas1p12fd75be0a752006267bbe2c5b3b1a444~L1ZmbG4zH0141101411eucas1p1c; Tue, 16 Aug 2022 13:15:43 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131543eusmtrp1ce374e143ed40b3fb8b3ad4feda88a32~L1ZmJw05K0149801498eusmtrp1F; Tue, 16 Aug 2022 13:15:42 +0000 (GMT) X-AuditID: cbfec7f4-dd7ff70000002753-15-62fb987f0dfc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id ED.A0.09095.E789BF26; Tue, 16 Aug 2022 14:15:42 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131542eusmtip1c4d8f6d05922324c8e9962539b0974ed~L1ZlxxJ302645326453eusmtip1d; Tue, 16 Aug 2022 13:15:42 +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 05/13] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size Date: Tue, 16 Aug 2022 15:15:28 +0200 Message-Id: <20220816131536.189406-6-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+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7r1M34nGVzttrJYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAldE/ ZS9TQaNIxdsZl5gaGM8IdDFyckgImEjcavzG3sXIxSEksIJRYvOKzawgCSGBL4wSnw7xQCQ+ M0rM2X2GDabj6aa3bBCJ5YwSXY9XMEI4LxglJr3bztTFyMHBJqAl0djJDtIgIpAuMaXlJQtI DbPAHSaJU++2giWEBaIlFk/6wQhiswioShzfPQNsNa+AlcSkJ99YILbJS8y89B2snlPAWuJf wyoWiBpBiZMzn4DZzEA1zVtnM4MskBDYzCkxd90yRohmF4mfH1dAnS0s8er4FnYIW0bi9OQe qAXVEk9v/I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sYoSwhSX+XOuCKnrGKHHr5hygIg4ONgEt icZOsHoRgVyJRcs6WEFqmAXeMEl8mP+JCSQhLBAp8bT/HZjNIqAqcXz3DFYQm1fASmLSk28s EAvkJWZe+g42iFPAWuJfwyqwuBBQTduxy8wQ9YISJ2c+AYszA9U3b53NPIFRYBaS1CwkqQWM TKsYRVJLi3PTc4sN9YoTc4tL89L1kvNzNzECo3fbsZ+bdzDOe/VR7xAjEwfjIUYJDmYlEV7B Fz+ShHhTEiurUovy44tKc1KLDzGaAt09kVlKNDkfmD7ySuINzQxMDU3MLA1MLc2MlcR5PQs6 EoUE0hNLUrNTUwtSi2D6mDg4pRqYGM4sWHNlgs+X+Zvd/tcrZ+y7cyTiiPY53byff5N/njx8 ZdHhez8sq+duPFkcm7qKj2EOZ3PO/1UFvEWR5ek6G/Lm6V4sKV7WLMXvPGspx2brW4drV7lJ xqX9eHpwn/X3ngmO1f6Hvn56IhXsP/f8/XpGuQdfLPkvZfSbvGpb/0HPqc7g0VMm2b18zU1M Z2rdblz/tHf6Prfyr3x/zY+73AoKT1OXY0/z3XT5lqmR0Ys2mbwCI6vf82531R+4m8OtvKfP 6Gr86fdP5S+EsFvzvTKwq3A0WLdC9onP9/tHT3Jf/hXIPUN/Q/X9VXbvurM+XwkI7l5b/OpI RGjgjQtabRe3WDR9Uqq9+ePbZe54FiWW4oxEQy3mouJEAMmD8ThnAwAA X-CMS-MailID: 20220816131543eucas1p12fd75be0a752006267bbe2c5b3b1a444 X-Msg-Generator: CA X-RootMTR: 20220816131543eucas1p12fd75be0a752006267bbe2c5b3b1a444 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131543eucas1p12fd75be0a752006267bbe2c5b3b1a444 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Remove the condition which disallows non-power_of_2 zone size ZNS drive to be updated and use generic method to calculate number of zones instead of relying on log and shift based calculation on zone size. The power_of_2 calculation has been replaced directly with generic calculation without special handling. Both modified functions are not used in hot paths, they are only used during initialization & revalidation of the ZNS device. As rounddown macro from math.h does not work for 32 bit architectures, round down operation is open coded. Reviewed-by: Luis Chamberlain Reviewed by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav --- drivers/nvme/host/zns.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 12316ab51bda..fe1d715d61cc 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -101,13 +101,6 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf) } ns->zsze = nvme_lba_to_sect(ns, le64_to_cpu(id->lbafe[lbaf].zsze)); - if (!is_power_of_2(ns->zsze)) { - dev_warn(ns->ctrl->device, - "invalid zone size:%llu for namespace:%u\n", - ns->zsze, ns->head->ns_id); - status = -ENODEV; - goto free_data; - } disk_set_zoned(ns->disk, BLK_ZONED_HM); blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); @@ -129,7 +122,7 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns, sizeof(struct nvme_zone_descriptor); nr_zones = min_t(unsigned int, nr_zones, - get_capacity(ns->disk) >> ilog2(ns->zsze)); + div64_u64(get_capacity(ns->disk), ns->zsze)); bufsize = sizeof(struct nvme_zone_report) + nr_zones * sizeof(struct nvme_zone_descriptor); @@ -182,6 +175,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, int ret, zone_idx = 0; unsigned int nz, i; size_t buflen; + u64 remainder = 0; if (ns->head->ids.csi != NVME_CSI_ZNS) return -EINVAL; @@ -197,7 +191,9 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, c.zmr.zrasf = NVME_ZRASF_ZONE_REPORT_ALL; c.zmr.pr = NVME_REPORT_ZONE_PARTIAL; - sector &= ~(ns->zsze - 1); + /* Round down the sector value to the nearest zone start */ + div64_u64_rem(sector, ns->zsze, &remainder); + sector -= remainder; while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) { memset(report, 0, buflen); From patchwork Tue Aug 16 13:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944916 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 E6877C25B0E for ; Tue, 16 Aug 2022 13:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235575AbiHPNPy (ORCPT ); Tue, 16 Aug 2022 09:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234231AbiHPNPu (ORCPT ); Tue, 16 Aug 2022 09:15:50 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 998B36050C for ; Tue, 16 Aug 2022 06:15:47 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131546euoutp010cc1067a0ba7027bece2113a942ad72d~L1ZpWsrEI2881628816euoutp01k for ; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131546euoutp010cc1067a0ba7027bece2113a942ad72d~L1ZpWsrEI2881628816euoutp01k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655746; bh=hLglEsgs8ISJExGYQKv645MJDunEKMqaZXVaT8ARNsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k8wPgQykHSBDfVQ2FnbeDy8kGcXDbZZLNSeoEK2iCUmQNpuLey9dlBwIL3LdpVA0m SFDxtiuDM9fPhZgHi630I8mNrYy024RH5mAPdUYRmWhIp4YzSmAlrAHSNIaCZU22Dd Xor9tswrDh5Fr7iIle9+KDqa+LuqWhRijX2VfQPo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131544eucas1p1c7b76e9abfcb2527a22590b7422d8bd8~L1ZniRo5z0141101411eucas1p1d; Tue, 16 Aug 2022 13:15:44 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 7D.B7.10067.0889BF26; Tue, 16 Aug 2022 14:15:44 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220816131544eucas1p24ce643970cc92636f9a42d24318ab051~L1ZnFOs7k0840008400eucas1p2D; Tue, 16 Aug 2022 13:15:44 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220816131544eusmtrp2f8b1f32559139fb423d630ae9a462c5b~L1ZnEb6z20621306213eusmtrp2K; Tue, 16 Aug 2022 13:15:44 +0000 (GMT) X-AuditID: cbfec7f4-dd7ff70000002753-17-62fb988086f5 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 4F.21.09038.F789BF26; Tue, 16 Aug 2022 14:15:43 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131543eusmtip13e675433a03a18e2d4a1a377f709840f~L1ZmySYCa2694326943eusmtip1B; Tue, 16 Aug 2022 13:15:43 +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 06/13] null_blk: allow zoned devices with non power-of-2 zone sizes Date: Tue, 16 Aug 2022 15:15:29 +0200 Message-Id: <20220816131536.189406-7-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+NgFnrMKsWRmVeSWpSXmKPExsWy7djPc7oNM34nGRw+KWWx/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2PW 7r/MBcelKx7O+8/ewLhcvIuRk0NCwETi9d4PzF2MXBxCAisYJZYsuMoK4XxhlLh+dBkjhPOZ UeLJrh3sMC3z5vazQySWM0pMn3UcynnBKDGt5yRLFyMHB5uAlkRjJ1iDiEC6xJSWlywgNcwC d5gkTr3byg5SIywQKdF61wWkhkVAVWLn7ftg9bwCVhIbPn5jhlgmLzHz0newOKeAtcS/hlUs EDWCEidnPgGzmYFqmrfOBvtBQmA7p8SHGcehLnWReHj0HROELSzx6vgWqLiMxP+d86Hi1RJP b/yGam5hlOjfuZ4N5DgJoG19Z3JATGYBTYn1u/Qhoo4SzyZmQph8EjfeCkJcwCcxadt0Zogw r0RHmxDEbCWJnT+fQO2UkLjcNIcFwvaQePV1CdMERsVZSH6ZheSXWQ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nq8DqhYBq2o5dZoaoF5Q4OfMJWJwZqL5562zmCYwCs5CkZiFJ LWBkWsUoklpanJueW2ykV5yYW1yal66XnJ+7iREYvduO/dyyg3Hlq496hxiZOBgPMUpwMCuJ 8Aq++JEkxJuSWFmVWpQfX1Sak1p8iNEU6O6JzFKiyfnA9JFXEm9oZmBqaGJmaWBqaWasJM7r WdCRKCSQnliSmp2aWpBaBNPHxMEp1cC04pOd+c5Mlx2sK3bqCpoUz7gjt3Bbl3CCIvcXH2V1 fde0OGata1veWXDJvDhT+lf8ZthT4WA5/rUfzXkcTh0KqBI3/nNQ5fBGV8HqjV9TngnaSIm+ n7Lsw7Hln+y4qqfqH0vMfSFqPmP3Zj4Xrqs/Da6dbd8qnH1S5MPSgBL/tN41lxJvXtt1pNim wzlyWodpadXy2advyTq3ae926V1pL6e2+sdWoZhT+tvdCpkWr2uvczjJk2V/015qtulW05K5 jjPs84+xnV7lIeV0adYO3eZNNaofO4uFz8x+kZYS3OIVtW9r4U9WnQrxvB4tTvVzggx3r72f 2ufMHBkyKfLdpYUFygUVf6KEN4fc2avEUpyRaKjFXFScCAB9m4dPZwMAAA== X-CMS-MailID: 20220816131544eucas1p24ce643970cc92636f9a42d24318ab051 X-Msg-Generator: CA X-RootMTR: 20220816131544eucas1p24ce643970cc92636f9a42d24318ab051 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131544eucas1p24ce643970cc92636f9a42d24318ab051 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Convert the power-of-2(po2) based calculation with zone size to be generic in null_zone_no with optimization for po2 zone sizes. The nr_zones calculation in null_init_zoned_dev has been replaced with a division without special handling for po2 zone sizes as this function is called only during the initialization and will not be invoked in the hot path. Reviewed-by: Luis Chamberlain Reviewed by: Adam Manzanares Reviewed-by: Hannes Reinecke Signed-off-by: Pankaj Raghav --- drivers/block/null_blk/main.c | 5 ++--- drivers/block/null_blk/null_blk.h | 1 + drivers/block/null_blk/zoned.c | 18 +++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index c451c477978f..f1e0605dee94 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -1976,9 +1976,8 @@ static int null_validate_conf(struct nullb_device *dev) if (dev->queue_mode == NULL_Q_BIO) dev->mbps = 0; - if (dev->zoned && - (!dev->zone_size || !is_power_of_2(dev->zone_size))) { - pr_err("zone_size must be power-of-two\n"); + if (dev->zoned && !dev->zone_size) { + pr_err("Invalid zero zone size\n"); return -EINVAL; } diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 94ff68052b1e..f63b6bed1bb3 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -83,6 +83,7 @@ struct nullb_device { unsigned int imp_close_zone_no; struct nullb_zone *zones; sector_t zone_size_sects; + unsigned int zone_size_sects_shift; bool need_zone_res_mgmt; spinlock_t zone_res_lock; diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c index 55a69e48ef8b..015f6823706c 100644 --- a/drivers/block/null_blk/zoned.c +++ b/drivers/block/null_blk/zoned.c @@ -16,7 +16,10 @@ static inline sector_t mb_to_sects(unsigned long mb) static inline unsigned int null_zone_no(struct nullb_device *dev, sector_t sect) { - return sect >> ilog2(dev->zone_size_sects); + if (dev->zone_size_sects_shift) + return sect >> dev->zone_size_sects_shift; + + return div64_u64(sect, dev->zone_size_sects); } static inline void null_lock_zone_res(struct nullb_device *dev) @@ -65,10 +68,6 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) sector_t sector = 0; unsigned int i; - if (!is_power_of_2(dev->zone_size)) { - pr_err("zone_size must be power-of-two\n"); - return -EINVAL; - } if (dev->zone_size > dev->size) { pr_err("Zone size larger than device capacity\n"); return -EINVAL; @@ -86,9 +85,14 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q) zone_capacity_sects = mb_to_sects(dev->zone_capacity); dev_capacity_sects = mb_to_sects(dev->size); dev->zone_size_sects = mb_to_sects(dev->zone_size); - dev->nr_zones = round_up(dev_capacity_sects, dev->zone_size_sects) - >> ilog2(dev->zone_size_sects); + if (is_power_of_2(dev->zone_size_sects)) + dev->zone_size_sects_shift = ilog2(dev->zone_size_sects); + else + dev->zone_size_sects_shift = 0; + + dev->nr_zones = DIV_ROUND_UP_SECTOR_T(dev_capacity_sects, + dev->zone_size_sects); dev->zones = kvmalloc_array(dev->nr_zones, sizeof(struct nullb_zone), GFP_KERNEL | __GFP_ZERO); if (!dev->zones) From patchwork Tue Aug 16 13:15:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944917 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 34979C25B0E for ; Tue, 16 Aug 2022 13:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235599AbiHPNP6 (ORCPT ); Tue, 16 Aug 2022 09:15:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234805AbiHPNPu (ORCPT ); Tue, 16 Aug 2022 09:15:50 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1F456173C for ; Tue, 16 Aug 2022 06:15:48 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131547euoutp01d5e750a06ecb5bdb8f1ed1ec57722ddb~L1ZqZGlgD0139901399euoutp01K for ; Tue, 16 Aug 2022 13:15:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131547euoutp01d5e750a06ecb5bdb8f1ed1ec57722ddb~L1ZqZGlgD0139901399euoutp01K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655747; bh=2l9t4o2MFdGXGYEr9szOD+OY2x6nysmCjdo7iJiFJ2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MgMRZtU2DkkDs7kBjuB0y+SrD21UrBtYAk5nAqcR/n7xykNigtyUpt9by5vYXNNEO aB4ipyR+zNUmXGr7TxN3kO+5t/U4b63zUdt2AUVUejCt/vIjQGOp1r0xh2LgTXMgNn DEcOWLIQ4x23tFXebZAOA+t96iLU2aVqLL5fUAMg= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220816131545eucas1p28cf18191fdc6dd8930e5677125a18d3b~L1ZotJ89I1908319083eucas1p2h; Tue, 16 Aug 2022 13:15:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 8F.65.09580.1889BF26; Tue, 16 Aug 2022 14:15:45 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220816131545eucas1p2cc7e6aad76abbe106a695f7396d38344~L1ZoHANYT3098130981eucas1p2D; Tue, 16 Aug 2022 13:15:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220816131545eusmtrp2e20876f331f41415549ea0fe23d6a07a~L1ZoGO_zg0621306213eusmtrp2M; Tue, 16 Aug 2022 13:15:45 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-e6-62fb98813cd2 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A0.31.09038.0889BF26; Tue, 16 Aug 2022 14:15:44 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131544eusmtip1d1134ed1ce5b864a51b18f04079f7d8b~L1ZnuzEBj2502525025eusmtip15; Tue, 16 Aug 2022 13:15:44 +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 07/13] zonefs: allow non power of 2 zoned devices Date: Tue, 16 Aug 2022 15:15:30 +0200 Message-Id: <20220816131536.189406-8-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+NgFnrAKsWRmVeSWpSXmKPExsWy7djP87qNM34nGRxdr26x/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK+PB hMSCFsGKFX+qGxgn8XUxcnJICJhInL57gKWLkYtDSGAFo8TB8+dZQBJCAl8YJVY260MkPjNK 3J52hwmmY9WDiWwQRcsZJV58c4IoesEo8aP1FlARBwebgJ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FrVyeaxeUm9 x+6bDWweO1vvs3q833eVzaNvyypGj82nqz0+b5LzaD/QzRTAE6VnU5RfWpKqkJFfXGKrFG1o YaRnaGmhZ2RiqWdobB5rZWSqpG9nk5Kak1mWWqRvl6CX8WBCYkGLYMWKP9UNjJP4uhg5OSQE TCRWPZjI1sXIxSEksJRR4u/pk4wQCQmJ2wuboGxhiT/XuqCKnjFKnPxzAMjh4GAT0JJo7GQH qRERyJVYtKyDFaSGWeANk8SH+Z+YQBLCAq4Sp/Y8ZAaxWQRUJW5PfQEW5xWwkmg98x1qgbzE zEvfwQZxClhL/GtYxQJiCwHVtB27zAxRLyhxcuYTsDgzUH3z1tnMExgFZiFJzUKSWsDItIpR JLW0ODc9t9hIrzgxt7g0L10vOT93EyMwbrcd+7llB+PKVx/1DjEycTAeYpTgYFYS4RV88SNJ iDclsbIqtSg/vqg0J7X4EKMp0N0TmaVEk/OBiSOvJN7QzMDU0MTM0sDU0sxYSZzXs6AjUUgg PbEkNTs1tSC1CKaPiYNTqoHJlmE+87pfaysvek3+oZJi+Oq0ml/oYbG3R0/9VRSqmtJ2elNP /6xwxY1rvN5nzAjcrPJpikKUxpZXQmosBvdm73t3e1KJUtyfTIVjvb+t4xpm75xz/eicvNIv aa8YoxJZj2b6/H1kdd3HQ/tk9zbtL7mPlQqFteL4Xz5gLe9T+pLWtILjG+v6h7/8Ha8qFIml 7l3s1xwZuEn7vNFZIbktb0sMWhXmTjgpdLlE58PVhcL7xZoME15O4w9XzRRZ2ZShuW/qtMTN BwNlzrjdqf8/s1jmdfH2p0peWzcWRrh7mc1Vf5j4rjl439L9X/Yqp1U+vlLn3cDPfnfW5DeL BTijt/y5U3TqWpzaytrXZgZ8SizFGYmGWsxFxYkAbgLaMGQDAAA= X-CMS-MailID: 20220816131545eucas1p2cc7e6aad76abbe106a695f7396d38344 X-Msg-Generator: CA X-RootMTR: 20220816131545eucas1p2cc7e6aad76abbe106a695f7396d38344 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131545eucas1p2cc7e6aad76abbe106a695f7396d38344 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The zone size shift variable is useful only if the zone sizes are known to be power of 2. Remove that variable and use generic helpers from block layer to calculate zone index in zonefs. Acked-by: Damien Le Moal Reviewed-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- fs/zonefs/super.c | 6 ++---- fs/zonefs/zonefs.h | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index 860f0b1032c6..e549ef16738c 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -476,10 +476,9 @@ static void __zonefs_io_error(struct inode *inode, bool write) { struct zonefs_inode_info *zi = ZONEFS_I(inode); struct super_block *sb = inode->i_sb; - struct zonefs_sb_info *sbi = ZONEFS_SB(sb); unsigned int noio_flag; unsigned int nr_zones = - zi->i_zone_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT); + bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT); struct zonefs_ioerr_data err = { .inode = inode, .write = write, @@ -1401,7 +1400,7 @@ static int zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone, struct zonefs_inode_info *zi = ZONEFS_I(inode); int ret = 0; - inode->i_ino = zone->start >> sbi->s_zone_sectors_shift; + inode->i_ino = bdev_zone_no(sb->s_bdev, zone->start); inode->i_mode = S_IFREG | sbi->s_perm; zi->i_ztype = type; @@ -1776,7 +1775,6 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent) * interface constraints. */ sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev)); - sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev)); sbi->s_uid = GLOBAL_ROOT_UID; sbi->s_gid = GLOBAL_ROOT_GID; sbi->s_perm = 0640; diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h index 4b3de66c3233..39895195cda6 100644 --- a/fs/zonefs/zonefs.h +++ b/fs/zonefs/zonefs.h @@ -177,7 +177,6 @@ struct zonefs_sb_info { kgid_t s_gid; umode_t s_perm; uuid_t s_uuid; - unsigned int s_zone_sectors_shift; unsigned int s_nr_files[ZONEFS_ZTYPE_MAX]; From patchwork Tue Aug 16 13:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944919 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 4AE04C25B0E for ; Tue, 16 Aug 2022 13:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235605AbiHPNP7 (ORCPT ); Tue, 16 Aug 2022 09:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235558AbiHPNPu (ORCPT ); Tue, 16 Aug 2022 09:15:50 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0BDE53D03 for ; Tue, 16 Aug 2022 06:15:49 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131548euoutp014ab5ce162778f8fd8bbb585399763e26~L1ZrbE79h0140001400euoutp01J for ; Tue, 16 Aug 2022 13:15:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131548euoutp014ab5ce162778f8fd8bbb585399763e26~L1ZrbE79h0140001400euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655748; bh=tSSBnG0aDQsGLDWCBqD+ZIZXJV/OR5HHGZmAzSOHsrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZjT6BcVWK/M/RWCJkvFVgEPS9WBA7XQd4IwGqlZTIslskr2TxhChMjBtUaUsG89d2 YvCiuEAYzQ1CcjFvFD61i7k/HQZb0PjLKt06ZlEB9mZt1ZYUjNgX350FKoEsIRNr/F 2Gv24/HW6SVWQxATyZN4RJAbhjcAn7bAmnt4W4rM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131546eucas1p1f3c231b04a31e7cc32176cfc05e83c72~L1ZphtR6j0141901419eucas1p1T; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 90.C7.10067.2889BF26; Tue, 16 Aug 2022 14:15:46 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c~L1ZpI_Gr_0139801398eucas1p1V; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220816131546eusmtrp2d9086ae758fb09eea5925b027df021b1~L1ZpIK9aC0621306213eusmtrp2Q; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-1e-62fb98822633 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 03.31.09038.2889BF26; Tue, 16 Aug 2022 14:15:46 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220816131545eusmtip2999fba249cde6ce2fe24d4c98362b6c3~L1Zox9x-f1650116501eusmtip2g; Tue, 16 Aug 2022 13:15:45 +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, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v11 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Tue, 16 Aug 2022 15:15:31 +0200 Message-Id: <20220816131536.189406-9-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+NgFnrIKsWRmVeSWpSXmKPExsWy7djPc7pNM34nGXz8oWKx/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2Ne u0TBPJ6KOQ1fWRoYW7i6GDk5JARMJK6vPsnUxcjFISSwglHi0+MvrBDOF0aJnXemMoFUCQl8 ZpT4u0gXpmPpidPMEEXLGSV+Nn5ghSh6wSix4JVqFyMHB5uAlkRjJztIWEQgXWJKy0sWEJtZ 4A6TROcHRRBbWCBEYu7l82BxFgFViW+LJoHZvAJWEteX/mOB2CUvMfPSd7A5nALWEv8aVkHV CEqcnPkEaqa8RPPW2WD3SAhs55T4sOoMG0Szi8T2j1uZIGxhiVfHt7BD2DIS/3fOh4pXSzy9 8RuquYV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YIWxhiT/XuthAbCGBZ4wSUyaLdzFycLAJ aEk0drKDhEUEciUWLetgBZnDLPCGSeJwTx8rSEJYIEhi6qk/YEUsAqoS3xZNYgGxeQWsJK4v /ccCMV9eYual72A1nALWEv8aVrFA7LKSaDt2mRmiXlDi5MwnYHFmoPrmrbOZJzAKzEKSmoUk tYCRaRWjSGppcW56brGRXnFibnFpXrpecn7uJkZg5G479nPLDsaVrz7qHWJk4mA8xCjBwawk wiv44keSEG9KYmVValF+fFFpTmrxIUZToLsnMkuJJucDU0deSbyhmYGpoYmZpYGppZmxkjiv Z0FHopBAemJJanZqakFqEUwfEwenVANTyEcWuxBfy6TpO6Pl/of4TFtWrS277sy/w40zew7f iN79+ulim5RPDFYcSzPtl27JudYRwKf6xC17yrl1Cy2W3SlPDi94vl5moXnzlCuHlcVW8Zju 2q/hzdm+tWyT9o9zb0/pW3uw7PGon35q7UqPRcuXd9l/85UpCf60oP7vPhGNB6u936ud9Wuy OtS5fY2fyxsTabv/cuvjPibbBBQ5JvxO2hBqLHFst3dgkmJ277d9h2Xizzw53B+bUBvsIHgi KEXp4axYp7o/rdNi9Zp4wxenrraPaN8gqh5qfju33DEuKmuhav+XJNGuFSWHknUCpFqdV//K /NZovUAkw+x2q7R0g9CSpbULCl/PjFViKc5INNRiLipOBAAvOmjGZQMAAA== X-CMS-MailID: 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c X-Msg-Generator: CA X-RootMTR: 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Luis Chamberlain dm-zoned relies on the assumption that the zone size is a power-of-2(po2) and the zone capacity is same as the zone size. Ensure only po2 devices can be used as dm-zoned target until a native support for zoned devices with non-po2 zone size is added. Reviewed-by: Hannes Reinecke Reviewed-by: Damien Le Moal Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/md/dm-zoned-target.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index 95b132b52f33..9325bf5dee81 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -792,6 +792,10 @@ static int dmz_fixup_devices(struct dm_target *ti) return -EINVAL; } zone_nr_sectors = bdev_zone_sectors(bdev); + if (!is_power_of_2(zone_nr_sectors)) { + ti->error = "Zone size is not a power-of-2 number of sectors"; + return -EINVAL; + } zoned_dev->zone_nr_sectors = zone_nr_sectors; zoned_dev->nr_zones = bdev_nr_zones(bdev); } @@ -804,6 +808,10 @@ static int dmz_fixup_devices(struct dm_target *ti) return -EINVAL; } zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev); + if (!is_power_of_2(zoned_dev->zone_nr_sectors)) { + ti->error = "Zone size is not a power-of-2 number of sectors"; + return -EINVAL; + } zoned_dev->nr_zones = bdev_nr_zones(bdev); } 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+Yq3x85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W/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; From patchwork Tue Aug 16 13:15:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944921 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 64AFDC28B2B for ; Tue, 16 Aug 2022 13:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235436AbiHPNQD (ORCPT ); Tue, 16 Aug 2022 09:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232696AbiHPNPx (ORCPT ); Tue, 16 Aug 2022 09:15:53 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 197DA5E306 for ; Tue, 16 Aug 2022 06:15:51 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131550euoutp02355c9b994f950d852814bca53edea993~L1ZtT2D9T2682226822euoutp02K for ; Tue, 16 Aug 2022 13:15:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220816131550euoutp02355c9b994f950d852814bca53edea993~L1ZtT2D9T2682226822euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655750; bh=rwrR95VBKntQTDKdi+ldY8ggDErFsfT3t9lp/si7I3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MwEzvTlqqgikNH93hU+Wqj/ChkKX3GhOECyZDjXopkbEIFKsNwqJprwN84qto1Fwk HXWEOZo5VP2WJGLOMWg7zqqSpCs02kq2EeQpd571ScwzCUhIBBNegRxFTqFX9TABjH BB1r6J7+z17fndIbBJoN94ubzkdTLbdTA+meWvsA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220816131548eucas1p2375e0cebff6f39ce61cc4c543cb9036a~L1ZrqxO3D3101631016eucas1p2K; Tue, 16 Aug 2022 13:15:48 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 59.A3.09664.4889BF26; Tue, 16 Aug 2022 14:15:48 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131548eucas1p1f480f8312e3060d0f633d97a90d7c84b~L1ZrPO_8J0139801398eucas1p1Z; Tue, 16 Aug 2022 13:15:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131548eusmtrp19e72020fa360af0f686a4a7fae4fc41d~L1ZrObTgs0519705197eusmtrp1H; Tue, 16 Aug 2022 13:15:48 +0000 (GMT) X-AuditID: cbfec7f2-d97ff700000025c0-18-62fb9884a47c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 95.B0.09095.4889BF26; Tue, 16 Aug 2022 14:15:48 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220816131547eusmtip2daaaaf59270cb91624eece8d5d73d1b6~L1ZqwGvIF1363513635eusmtip2j; Tue, 16 Aug 2022 13:15:47 +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 Subject: [PATCH v11 10/13] dm-table: allow zoned devices with non power-of-2 zone sizes Date: Tue, 16 Aug 2022 15:15:33 +0200 Message-Id: <20220816131536.189406-11-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+NgFrrHKsWRmVeSWpSXmKPExsWy7djP87otM34nGcx9Z2ax/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW3xe2sJusebmUxaLE7ekHQQ9Ll/x9tg56y67x+WzpR6bVnWyeWxeUu+x+2YD m8fO1vusHu/3XWXz6NuyitFj8+lqj8+b5DzaD3QzBfBEcdmkpOZklqUW6dslcGVcvn+HteAI b8Wqhy2MDYwfuLoYOTkkBEwkVj9/wAhiCwmsYJQ4Pj2ti5ELyP7CKPGoaz0bhPOZUWL1hXks MB3fF+5ggkgsZ5RYPv8lI4TzglHi2Iwu5i5GDg42AS2Jxk52kAYRgXSJKS0vWUBqmAW2MUm8 uTQBbJ+wQKTEigffmEFsFgFViQ+zVoA18ApYS7z6eJAZYpu8xMxL38HinEDxfw2rWCBqBCVO znwCZjMD1TRvnc0MskBCYD2nxMrm2VCnuki0r1rKBGELS7w6voUdwpaROD25B6qmWuLpjd9Q zS2MEv07QZ7mAHKsJfrO5ICYzAKaEut36UNEHSX+PPGGMPkkbrwVhLiAT2LStunMEGFeiY42 IYjZShI7fz6B2ikhcblpDtROD4kb52+zTWBUnIXkl1lIfpmFsHYBI/MqRvHU0uLc9NRiw7zU cr3ixNzi0rx0veT83E2MwCR4+t/xTzsY5776qHeIkYmD8RCjBAezkgiv4IsfSUK8KYmVValF +fFFpTmpxYcYpTlYlMR5kzM3JAoJpCeWpGanphakFsFkmTg4pRqYvF7VFr03bEuKKY+VOvWv 77jBhKfRb8xnqF6b+V81nuHb8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EIYH0 xJLU7NTUgtQimD4mDk6pBibfloOiOivy/xmvuWt5UCxuQvg0yQXnHh4IndWafOJ1+LYoZcZ7 rAlzj0Yv7k15JvzpMXv4U961yrphK/Ku635bqvLt3kKJP1rvFDcnX3uwLDvJnENRed/UhuNu Gsd0a/4rWLv85jg3h2nue/50synGz3d9ZHgv/5yhdl7d0wsfGxQaTkpePr3pKm/cmb7OotNZ hQyB6Y4vz/y9ZKDVYNsW1hX1xPOc6huHezvXfPn9fan8Lp27B+V+GT1JjP3FJSV0SNXz2/rl RVkKndUCh67aBGxdWR6llOz5sbuc20uMP+ty4t4d0cGZE3azyPtnJk85ctl4jnSCy0/pi0rF 2UtSjVZ/3cMRrnn16rmn15OVWIozEg21mIuKEwFRic8nYQMAAA== X-CMS-MailID: 20220816131548eucas1p1f480f8312e3060d0f633d97a90d7c84b X-Msg-Generator: CA X-RootMTR: 20220816131548eucas1p1f480f8312e3060d0f633d97a90d7c84b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131548eucas1p1f480f8312e3060d0f633d97a90d7c84b References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Allow dm to support zoned devices with non power-of-2(po2) zone sizes as the block layer now supports it. Signed-off-by: Pankaj Raghav Reviewed-by: Bart Van Assche Reviewed-by: Damien Le Moal --- drivers/md/dm-table.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 332f96b58252..31eb1d29d136 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -250,7 +250,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, if (bdev_is_zoned(bdev)) { unsigned int zone_sectors = bdev_zone_sectors(bdev); - if (start & (zone_sectors - 1)) { + if (!bdev_is_zone_start(bdev, start)) { DMWARN("%s: start=%llu not aligned to h/w zone size %u of %pg", dm_device_name(ti->table->md), (unsigned long long)start, @@ -267,7 +267,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, * devices do not end up with a smaller zone in the middle of * the sector range. */ - if (len & (zone_sectors - 1)) { + if (!bdev_is_zone_start(bdev, len)) { DMWARN("%s: len=%llu not aligned to h/w zone size %u of %pg", dm_device_name(ti->table->md), (unsigned long long)len, @@ -1642,8 +1642,7 @@ static int validate_hardware_zoned_model(struct dm_table *t, return -EINVAL; } - /* Check zone size validity and compatibility */ - if (!zone_sectors || !is_power_of_2(zone_sectors)) + if (!zone_sectors) return -EINVAL; if (dm_table_any_dev_attr(t, device_not_matches_zone_sectors, &zone_sectors)) { From patchwork Tue Aug 16 13:15:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944922 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 42BF9C28B2B for ; Tue, 16 Aug 2022 13:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235631AbiHPNQK (ORCPT ); Tue, 16 Aug 2022 09:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235572AbiHPNPy (ORCPT ); Tue, 16 Aug 2022 09:15:54 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07DD35F213 for ; Tue, 16 Aug 2022 06:15:53 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131551euoutp02b60f4a4cfdf16e7df75e89d2204ac4ab~L1ZuV1UXK2682526825euoutp02V for ; Tue, 16 Aug 2022 13:15:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220816131551euoutp02b60f4a4cfdf16e7df75e89d2204ac4ab~L1ZuV1UXK2682526825euoutp02V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655751; bh=lA4ACIhgPS1mwgZjIDSka7RcIpNQB3Ybt1avCcUQ/Cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fDH38K2GOpbfY5X1mZbPN66TF+MO4Q70j41XtLjvIForjppk7GPpF6aTfBLwqLmJ1 IivBhqLpJIsDwa7NrIgmxiI1HDfVACr9zHnGCjgI0Mq3moj0cM7XfejZsSwPTA6bil L7rOZwyMMrJTNw/zXsJYG9CfVx2R1LJCdw3+y7Wc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131549eucas1p17fa1579e347d9cfeef06118a51426172~L1Zsdxeee0548905489eucas1p16; Tue, 16 Aug 2022 13:15:49 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 03.75.09580.5889BF26; Tue, 16 Aug 2022 14:15:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220816131549eucas1p2b7079d3222e2a3313c7bf19c712d6e0e~L1ZsCVUUl3098130981eucas1p2I; Tue, 16 Aug 2022 13:15:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220816131549eusmtrp20ef0d99d7fedbc189849e7809c5d583a~L1ZsBcCrj0621306213eusmtrp2c; Tue, 16 Aug 2022 13:15:49 +0000 (GMT) X-AuditID: cbfec7f5-1bfc7a800000256c-f5-62fb98856cc8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 06.31.09038.5889BF26; Tue, 16 Aug 2022 14:15:49 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131548eusmtip1614be62435f7387e8d91eace6aacd19c~L1ZrtB0c12694326943eusmtip1D; Tue, 16 Aug 2022 13:15:48 +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 Subject: [PATCH v11 11/13] dm: call dm_zone_endio after the target endio callback for zoned devices Date: Tue, 16 Aug 2022 15:15:34 +0200 Message-Id: <20220816131536.189406-12-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+NgFrrDKsWRmVeSWpSXmKPExsWy7djP87qtM34nGcxer2ex/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW3xe2sJusebmUxaLE7ekHQQ9Ll/x9tg56y67x+WzpR6bVnWyeWxeUu+x+2YD m8fO1vusHu/3XWXz6NuyitFj8+lqj8+b5DzaD3QzBfBEcdmkpOZklqUW6dslcGWsPK9a8Ja3 YtafXvYGxqXcXYycHBICJhIrvz9hAbGFBFYwSiw7ntbFyAVkf2GUmDfrGguE85lR4vDxbmaY jkU7NkB1LGeU2HIuE6LoBaNE/4pjrF2MHBxsAloSjZ3sIDUiAukSU1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z6NuyitFj8+lqj8+b5DzaD3QzBfBE6dkU5ZeWpCpk5BeX2CpFG1oY6Rla WugZmVjqGRqbx1oZmSrp29mkpOZklqUW6dsl6GWsPK9a8Ja3YtafXvYGxqXcXYycHBICJhKL dmxg6WLk4hASWMoo8erPVFaIhITE7YVNjBC2sMSfa11sEEXPGCX+b1vP3MXIwcEmoCXR2MkO UiMikCuxaFkHK0gNs8ARJokF05czgySEBZIlWvYsAqtnEVCVmNgTAhLmFbCWaOxeyAQxX15i 5qXvYHM4geL/GlaxgNhCAlYSbccuM0PUC0qcnPkELM4MVN+8dTbzBEaBWUhSs5CkFjAyrWIU SS0tzk3PLTbSK07MLS7NS9dLzs/dxAiM123Hfm7Zwbjy1Ue9Q4xMHIyHGCU4mJVEeAVf/EgS 4k1JrKxKLcqPLyrNSS0+xGgKdPZEZinR5HxgwsgriTc0MzA1NDGzNDC1NDNWEuf1LOhIFBJI TyxJzU5NLUgtgulj4uCUamDSEHjPfFm5rvvMA7+NM780TA/V+izLrL2eRXOj+JLNi5qu5+of fBxYrPX1iWjuntp5t5TjEuwPRE3VPVB9UXXKXOW3NzhNv/SwnFEWNhO5vP5X/dn1wqW5ZV8C kv59ePlQ/XwJY2KD93/1SQ1c1YXO3V8aug2Sk1h7wpbZT927p+33VoOaz4x758pNiSoMe/J6 ZcXvdUHvzxaZy3Bf+RvdcWWVyoOgz128WzUl2MtmaV5heJK2eaF6AmtN0Q3zrUwipm4Xznzg b32ypMn/enqP8RvduZYrWzyP1sza6MUWWLDpzM17vLb3U7a6sYZacKxjnXB82+PkV2tUgvz4 /WbMTd4SxcQzw7Ti9a7m/eZKLMUZiYZazEXFiQC25n6hYAMAAA== X-CMS-MailID: 20220816131549eucas1p2b7079d3222e2a3313c7bf19c712d6e0e X-Msg-Generator: CA X-RootMTR: 20220816131549eucas1p2b7079d3222e2a3313c7bf19c712d6e0e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131549eucas1p2b7079d3222e2a3313c7bf19c712d6e0e References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org dm_zone_endio() updates the bi_sector of orig bio for zoned devices that uses either native append or append emulation, and it is called before the endio of the target. But target endio can still update the clone bio after dm_zone_endio is called, thereby, the orig bio does not contain the updated information anymore. Currently, this is not a problem as the targets that support zoned devices such as dm-zoned, dm-linear, and dm-crypt do not have an endio function, and even if they do (such as dm-flakey), they don't modify the bio->bi_iter.bi_sector of the cloned bio that is used to update the orig_bio's bi_sector in dm_zone_endio function. This is a prep patch for the new dm-po2zone target as it modifies bi_sector in the endio callback. Call dm_zone_endio for zoned devices after calling the target's endio function. Signed-off-by: Pankaj Raghav --- drivers/md/dm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 60549b65c799..58b392c51d04 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1122,10 +1122,6 @@ static void clone_endio(struct bio *bio) disable_write_zeroes(md); } - if (static_branch_unlikely(&zoned_enabled) && - unlikely(bdev_is_zoned(bio->bi_bdev))) - dm_zone_endio(io, bio); - if (endio) { int r = endio(ti, bio, &error); switch (r) { @@ -1154,6 +1150,10 @@ static void clone_endio(struct bio *bio) } } + if (static_branch_unlikely(&zoned_enabled) && + unlikely(bdev_is_zoned(bio->bi_bdev))) + dm_zone_endio(io, bio); + if (static_branch_unlikely(&swap_bios_enabled) && unlikely(swap_bios_limit(ti, bio))) up(&md->swap_bios_semaphore); From patchwork Tue Aug 16 13:15:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944923 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 80FBFC2BB41 for ; Tue, 16 Aug 2022 13:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235635AbiHPNQL (ORCPT ); Tue, 16 Aug 2022 09:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235586AbiHPNPz (ORCPT ); Tue, 16 Aug 2022 09:15:55 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16498606AD for ; Tue, 16 Aug 2022 06:15:53 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131552euoutp0121dfec17741435b3455720df4a8d9013~L1ZvGUTT_0140001400euoutp01R for ; Tue, 16 Aug 2022 13:15:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131552euoutp0121dfec17741435b3455720df4a8d9013~L1ZvGUTT_0140001400euoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655752; bh=ZgoaFDwLzDUOxKE5rEa1NqlfNa53+tMH9mlTVfvbwSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n6CWcXzf4VhCBb1ep6HnQQBy4onEEBfOlxNcfu1PpH8wlBzY6gBIwMhG1ZqCHnSaO xPm7W6vFwFD2yCCZkw9zgpdhQflhYGKhR/h4XcD8vdjoFaqk+YIYN6lyNjdLwZl+fP N1Y+K2gRpHbda8p3qKe726B7NahxJ898I0mxgLEk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131550eucas1p1d3561ab84d8887214456758aca5634b1~L1Ztdo4fF0141901419eucas1p1Y; Tue, 16 Aug 2022 13:15:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 85.75.09580.6889BF26; Tue, 16 Aug 2022 14:15:50 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220816131550eucas1p2d13098e9f0ed146ed1d01dc4dd984820~L1ZtFFlZx0994909949eucas1p2b; Tue, 16 Aug 2022 13:15:50 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131550eusmtrp1acf217c5bc9f2b00b0e437c738c2547c~L1ZtEAb6N0519705197eusmtrp1K; Tue, 16 Aug 2022 13:15:50 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-fb-62fb9886a3d5 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 8C.B0.09095.6889BF26; Tue, 16 Aug 2022 14:15:50 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220816131550eusmtip1176fce6aa3539b535662242fc445cd4c~L1Zs0h-n42991329913eusmtip1c; Tue, 16 Aug 2022 13:15:50 +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 Subject: [PATCH v11 12/13] dm: introduce DM_EMULATED_ZONES target type Date: Tue, 16 Aug 2022 15:15:35 +0200 Message-Id: <20220816131536.189406-13-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+NgFrrHKsWRmVeSWpSXmKPExsWy7djPc7ptM34nGfzbb2Cx/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW3xe2sJusebmUxaLE7ekHQQ9Ll/x9tg56y67x+WzpR6bVnWyeWxeUu+x+2YD m8fO1vusHu/3XWXz6NuyitFj8+lqj8+b5DzaD3QzBfBEcdmkpOZklqUW6dslcGU0LRQpaBCr uDR3G1MD426hLkYODgkBE4n1axO6GLk4hARWMEqsn7yaHcL5wijR93EyE4TzmVGi+cIHti5G TrCOi4tnsUIkljNKbD/RxQLhvGCUePB0IiPIXDYBLYnGTnaQBhGBdIkpLS/BapgFtjFJvLk0 gREkISzgJtHeMB+siEVAVWLet16wDbwC1hITTzcxQ2yTl5h56TtYDSdQ/F/DKhaIGkGJkzOf gNnMQDXNW2czgyyQEFjPKfFq+k9WiGYXieUHtrBA2MISr45vYYewZSROT+6BildLPL3xG6q5 hVGif+d6NkjIWEv0nckBMZkFNCXW79KHKHeU+PT2KQtEBZ/EjbeCECfwSUzaNp0ZIswr0dEm BFGtJLHz5xOopRISl5vmQC31kNh5aCPbBEbFWUiemYXkmVkIexcwMq9iFE8tLc5NTy02zkst 1ytOzC0uzUvXS87P3cQITIKn/x3/uoNxxauPeocYmTgYDzFKcDArifAKvviRJMSbklhZlVqU H19UmpNafIhRmoNFSZw3OXNDopBAemJJanZqakFqEUyWiYNTqoGpNvJeWKZEi3eC6RK/fatK 5Er6rLcvFe1ZsMDrqBRH6lSrGRNrdyZm//njc32BylLFnX6XtFJfedwRl1/9TG32U+/zh5Yv rarZx9iwee7V7wdPsWZ99fa4xM/hqs4uxb54pW/iUR8Hs4ecM87/bf67rkVpiUJ94GrrLzkx C3WkZBQ4RJz/n5nFcZaj46tY3iWHI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1HNJZE1bN+Z81oil410/hl5Y2/u5d+v7Df0y7y1nrXL4fnr7WUfdmnLbB52TFBp1lJpoo7 WF709uy5tqw+b82kYOVHM5/VPjr84PBUxYucO04LLnzPLzw15dIZoZItNQsvPrO6l5ByXP15 7DMVz+DJgmH8rP2+U7Zl8z8z9at/V7rfYf2eG9aM6ku05xfoRm5YacjNu33/JAf+3paT8lem NTtu+urceJc/SmXuttKl08qVWIozEg21mIuKEwEcj+o+YQMAAA== X-CMS-MailID: 20220816131550eucas1p2d13098e9f0ed146ed1d01dc4dd984820 X-Msg-Generator: CA X-RootMTR: 20220816131550eucas1p2d13098e9f0ed146ed1d01dc4dd984820 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131550eucas1p2d13098e9f0ed146ed1d01dc4dd984820 References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Introduce a new target type DM_EMULATED_ZONES for targets with a different number of sectors per zone (aka zone size) than the underlying device zone size. This target type is introduced as the existing zoned targets assume that the target and the underlying device have the same zone size. The new target: dm-po2zone will use this new target type as it emulates the zone boundary that is different from the underlying zoned device. Signed-off-by: Pankaj Raghav Reviewed-by: Damien Le Moal --- drivers/md/dm-table.c | 13 ++++++++++--- include/linux/device-mapper.h | 9 +++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 31eb1d29d136..b37991ea3ffb 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1614,13 +1614,20 @@ static bool dm_table_supports_zoned_model(struct dm_table *t, return true; } -static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev, +/* + * Callback function to check for device zone sector across devices. If the + * DM_TARGET_EMULATED_ZONES target feature flag is not set, then the target + * should have the same zone sector as the underlying devices. + */ +static int check_valid_device_zone_sectors(struct dm_target *ti, struct dm_dev *dev, sector_t start, sector_t len, void *data) { unsigned int *zone_sectors = data; - if (!bdev_is_zoned(dev->bdev)) + if (!bdev_is_zoned(dev->bdev) || + dm_target_supports_emulated_zones(ti->type)) return 0; + return bdev_zone_sectors(dev->bdev) != *zone_sectors; } @@ -1645,7 +1652,7 @@ static int validate_hardware_zoned_model(struct dm_table *t, if (!zone_sectors) return -EINVAL; - if (dm_table_any_dev_attr(t, device_not_matches_zone_sectors, &zone_sectors)) { + if (dm_table_any_dev_attr(t, check_valid_device_zone_sectors, &zone_sectors)) { DMERR("%s: zone sectors is not consistent across all zoned devices", dm_device_name(t->md)); return -EINVAL; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 04c6acf7faaa..83e20de264c9 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -294,6 +294,15 @@ struct target_type { #define dm_target_supports_mixed_zoned_model(type) (false) #endif +#ifdef CONFIG_BLK_DEV_ZONED +#define DM_TARGET_EMULATED_ZONES 0x00000400 +#define dm_target_supports_emulated_zones(type) \ + ((type)->features & DM_TARGET_EMULATED_ZONES) +#else +#define DM_TARGET_EMULATED_ZONES 0x00000000 +#define dm_target_supports_emulated_zones(type) (false) +#endif + struct dm_target { struct dm_table *table; struct target_type *type; From patchwork Tue Aug 16 13:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944924 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 11B79C25B0E for ; Tue, 16 Aug 2022 13:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235604AbiHPNQX (ORCPT ); Tue, 16 Aug 2022 09:16:23 -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 S235603AbiHPNP6 (ORCPT ); Tue, 16 Aug 2022 09:15:58 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9693162A9A for ; Tue, 16 Aug 2022 06:15:55 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131553euoutp02f8def4855aae45f838daeb0107a26960~L1ZwKFUmJ2682126821euoutp02S for ; Tue, 16 Aug 2022 13:15:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220816131553euoutp02f8def4855aae45f838daeb0107a26960~L1ZwKFUmJ2682126821euoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655753; bh=PvnenMuRv4p19PPEMOW1GA5OXgVclqzULdTF9h0TpXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Chr9StB+BuLCOZziSJvQFNcAbac7bnxFyktdQdTage+kX7iuSqRdEer5fQGfkvFx9 pvhOrv9jHAgW5+8DdtZUBozaDUQJN+6a8xUdmqsqsi5WgW1mMLCYRp0e7UQ/xXbMa+ GQbaKc3MDdn8yVdH8Oh4STKolwFhusk0tCQwJx7E= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131552eucas1p1709a353975f87319714174c850fd7b1d~L1ZunC-aD0140201402eucas1p1f; Tue, 16 Aug 2022 13:15:52 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id AC.75.09580.7889BF26; Tue, 16 Aug 2022 14:15:52 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220816131551eucas1p218faf35348e78a73aaa87d5477ecdb2e~L1ZuLzZAy2105421054eucas1p2Y; Tue, 16 Aug 2022 13:15:51 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220816131551eusmtrp1815fdc7c94e0639069a8d54ef394dfd4~L1ZuLA3xS0149801498eusmtrp1U; Tue, 16 Aug 2022 13:15:51 +0000 (GMT) X-AuditID: cbfec7f5-9adff7000000256c-02-62fb98871665 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 4E.B0.09095.7889BF26; Tue, 16 Aug 2022 14:15:51 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220816131551eusmtip2e31148a6f0507b64d252ad661f155c16~L1Zt06k2_1196811968eusmtip2e; Tue, 16 Aug 2022 13:15:51 +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 , Johannes Thumshirn , Damien Le Moal Subject: [PATCH v11 13/13] dm: add power-of-2 target for zoned devices with non power-of-2 zone sizes Date: Tue, 16 Aug 2022 15:15:36 +0200 Message-Id: <20220816131536.189406-14-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+NgFnrMKsWRmVeSWpSXmKPExsWy7djPc7odM34nGTSvYrRYf+oYs8Xqu/1s FtM+/GS2+H32PLNFa/s3Jou972azWtw8sJPJYs+iSUw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/cLcXUV3GPl9C3uRsn6GRNYSwWu pQkuvWV24qfOk0mfnRKnxXgZ7D9n2tA1/8cb+633ot3Xh97ZqPTq86sSp0zRhWKXTnAsPLLF asHs2/vdE/cEZe3ax/aitJVLiaU4I9FQi7moOBEA7hQFAWUDAAA= X-CMS-MailID: 20220816131551eucas1p218faf35348e78a73aaa87d5477ecdb2e X-Msg-Generator: CA X-RootMTR: 20220816131551eucas1p218faf35348e78a73aaa87d5477ecdb2e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131551eucas1p218faf35348e78a73aaa87d5477ecdb2e References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Only zoned devices with power-of-2(po2) number of sectors per zone(zone size) were supported in linux but now non power-of-2(npo2) zone sizes support has been added to the block layer. Filesystems such as F2FS and btrfs have support for zoned devices with po2 zone size assumption. Before adding native support for npo2 zone sizes, it was suggested to create a dm target for npo2 zone size device to appear as a po2 zone size target so that file systems can initially work without any explicit changes by using this target. The design of this target is very simple: remap the device zone size to the zone capacity and change the zone size to be the nearest power of 2 value. For e.g., a device with a zone size/capacity of 3M will have an equivalent target layout as follows: Device layout :- zone capacity = 3M zone size = 3M |--------------|-------------| 0 3M 6M Target layout :- zone capacity=3M zone size = 4M |--------------|---|--------------|---| 0 3M 4M 7M 8M The area between target's zone capacity and zone size will be emulated in the target. The read IOs that fall in the emulated gap area will return 0 filled bio and all the other IOs in that area will result in an error. If a read IO span across the emulated area boundary, then the IOs are split across them. All other IO operations that span across the emulated area boundary will result in an error. The target can be easily created as follows: dmsetup create