From patchwork Fri Jan 6 08:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13091073 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 E0E32C54E76 for ; Fri, 6 Jan 2023 08:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232316AbjAFIdj (ORCPT ); Fri, 6 Jan 2023 03:33:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232415AbjAFId1 (ORCPT ); Fri, 6 Jan 2023 03:33:27 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B937A93B for ; Fri, 6 Jan 2023 00:33:23 -0800 (PST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083321euoutp02a2c3b92c0c8cf9cc3629d5d70fc83757~3qy4eITyO2166121661euoutp02b for ; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230106083321euoutp02a2c3b92c0c8cf9cc3629d5d70fc83757~3qy4eITyO2166121661euoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994001; bh=xL98W+EK2xf54BjrEuaYdsMq2UetfroxJnaNHM1J0YQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F5Kt3ipmIqt9FPhQy71S0Xvmh86cC9Carqc/YhAA+WhVkmforjvQnKtdEXIrbVMrK IVlmC25Mcvdf09/FaahR5ulL8H1NPew4qWLZuMpX4lLZtV5EEQ33tYcKBtyVvGqlqc yu4TOC4G0GPHK3+4YgqYFlOl3vzR01T6/jKsVUsk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230106083319eucas1p2e3212c7c60824af430d2b887b4feb81a~3qy3WM79E3119231192eucas1p2D; Fri, 6 Jan 2023 08:33:19 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A7.14.61936.FCCD7B36; Fri, 6 Jan 2023 08:33:19 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230106083319eucas1p1e58f4ab0d3ff59a328a2da2922d76038~3qy28xCRM1636916369eucas1p1N; Fri, 6 Jan 2023 08:33:19 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230106083319eusmtrp2f28926097487b7893e7b9aeafb0edc06~3qy28ACgL0987109871eusmtrp2j; Fri, 6 Jan 2023 08:33:19 +0000 (GMT) X-AuditID: cbfec7f4-a2dff7000002f1f0-d2-63b7dccfd9b7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FA.AB.52424.FCCD7B36; Fri, 6 Jan 2023 08:33:19 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230106083319eusmtip121f48b06b25f955e94de4a91b3bdc881~3qy2vWoUw0382103821eusmtip1Z; Fri, 6 Jan 2023 08:33:19 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 1/7] block: remove superfluous check for request queue in bdev_is_zoned Date: Fri, 6 Jan 2023 09:33:11 +0100 Message-Id: <20230106083317.93938-2-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMKsWRmVeSWpSXmKPExsWy7djPc7rn72xPNljxy9Bi9d1+NotpH34y W/w+e57ZYu+72awWNw/sZLLYs2gSk8XK1UeZLM68/MxisfeWtsXlXXPYLOYve8pu8XlpC7vF iVvSDrwel694e1w+W+qxaVUnm8fmJfUeu282sHnsbL3P6nF2paPH+31X2Tz6tqxi9Nh8utrj 8ya5AO4oLpuU1JzMstQifbsErow1PWdYC66zVfzsucXawHiJtYuRk0NCwESi+ewili5GLg4h gRWMEosWTGUDSQgJfGGUWHnUDCLxmVGi78E+FpiO98svMkIkljNKnGpcyQLR8YJR4kV7ahcj BwebgJZEYyc7SFhEQFhif0cr2AZmgc1MErd/r2UESQgLRErc/7UEbBuLgKrEt7UXwOK8ApYS cxa2M0Esk5eYeek72CBOASuJ59PXMEHUCEqcnPkEbC8zUE3z1tnMIAskBLo5JRafWgz1m4vE /kPLmSFsYYlXx7ewQ9gyEv93zodaUC3x9MZvqOYWRon+nevZQD6QELCW6DuTA2IyC2hKrN+l DxF1lLjd7Qph8knceCsIcQGfxKRt05khwrwSHW1CELOVJHb+fAK1U0LictMcaAh6SBzc94x9 AqPiLCS/zELyyyyEtQsYmVcxiqeWFuempxYb5aWW6xUn5haX5qXrJefnbmIEprPT/45/2cG4 /NVHvUOMTByMhxglOJiVRHjL+rclC/GmJFZWpRblxxeV5qQWH2KU5mBREuedsXV+spBAemJJ anZqakFqEUyWiYNTqoFJd50j46ZtXbYbdGs0Nthc/Cn8+VGw3AaLjQenZHy90+B7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qeJv 1n99F8tFAiel2m576bV1UceCicoXVrC4h7g8XZQZtX/hpz0Ld3yQ43TaoPRpwsr3b1NPrxL1 0GgRvyPccchFTC7nvP/eT5fcy5vupicYT05dtflryHl/dYnvdQtUXhW0zy69aLHubM8H71r3 eNF/rlLONxuSM53F+ZY/iBGeduiF4SS729acSdKGVW7XGAOv3fn1J/LoF1WnZ9mn5J+3XGKp 6J2yYuNCrzdnzv77bbnig3F0KLtG05z9JaZHtLr7ytfd/fKmVfbnr+i3T7K1fj2sqnLyadUs Wp70KP3//S1fQlrP7zhw++dmg7MeqUc2PT4g/mlPV+D2QutZR1/HTFTP4Dz/XomlOCPRUIu5 qDgRANWNwXtHAwAA X-CMS-MailID: 20230106083319eucas1p1e58f4ab0d3ff59a328a2da2922d76038 X-Msg-Generator: CA X-RootMTR: 20230106083319eucas1p1e58f4ab0d3ff59a328a2da2922d76038 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083319eucas1p1e58f4ab0d3ff59a328a2da2922d76038 References: <20230106083317.93938-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Remove the superfluous request queue check in bdev_is_zoned() as the bdev_get_queue can never return NULL. Signed-off-by: Pankaj Raghav Reviewed-by: Damien Le Moal Reviewed-by: Bart Van Assche Reviewed-by: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- include/linux/blkdev.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 43d4e073b111..0e40b014c40b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1283,12 +1283,7 @@ static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) 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; + return blk_queue_is_zoned(bdev_get_queue(bdev)); } static inline bool bdev_op_is_zoned_write(struct block_device *bdev, From patchwork Fri Jan 6 08:33:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13091071 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 70C55C5479D for ; Fri, 6 Jan 2023 08:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232243AbjAFIdh (ORCPT ); Fri, 6 Jan 2023 03:33:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232390AbjAFId0 (ORCPT ); Fri, 6 Jan 2023 03:33:26 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 505CB67BDB for ; Fri, 6 Jan 2023 00:33:23 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083321euoutp02cccd26fb849233f7769bf0f4f3d8a49b~3qy5BThM92166021660euoutp02d for ; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230106083321euoutp02cccd26fb849233f7769bf0f4f3d8a49b~3qy5BThM92166021660euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994001; bh=mYUOjDUgV5uRZr8FSI2sN9uglijkdaYClIStHAMPSkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VmeTtBF5gK5bztpCTGGZApS6CQVXo9uIwcf3KtFV9+4tNaM0IfiDRBHi8xxwu8SKG IeVjhxHeDcvSWZSGlFkTk70SzePsOGpxp4y5eqRVSjh7jKqoyJQLa5aGP1URdpjuWQ TltkqGJuqrZml32qlhsDnXSEpmn5p3T65m6Jqfp0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230106083320eucas1p2d90ff0852e090e65aca5fa311795922e~3qy3_jx7W0127301273eucas1p2-; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 46.43.43884.0DCD7B36; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230106083320eucas1p1f8de0c6ecf351738e8f0ee5f3390d94f~3qy3k3X6I2244622446eucas1p12; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230106083320eusmtrp1ca7857a1c230a82c8c50a2ca90d049a8~3qy3kPC_x2166121661eusmtrp1h; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) X-AuditID: cbfec7f5-271ff7000000ab6c-44-63b7dcd0381b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id E7.C6.23420.0DCD7B36; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230106083319eusmtip2fc156a9b99243a61ab87bd75fb6194fb~3qy3WgiZY2797827978eusmtip2g; Fri, 6 Jan 2023 08:33:19 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 2/7] block: add a new helper bdev_{is_zone_start, offset_from_zone_start} Date: Fri, 6 Jan 2023 09:33:12 +0100 Message-Id: <20230106083317.93938-3-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKKsWRmVeSWpSXmKPExsWy7djP87oX7mxPNti9T8li9d1+NotpH34y W/w+e57ZYu+72awWNw/sZLLYs2gSk8XK1UeZLM68/MxisfeWtsXlXXPYLOYve8pu8XlpC7vF iVvSDrwel694e1w+W+qxaVUnm8fmJfUeu282sHnsbL3P6nF2paPH+31X2Tz6tqxi9Nh8utrj 8ya5AO4oLpuU1JzMstQifbsErowPy7cxF8wXqVhxdjNTA+NlgS5GTg4JAROJ3xP62LoYuTiE BFYwStx/9IIRwvnCKPHozCdmCOczo8TerQeZYFounF0PVbWcUWLD5ulQ/S8YJd7v/QPUwsHB JqAl0djJDtIgIiAssb+jlQWkhllgM5PE7d9rGUESwgLREqdm72AFsVkEVCX+9xwAs3kFLCXW fp3PCLFNXmLmpe9ggzgFrCSeT1/DBFEjKHFy5hMWEJsZqKZ562xmiPpuTolVZ5QhbBeJ09d3 QM0Rlnh1fAs7hC0jcXpyDwuEXS3x9MZvsDclBFoYJfp3rmcDeUBCwFqi70wOiMksoCmxfpc+ RLmjxLo955ggKvgkbrwVhLiAT2LStunMEGFeiY42IYhqJYmdP59ALZWQuNw0B2qph8SDydvZ JjAqzkLyyywkv8xC2LuAkXkVo3hqaXFuemqxcV5quV5xYm5xaV66XnJ+7iZGYEo7/e/41x2M K1591DvEyMTBeIhRgoNZSYS3rH9bshBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHeGVvnJwsJpCeW pGanphakFsFkmTg4pRqYpt9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OzU1ILUIpg+Jg5OqQamI6lXqrWu+PBt NXv77vPNgrDOTcvVy6QP/nTfJaI450CtzxZrrRXfk7bKSlQJrX/39Nn3bVKbbgmbTDxXY6t6 d99e4xxhH+t/hmmx/h8ffDI8edp76SJ7q+6SWQKJZ3bMWTuL585LBvdXLU6x86+1rWb4Uv3t QtzX5ddu8Dsmvbk/w6j5xsQvcWlOrPy3z2Se1t3+WYerV31d8OLUbo+8W2cFf00Ne364Y+/V T84Gu+SXhDCGxIXGP3v4ifPpnfc3mI1nS6l3n08JWnDiZAnjnnaTRuuQnsnppyoj/1hp1/R+ XZDhPHWJUI53EHv3/8ytDw4/imFUFN0/22JZ/IJXm3V+SvUcerqhYY3jpJ1fUpVYijMSDbWY i4oTASPl4khIAwAA X-CMS-MailID: 20230106083320eucas1p1f8de0c6ecf351738e8f0ee5f3390d94f X-Msg-Generator: CA X-RootMTR: 20230106083320eucas1p1f8de0c6ecf351738e8f0ee5f3390d94f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083320eucas1p1f8de0c6ecf351738e8f0ee5f3390d94f References: <20230106083317.93938-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of open coding to check for zone start, add a helper to improve readability and store the logic in one place. bdev_offset_from_zone_start() will be used later in the series. Signed-off-by: Pankaj Raghav Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- block/blk-core.c | 2 +- block/blk-zoned.c | 4 ++-- include/linux/blkdev.h | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 9321767470dc..0405b3144e7a 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -573,7 +573,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 db829401d8d0..614b575be899 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -277,10 +277,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; /* diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 0e40b014c40b..04b7cbfd7a2a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -715,6 +715,7 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector) { return 0; } + static inline unsigned int bdev_max_open_zones(struct block_device *bdev) { return 0; @@ -1304,6 +1305,23 @@ static inline sector_t bdev_zone_sectors(struct block_device *bdev) return q->limits.chunk_sectors; } +static inline sector_t bdev_offset_from_zone_start(struct block_device *bdev, + sector_t sec) +{ + if (!bdev_is_zoned(bdev)) + return 0; + + return sec & (bdev_zone_sectors(bdev) - 1); +} + +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 int queue_dma_alignment(const struct request_queue *q) { return q ? q->limits.dma_alignment : 511; From patchwork Fri Jan 6 08:33:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13091074 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 01A52C54EBF for ; Fri, 6 Jan 2023 08:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbjAFIdk (ORCPT ); Fri, 6 Jan 2023 03:33:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232411AbjAFId1 (ORCPT ); Fri, 6 Jan 2023 03:33:27 -0500 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508D27A937 for ; Fri, 6 Jan 2023 00:33:23 -0800 (PST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083322euoutp01f880f3e18b004f8c6fdd430a5a920b36~3qy5chvtC2179921799euoutp01j for ; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230106083322euoutp01f880f3e18b004f8c6fdd430a5a920b36~3qy5chvtC2179921799euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994002; bh=b0SsOCCybnCd/B43+zTI9/vDTuEOnzsWfQZ0xnE/tuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EYMHHFM5dYEkg65JHYPztPrOjCGqjbEHNX2jwOLCIYK6/ZW/3jJIytbCMC0fSWFyW ipl28gk9AXoKWXYPv2QzRiuTNZVlXrERsNMqNzdhFTkeL+Ch6/kHn0zIAJtrD+EKy/ LfkkIGiOmeZa8y/E/QNGNsSinfLv4s1lc+n0IvOo= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230106083321eucas1p14d9bd46a8be92a470a20e58d21071bb4~3qy4n0gEE1079910799eucas1p1H; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BD.93.56180.1DCD7B36; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230106083320eucas1p1d23de4ad21d0a7aecb74c549ebc7757c~3qy4JXsly2243322433eucas1p1A; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230106083320eusmtrp15998075ae20ab5f906a740e158118e4d~3qy4Izv5j2166121661eusmtrp1i; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) X-AuditID: cbfec7f2-acbff7000000db74-9b-63b7dcd14f91 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F8.C6.23420.0DCD7B36; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230106083320eusmtip25d92d5b1666eb6931c86064692a73f87~3qy3_HtjY2941329413eusmtip2D; Fri, 6 Jan 2023 08:33:20 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 3/7] nvmet: introduce bdev_zone_no helper Date: Fri, 6 Jan 2023 09:33:13 +0100 Message-Id: <20230106083317.93938-4-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0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5oeNmvT9kn8R2sCWRtkQ47s2ZbmtMrA4lnDWf43OsvylR792JMrrWPTN3PKBUuu R9/2vP+1QepEseipM7NmtV0Is0hcdaHkuebu8FlyGj4HRc50OxbPWMklrcRSnJFoqMVcVJwI AIlgaJxHAwAA X-CMS-MailID: 20230106083320eucas1p1d23de4ad21d0a7aecb74c549ebc7757c X-Msg-Generator: CA X-RootMTR: 20230106083320eucas1p1d23de4ad21d0a7aecb74c549ebc7757c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083320eucas1p1d23de4ad21d0a7aecb74c549ebc7757c References: <20230106083317.93938-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. Signed-off-by: Pankaj Raghav Reviewed-by: Damien Le Moal Reviewed-by: Bart Van Assche Reviewed-by: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig --- 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 1254cf57e008..7e4292d88016 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -254,8 +254,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 04b7cbfd7a2a..669cf4fed1ad 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1287,6 +1287,11 @@ static inline bool bdev_is_zoned(struct block_device *bdev) return blk_queue_is_zoned(bdev_get_queue(bdev)); } +static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec) +{ + return disk_zone_no(bdev->bd_disk, sec); +} + static inline bool bdev_op_is_zoned_write(struct block_device *bdev, blk_opf_t op) { From patchwork Fri Jan 6 08:33:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13091076 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 89A20C3DA7A for ; Fri, 6 Jan 2023 08:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjAFIeK (ORCPT ); Fri, 6 Jan 2023 03:34:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232433AbjAFId1 (ORCPT ); Fri, 6 Jan 2023 03:33:27 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5131F80AC2 for ; Fri, 6 Jan 2023 00:33:24 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083322euoutp0207fadc1d71a64da7488394a8de3fd0a7~3qy6Lx5eD2142821428euoutp02o for ; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230106083322euoutp0207fadc1d71a64da7488394a8de3fd0a7~3qy6Lx5eD2142821428euoutp02o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994003; bh=LXXa5WqRMuw776PYfMbNhiRBXFUIY42wRgq3is6fToE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dfYx0haNy/Z/IHN2Jg15oeG3zyLR+5J6K4SMptCdBwRXbGvciBpxgPLCHxl5okyQT jFH/oeA9BE98cmeKnb0avDbZ+s1xr5VtTkeLnliH6Ad9xTDeJtYmEEnoSe9md9liaw QXOltcxuyS4Lln43dbMfeoEP0csvFtq2zs2WKkZ0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230106083322eucas1p1c3c3079982519376276cf618f4614634~3qy5RsdUQ1103011030eucas1p1F; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 2F.93.56180.1DCD7B36; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230106083321eucas1p15e9087bcc62bc6a4f5a61467e1c98698~3qy44kw8g2243222432eucas1p1A; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230106083321eusmtrp2d3f5148d45e550f1ae35a15ae7e369b6~3qy436qaB1128211282eusmtrp2B; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) X-AuditID: cbfec7f2-acbff7000000db74-9f-63b7dcd19fcb Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AC.AB.52424.1DCD7B36; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230106083321eusmtip134788efdb299072ab1171e30bcf8eb04~3qy4l1qIF1412914129eusmtip1J; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 4/7] zonefs: use bdev_zone_no helper to calculate the zone index Date: Fri, 6 Jan 2023 09:33:14 +0100 Message-Id: <20230106083317.93938-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7djPc7oX72xPNljYZWWx+m4/m8W0Dz+Z LX6fPc9ssffdbFaLmwd2MlnsWTSJyWLl6qNMFmdefmax2HtL2+LyrjlsFvOXPWW3+Ly0hd3i xC1pB16Py1e8PS6fLfXYtKqTzWPzknqP3Tcb2Dx2tt5n9Ti70tHj/b6rbB59W1Yxemw+Xe3x eZNcAHcUl01Kak5mWWqRvl0CV8bP3ZeYCw4IVjz++Zy5gXE7XxcjJ4eEgInE1KOX2bsYuTiE BFYwSly+uYQJwvnCKNH2Zj8LhPOZUWLy1ZmsMC3t675CVS1nlGi8fQDKeQFUtecTYxcjBweb gJZEYyc7SIOIgLDE/o5WsEnMApuZJG7/XssIkhAWCJL4d3ceC4jNIqAqsefcNrANvAKWEg/2 LYTaJi8x89J3sEGcAlYSz6evYYKoEZQ4OfMJWC8zUE3z1tnMIAskBLo5JdpnbWOBaHaR+Hz8 HiOELSzx6vgWdghbRuL/zvlMEHa1xNMbv6GaWxgl+neuZwP5QELAWqLvTA6IySygKbF+lz5E uaNEU+sfqAo+iRtvBSFO4JOYtG06M0SYV6KjTQiiWkli588nUEslJC43zYE6zEP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Ggmo6PvWwQ9YIS J2c+YQGxmYHqm7fOZp7AKDALSWoWktQCRqZVjCKppcW56bnFRnrFibnFpXnpesn5uZsYgfG3 7djPLTsYV776qHeIkYmD8RCjBAezkghvWf+2ZCHelMTKqtSi/Pii0pzU4kOMpkB3T2SWEk3O ByaAvJJ4QzMDU0MTM0sDU0szYyVxXs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGJlGOhx+rLt4T fHKhOv0Oq8zv3A8mViY7pycpP1ZjPzyjxKLw5pnMyR27ZjGdWFLoszLUwdLK8esNa9lZIsUn Mw+6cMxcl635nv2Z5dTdRS/L2P+s3Hm3VTn90gSeJYdDZFP2PgttMkmJnrzt5s/HTalO8nq/ AuyeWDmlf717l9Nkrs2k0q2bmrNOtyw7le/hdlRP4OHEzXYBPadLGUL6taclPn7uf1rz8RrJ WN0J1i0zJ1ytXyU753Lu2gyfbJNinUk6vkrH7MPNm5LvSm099CTRPXffy+SnPCvTJoS+fZC9 eFKa/78w767exJhzXCZndmwW2TJ3r0NJOYPBJZs/zGJ6sYduLil/m95z0l5knRJLcUaioRZz UXEiAM7UemJIAwAA X-CMS-MailID: 20230106083321eucas1p15e9087bcc62bc6a4f5a61467e1c98698 X-Msg-Generator: CA X-RootMTR: 20230106083321eucas1p15e9087bcc62bc6a4f5a61467e1c98698 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083321eucas1p15e9087bcc62bc6a4f5a61467e1c98698 References: <20230106083317.93938-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use bdev_zone_no() helper instead of opencoding the logic to find the zone index. Signed-off-by: Pankaj Raghav --- fs/zonefs/super.c | 8 +++----- fs/zonefs/zonefs.h | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index 2c53fbb8d918..c2ddc62e99dc 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -487,7 +487,6 @@ 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 = 1; struct zonefs_ioerr_data err = { @@ -502,8 +501,8 @@ static void __zonefs_io_error(struct inode *inode, bool write) * size is always larger than the device zone size. */ if (zi->i_zone_size > bdev_zone_sectors(sb->s_bdev)) - nr_zones = zi->i_zone_size >> - (sbi->s_zone_sectors_shift + SECTOR_SHIFT); + nr_zones = + bdev_zone_no(sb->s_bdev, zi->i_zone_size >> SECTOR_SHIFT); /* * Memory allocations in blkdev_report_zones() can trigger a memory @@ -1420,7 +1419,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; @@ -1804,7 +1803,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 1dbe78119ff1..703bc4505b29 100644 --- a/fs/zonefs/zonefs.h +++ b/fs/zonefs/zonefs.h @@ -179,7 +179,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 Fri Jan 6 08:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13091075 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 502FCC54EF0 for ; Fri, 6 Jan 2023 08:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232396AbjAFIdp (ORCPT ); Fri, 6 Jan 2023 03:33:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232424AbjAFId1 (ORCPT ); Fri, 6 Jan 2023 03:33:27 -0500 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 215A280AC6 for ; Fri, 6 Jan 2023 00:33:25 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083324euoutp017af90767e5ce3d41515b55aa04b416c6~3qy7I8SlY1990519905euoutp019 for ; Fri, 6 Jan 2023 08:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230106083324euoutp017af90767e5ce3d41515b55aa04b416c6~3qy7I8SlY1990519905euoutp019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994004; bh=2fIGGCsma0+nVBZgfpMGxL+SDIiTbKkvsObjxRsUwIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MbiSJYvdvkNeL4z4kNKj9/QEI3bp7dNQ1PF9b3K7CyfS0JqDl7mSIdb6N/Sww2iXZ DEY7DMyMNWIuq9gWCNveg6wGbmAsIe0Uru26MamRaP2H4PR1bSY/6Ec8HZM50Ev/vC te0iWVFcPVJQAXl8InqQDOHQc1u4CDnwEF+KHTfY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230106083322eucas1p2971716b1ceb1cf2f5b90a0b696f8ac40~3qy51-6_o2329223292eucas1p2b; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id E7.43.43884.2DCD7B36; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0~3qy5cK3zL2329223292eucas1p2a; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230106083322eusmtrp14b2b106c1afd8945ed5347acbbf4cd5e~3qy5bgmoU2166121661eusmtrp1k; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) X-AuditID: cbfec7f5-25bff7000000ab6c-49-63b7dcd2ee91 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 0A.C6.23420.2DCD7B36; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230106083321eusmtip292f5234c8251a10cc76fbb993a2024c1~3qy5MIvO82941329413eusmtip2E; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Luis Chamberlain , Johannes Thumshirn , Pankaj Raghav Subject: [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Fri, 6 Jan 2023 09:33:15 +0100 Message-Id: <20230106083317.93938-6-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKKsWRmVeSWpSXmKPExsWy7djP87qX7mxPNjj1U9Zi9d1+NotpH34y W/w+e57ZYu+72awWNw/sZLLYs2gSk8XK1UeZLP523WOyOPPyM4vF3lvaFpd3zWGzmL/sKbvF jQlPGS0+L21htzhxS9qB3+PyFW+Py2dLPTat6mTz2Lyk3mP3zQY2j52t91k9zq509Hi/7yqb R9+WVYwem09Xe3zeJOfRfqCbKYAnissmJTUnsyy1SN8ugSvjQutMloL9vBXrby5namCcyt3F yMkhIWAicWzBSZYuRi4OIYEVjBKLTq5lgnC+MEqsP3oWKvOZUeLA1O3MMC0diw5AJZYzShw7 28kM4bxglDj5/T5jFyMHB5uAlkRjJztIg4iAsMT+jlawBmaBHmaJ3Xc+M4EkhAV8JLp/bWQE sVkEVCXm3LzPAmLzClhK3L2+BmqbvMTMS9/BBnEKWEk8n76GCaJGUOLkzCdg9cxANc1bZ4Md ISEwm1PiwJrT7BDNLhJtU9sZIWxhiVfHt0DFZSROT+5hgbCrJZ7e+A3V3MIo0b9zPRvIBxIC 1hJ9Z3JATGYBTYn1u/Qhyh0l1ixexQJRwSdx460gxAl8EpO2TWeGCPNKdLQJQVQrSez8+QRq qYTE5aY5UEs9JP53LWGawKg4C8kzs5A8Mwth7wJG5lWM4qmlxbnpqcXGeanlesWJucWleel6 yfm5mxiBKe/0v+NfdzCuePVR7xAjEwfjIUYJDmYlEd6y/m3JQrwpiZVVqUX58UWlOanFhxil OViUxHlnbJ2fLCSQnliSmp2aWpBaBJNl4uCUamDS6Smd2XLy7OXvL+bWmtp7z1Pc0L4pauuH P1cnRE5vPH9qQvCDQ7FXMw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TB1mdzP3lr/US1n1otJEhdWGUZsWTqFyz/m0BmZjxMenuqex//nC1tAN1PP9Xr2dVWXbz7S VZzopTgtz/1qxfTl6dOeadce77H4JDY78roph1LTG4GMGVb3jJTeMwmGrH99t/70/MUW95xs 0i6aMqrE8245FJiT0rPER3dn7T/33UteHbp24FeGQMj/V59UwljNEjZ0quzPuDy3+or6jkf7 fBfHunfdNN9SceIP76Nd9788i81Xq1hs4G4437Rix/rHVypKmRkSLrJc90qPv7ja69XLrDxx yUlX7tu2G0Vb3TOpj+qpmrUjXDYmRerm+ozQs7dPfeVeWKuYOev3Nq/paV6PO/7UN5aUuB49 Ny9DiaU4I9FQi7moOBEAFX/yu1cDAAA= X-CMS-MailID: 20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0 X-Msg-Generator: CA X-RootMTR: 20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0 References: <20230106083317.93938-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 Reviewed-by: Bart Van Assche Reviewed-by: Mike Snitzer Reviewed-by: Johannes Thumshirn 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 Fri Jan 6 08:33:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13091078 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 C0628C54E76 for ; Fri, 6 Jan 2023 08:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231922AbjAFIeL (ORCPT ); Fri, 6 Jan 2023 03:34:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232456AbjAFId3 (ORCPT ); Fri, 6 Jan 2023 03:33:29 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F054E7A937 for ; Fri, 6 Jan 2023 00:33:27 -0800 (PST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083324euoutp02e7d2363ecc1c4c041dd4beec48531ea8~3qy7u2NQ32142821428euoutp02q for ; Fri, 6 Jan 2023 08:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230106083324euoutp02e7d2363ecc1c4c041dd4beec48531ea8~3qy7u2NQ32142821428euoutp02q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994004; bh=VLRJd/g9zW/ZTmb/70CCbE3iGbRVLutU6c9iT4cK22Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9qafOCdbAJ7L0vtSLa2LQ7W3Ukf2Hi+mHXzG7ZYz4Zc6SaL+IoF9oAdgS3uWatzn wiTMdjuJDgocD81JFFpBD6i49C8UtM6WvLYWnpdHht8RBh8VhG9Hub9Gd3+HHNVHoB qkmzEGjGTTCTzsTLLScTOabHi33N1OpJxrWaEItY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230106083323eucas1p1a65f5682e8176e747042a06939916e1c~3qy6Zaafa1079910799eucas1p1N; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 50.A3.56180.3DCD7B36; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338~3qy6AgovI1079910799eucas1p1M; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230106083322eusmtrp2ce6bf037b828e56c769e14ab7c11768d~3qy5-wgci1128211282eusmtrp2E; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) X-AuditID: cbfec7f2-ab5ff7000000db74-a2-63b7dcd32d2f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FD.AB.52424.2DCD7B36; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230106083322eusmtip1c280cca29120352af56f70ae80405570~3qy50uWRv0965409654eusmtip1b; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Pankaj Raghav , Luis Chamberlain , Johannes Thumshirn Subject: [PATCH 6/7] dm-zone: use generic helpers to calculate offset from zone start Date: Fri, 6 Jan 2023 09:33:16 +0100 Message-Id: <20230106083317.93938-7-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMKsWRmVeSWpSXmKPExsWy7djPc7qX72xPNvjwidNi9d1+NotpH34y W/w+e57ZYu+72awWNw/sZLLYs2gSk8XK1UeZLP523WOyOPPyM4vF3lvaFpd3zWGzmL/sKbvF jQlPGS0+L21htzhxS9qB3+PyFW+Py2dLPTat6mTz2Lyk3mP3zQY2j52t91k9zq509Hi/7yqb R9+WVYwem09Xe3zeJOfRfqCbKYAnissmJTUnsyy1SN8ugSvj+ZFnTAUTeSquzl7H2sDYzdXF yMkhIWAicf9FO1sXIxeHkMAKRoln656zQzhfGCX6ll1ihHA+M0o03ZvIBNPyqfs4E0RiOaNE Q89CKOcFo8Sjf5OB+jk42AS0JBo72UEaRASEJfZ3tLKA1DAL9DBLvF/wgxkkISwQLnF7xxYW EJtFQFVixsyTrCA2r4ClxK1pk5ghtslLzLz0HWwQp4CVxPPpa5ggagQlTs58At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zl7H2sDYzdXFyMkhIWAi8an7OFMXIxeHkMBS RomLd2azQyQkJG4vbGKEsIUl/lzrYgOxhQSeMUos2ZPWxcjBwSagJdHYCVYuAlSyv6OVBWQO s8AcZomp66axgCSEBUIlDrz9DTaHRUBVYsbMk6wgNq+ApcStaZOYIebLS8y89B1sEKeAlcTz 6WuYIHZZSnR87GWDqBeUODnzCdhMZqD65q2zmScwCsxCkpqFJLWAkWkVo0hqaXFuem6xkV5x Ym5xaV66XnJ+7iZGYGxuO/Zzyw7Gla8+6h1iZOJgPMQowcGsJMJb1r8tWYg3JbGyKrUoP76o NCe1+BCjKdDdE5mlRJPzgckhryTe0MzA1NDEzNLA1NLMWEmc17OgI1FIID2xJDU7NbUgtQim j4mDU6qBSXBea9OfVXM/ll56GbnRkEfp2+Vqr6VvhGQmTnwxN0e91m5x5mK5xbcFbD4uOmfH dX3OW182RuHV8ZPu8iTIbLE8ztXyVayoW+7Jnw8/HnEnC686cTq09r1G9dLY/rqHNhu1u1TW Ve+P5lF6sPL5kuuPA0vK1z2aukTymn3mw/gbuvfbeXZxv4/QtTpifefdK91IcYPAaduW9vp9 EuFY4eLdL7z7SNieFfMNuaTfP9nyyjjI7cyee+f5btRE2ul9cT0qeolb/J8716tzbmvvB680 /HhlWwxzfuAOsf+9at+uzWaTcPMR+X9yi5rV5ccrr4b0shRd+MagoGX5psXj64PEyF6e25Wl yxpmf/j25ZISS3FGoqEWc1FxIgBd2zqqVgMAAA== X-CMS-MailID: 20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338 X-Msg-Generator: CA X-RootMTR: 20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083322eucas1p1ce3ca7b02ca87bb2be8543291e223338 References: <20230106083317.93938-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 open coding. Signed-off-by: Pankaj Raghav Reviewed-by: Luis Chamberlain Reviewed-by: Damien Le Moal Reviewed-by: Bart Van Assche Reviewed-by: Johannes Thumshirn Reviewed-by: Mike Snitzer --- drivers/md/dm-zone.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 3dafc0e8b7a9..ac6fc1293d41 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -390,7 +390,8 @@ static bool dm_zone_map_bio_begin(struct mapped_device *md, case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE: /* Writes must be aligned to the zone write pointer */ - if ((clone->bi_iter.bi_sector & (zsectors - 1)) != zwp_offset) + if (bdev_offset_from_zone_start(md->disk->part0, + clone->bi_iter.bi_sector) != zwp_offset) return false; break; case REQ_OP_ZONE_APPEND: @@ -602,11 +603,8 @@ void dm_zone_endio(struct dm_io *io, struct bio *clone) */ if (clone->bi_status == BLK_STS_OK && bio_op(clone) == REQ_OP_ZONE_APPEND) { - sector_t mask = - (sector_t)bdev_zone_sectors(disk->part0) - 1; - orig_bio->bi_iter.bi_sector += - clone->bi_iter.bi_sector & mask; + bdev_offset_from_zone_start(disk->part0, clone->bi_iter.bi_sector); } return; From patchwork Fri Jan 6 08:33:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 13091077 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 896C9C3DA7A for ; Fri, 6 Jan 2023 08:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbjAFIeK (ORCPT ); Fri, 6 Jan 2023 03:34:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232457AbjAFId3 (ORCPT ); Fri, 6 Jan 2023 03:33:29 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00226ADAB for ; Fri, 6 Jan 2023 00:33:27 -0800 (PST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083325euoutp02c9cf93ab1b90b4aa165c5c7e2763fff8~3qy8kvg-d2142821428euoutp02s for ; Fri, 6 Jan 2023 08:33:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230106083325euoutp02c9cf93ab1b90b4aa165c5c7e2763fff8~3qy8kvg-d2142821428euoutp02s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994005; bh=ki5YCi75NytYdqt7jBnGHXj1OOScNdOplcKKRH7vS3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YtzsNb3p5ukwBbg3Z1DF6RY7c2g7hjRifZy337iRD0UoyWinTYTFvqz05If70KWdW J3a+eKZR3qk6/uvzGxmgvAbd1sgCi9h4q8U1q2BRVNeXc95m2XSKLjvre1KdTwkeYg yThgZYnKFjSmYkEqNBGOXv/UQeHt+mIs9k4NxI1c= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230106083324eucas1p2a41a4dc8a4943a42cebd2faff7b4f11b~3qy7O-sUd0368903689eucas1p23; Fri, 6 Jan 2023 08:33:24 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 5A.14.61936.3DCD7B36; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230106083323eucas1p2f0f6d5d5c1c3713be35b841157ae463e~3qy6rXvLi0142401424eucas1p2Q; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230106083323eusmtrp21b31fb042b763934d753f5d411f81c64~3qy6qwBSI1128211282eusmtrp2F; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) X-AuditID: cbfec7f4-a2dff7000002f1f0-de-63b7dcd3c38d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FE.AB.52424.3DCD7B36; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230106083323eusmtip2fe614ae8c9a0dcec5c403fa52c600eb8~3qy6fASkM2941329413eusmtip2G; Fri, 6 Jan 2023 08:33:23 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Pankaj Raghav Subject: [PATCH 7/7] dm: call dm_zone_endio after the target endio callback for zoned devices Date: Fri, 6 Jan 2023 09:33:17 +0100 Message-Id: <20230106083317.93938-8-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEKsWRmVeSWpSXmKPExsWy7djPc7qX72xPNvi01dpi9d1+NotpH34y W/w+e57ZYu+72awWNw/sZLLYs2gSk8XK1UeZLM68/MxisfeWtsXlXXPYLOYve8pu8XlpC7vF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M+6dRgMAAA== X-CMS-MailID: 20230106083323eucas1p2f0f6d5d5c1c3713be35b841157ae463e X-Msg-Generator: CA X-RootMTR: 20230106083323eucas1p2f0f6d5d5c1c3713be35b841157ae463e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083323eucas1p2f0f6d5d5c1c3713be35b841157ae463e References: <20230106083317.93938-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. Call dm_zone_endio for zoned devices after calling the target's endio function. Reviewed-by: Mike Snitzer Reviewed-by: Bart Van Assche 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 b424a6ee27ba..fdef74fe8bd1 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1109,10 +1109,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) { @@ -1141,6 +1137,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);