From patchwork Thu Aug 11 14:30: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: 12941473 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 D7FD3C3F6B0 for ; Thu, 11 Aug 2022 14:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235270AbiHKObD (ORCPT ); Thu, 11 Aug 2022 10:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235180AbiHKOay (ORCPT ); Thu, 11 Aug 2022 10:30:54 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CBB36C127 for ; Thu, 11 Aug 2022 07:30:51 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143048euoutp014f41e23d3d9b2a02d9be0f63899e15f8~KUMuq0ISA2164821648euoutp01F for ; Thu, 11 Aug 2022 14:30:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143048euoutp014f41e23d3d9b2a02d9be0f63899e15f8~KUMuq0ISA2164821648euoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228248; bh=AD8v/RK3vFIqsgabYiTtVZbPbcAOQ4zUOz/AmbfbvbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SnL2YnjAOjY9wL4Wt4C64w9KF1nFRqZdaZW/RDnlmzzKZIiBg8J4TFoE+2N8hsPIG DQOZaXUJGT6OwD2yA6ljG3xTF1AdF/bEc5qPJ3wD7qNQyKXJeVYAHdOY4+lxJ8AJKF HuVER4Y91IZPsdaCukU9YV9lkh8JP5DXOhm2/9Vc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143046eucas1p2aca499e896bb89a154e4a4b1bdf718e2~KUMs082vL1006810068eucas1p2D; Thu, 11 Aug 2022 14:30:46 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 58.8C.09580.69215F26; Thu, 11 Aug 2022 15:30:46 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220811143045eucas1p2773a7e7bbe9f3667d1105cc1465dac42~KUMsXYqvE2328423284eucas1p2G; Thu, 11 Aug 2022 14:30:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220811143045eusmtrp2a1accb11028d7272eec67818e141c2aa~KUMsWeF4W0786307863eusmtrp2t; Thu, 11 Aug 2022 14:30:45 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-a0-62f51296b42f Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FB.00.09038.59215F26; Thu, 11 Aug 2022 15:30:45 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220811143045eusmtip2ddbb16a5b5589429fc9855578ecfe1d6~KUMsA2dat1262412624eusmtip2w; Thu, 11 Aug 2022 14:30:45 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Luis Chamberlain , Adam Manzanares Subject: [PATCH v10 01/13] block: make bdev_nr_zones and disk_zone_no generic for npo2 zone size Date: Thu, 11 Aug 2022 16:30:31 +0200 Message-Id: <20220811143043.126029-2-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJKsWRmVeSWpSXmKPExsWy7djP87rThL4mGRx8KmAx/bCixfpTx5gt Vt/tZ7OY9uEns8Xvs+eZLfa+m81qcfPATiaLPYsmMVmsXH2UyeLJ+lnMFn+77jFZ7L2lbXF5 1xw2i/nLnrJbTGj7ymxxY8JTRovPS1vYLdbcfMpiceKWtIOwx+Ur3h47Z91l97h8ttRj06pO No/NS+o9dt9sYPPY2Xqf1eP9vqtsHn1bVjF6bD5d7fF5k5xH+4FupgCeKC6blNSczLLUIn27 BK6Mv1PbmQquilQ8m/CKrYFxlmAXIyeHhICJRNPrMyxdjFwcQgIrGCXObFzPDuF8YZRo7Z7O COF8ZpSYPuUZO0zLjvZFTBCJ5YwSnTcmM0M4Lxglzr/YAlTFwcEmoCXR2AnWICKQLrF+wXKw HcwCXcwSj07+ZwZJCAskSUy+fYEFxGYRUJXoeraHFcTmFbCS2Nn9nBVim7zEzEvfwQZxClhL TFh0kQmiRlDi5MwnYL3MQDXNW2eDHSEhsJ9T4taew1CnukicP/aGBcIWlnh1fAtUXEbi/875 TBB2tcTTG7+hmlsYJfp3rmcD+UACaFvfmRwQk1lAU2L9Ln2IckeJ8xv+MkJU8EnceCsIcQKf xKRt05khwrwSHW1CENVKEjt/PoFaKiFxuWkO1DEeEi/OLWKewKg4C8kzs5A8Mwth7wJG5lWM 4qmlxb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rFD1AtKnJz5hAXEZgaqb946m3kCo8As JKlZSFILGJlWMYqklhbnpucWG+kVJ+YWl+al6yXn525iBEbwtmM/t+xgXPnqo94hRiYOxkOM EhzMSiK8ZYs+JwnxpiRWVqUW5ccXleakFh9iNAW6eyKzlGhyPjCF5JXEG5oZmBqamFkamFqa GSuJ83oWdCQKCaQnlqRmp6YWpBbB9DFxcEo1MO0s39O89Zd3gz+XWZqRQ+At63VSpTM3fVk5 5S73vGPKOXUZ8ZF7k+yqRd58W/l1VbPOgg18ewNux0ptasgKzfQ2Ot7Hkvvh4DMR67/hN19m 1Kx7rRTyy2B1wdvt0z3/5nNJH9fZv/Lm90zm2Vc3zVwpPbt0cc05yVeVqnJuLQ5hE6ZMXrTq STHLhS9n0kslGStDo+of3Be7WHfs6CXbovqpjSc77u9zUUtSl51z69rk26XLvxTdFXPnTz4h td7V4OiVJV+ZGA72rkysPr7nFKsex20ncempbVXKt171a4r6rd88MTF5Zk7hxJoJOl6F+Z/9 5Z9fm64daeIvIp51e0fjy4n2c6u2i520+iz+7boSS3FGoqEWc1FxIgAWpoobaQMAAA== X-CMS-MailID: 20220811143045eucas1p2773a7e7bbe9f3667d1105cc1465dac42 X-Msg-Generator: CA X-RootMTR: 20220811143045eucas1p2773a7e7bbe9f3667d1105cc1465dac42 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143045eucas1p2773a7e7bbe9f3667d1105cc1465dac42 References: <20220811143043.126029-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 Thu Aug 11 14:30: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: 12941475 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 85C80C25B0C for ; Thu, 11 Aug 2022 14:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234549AbiHKObF (ORCPT ); Thu, 11 Aug 2022 10:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234648AbiHKOay (ORCPT ); Thu, 11 Aug 2022 10:30:54 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7446BD48 for ; Thu, 11 Aug 2022 07:30:51 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143049euoutp017d6d5a9b7091b2ae5817e7a14feff7c0~KUMvoyrXK2260722607euoutp01H for ; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143049euoutp017d6d5a9b7091b2ae5817e7a14feff7c0~KUMvoyrXK2260722607euoutp01H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228249; bh=IETSHhg+Pz8bc6feXW/VCb8IyBS9MrfSYvdPWvuUfIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUJjmSETtKrfnHjivgZ2RCbNIwYaxlgocTXAgW3jGYdvlF9gFqD56GoEEsuzPvOL6 HVWYG34/qOyGtfUiu/pb01V3dBVGj2kM7dm6XtA0AEhuJM3J8GL/CI/fq1SPHK3DRk 3FK1aU+6aJAXV8+Tapp7iF+V4xZwxB3sffsmhFhs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143047eucas1p2b9a2611311d138dadaa78f294cb95c04~KUMuDO0vk2328423284eucas1p2K; Thu, 11 Aug 2022 14:30:47 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5A.8C.09580.79215F26; Thu, 11 Aug 2022 15:30:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220811143046eucas1p2e49a778cff29476c7ebaef1d1c67d86c~KUMtbE4vD1005510055eucas1p26; Thu, 11 Aug 2022 14:30:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143046eusmtrp138eff0a7326f9b32d9d9e7bd5354f752~KUMtaNGU02320623206eusmtrp1O; Thu, 11 Aug 2022 14:30:46 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-a4-62f512979374 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1E.00.09038.69215F26; Thu, 11 Aug 2022 15:30:46 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220811143046eusmtip24bbf8f26edcb02bde2c4177a98ae4647~KUMs-Uyjg1162311623eusmtip2J; Thu, 11 Aug 2022 14:30:46 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav Subject: [PATCH v10 02/13] block:rearrange bdev_{is_zoned,zone_sectors,get_queue} helpers in blkdev.h Date: Thu, 11 Aug 2022 16:30:32 +0200 Message-Id: <20220811143043.126029-3-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFKsWRmVeSWpSXmKPExsWy7djP87rThb4mGSztkbJYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDIajjSwFdwW rdj08h17A2OfUBcjJ4eEgInE6j3vmUBsIYEVjBLTTwlB2F8YJZ7PVO5i5AKyPzNKHO1ezgjT 8LRjKSNEYjmjxImfB5khOl4wSizZHdHFyMHBJqAl0djJDhIWEUiXWL9gOQuIzSywjUliywNh EFsYKL7n9js2EJtFQFXixuXFrCA2r4CVxJb9rcwQu+QlZl76DjaHU8BaYsKii0wQNYISJ2c+ gZopL9G8dTYzyD0SAus5JS6un8YOcoOEgIvEvy3qEHOEJV4d38IOYctInJ7cwwJhV0s8vfEb qreFUaJ/53o2iF5rib4zOSAms4CmxPpd+hBRR4nvcwUgTD6JG28FIQ7gk5i0bTozRJhXoqMN GrBKEjt/PoHaKSFxuWkO1E4PicWN35gmMCrOQvLKLCSvzEJYu4CReRWjeGppcW56arFxXmq5 XnFibnFpXrpecn7uJkZg8jv97/jXHYwrXn3UO8TIxMF4iFGCg1lJhLds0eckId6UxMqq1KL8 +KLSnNTiQ4zSHCxK4rzJmRsShQTSE0tSs1NTC1KLYLJMHJxSDUxT2yXbnv4Jd97EHtDKw3G3 +fOM2kPmfOtKeK+dv9PvLlzsxsf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83oWdCQK CaQnlqRmp6YWpBbB9DFxcEo1MJVeP6X3SWl/edOdO3IGOessTsxvXi55KTTxAefrrXcWzleR 4zPnzF9iWHvjixzTvGO+Ftcuva87O0XITC5gPiPHgb7FViWN50Ps2aLnfpURTJx9scB7SvPR tmBD05JVmU/9/9Wm8FyZs1MqsUbbuTWLh2NVp3YPG6Mdd9ru0BrTY92huzIzva8pv/0mqsJa 47bd7e5G27OGZWxncxeennNSWauzc1bzjJmPoiP+fZvNvXnLjoyrrv8Kb8sX1qdMytwpv2RG NffkbdM8As/v9frb6NlSc4XLneOuF+f2qC05vxfmvNhyQG3GlYlC7y4/yS25IuSh1PTwy5zQ wt+WH+sEuhMclY9fCimx4gtnUGIpzkg01GIuKk4EAGMLFrxgAwAA X-CMS-MailID: 20220811143046eucas1p2e49a778cff29476c7ebaef1d1c67d86c X-Msg-Generator: CA X-RootMTR: 20220811143046eucas1p2e49a778cff29476c7ebaef1d1c67d86c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143046eucas1p2e49a778cff29476c7ebaef1d1c67d86c References: <20220811143043.126029-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: Bart Van Assche 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 Thu Aug 11 14:30: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: 12941477 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 997F4C19F2A for ; Thu, 11 Aug 2022 14:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235112AbiHKObG (ORCPT ); Thu, 11 Aug 2022 10:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235399AbiHKOa4 (ORCPT ); Thu, 11 Aug 2022 10:30:56 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D8274DEE for ; Thu, 11 Aug 2022 07:30:55 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143050euoutp01d38d7b4b8d30ce61507c6e7dcffa92cd~KUMwnjRWR2261422614euoutp01E for ; Thu, 11 Aug 2022 14:30:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143050euoutp01d38d7b4b8d30ce61507c6e7dcffa92cd~KUMwnjRWR2261422614euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228250; bh=OX60KjudRLvNZCiTdE3cUfkGk6srYbDq6kJdBqLbD0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7AzQ2byruGaGJ5QCusbSl/QUmKVeZjAjPNEJ/gt11ESpJHgTpiKCLu6bE8BwEjfa H6Lg89Nsn9JgbkutuWFKg1oaAC9uFkgLPHXT4dK0rZffIwjZnYuj1InkFkkvyrEx6p S6PpK2/Yj2qOg719to05b49EkMVrOpcAnGAAj5HE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143048eucas1p277bf654881b519a9eeebb4fd14817ae0~KUMvJDs-h1007210072eucas1p2V; Thu, 11 Aug 2022 14:30:48 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id B1.EF.10067.89215F26; Thu, 11 Aug 2022 15:30:48 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220811143048eucas1p10e3ae3ef0c93228e9598e1a1a613f6e1~KUMuipDMR0779607796eucas1p1g; Thu, 11 Aug 2022 14:30:48 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143048eusmtrp150ece03c3fbe6de438b4d5451a893407~KUMuhy_yl2320623206eusmtrp1W; Thu, 11 Aug 2022 14:30:48 +0000 (GMT) X-AuditID: cbfec7f4-5ce7da8000002753-4b-62f5129809d6 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A0.10.09038.89215F26; Thu, 11 Aug 2022 15:30:48 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143047eusmtip181ce57f2cd123cd0d1000b17febb9dd1~KUMuJcH4f3243132431eusmtip1B; Thu, 11 Aug 2022 14:30:47 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v10 03/13] block: allow blk-zoned devices to have non-power-of-2 zone size Date: Thu, 11 Aug 2022 16:30:33 +0200 Message-Id: <20220811143043.126029-4-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMKsWRmVeSWpSXmKPExsWy7djPc7ozhL4mGbz+oWux/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2PC nR/MBa/VKw5Pf87UwLhDoYuRk0NCwERi2qkJjF2MXBxCAisYJX4+msMM4XxhlDi2dTVU5jOj xO5rnxlhWj5OmM8EkVjOKPF3/3oWCOcFo8Tb5n1ADgcHm4CWRGMnO0iDiEC6xPoFy8FqmAXu MEl8v9fDBpIQFoiR2Lt9GzOIzSKgKnHg1FywBl4BK4nz889CbZOXmHnpO1icU8BaYsKii0wQ NYISJ2c+YQGxmYFqmrfOZoao384p0b1OC8J2kVgx5wkThC0s8er4FnYIW0bi9OQeFgi7WuLp jd9gP0sItDBK9O9czwbygATQsr4zOSAms4CmxPpd+hBRR4mutakQJp/EjbeCEAfwSUzaNp0Z Iswr0dEmBDFbSWLnzydQOyUkLjfNgdrpITF3yV/mCYyKs5C8MgvJK7MQ1i5gZF7FKJ5aWpyb nlpslJdarlecmFtcmpeul5yfu4kRmA5P/zv+ZQfj8lcf9Q4xMnEwHmKU4GBWEuEtW/Q5SYg3 JbGyKrUoP76oNCe1+BCjNAeLkjhvcuaGRCGB9MSS1OzU1ILUIpgsEwenVAOTf51GrMrrSLY7 fSc6Hv9a0frG786x8PpJR/dP4Aq/pmcyR70t5qLHycqHAr8Lzp47JZ0rwLz4h6PC5frDZ1K9 ip5uM9P6/enS6aKoCQct/7GmX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y66HgNt8n RUcbOZ8rmIkFnOBzTko9cH+PdKpN9GuP8+8ZjB9mRRzbfWb/r0lGtcKF3jNbRXoNhNJeqfhc jryQnHSw8V7ajj+e+R8PzN6bWn6cNfTah1+avHuf7ZQtj1g8+0e5q+GO5z8yCvzUTu9c/DFt DavkxbdzNvVJ2C7ytxW96OAirvpx7vQpQc9OXGbJ2e2oJhjG0FZ0wmWZ5AoFExaJrR3Ls4MP tqvW6pe6T+t4+aPphkFa3nmjNXm/WZOUq7b5Hv2ZsylR7CmX0aru3h2T7qX7JNfMTzL55rd6 iZf/v1utR1/qSF9Wtuiv2VQQdd8wbIESS3FGoqEWc1FxIgCgSbVVZgMAAA== X-CMS-MailID: 20220811143048eucas1p10e3ae3ef0c93228e9598e1a1a613f6e1 X-Msg-Generator: CA X-RootMTR: 20220811143048eucas1p10e3ae3ef0c93228e9598e1a1a613f6e1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143048eucas1p10e3ae3ef0c93228e9598e1a1a613f6e1 References: <20220811143043.126029-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 Thu Aug 11 14:30: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: 12941476 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 E7BB4C25B0D for ; Thu, 11 Aug 2022 14:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235005AbiHKObF (ORCPT ); Thu, 11 Aug 2022 10:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235351AbiHKOa4 (ORCPT ); Thu, 11 Aug 2022 10:30:56 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2996BD48 for ; Thu, 11 Aug 2022 07:30:55 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143051euoutp0174cbfb93f57a06379a01b870095b0ba7~KUMxqK2fE2136521365euoutp01b for ; Thu, 11 Aug 2022 14:30:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143051euoutp0174cbfb93f57a06379a01b870095b0ba7~KUMxqK2fE2136521365euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228251; bh=tGdXrZOo82rW1rnRJeQcvmwRabixUhHDV5CM9X+9nHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIIVgrmdDjVY7c6oUankpYVIjETFb1jFWYQyCvWLeMj8aHxZBr++3Pu5U3A7LbLdb lT7GQJjgYhlpAuMrvH3Y427Z7xiEuAVwsqDoyQLEiHQUiUlu1lMx20HKy48c0fVhFN Os7p2qwwfb3WWQVzL0EtAayOFht3NatXh5861rbM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143049eucas1p27cb8b7758e8a5e7b59456f22fb326720~KUMwHY_MB1006810068eucas1p2M; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 92.3A.09664.99215F26; Thu, 11 Aug 2022 15:30:49 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204~KUMvfQPuc0779607796eucas1p1j; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143049eusmtrp1e3aae0de0e516634df21100a3c33ba88~KUMvdqMez2320623206eusmtrp1b; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-ee-62f51299c5cc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D2.10.09038.99215F26; Thu, 11 Aug 2022 15:30:49 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143048eusmtip11fa620b806bf661c7086d78210f8c4d5~KUMvLFObd3242632426eusmtip1D; Thu, 11 Aug 2022 14:30:48 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Johannes Thumshirn , Luis Chamberlain Subject: [PATCH v10 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Thu, 11 Aug 2022 16:30:34 +0200 Message-Id: <20220811143043.126029-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSW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sgnqF9jOX43SmuW6p3p7nQt7 9FPhjaL1qmUKb3adjOHS/pD6/7ULj9Ky+tgki/2x3CqWom+77vzQMrYwlz6vXfPE9cVxLc/d 5coPpjoI7Xi0fev08xnHJ2+b1bqReYaZ/qc9H1WPPfnTw3Z2rv9Upo+uWakvWrJf7fvSUPxn 7aRG+3snru5VvRD5fjPDRrsbl9KDp3QqsRRnJBpqMRcVJwIASf8/ImQDAAA= X-CMS-MailID: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204 X-Msg-Generator: CA X-RootMTR: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143049eucas1p141d029f2efd6703b596bbea71ab69204 References: <20220811143043.126029-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 Thu Aug 11 14:30: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: 12941481 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 7CB01C25B0E for ; Thu, 11 Aug 2022 14:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234582AbiHKObJ (ORCPT ); Thu, 11 Aug 2022 10:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235513AbiHKOa5 (ORCPT ); Thu, 11 Aug 2022 10:30:57 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCEF66CD18 for ; Thu, 11 Aug 2022 07:30:55 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143052euoutp015059e2e467ba00a77df8320101351d9e~KUMyq6M4y2260722607euoutp01O for ; Thu, 11 Aug 2022 14:30:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143052euoutp015059e2e467ba00a77df8320101351d9e~KUMyq6M4y2260722607euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228252; bh=E+La7o2Zl30I/sNS3Lx2T739zrulxOvYuda5lE4fWfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C+58itCREFNkgY4yVDvsTp6oumwsp/0bIQmrp5p+1QC0x9Ei89VmgZ7VJfRZKFFko zI+88bQEe0b+DxO4itmpO3lnZ86bBQ7ZRVFH3ujuPxE5KVeEYDGUH83BDfLht2nSe0 jLdKLUUTZe1tdFCrsIhAd/RKzNmGxiOB7latB630= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143050eucas1p2082dc6853555f1a80ee9994af529d4a9~KUMw84uep1006410064eucas1p2I; Thu, 11 Aug 2022 14:30:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D3.EF.10067.A9215F26; Thu, 11 Aug 2022 15:30:50 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220811143050eucas1p12321909b1b7f94182708b935b35e4ff9~KUMwdpqRb1846918469eucas1p1F; Thu, 11 Aug 2022 14:30:50 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220811143050eusmtrp2ebea614a3e934204df9673ec6f2405dd~KUMwctMAb0788907889eusmtrp2r; Thu, 11 Aug 2022 14:30:50 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-4f-62f5129a6172 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F0.9F.09095.A9215F26; Thu, 11 Aug 2022 15:30:50 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220811143049eusmtip20b2ace903518564fc96a4d8c6eba6861~KUMwH0_b11037010370eusmtip24; Thu, 11 Aug 2022 14:30:49 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v10 05/13] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size Date: Thu, 11 Aug 2022 16:30:35 +0200 Message-Id: <20220811143043.126029-6-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKKsWRmVeSWpSXmKPExsWy7djPc7qzhL4mGSy8rGqx/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2Pz /q3sBX0iFUc6J7M0MF4S6GLk5JAQMJHoPH2IpYuRi0NIYAWjxJ2ZqxghnC+MElu+zWKHcD4z Svx5vYIFpmVRdxNUy3JGif27W6GqXjBKrOj/DdTPwcEmoCXR2MkO0iAikC6xfsFysAZmgTtM Et/v9bCBJIQFoiXubZ/LBGKzCKhKrHy8DszmFbCSePJrHzvENnmJmZe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GGkZ2hpoWdkYqlnaGwea2VkqqRvZ5OSmpNZllqkb5egl7F5/1b2gj6RiiOdk1kaGC8JdDFy ckgImEgs6m5i6WLk4hASWMoo8eZkEyNEQkLi9kIYW1jiz7UuNoiiZ4wSpxcfZe1i5OBgE9CS aOxkBzFFBHIlDh4JBClhFnjDJNF5fQ8LSK+wQKTE1LXv2EBsFgFViZWP1zGB2LwCVhJPfu1j h5gvLzHz0ncwm1PAWmLCootgNUJANRM6jrFD1AtKnJz5BGwmM1B989bZzBMYBWYhSc1CklrA yLSKUSS1tDg3PbfYUK84Mbe4NC9dLzk/dxMjMHa3Hfu5eQfjvFcf9Q4xMnEwHmKU4GBWEuEt W/Q5SYg3JbGyKrUoP76oNCe1+BCjKdDdE5mlRJPzgckjryTe0MzA1NDEzNLA1NLMWEmc17Og I1FIID2xJDU7NbUgtQimj4mDU6qBaZ4nW94lV5GDxepc1yarSXMKltaVJ2i/P7HZPaxiAt96 vSbOr1E6TC+S56wvNmbO/rquW5Df+pZcyLtNU3RnyzXsl8kIOjI59WGdO/PBvy9El+afnzGz farE/8L5/+wa1vN4ieqmc7+8GJ6sPvnbdnGfrWs/iK0u5rA9t6bEc68U36XLbs6L+vviT/SL zCgtjXsUlqy1aYm73sumxxZM57IDfpztOnT/nGGQdeq3FPb412cqI6PY/30/+pozpP+Z5Jqd HUevmX1hNs4yvnXnz6rrXxfxxyVK1ppLvs39/7PsuOL9xE9lywQLLicGXnRzjSlstK46uHyt zZnKI2tfHbNWrff3Kf5ovktiu9p3JZbijERDLeai4kQA6RxxWmYDAAA= X-CMS-MailID: 20220811143050eucas1p12321909b1b7f94182708b935b35e4ff9 X-Msg-Generator: CA X-RootMTR: 20220811143050eucas1p12321909b1b7f94182708b935b35e4ff9 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143050eucas1p12321909b1b7f94182708b935b35e4ff9 References: <20220811143043.126029-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 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 12316ab51bda..73e4ad495ae8 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,11 @@ 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 Thu Aug 11 14:30: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: 12941480 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 35E5CC19F2A for ; Thu, 11 Aug 2022 14:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235315AbiHKObJ (ORCPT ); Thu, 11 Aug 2022 10:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235521AbiHKOa6 (ORCPT ); Thu, 11 Aug 2022 10:30:58 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCE016BD63 for ; Thu, 11 Aug 2022 07:30:55 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143053euoutp01c6e2831b56a36134ea99a49f7dfee316~KUMzdLi5o2260922609euoutp01- for ; Thu, 11 Aug 2022 14:30:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143053euoutp01c6e2831b56a36134ea99a49f7dfee316~KUMzdLi5o2260922609euoutp01- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228253; bh=hLglEsgs8ISJExGYQKv645MJDunEKMqaZXVaT8ARNsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BOIX5xaTOZ6NelpiBhQrY8C2ZrcsCvPTF4Aoj8mSdsKAgfXEqKBRb0GLs3jAKjat3 mhSZ+yrdtZDPd7DvC4LAGIYKcQryhkqGkok0+TKfWmfu3JKIZrQvgM5bAFLxXXmvIa 6hc0YqAcuC5pOwzJqgyDNkqDnubk4lmasVQoFdMk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143051eucas1p22c12a3fad3aa2314c7907177ad872b77~KUMx7BKQL2328523285eucas1p2M; Thu, 11 Aug 2022 14:30:51 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5D.8C.09580.B9215F26; Thu, 11 Aug 2022 15:30:51 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220811143051eucas1p24c16e378cd8080b0b22f5fb4d7659cf0~KUMxcTM6Q1006810068eucas1p2R; Thu, 11 Aug 2022 14:30:51 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143051eusmtrp1d7496c7528a7fa92d9ac255c5c0b907e~KUMxbLITs2320623206eusmtrp1g; Thu, 11 Aug 2022 14:30:51 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-b2-62f5129b3da4 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 25.10.09038.B9215F26; Thu, 11 Aug 2022 15:30:51 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143050eusmtip1008edb8f42bfb1b0c7b8a2557599ca5a~KUMxC32YU3243132431eusmtip1C; Thu, 11 Aug 2022 14:30:50 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v10 06/13] null_blk: allow zoned devices with non power-of-2 zone sizes Date: Thu, 11 Aug 2022 16:30:36 +0200 Message-Id: <20220811143043.126029-7-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMKsWRmVeSWpSXmKPExsWy7djPc7qzhb4mGbT+1rRYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlTFr 91/mguPSFQ/n/WdvYFwu3sXIySEhYCLx+8sGpi5GLg4hgRWMEu//n2OEcL4wSnxq2cQKUiUk 8JlR4vzCGpiOSat7GSHiyxklJqxzgmh4wSjR0X0EKMHBwSagJdHYyQ5SIyKQLrF+wXIWkBpm gTtMEt/v9bCBJIQFIiX2tE4AK2IRUJXo7tvIBGLzClhJbOj/wgqxTF5i5qXvYDWcAtYSExZd hKoRlDg58wkLiM0MVNO8dTYzyAIJgd2cEq8mnGKBaHaR+Ph4FtQgYYlXx7ewQ9gyEqcn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YxAhhC0v8udbFBlH0jFFixf79rF2MHBxs AloSjZ3sIKaIQK7EwSOBICXMAm+YJDqv72EB6RUWCJeYdPIAK4jNIqAq0d23kQnE5hWwktjQ /4UVYr68xMxL39lBbE4Ba4kJiy6C1QgB1UzoOMYOUS8ocXLmE7CZzED1zVtnM09gFJiFJDUL SWoBI9MqRpHU0uLc9NxiI73ixNzi0rx0veT83E2MwNjdduznlh2MK1991DvEyMTBeIhRgoNZ SYS3bNHnJCHelMTKqtSi/Pii0pzU4kOMpkB3T2SWEk3OByaPvJJ4QzMDU0MTM0sDU0szYyVx Xs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGpsa3QXqLTXNncO3Zs0Yherfn5zcpnyfzLtL2S2na orflw80EsbVbL2y/pZB1ICtg1buNdpdZcjnV2vOET2vd+9fKHay3+N5HhwNzsj0vbXWYfXyH Sp5L8oz1ZWXKdh03fpiYdMZnRcvsKm65Y16kdilafVlX0D82hZVrJV2XeLSlidSWfjHSiP7W dX/S/I2e63lOXV7QuMZjk1vNb+O6yUF3T5d/ZLtpOGflpRt2EpdrO/vW79u1/Wf21INnvE9F 2VyO+iS54/86haAY5um7F88p+W5br9txzlhc6+XzxXuj/r716eOZyZP4+/qS7fM1pxwuTIwM Vw6xNHxovpfpOvPXhBszFZb+atK+crH3Z5ASS3FGoqEWc1FxIgBNyj/zZgMAAA== X-CMS-MailID: 20220811143051eucas1p24c16e378cd8080b0b22f5fb4d7659cf0 X-Msg-Generator: CA X-RootMTR: 20220811143051eucas1p24c16e378cd8080b0b22f5fb4d7659cf0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143051eucas1p24c16e378cd8080b0b22f5fb4d7659cf0 References: <20220811143043.126029-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 Thu Aug 11 14:30:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12941479 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 D7112C25B0C for ; Thu, 11 Aug 2022 14:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235522AbiHKObH (ORCPT ); Thu, 11 Aug 2022 10:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235518AbiHKOa5 (ORCPT ); Thu, 11 Aug 2022 10:30:57 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD4C6CD11 for ; Thu, 11 Aug 2022 07:30:56 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143054euoutp01c9a8214b882b74d38ccd76951a1c0ad1~KUM0iUJ-o2260022600euoutp01F for ; Thu, 11 Aug 2022 14:30:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143054euoutp01c9a8214b882b74d38ccd76951a1c0ad1~KUM0iUJ-o2260022600euoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228254; bh=2l9t4o2MFdGXGYEr9szOD+OY2x6nysmCjdo7iJiFJ2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rL6jnRl1RMdh3/OcTJNYgtkjrKa/B5ReWGPLRdxP4VNAdBgv4P/lS3zr7paoVy+LW SsXL8DRqqQ2ru+0GEbn1E5YA00ajFP+MwMl9zXgYN8fjChKkyD7nV9EMguXe0sv1bH Vz0UJp8mCla8OZZe1ifiyBh5GstDQLy6sNc0veZc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143052eucas1p2c80d56c33b4de812a99a8a809f90fe79~KUMy-4N311006010060eucas1p24; Thu, 11 Aug 2022 14:30:52 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 0F.8C.09580.C9215F26; Thu, 11 Aug 2022 15:30:52 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220811143052eucas1p1426fad3e5fd52fb93243e5daaf06ce7d~KUMydxxFi1847718477eucas1p1G; Thu, 11 Aug 2022 14:30:52 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143052eusmtrp193c0c83557bdec3951e0c1358968aa6b~KUMydATEu2320623206eusmtrp1i; Thu, 11 Aug 2022 14:30:52 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-b8-62f5129ca67a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 96.10.09038.C9215F26; Thu, 11 Aug 2022 15:30:52 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143052eusmtip1613c100c3ae3a1505b311b2c49a57eae~KUMyHr7H62339723397eusmtip1I; Thu, 11 Aug 2022 14:30:52 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v10 07/13] zonefs: allow non power of 2 zoned devices Date: Thu, 11 Aug 2022 16:30:37 +0200 Message-Id: <20220811143043.126029-8-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEKsWRmVeSWpSXmKPExsWy7djP87pzhL4mGVw7aW6x/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyY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yeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCdKz6Yov7QkVSEjv7jEVina 0MJIz9DSQs/IxFLP0Ng81srIVEnfziYlNSezLLVI3y5BL+PBhMSCFsGKFX+qGxgn8XUxcnJI CJhIvL24hqWLkYtDSGApo8TbX1PZIBISErcXNjFC2MISf651sUEUPWOUeDd/JnsXIwcHm4CW RGMnmCkikCtx8EggSAmzwBsmic7re1hAeoUFXCVuTjjBDGKzCKhK/Pq3nBXE5hWwknh76DIr xHx5iZmXvrOD2JwC1hITFl1kArGFgGomdBxjh6gXlDg58wnYTGag+uats5knMArMQpKahSS1 gJFpFaNIamlxbnpusZFecWJucWleul5yfu4mRmDcbjv2c8sOxpWvPuodYmTiYDzEKMHBrCTC W7boc5IQb0piZVVqUX58UWlOavEhRlOguycyS4km5wMTR15JvKGZgamhiZmlgamlmbGSOK9n QUeikEB6YklqdmpqQWoRTB8TB6dUA5N+c0e8vsDd/Tm690oEH85fNSdTUYwj7Dur67KG5Txu RpwpScGWp1S312mVnFlnn604eVlEyIsdzzZ+aPms1aXseuOmU2HeO/3n/EH7LGsy1ZL3ea3O r9jx7oXQZXv/wIl+GnP98k58DbIMWyi2p5V9xen83DirxbvO6bzc3adzuWHZg/2iAWlS3/UL X6yYmGsvaZV5489iaeneVY3Wj+5MTZDSEWNj//NuYuinLyL/J5RIdb/5ebnYNTcj9PDS9Wf/ LBRfnpk56Y/4rfLHtxonJB4Q0juvf/vPkj3dBteibPLMuMWMm69eONX+tPOIxnu5iYwy8ZOq 5/TaXC84o52yYrr5XuGiCvb7xzrf9yixFGckGmoxFxUnAgCnnBacZAMAAA== X-CMS-MailID: 20220811143052eucas1p1426fad3e5fd52fb93243e5daaf06ce7d X-Msg-Generator: CA X-RootMTR: 20220811143052eucas1p1426fad3e5fd52fb93243e5daaf06ce7d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143052eucas1p1426fad3e5fd52fb93243e5daaf06ce7d References: <20220811143043.126029-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 Thu Aug 11 14:30:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12941478 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 EFD1EC25B07 for ; Thu, 11 Aug 2022 14:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235399AbiHKObH (ORCPT ); Thu, 11 Aug 2022 10:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235522AbiHKOa7 (ORCPT ); Thu, 11 Aug 2022 10:30:59 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D7E6CD02 for ; Thu, 11 Aug 2022 07:30:56 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143055euoutp01ae7af987ae204fefd7450bbde4b67dbc~KUM1WRfpe2164821648euoutp01R for ; Thu, 11 Aug 2022 14:30:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143055euoutp01ae7af987ae204fefd7450bbde4b67dbc~KUM1WRfpe2164821648euoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228255; bh=tSSBnG0aDQsGLDWCBqD+ZIZXJV/OR5HHGZmAzSOHsrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M8USTs3X6zeQ/nIQcVJ5yHUy7tSjnkzCFNg1sJuJ8UdZXeNciq8eEAOAvZoRnhmyf 7pFkrvXvTWH/B8P0PWOmmsc4Eunp+cS2WUlJJs0qB0FtDX4Wy+2IpEqNvjS8cy71Jo vY9JY6w44nYggn7hoNqwBlZHui74jJfQsiD7wszo= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143054eucas1p275d5a0a71bb6714726ff4a4187e14189~KUMz_-RZE1005510055eucas1p2H; Thu, 11 Aug 2022 14:30:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 46.3A.09664.D9215F26; Thu, 11 Aug 2022 15:30:53 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220811143053eucas1p2eda49423b8f18ef71c47583af4855f6b~KUMzZ5MdM1005510055eucas1p2G; Thu, 11 Aug 2022 14:30:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143053eusmtrp1a08b048090db4872f06982c25c931709~KUMzY-2Q02320623206eusmtrp1m; Thu, 11 Aug 2022 14:30:53 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-fc-62f5129db8ef Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 19.10.09038.D9215F26; Thu, 11 Aug 2022 15:30:53 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220811143053eusmtip29653ad79baf31ba06934a9814941ca96~KUMzErsQ41543015430eusmtip2O; Thu, 11 Aug 2022 14:30:53 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v10 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Thu, 11 Aug 2022 16:30:38 +0200 Message-Id: <20220811143043.126029-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7pzhb4mGdxpt7ZYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlTGv XaJgHk/FnIavLA2MLVxdjJwcEgImErc2XWHsYuTiEBJYwSgx4ek0NgjnC6PE11edrBDOZ0aJ puWn2WBaJp6bBNWynFGiY/8bKOcFo8TCvt1AVRwcbAJaEo2d7CANIgLpEusXLGcBqWEWuMMk sXzvJUaQhLBAiMSivZfAprIIqEq0vHwE1sArYCXR33iEEWKbvMTMS9/B4pwC1hITFl1kgqgR lDg58wkLiM0MVNO8dTYzyAIJgc2cEre/b2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A2MLVxdjJwc EgImEhPPTWLsYuTiEBJYyiix8NI5VoiEhMTthU2MELawxJ9rXWwQRc8YJR7e/c7SxcjBwSag JdHYyQ5iigjkShw8EghSwizwhknixqu37CC9wgJBEie3zGQBsVkEVCVaXj4Ci/MKWEn0Nx6B mi8vMfPSd7A4p4C1xIRFF5lAbCGgmgkdx6DqBSVOznwCNocZqL5562zmCYwCs5CkZiFJLWBk WsUoklpanJueW2ykV5yYW1yal66XnJ+7iREYuduO/dyyg3Hlq496hxiZOBgPMUpwMCuJ8JYt +pwkxJuSWFmVWpQfX1Sak1p8iNEU6O6JzFKiyfnA1JFXEm9oZmBqaGJmaWBqaWasJM7rWdCR KCSQnliSmp2aWpBaBNPHxMEp1cAUrTf/n3huul3/hOeHXWveeJVfjvyZlCfqU9bad/y9tZ3Z iUdG0XaP16979zLv8e4NKcxzn526aOq9atPFRRpFpbIsK4viS1STTgjEfHtmr/1m/7umDXca VwhWl84WPX7hq/uvp5//fWScuvft9pjVZ2qOrDFfLPyi6+ivwqyYzoR9luZa3mHF7/oePLcX LGafHXbeIHTx92t+Kx55b5CI+3T4mGn47RQevlSHCRz+0+ZF89wUK5ycxMlZvD99/uewfkWP JyUxS0SV2FR7JgRwVbUHiJ9M7z0+Q7dY20BllfFZtyN7wx7Oi/8j8KTYcqdP/KeOvScXeAk7 J9+Ocg9IP3vqz5zrU1ufZv1a0S2oxFKckWioxVxUnAgA754+jWUDAAA= X-CMS-MailID: 20220811143053eucas1p2eda49423b8f18ef71c47583af4855f6b X-Msg-Generator: CA X-RootMTR: 20220811143053eucas1p2eda49423b8f18ef71c47583af4855f6b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143053eucas1p2eda49423b8f18ef71c47583af4855f6b References: <20220811143043.126029-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 Thu Aug 11 14:30:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12941483 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 46709C19F2A for ; Thu, 11 Aug 2022 14:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235554AbiHKObL (ORCPT ); Thu, 11 Aug 2022 10:31:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235527AbiHKObA (ORCPT ); Thu, 11 Aug 2022 10:31:00 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D49E974E1C for ; Thu, 11 Aug 2022 07:30:57 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143056euoutp0127898fc0c23b57b5bcd74f87761ef153~KUM2ZwZxk2260722607euoutp01S for ; Thu, 11 Aug 2022 14:30:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143056euoutp0127898fc0c23b57b5bcd74f87761ef153~KUM2ZwZxk2260722607euoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228256; bh=rIbhfxDBpj+Ii51tIIt4kTVb6ZA8NV8eQeaNrvmy2UQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h9zUUwI568qVkNe5i6/uPwINDBUowXjf+xysvYJfHj2NweRWsmAq12Ik7aj73bfNH F+GcV8ggkZtv01mKwlu8719WprtWCPlstIIFaKcuZ2DdjTuU6lTCmDkuw1OYusit9I mKPcgDm6jNu4CbWxz7a56b/B56+Bko/Vqkg8VefY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143055eucas1p2d51c4b46b22206be2fa360812fdffb61~KUM08FzKq1001410014eucas1p2E; Thu, 11 Aug 2022 14:30:55 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D1.9C.09580.E9215F26; Thu, 11 Aug 2022 15:30:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220811143054eucas1p219e5b31b24cca97e2bc563351436543d~KUM0gN7qH2359623596eucas1p2H; Thu, 11 Aug 2022 14:30:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220811143054eusmtrp287d06731f2d99f572e10a6e3fb2ba578~KUM0fcGiW0788907889eusmtrp2w; Thu, 11 Aug 2022 14:30:54 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-be-62f5129ea721 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 34.9F.09095.E9215F26; Thu, 11 Aug 2022 15:30:54 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143054eusmtip1fd57ba199cdde6dcf3aee0684ec592b4~KUM0IuVmv3243332433eusmtip1C; Thu, 11 Aug 2022 14:30:54 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v10 09/13] dm-zone: use generic helpers to calculate offset from zone start Date: Thu, 11 Aug 2022 16:30:39 +0200 Message-Id: <20220811143043.126029-10-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01SbUxTZxjNe+/t7S1acylG3yjqdrWLslE1mOxdZIILW27ij0kiMcOYWfCK pC2a1gpKFhjiB98dyUBax9coX7qU0KKtCtPKp6gEK1qIbUnWxlmzAUFkDSi23Jr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s9H0vfekYtJStxSrdu4pf7NT84o/8oOO8UqrT1miiXVr1Mn TE0RWL4lLvXSq5nPKj3cNtbE5HduVGIpzkg01GIuKk4EAHvjSxNlAwAA X-CMS-MailID: 20220811143054eucas1p219e5b31b24cca97e2bc563351436543d X-Msg-Generator: CA X-RootMTR: 20220811143054eucas1p219e5b31b24cca97e2bc563351436543d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143054eucas1p219e5b31b24cca97e2bc563351436543d References: <20220811143043.126029-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 Thu Aug 11 14:30:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12941482 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 41435C25B0C for ; Thu, 11 Aug 2022 14:31:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235518AbiHKObK (ORCPT ); Thu, 11 Aug 2022 10:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235540AbiHKObB (ORCPT ); Thu, 11 Aug 2022 10:31:01 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3BC8753A6 for ; Thu, 11 Aug 2022 07:30:58 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143057euoutp02e8937afa64d43cfd0d5241a629b8080d~KUM3ivhdr1911919119euoutp02V for ; Thu, 11 Aug 2022 14:30:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220811143057euoutp02e8937afa64d43cfd0d5241a629b8080d~KUM3ivhdr1911919119euoutp02V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228257; bh=rwrR95VBKntQTDKdi+ldY8ggDErFsfT3t9lp/si7I3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ai6aDrNkh0eQwL/qofv+ISxJWVGmLw4uuTo9XT81CcoUbMFTCV/Yd+fpYssbfazrU G6f9sa/6MC1Pfjh6REpiCrjUXLNF8EHUj3wkcu1+Y4xtIbRTfXG6Np3OSDSI/7lYRD eLcZWS03lU7z+gDoTBs6dp6UrvchnKFdrgSELeDM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143056eucas1p29b49d12b0338a4711a28d327fff7e6ef~KUM2A2ali2350223502eucas1p2N; Thu, 11 Aug 2022 14:30:56 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C8.3A.09664.0A215F26; Thu, 11 Aug 2022 15:30:56 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220811143055eucas1p2211be7f9ed867e40df58c25e6222be2d~KUM1h4IZp1002510025eucas1p2N; Thu, 11 Aug 2022 14:30:55 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220811143055eusmtrp21d2729a01fe711c562dc7208725ba968~KUM1g-qmk0788907889eusmtrp2y; Thu, 11 Aug 2022 14:30:55 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-06-62f512a0328a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C5.9F.09095.F9215F26; Thu, 11 Aug 2022 15:30:55 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220811143055eusmtip27cf972cf7bdafadf6e46b39ae5ae2fed~KUM1NLS-a1262412624eusmtip2y; Thu, 11 Aug 2022 14:30:55 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav Subject: [PATCH v10 10/13] dm-table: allow zoned devices with non power-of-2 zone sizes Date: Thu, 11 Aug 2022 16:30:40 +0200 Message-Id: <20220811143043.126029-11-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDKsWRmVeSWpSXmKPExsWy7djP87oLhL4mGcxdzG6x/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW3xe2sJusebmUxaLE7ekHQQ9Ll/x9tg56y67x+WzpR6bVnWyeWxeUu+x+2YD m8fO1vusHu/3XWXz6NuyitFj8+lqj8+b5DzaD3QzBfBEcdmkpOZklqUW6dslcGVcvn+HteAI b8Wqhy2MDYwfuLoYOTkkBEwk1h3Zxd7FyMUhJLCCUWLnzw3MIAkhgS+MEtfnikIkPjNKvD+4 ggWm49uGfVAdyxklFu6exwTR8YJR4t/LiC5GDg42AS2Jxk52kLCIQLrE+gXLwXqZBbYxSWx5 IAxiCwtESrTe6gCrYRFQlbi5/isbiM0rYC1xaskSVohd8hIzL30Hq+EEik9YdJEJokZQ4uTM J1Az5SWat85mBrlHQmA9p8TSS+eYIJpdJNbeWAFlC0u8Or6FHcKWkfi/cz5UvFri6Y3fUM0t jBL9O9ezgTwgAbSt70wOiMksoCmxfpc+RNRRYtJHWwiTT+LGW0GIC/gkJm2bzgwR5pXoaBOC mK0EDM0nUDslJC43zYEGoIdEz4oupgmMirOQ/DILyS+zENYuYGRexSieWlqcm55abJiXWq5X nJhbXJqXrpecn7uJEZgAT/87/mkH49xXH/UOMTJxMB5ilOBgVhLhLVv0OUmINyWxsiq1KD++ qDQntfgQozQHi5I4b3LmhkQhgfTEktTs1NSC1CKYLBMHp1QDU+3enqtOzH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IrOUaHI+MGXklcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJ pCeWpGanphakFsH0MXFwSjUwce1/6Ljx3l6GRN/Xnx3m8p54dIHzrE+sDFO1mYBIxw6DR4kt rSaRWR488ziUVY4G2q7Q9zrx7D8r55+IMwZLw/601cc/16hMnR9aoGAY7ylrN+1lzGSfSRtU 2/n+f165780Et9VzZ/pJvn37UtRexfcIe9q63thDSvf9k6/PeDrj80Z7vv+CpmFuPDN0cs9G BMxr9/yxaefz/ZLbO5ii7c5niy+M+fYnPefRVs3s+O3KMtfjahZXpzY1X4u4sbDN2pvj7WLh 7Hkmv3uFXKR/Wk62VuafU/swomfOxRNa3+ZtdvXnZn2oIVP3kHmZ760FBxuFvqiv9Lit+tXe vLXu+Sft/48DGKbfVS+p3j1PiaU4I9FQi7moOBEAYdrlj2EDAAA= X-CMS-MailID: 20220811143055eucas1p2211be7f9ed867e40df58c25e6222be2d X-Msg-Generator: CA X-RootMTR: 20220811143055eucas1p2211be7f9ed867e40df58c25e6222be2d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143055eucas1p2211be7f9ed867e40df58c25e6222be2d References: <20220811143043.126029-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 Thu Aug 11 14:30:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12941484 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 A720BC25B07 for ; Thu, 11 Aug 2022 14:31:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235312AbiHKObM (ORCPT ); Thu, 11 Aug 2022 10:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235537AbiHKObB (ORCPT ); Thu, 11 Aug 2022 10:31:01 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2EB4647FA for ; Thu, 11 Aug 2022 07:30:59 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143058euoutp027f3e9d59ca2d3367baaa370900b4faec~KUM4dNYDu1916519165euoutp02O for ; Thu, 11 Aug 2022 14:30:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220811143058euoutp027f3e9d59ca2d3367baaa370900b4faec~KUM4dNYDu1916519165euoutp02O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228258; bh=lA4ACIhgPS1mwgZjIDSka7RcIpNQB3Ybt1avCcUQ/Cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0TPeXeHN8PTA6FW37forHrG7f7AlOGS2BK+2YljPf368nKoRR47TKOqKx1sLC6XT tQZwyp0+mut6LQ/Z0lsoLsoY+C0HNO0lcxW3EhYM+y3JLJXsCymHLD6UX8TBpOhDTT e6NFKooLtRO6MrVhguJXD+YPYXbQd7jn3ROqIv+I= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220811143057eucas1p216223c029efa1998ccb79a46fc64c3c3~KUM3Cf9rH1006010060eucas1p2E; Thu, 11 Aug 2022 14:30:57 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F9.EF.10067.1A215F26; Thu, 11 Aug 2022 15:30:57 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220811143056eucas1p13136f35c6f0c7c2717b68a63c8d4c7c6~KUM2k0vmR0222302223eucas1p1m; Thu, 11 Aug 2022 14:30:56 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220811143056eusmtrp18ae8a15c69fb595a999ace9730c8135c~KUM2jz95k2320623206eusmtrp1u; Thu, 11 Aug 2022 14:30:56 +0000 (GMT) X-AuditID: cbfec7f4-dd7ff70000002753-62-62f512a18632 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id EB.10.09038.0A215F26; Thu, 11 Aug 2022 15:30:56 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220811143056eusmtip2b4d22c9e91ac86e932b862deddd8d3aa~KUM2NjP9e1283212832eusmtip2E; Thu, 11 Aug 2022 14:30:56 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav Subject: [PATCH v10 11/13] dm: call dm_zone_endio after the target endio callback for zoned devices Date: Thu, 11 Aug 2022 16:30:41 +0200 Message-Id: <20220811143043.126029-12-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNKsWRmVeSWpSXmKPExsWy7djP87oLhb4mGXybwW+x/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW3xe2sJusebmUxaLE7ekHQQ9Ll/x9tg56y67x+WzpR6bVnWyeWxeUu+x+2YD m8fO1vusHu/3XWXz6NuyitFj8+lqj8+b5DzaD3QzBfBEcdmkpOZklqUW6dslcGWsPK9a8Ja3 YtafXvYGxqXcXYycHBICJhKt5/+zdzFycQgJrGCUmHb1KzOE84VR4l1zL1TmM6PE1q8nWGBa tkxqZ4FILGeUWHzxMhtIQkjgBaN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bOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAnii9GyK8ktLUhUy8otLbJWiDS2M9Awt LfSMTCz1DI3NY62MTJX07WxSUnMyy1KL9O0S9DJWnlcteMtbMetPL3sD41LuLkZODgkBE4kt k9pZuhi5OIQEljJKdB9fxASRkJC4vbCJEcIWlvhzrYsNougZo0Tz8X9ARRwcbAJaEo2d7CCm iECuxMEjgSAlzAJHmCSa3+5iAekVFkiWmHbrEjOIzSKgKrHkUA/YfF4Ba4krUx9CzZeXmHnp OzuIzQkUn7DoIliNkICVxISOY+wQ9YISJ2c+AZvJDFTfvHU28wRGgVlIUrOQpBYwMq1iFEkt Lc5Nzy020itOzC0uzUvXS87P3cQIjNdtx35u2cG48tVHvUOMTByMhxglOJiVRHjLFn1OEuJN SaysSi3Kjy8qzUktPsRoCnT3RGYp0eR8YMLIK4k3NDMwNTQxszQwtTQzVhLn9SzoSBQSSE8s Sc1OTS1ILYLpY+LglGpgUlRhj1zRU7JO80QRX07u/XMbPxTXHZdZNCF9w8pnn2WNo1YqWcrH fza4JCfQ+Y7t8pXuII+ARd37j03sFP3wTTngmtgcqWcmEQpivYcFZoeH7d3xdsFR44QUc4mn Ql32tX8Oer+70vXYiH+xYTc/h/qu2RyTjkUdTu7JPsd/NaPyRdPiEo8mUeafJ4/tDnn2wHna ZpEYF9edsb1/NumaabFJfFXUCmV0Xvpl4uFT819PD3rvaDyhJ6jvxTSx37OuXmsqV6rdbCq7 0UzPTNd0oc5fnkbPyEO3m39ytny3WtNfv01x3SyTP64B5nWna6ecTuhk3KC/U3lLWEZro9zH KRKfXuxbovV9QnZt8vy1SizFGYmGWsxFxYkARy5Ry2ADAAA= X-CMS-MailID: 20220811143056eucas1p13136f35c6f0c7c2717b68a63c8d4c7c6 X-Msg-Generator: CA X-RootMTR: 20220811143056eucas1p13136f35c6f0c7c2717b68a63c8d4c7c6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143056eucas1p13136f35c6f0c7c2717b68a63c8d4c7c6 References: <20220811143043.126029-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 Thu Aug 11 14:30:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12941485 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 D8037C19F2A for ; Thu, 11 Aug 2022 14:31:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235537AbiHKObN (ORCPT ); Thu, 11 Aug 2022 10:31:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235542AbiHKObC (ORCPT ); Thu, 11 Aug 2022 10:31:02 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014586CD11 for ; Thu, 11 Aug 2022 07:31:01 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143059euoutp019fc1c868ab9a83f1a21d5dc0c67bef59~KUM5brWEu2260022600euoutp01O for ; Thu, 11 Aug 2022 14:30:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143059euoutp019fc1c868ab9a83f1a21d5dc0c67bef59~KUM5brWEu2260022600euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228259; bh=ZgoaFDwLzDUOxKE5rEa1NqlfNa53+tMH9mlTVfvbwSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fWoF1bMy6CKpts2llSxoX8miVOk3ZZmJgmPvPlQoZxbsGowDjhWrLMxPyG7ihx85n pYT+dQOezPbwT0z+jfoykl4/6mK8lWnfNb0DOM6HV36IQNabKJxGWehx/7/qy/+Y3G UFk2DGX+xo4d+snDV7nXVIXfH0vhD1lxOEv9foVc= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220811143058eucas1p17dcf2b8581d292ab7fe10362a23a4ae1~KUM34Vt8V1645216452eucas1p1X; Thu, 11 Aug 2022 14:30:58 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 4B.3A.09664.2A215F26; Thu, 11 Aug 2022 15:30:58 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220811143057eucas1p1210aba036ebd96d290d74bfe0231299c~KUM3fVZDf2154221542eucas1p1E; Thu, 11 Aug 2022 14:30:57 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220811143057eusmtrp2433e006f90ec6fae8023f2db37972a14~KUM3ek6H_0786307863eusmtrp2A; Thu, 11 Aug 2022 14:30:57 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-0e-62f512a2c3d8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 68.9F.09095.1A215F26; Thu, 11 Aug 2022 15:30:57 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143057eusmtip13d5e96b5dd5157117d672e5efbd7ce57~KUM3LYK1X3243132431eusmtip1G; Thu, 11 Aug 2022 14:30:57 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav Subject: [PATCH v10 12/13] dm: introduce DM_EMULATED_ZONES target type Date: Thu, 11 Aug 2022 16:30:42 +0200 Message-Id: <20220811143043.126029-13-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLKsWRmVeSWpSXmKPExsWy7djP87qLhL4mGZzt47BYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDKaFooUNIhV XJq7jamBcbdQFyMHh4SAicTG3zxdjFwcQgIrGCWe7TvBDOF8YZTYOHktlPOZUWL/sv9MXYyc YB0zbu1kgkgsZ5Q4dvMTK4TzglFi0t0vbCBz2QS0JBo72UEaRATSJdYvWM4CYjMLbGOS2PJA GMQWFnCTuHWjjxXEZhFQlbi25ymYzStgLbFm5kyoZfISMy99B5vDCRSfsOgiE0SNoMTJmU+g ZspLNG+dDXaphMBqTolbv/qgml0kjvw7ywphC0u8Or6FHcKWkfi/cz5UTbXE0xu/oZpbGCX6 d65ngwSMtUTfmRwQk1lAU2L9Ln2IckeJwz++M0NU8EnceCsIcQKfxKRt06HCvBIdbUIQ1UoS O38+gVoqIXG5aQ4LhO0hsf38E/YJjIqzkDwzC8kzsxD2LmBkXsUonlpanJueWmyYl1quV5yY W1yal66XnJ+7iRGYAk//O/5pB+PcVx/1DjEycTAeYpTgYFYS4S1b9DlJiDclsbIqtSg/vqg0 J7X4EKM0B4uSOG9y5oZEIYH0xJLU7NTUgtQimCwTB6dUA9OEzanz14sduH7li5QlP4OMwFvn CM9qC04el9WmMeY5e6P4Ar/qtkTW75USZT5x6c6ppubLprcvGL89tvFTjOf2y0tOqmr3/1ew z9p33eTF+oTkk5yRQem/A9R2/NlfmvGtVVj59bQzp7oNXzwPSj4Y8ToqXGjdiTtbYxMWya5/ evYV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2bcwPty1/ua2datm LjIyt3R663OjLjxAnWsG5/Et7o+f3f44wVk1/tty0fnZ/POv8SwMvpE25c0ln2PPQld7Tfm0 8L6bvvbqtesNb/F7n555zPCcg0Bo1X/13gjpN2Hifmu0r5a+Z9x8+kfYpV3t9bw/Dl9+w/5I eMnWPypXKtYrFa5+o1nBMreqMcvyOF/5pv1zYtnvM53fZy251e/VPjvZV4+OZ/6U/XyK6fK7 y/Ib2I1zU6fYVU75mKv6S4mlOCPRUIu5qDgRAIqwiJhfAwAA X-CMS-MailID: 20220811143057eucas1p1210aba036ebd96d290d74bfe0231299c X-Msg-Generator: CA X-RootMTR: 20220811143057eucas1p1210aba036ebd96d290d74bfe0231299c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143057eucas1p1210aba036ebd96d290d74bfe0231299c References: <20220811143043.126029-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 Thu Aug 11 14:30:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12941486 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 02F98C25B07 for ; Thu, 11 Aug 2022 14:31:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235143AbiHKObP (ORCPT ); Thu, 11 Aug 2022 10:31:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235528AbiHKObE (ORCPT ); Thu, 11 Aug 2022 10:31:04 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 085E96BD48 for ; Thu, 11 Aug 2022 07:31:03 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220811143101euoutp01940c719f61ff212e1e26e2325b9b4716~KUM7TzfBQ2304723047euoutp01A for ; Thu, 11 Aug 2022 14:31:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220811143101euoutp01940c719f61ff212e1e26e2325b9b4716~KUM7TzfBQ2304723047euoutp01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660228261; bh=IUoyViCkp3U4Q2I4KlB9fJBiLbxoRuZRmvXdr8vBKuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5mnu1ZU8jhMXs7D+vSKNJsr68tpM3M8oXucQZ2iQUMgbQXrVnAHwTeyU3sYCkuFW EFxt6sGPcLduFfkNG6GLwcSZoVBF4aB9SOTkFcmXz5EW+17lP2qTeDlZ2agio1oo4J bQGtLGHVi/q62pNljs+JGU58AGMDq+fPmKzFZ8yw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220811143059eucas1p1e317135f18477c5d913e987c19bcbcbe~KUM5Yg33T1847718477eucas1p1N; Thu, 11 Aug 2022 14:30:59 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 3D.3A.09664.3A215F26; Thu, 11 Aug 2022 15:30:59 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220811143058eucas1p247291685ffff7a75186947fd30b5c13f~KUM4hWTb42359623596eucas1p2O; Thu, 11 Aug 2022 14:30:58 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220811143058eusmtrp28f9fb8f8a36160410731318772fa88f6~KUM4gZwt30788907889eusmtrp22; Thu, 11 Aug 2022 14:30:58 +0000 (GMT) X-AuditID: cbfec7f2-d97ff700000025c0-15-62f512a3e869 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 89.9F.09095.2A215F26; Thu, 11 Aug 2022 15:30:58 +0100 (BST) Received: from localhost (unknown [106.210.248.43]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220811143058eusmtip172ed3770e81c435d3d628314002e940f~KUM4IHz2d1917919179eusmtip1b; Thu, 11 Aug 2022 14:30:58 +0000 (GMT) From: Pankaj Raghav To: snitzer@kernel.org, axboe@kernel.dk, hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com Cc: linux-block@vger.kernel.org, Johannes.Thumshirn@wdc.com, bvanassche@acm.org, matias.bjorling@wdc.com, hare@suse.de, gost.dev@samsung.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, pankydev8@gmail.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Pankaj Raghav , Johannes Thumshirn , Damien Le Moal , Joel Granados Subject: [PATCH v10 13/13] dm: add power-of-2 target for zoned devices with non power-of-2 zone sizes Date: Thu, 11 Aug 2022 16:30:43 +0200 Message-Id: <20220811143043.126029-14-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220811143043.126029-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFKsWRmVeSWpSXmKPExsWy7djPc7qLhb4mGUy5p2ux/tQxZovVd/vZ LKZ9+Mls8fvseWaL1vZv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wnzdV+cYB9ZpXPKcdW3dfaR/5EqNnN7Zoe cOtpx+2EdUt8WW6q8icLCF1OMpUoM711WzdH/f1eBpEEK9afHMGvRPyPtBa/Y23cM+93Xr7e 5rftJh1frnr9OrhvxZ0M5TUTFnUtfuw3z/F+mhJLcUaioRZzUXEiACsf2JRrAwAA X-CMS-MailID: 20220811143058eucas1p247291685ffff7a75186947fd30b5c13f X-Msg-Generator: CA X-RootMTR: 20220811143058eucas1p247291685ffff7a75186947fd30b5c13f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220811143058eucas1p247291685ffff7a75186947fd30b5c13f References: <20220811143043.126029-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 size zoned 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 number of sectors. 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