From patchwork Mon Sep 12 08:21:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973433 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 0F6B7ECAAA1 for ; Mon, 12 Sep 2022 08:23:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230237AbiILIW7 (ORCPT ); Mon, 12 Sep 2022 04:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbiILIW3 (ORCPT ); Mon, 12 Sep 2022 04:22:29 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C6832DAA8 for ; Mon, 12 Sep 2022 01:22:26 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082214euoutp0282fabd07998500d1cb23f2321ed1595b~UD0EKBuNA2458624586euoutp024 for ; Mon, 12 Sep 2022 08:22:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082214euoutp0282fabd07998500d1cb23f2321ed1595b~UD0EKBuNA2458624586euoutp024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970934; bh=AD8v/RK3vFIqsgabYiTtVZbPbcAOQ4zUOz/AmbfbvbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TRqX/k2uvt0NXazwL9MRQaxiFj1YX2mW5l7vnKM/jZ1A+mYDZn2Bh7kxWKUjvugDK Ry4e+kR6Yabb95tfx0RLPRJ/Ifq6woKBvZFO/R+hxqy7F8sWKduQqSjbkWsCj21lTP 7Srjof5lKaJl7/hiEMAUOmEHIG+51GdelaeUIPko= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082207eucas1p29c7db135677f5003724aae601b8c346b~UDz9pzoBc0134101341eucas1p2i; Mon, 12 Sep 2022 08:22:07 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id A0.98.29727.F2CEE136; Mon, 12 Sep 2022 09:22:07 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082206eucas1p25336d07279850f7009be6b5d1fccf558~UDz9G3b792084220842eucas1p2y; Mon, 12 Sep 2022 08:22:06 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220912082206eusmtrp1650c92c0efd28a6fd06dff561d98c82c~UDz9F6VZF1301813018eusmtrp1S; Mon, 12 Sep 2022 08:22:06 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-de-631eec2fb1fe Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 64.2F.07473.E2CEE136; Mon, 12 Sep 2022 09:22:06 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220912082206eusmtip101d2c775cf01540cc46c480381f1d24c~UDz8utiBG1320313203eusmtip1f; Mon, 12 Sep 2022 08:22:06 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Luis Chamberlain , Adam Manzanares Subject: [PATCH v13 01/13] block: make bdev_nr_zones and disk_zone_no generic for npo2 zone size Date: Mon, 12 Sep 2022 10:21:52 +0200 Message-Id: <20220912082204.51189-2-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBKsWRmVeSWpSXmKPExsWy7djP87r6b+SSDX58FbGYfljRYv2pY8wW q+/2s1lM+/CT2eL32fPMFnvfzWa1uHlgJ5PFnkWTmCxWrj7KZPFk/Sxmi79d95gs9t7Stri8 aw6bxfxlT9ktJrR9Zba4MeEpo8XnpS3sFmtuPmWxOHFL2kHY4/IVb4+ds+6ye1w+W+qxaVUn m8fmJfUeu282sHnsbL3P6vF+31U2j74tqxg9Np+u9vi8Sc6j/UA3UwBPFJdNSmpOZllqkb5d AlfG36ntTAVXRSqeTXjF1sA4S7CLkZNDQsBE4nDjSsYuRi4OIYEVjBJztq5jhXC+MErcXrWK DcL5zCix7MZq9i5GDrCWm40pEPHljBKf1kxngXBeMkpMvvuYBaSITUBLorGTHWSFiEC6xPfp 75hAapgFupglDny/wAaSEBZIkrj98R8TiM0ioCqxZdskMJtXwFKi7/c0Voj75CVmXvoONohT wEri9apWRogaQYmTM5+wgNjMQDXNW2czgyyQENjPKdE8awpUs4vE1hkfmCFsYYlXx7ewQ9gy Eqcn97BA2NUST2/8hmpuYZTo37meDeJNa4m+MzkgJrOApsT6XfoQ5Y4Sly88YYKo4JO48VYQ 4gQ+iUnbpjNDhHklOtqEIKqVJHb+fAK1VELictMcqKUeEj2PH7JMYFScheSZWUiemYWwdwEj 8ypG8dTS4tz01GLDvNRyveLE3OLSvHS95PzcTYzAxH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/eOpt5AqPA LCSpWUhSCxiZVjGKpJYW56bnFhvqFSfmFpfmpesl5+duYgRG8LZjPzfvYJz36qPeIUYmDsZD jBIczEoivCyG0slCvCmJlVWpRfnxRaU5qcWHGE2B7p7ILCWanA9MIXkl8YZmBqaGJmaWBqaW ZsZK4ryeBR2JQgLpiSWp2ampBalFMH1MHJxSDUyMwefPHo5+5nDQQYhxwpFFVzInPmv7s55h pcYShqDkTZJie7e9+Lpb2f2pYmH6+rnPztgrG8oqpc8WXXjkltXuLZtOvz+bfKHr2U83s6k1 TsffRRyMjG66yi9Wse7I18OJ0i5ya9kkT6h+sEhs3Hz04PrJ2p9P6iVq35v3bEFt2a/gQ8f5 ZJM3XlFTVN4/32bDj0lPzdf8K7xzmeE/a7BK+Zb5OlfUzxzrjNsmFyd2p2Zzhv51rUO+zme3 igcXf2fvs923kbV6DYvgoWbf1HXXw4/Vrb0Qsf750b9F+YuTMzb+j27Xf3nh1MT9R9YvWRwi OeGFYOUt52dbb+xJXMns+dhWVv/pt8N6aZUhkZmeR5VYijMSDbWYi4oTAWwtWAxpAwAA X-CMS-MailID: 20220912082206eucas1p25336d07279850f7009be6b5d1fccf558 X-Msg-Generator: CA X-RootMTR: 20220912082206eucas1p25336d07279850f7009be6b5d1fccf558 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082206eucas1p25336d07279850f7009be6b5d1fccf558 References: <20220912082204.51189-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 Reviewed-by: Johannes Thumshirn Reviewed-by: Chaitanya Kulkarni --- 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 Mon Sep 12 08:21:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973432 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 01B11ECAAD5 for ; Mon, 12 Sep 2022 08:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbiILIW6 (ORCPT ); Mon, 12 Sep 2022 04:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbiILIW3 (ORCPT ); Mon, 12 Sep 2022 04:22:29 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C4E42DA9F for ; Mon, 12 Sep 2022 01:22:26 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082215euoutp012b1e563e3f1addf719b240dc7d1f8d17~UD0Ez-xAS1429114291euoutp01I for ; Mon, 12 Sep 2022 08:22:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220912082215euoutp012b1e563e3f1addf719b240dc7d1f8d17~UD0Ez-xAS1429114291euoutp01I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970935; bh=ZkEQ96cJVfEIkMIR9OActXMeVsUQhG06cu9eRzMqsY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WES+cQ+2w71fkZX3zUGSbeDtqfkI8d93lrzje95Ep4CaXS5uZoZLIURjOQvgTccwu oI4mXfB+iUUuPfz6LmJ33GkzaB91mtmlXrpIO/Znv6SQmVXPpHJo28ZwonyxZBP/Gr oxJCmoCc/jy8/mRMEgG9FpleZdm3Fi0oluZQHS1s= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082208eucas1p2c68fa5bb7ebe6e79e708799a3c8fafa4~UDz_jWnP-2521625216eucas1p29; Mon, 12 Sep 2022 08:22:08 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 12.98.29727.03CEE136; Mon, 12 Sep 2022 09:22:08 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220912082207eucas1p14b1bcefc6045a0a835e83db8ed810d5e~UDz_J7ijQ1135111351eucas1p1p; Mon, 12 Sep 2022 08:22:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220912082207eusmtrp2551c7002f1c8dffd039c15e861705810~UDz_JGrjO3082830828eusmtrp2P; Mon, 12 Sep 2022 08:22:07 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-e2-631eec30db5d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D5.33.10862.F2CEE136; Mon, 12 Sep 2022 09:22:07 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220912082207eusmtip20acf27f91edbff5da8aa4a9d10228a95~UDz9z3BZ72962629626eusmtip2_; Mon, 12 Sep 2022 08:22:07 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav Subject: [PATCH v13 02/13] block: rearrange bdev_{is_zoned,zone_sectors,get_queue} helper in blkdev.h Date: Mon, 12 Sep 2022 10:21:53 +0200 Message-Id: <20220912082204.51189-3-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDKsWRmVeSWpSXmKPExsWy7djPc7oGb+SSDZasFLFYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDJm7tvBXDBb rOLszunMDYwnhLoYOTkkBEwkdu1dzNLFyMUhJLCCUeJH7yJWkISQwBdGic8H2SASnxklvp7t ZYHpuPboByNEYjmjxMVZs6DaXzJKfOr5x9TFyMHBJqAl0djJDtIgIpAu8X36OyaQGmaBbUwS 9x++YAapEQZKvFjuBVLDIqAq0fPnPitImFfAUmLfnEqIXfISMy99BxvDKWAl8XpVKyOIzSsg KHFy5hOwe5iBapq3zmaGqF/PKTG50wTCdpHY8PkKI4QtLPHq+BZ2CFtG4v/O+UwQdrXE0xu/ mUFOkxBoYZTo37meDeQGCQFrib4zOSAms4CmxPpd+hDljhKTvjSyQ1TwSdx4KwhxAZ/EpG3T mSHCvBIdbdCgVZLY+fMJ1FIJictNc6AB6CHxt2E60wRGxVlIfpmF5JdZCHsXMDKvYhRPLS3O TU8tNsxLLdcrTswtLs1L10vOz93ECEyAp/8d/7SDce6rj3qHGJk4GA8xSnAwK4nwshhKJwvx piRWVqUW5ccXleakFh9ilOZgURLnTc7ckCgkkJ5YkpqdmlqQWgSTZeLglGpgCqn+n1P1idNx N/u/gDn8Hy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YGppZmxkrivJ4FHYlCAumJ JanZqakFqUUwfUwcnFINTJsPLThWW/1k17HLiv+7TCYFvF7mK5DxPKDsbsepwI5ZAXwKk951 rDE2XdRrznRn0017yYd+13/nnfa1c7u1sGX5xHMFu2958K4uX+SSclokOItz57vHbMr2Vnv/ /u/b122vdL1/xYq5ryN+dyqYPl96deKC554MOwMyNv0p2fNqau35c503p2Ya1cZGlkrVOnJy S93+ONkqwf712ymnud+lX5hx43HLuef/Vb9NWdyhOTezLybE/8vJ9WxLBJizvb0t5FNsG3UO rD/VtOKY7LfX+smfrxz7HbqDJ1nStUh9tc3knzUd1i27XY2UlHd5Tt30SYZv/esVEtKO7x2U t6x+eCPo/HauB7vP5TvOYlBQYinOSDTUYi4qTgQALhcDLGADAAA= X-CMS-MailID: 20220912082207eucas1p14b1bcefc6045a0a835e83db8ed810d5e X-Msg-Generator: CA X-RootMTR: 20220912082207eucas1p14b1bcefc6045a0a835e83db8ed810d5e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082207eucas1p14b1bcefc6045a0a835e83db8ed810d5e References: <20220912082204.51189-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Define bdev_is_zoned(), bdev_zone_sectors() and bdev_get_queue() earlier in the blkdev.h include file. Simplify bdev_is_zoned() by removing the superfluous NULL check for request queue while we are at it. This commit has no functional change, and it is a prep patch for allowing zoned devices with non-power-of-2 zone sizes in the block layer. Signed-off-by: Pankaj Raghav Reviewed-by: Damien Le Moal Reviewed-by: Bart Van Assche Reviewed-by: Johannes Thumshirn Reviewed-by: Chaitanya Kulkarni --- 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 Mon Sep 12 08:21:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973434 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 86063ECAAD5 for ; Mon, 12 Sep 2022 08:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbiILIXA (ORCPT ); Mon, 12 Sep 2022 04:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbiILIW3 (ORCPT ); Mon, 12 Sep 2022 04:22:29 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C5AB2DAA7 for ; Mon, 12 Sep 2022 01:22:26 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082212euoutp025fdeb08d8a10efae3150496bd8e68490~UD0CgJQai2264822648euoutp02g for ; Mon, 12 Sep 2022 08:22:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082212euoutp025fdeb08d8a10efae3150496bd8e68490~UD0CgJQai2264822648euoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970932; bh=ObXXkVs0jGDKCmEhpNVJ0p5o0WckGSN2AWqGCJVENLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BzugWKerNpXqGXcJ1AEQRItPDAfM9ZCJ5fvNR9mZbFBBxtwipAXBVF7pOT724huXq ofAQ5PIZo9mQeC5nhlzMu8KL+mh17x21p4jmxhWECusajguRtWYjn/1TRU4r9gURjC zoaLzJrctaV8DhwX2p3g2xyRAUrU0UchV8Ht3xVw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082209eucas1p2069cce282a374a5a253ecba71b2b97d9~UDz-xGiYK3082430824eucas1p2D; Mon, 12 Sep 2022 08:22:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 0C.46.07817.13CEE136; Mon, 12 Sep 2022 09:22:09 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082209eucas1p2747fa09635df54a6c76821585776672f~UDz-Rgzrq2521325213eucas1p2J; Mon, 12 Sep 2022 08:22:09 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220912082209eusmtrp115ccb9dbe793be17fad981d513ee7bf9~UDz-QtHke1301813018eusmtrp1X; Mon, 12 Sep 2022 08:22:09 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-ab-631eec31ac18 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A6.2F.07473.13CEE136; Mon, 12 Sep 2022 09:22:09 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220912082208eusmtip2a0feeb2bf2cebe4277077635b3fe4c0e~UDz_6zPMg2614326143eusmtip22; Mon, 12 Sep 2022 08:22:08 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v13 03/13] block: allow blk-zoned devices to have non-power-of-2 zone size Date: Mon, 12 Sep 2022 10:21:54 +0200 Message-Id: <20220912082204.51189-4-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7qGb+SSDaZsUrVYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlfGs fwF7wWv1iv5LG9gbGHcodDFyckgImEgsubaRqYuRi0NIYAWjxObVrVDOF0aJe9v/M0M4nxkl /n34ywzTsubTWajEckaJk5vmMkI4LxklLj1/DdTPwcEmoCXR2MkO0iAikC7xffo7sLHMAneY JJoOvWAESQgLxEgs23SDBcRmEVCVWLXlN1icV8BS4sj540wQ2+QlZl76DjaIU8BK4vWqVqga QYmTM5+A9TID1TRvnQ12kYTAdk6JzWu/sYAcISHgInFpiiLEHGGJV8e3sEPYMhKnJ/ewQNjV Ek9v/IbqbWGU6N+5ng2i11qi70wOiMksoCmxfpc+RLmjxJkv+5ghKvgkbrwVhLiAT2LStulQ YV6JjjYhiGoliZ0/n0AtlZC43DQHaqmHxONju9kmMCrOQvLLLCS/zELYu4CReRWjeGppcW56 arFRXmq5XnFibnFpXrpecn7uJkZgQjz97/iXHYzLX33UO8TIxMF4iFGCg1lJhJfFUDpZiDcl sbIqtSg/vqg0J7X4EKM0B4uSOG9y5oZEIYH0xJLU7NTUgtQimCwTB6dUA1P3G5OTwZMTeDUs Y/yvZSgp/1vQ+olr5ryUl1FfK06+vZrvE7hr/X67zsDdq8UWPrU8vdNH8MZGlrAniv0Sl1TT MjN7pFY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2hi2Z3hEevuBZrM61z98yf yzh+6Df+uWITOrHos/X7LU/reo0e3av8Nr9l12vezXflvvh8PBGWaru/IIBj8cZFCvs3V9/d kPflDn9aY3aSD4/lpNVH3dQfJk8Nvq7msqjazfpN/O/sOVHVxTPF3vJ4tbC7sMraJYru6LrW G9bKGr02xfi9XLJJ7E2vKSabX7VodqgeYvP9Irh3K0sha7Re+GfTTS9rL9SfO6Fxon5flMat Uw1aO29MzyiyYNldqHFBLyhM9PfaqNYwzgqtH0ITtpn5PGxacccvmf3NHP6PTFZfWqxqtMRv vJv28qDy83VLSpsevbO9wfJrzf//j3SUWIozEg21mIuKEwHIh7jNZwMAAA== X-CMS-MailID: 20220912082209eucas1p2747fa09635df54a6c76821585776672f X-Msg-Generator: CA X-RootMTR: 20220912082209eucas1p2747fa09635df54a6c76821585776672f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082209eucas1p2747fa09635df54a6c76821585776672f References: <20220912082204.51189-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 Reviewed-by: Johannes Thumshirn --- 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 fe6b27e3a513..291149289178 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -560,7 +560,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 Mon Sep 12 08:21:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973439 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 579A9ECAAD5 for ; Mon, 12 Sep 2022 08:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbiILIXn (ORCPT ); Mon, 12 Sep 2022 04:23:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbiILIWq (ORCPT ); Mon, 12 Sep 2022 04:22:46 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 798AE2F03B for ; Mon, 12 Sep 2022 01:22:41 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082221euoutp020c8d9b8ded0c7c08a9bada993261ece2~UD0KZlnZY2672726727euoutp02G for ; Mon, 12 Sep 2022 08:22:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082221euoutp020c8d9b8ded0c7c08a9bada993261ece2~UD0KZlnZY2672726727euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970941; bh=tGdXrZOo82rW1rnRJeQcvmwRabixUhHDV5CM9X+9nHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yx6qvHNIXdR1X377oa1ahBEMKO+nitw1GbVaZcwzfNA23DZeC/koX/3s00hunzGf8 Miq2fc98DBdtblc/1788pWk8FPQwmkdNCmJqf5HoNUv2ntQdH1Nf4BENzVB7NklDHO 5HYf13qVilMSqozQclEyUdbGB4xVmI7PFbInWOTA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082211eucas1p2f4e53c71b5ea9a1f0214abe7042837cf~UD0A-672_2521325213eucas1p2K; Mon, 12 Sep 2022 08:22:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FD.93.19378.23CEE136; Mon, 12 Sep 2022 09:22:10 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082210eucas1p2a27e358b12b0e4b06a7e00938251c90c~UD0ATwGB62085220852eucas1p28; Mon, 12 Sep 2022 08:22:10 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220912082210eusmtrp1f5c6636a975c4ba6a58f300fa8852a07~UD0ASz6Sq1301813018eusmtrp1a; Mon, 12 Sep 2022 08:22:10 +0000 (GMT) X-AuditID: cbfec7f5-a4dff70000014bb2-4c-631eec32418d Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 38.2F.07473.23CEE136; Mon, 12 Sep 2022 09:22:10 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220912082209eusmtip191ef30b7acb64dd77f15d10c24dee9b1~UD0AAjOPs0956209562eusmtip1a; Mon, 12 Sep 2022 08:22:09 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Johannes Thumshirn , Luis Chamberlain Subject: [PATCH v13 04/13] nvmet: Allow ZNS target to support non-power_of_2 zone sizes Date: Mon, 12 Sep 2022 10:21:55 +0200 Message-Id: <20220912082204.51189-5-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEKsWRmVeSWpSXmKPExsWy7djPc7pG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/6vceVKuxbP8snXe6Z29nouffrezjPPW/aG35PPHNW5Jte37Kp699Vx9v+Ncgen Tzn+6H7sVrdn4QmsWzwkbl7uelL/8ec2JcW3msuvPFG/wZX2Sev8qf+SW5STV+05avF6N8ei ThmRN7pC65/yWv0Ufvph6+0/f3pyhXcpsRRnJBpqMRcVJwIAwJIQXGcDAAA= X-CMS-MailID: 20220912082210eucas1p2a27e358b12b0e4b06a7e00938251c90c X-Msg-Generator: CA X-RootMTR: 20220912082210eucas1p2a27e358b12b0e4b06a7e00938251c90c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082210eucas1p2a27e358b12b0e4b06a7e00938251c90c References: <20220912082204.51189-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 Reviewed-by: Chaitanya Kulkarni --- 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 Mon Sep 12 08:21:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973436 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 B9F07ECAAD5 for ; Mon, 12 Sep 2022 08:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbiILIXD (ORCPT ); Mon, 12 Sep 2022 04:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbiILIWa (ORCPT ); Mon, 12 Sep 2022 04:22:30 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E2942DA97 for ; Mon, 12 Sep 2022 01:22:28 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082216euoutp02d454110e6a654742dcf45d193bde6cb6~UD0GcvJsI2458624586euoutp02- for ; Mon, 12 Sep 2022 08:22:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082216euoutp02d454110e6a654742dcf45d193bde6cb6~UD0GcvJsI2458624586euoutp02- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970936; bh=6KLZnW+r2Lo4etQGdD1QpBP8NjREYU10ycW8QMjCE4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIl1tu59uKJbkADzKipi+tnlrlIA6IEs2p7C7rGTnOJLPvjENbT/3cTQBKqg7Nolu FhKPAjHZMpHBRRkhNRpaXISqvGYmztTFw/QqHo/FgXlM2qUOTKd6lGAycpg3KiOghb AIse9RtviOJFl5FL1qpifjzE9sJIvuUSh4KBifog= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082212eucas1p227cff65cf4d38a4326b690c0955c4dad~UD0CRIaG83149631496eucas1p2I; Mon, 12 Sep 2022 08:22:12 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F7.98.29727.43CEE136; Mon, 12 Sep 2022 09:22:12 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082211eucas1p2d7cbc34d8ba679e525442128698a1116~UD0BaXdfk0134901349eucas1p24; Mon, 12 Sep 2022 08:22:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220912082211eusmtrp1a506910c09c509ba02e69c14d0927f7b~UD0BZjqKh1301813018eusmtrp1h; Mon, 12 Sep 2022 08:22:11 +0000 (GMT) X-AuditID: cbfec7f2-7932da800001741f-f8-631eec345fe9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2B.2F.07473.33CEE136; Mon, 12 Sep 2022 09:22:11 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220912082211eusmtip12c21b3997194ab192c3022a7c08b005b~UD0BBbxCs0841308413eusmtip1V; Mon, 12 Sep 2022 08:22:11 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v13 05/13] nvme: zns: Allow ZNS drives that have non-power_of_2 zone size Date: Mon, 12 Sep 2022 10:21:56 +0200 Message-Id: <20220912082204.51189-6-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMKsWRmVeSWpSXmKPExsWy7djP87omb+SSDU7sE7ZYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlTG7 ZRtbwRaRit2n37A2MP4U6GLk5JAQMJHYdLSFvYuRi0NIYAWjxJuDL9ggnC+MEl9+r2WGcD4z Ssw+85QNpmXymTlMILaQwHJGicY/ZRBFLxkl5hx9xtLFyMHBJqAl0djJDlIjIpAu8X36OyaQ GmaBO0wSTYdeMIIkhAWiJX7c6GQFsVkEVCWuvusCs3kFLCVO73jMCrFMXmLmpe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naGwea2VkqqRvZ5OSmpNZllqkb5eglzG7ZRtbwRaRit2n37A2MP4U6GLk 5JAQMJGYfGYOUxcjF4eQwFJGiWd7P7BAJCQkbi9sYoSwhSX+XOtigyh6zihxfPU/oCIODjYB LYnGTnaQGhGBXInPK3+A1TALvGGS+LJkEhNIQlggUuLO3IVgRSwCqhJX33Wxgti8ApYSp3c8 ZoVYIC8x89J3sBpOASuJ16tawRYLAdWc/XaDHaJeUOLkzCdgxzED1Tdvnc08gVFgFpLULCSp BYxMqxhFUkuLc9Nziw31ihNzi0vz0vWS83M3MQKjd9uxn5t3MM579VHvECMTB+MhRgkOZiUR XhZD6WQh3pTEyqrUovz4otKc1OJDjKZAd09klhJNzgemj7ySeEMzA1NDEzNLA1NLM2MlcV7P go5EIYH0xJLU7NTUgtQimD4mDk6pBibJ5eof5ijMiUs+dUUlI3T+MtMDM1r/3+OaFX+x3PxM 3zqhxvpP9ySyf3zi3aghPG/fBd3jgUqhG27vbOub3+qkPo+ZaXvfH8F9YjP5eb9POOwRuccr LfPi31MHVvTfX/X3oOSlv5H/xOUX7P6sZpMYkMxvt93nXMzshHLlokkng9c+fBRvrPbDUbYq ds5Kw7DbNw482hnYEp5efXfVHLPcl9tduN02bg7Zsvfgs21aH+JUb0/v89vmGy2X8cKg6oY6 f0zK8mZXm0+cJeturVO50+aY7v+u/6r4/7P2mk9MCr75SM06XRrZJi6abXZgxqwF566I/H3M vOR38Ym3Aqdc1mV1nZRJDmQr/dsslvhAiaU4I9FQi7moOBEAzfaJO2cDAAA= X-CMS-MailID: 20220912082211eucas1p2d7cbc34d8ba679e525442128698a1116 X-Msg-Generator: CA X-RootMTR: 20220912082211eucas1p2d7cbc34d8ba679e525442128698a1116 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082211eucas1p2d7cbc34d8ba679e525442128698a1116 References: <20220912082204.51189-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 Reviewed-by: Bart Van Assche Signed-off-by: Pankaj Raghav Reviewed-by: Chaitanya Kulkarni --- drivers/nvme/host/zns.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index 12316ab51bda..fe1d715d61cc 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -101,13 +101,6 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf) } ns->zsze = nvme_lba_to_sect(ns, le64_to_cpu(id->lbafe[lbaf].zsze)); - if (!is_power_of_2(ns->zsze)) { - dev_warn(ns->ctrl->device, - "invalid zone size:%llu for namespace:%u\n", - ns->zsze, ns->head->ns_id); - status = -ENODEV; - goto free_data; - } disk_set_zoned(ns->disk, BLK_ZONED_HM); blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); @@ -129,7 +122,7 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_ns *ns, sizeof(struct nvme_zone_descriptor); nr_zones = min_t(unsigned int, nr_zones, - get_capacity(ns->disk) >> ilog2(ns->zsze)); + div64_u64(get_capacity(ns->disk), ns->zsze)); bufsize = sizeof(struct nvme_zone_report) + nr_zones * sizeof(struct nvme_zone_descriptor); @@ -182,6 +175,7 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, int ret, zone_idx = 0; unsigned int nz, i; size_t buflen; + u64 remainder = 0; if (ns->head->ids.csi != NVME_CSI_ZNS) return -EINVAL; @@ -197,7 +191,9 @@ int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, c.zmr.zrasf = NVME_ZRASF_ZONE_REPORT_ALL; c.zmr.pr = NVME_REPORT_ZONE_PARTIAL; - sector &= ~(ns->zsze - 1); + /* Round down the sector value to the nearest zone start */ + div64_u64_rem(sector, ns->zsze, &remainder); + sector -= remainder; while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) { memset(report, 0, buflen); From patchwork Mon Sep 12 08:21:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973435 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 54D2BC6FA8D for ; Mon, 12 Sep 2022 08:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbiILIXC (ORCPT ); Mon, 12 Sep 2022 04:23:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230255AbiILIWa (ORCPT ); Mon, 12 Sep 2022 04:22:30 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 678372DAAF for ; Mon, 12 Sep 2022 01:22:26 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082215euoutp01ba8afac82128e278a8423ee994608cc4~UD0E9JDCb1402414024euoutp01R for ; Mon, 12 Sep 2022 08:22:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220912082215euoutp01ba8afac82128e278a8423ee994608cc4~UD0E9JDCb1402414024euoutp01R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970935; bh=BWkW98eOYak4zoJYsjIHeJX+UtNkNe/AaFvL+9lXLPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dc4I6CFYbomyy5b0qJYMbsieJzFdgHiUDL7hiZOk2cKCrFi8k/SX/RQ38n9RHxKmF rf+QrdVkmrojUBOqhafy+QFyoDpFLd+P9EgBFkBaLTtt9emr2AOKz7PcBPuvKocUrD /5A6TwcQRwxyj+N7PMoEYegcXuT5U5ebWqCDAL4I= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082213eucas1p2f46e7a125861f32b6781e8a09d5f8eb4~UD0DIBvFE2083820838eucas1p2T; Mon, 12 Sep 2022 08:22:13 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E9.98.29727.53CEE136; Mon, 12 Sep 2022 09:22:13 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220912082212eucas1p1032064dd2ac1638d7d18be7e6fe5344e~UD0CdqmFI1461814618eucas1p1o; Mon, 12 Sep 2022 08:22:12 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220912082212eusmtrp2c8b581788d5d7886c123129df284080b~UD0CcrZHl3082830828eusmtrp2g; Mon, 12 Sep 2022 08:22:12 +0000 (GMT) X-AuditID: cbfec7f2-7932da800001741f-fc-631eec35cae0 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5B.33.10862.43CEE136; Mon, 12 Sep 2022 09:22:12 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220912082212eusmtip2ed666c70861a0e51ee5767060b80e032~UD0CGqnNM2388123881eusmtip2h; Mon, 12 Sep 2022 08:22:12 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v13 06/13] null_blk: allow zoned devices with non power-of-2 zone sizes Date: Mon, 12 Sep 2022 10:21:57 +0200 Message-Id: <20220912082204.51189-7-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMKsWRmVeSWpSXmKPExsWy7djP87qmb+SSDeZ1CVisP3WM2WL13X42 i2kffjJb/D57ntli77vZrBY3D+xkstizaBKTxcrVR5ksnqyfxWzxt+sek8XeW9oWl3fNYbOY v+wpu8WEtq/MFjcmPGW0+Ly0hd1izc2nLBYnbkk7CHlcvuLtsXPWXXaPy2dLPTat6mTz2Lyk 3mP3zQY2j52t91k93u+7yubRt2UVo8fm09UenzfJebQf6GYK4InisklJzcksSy3St0vgyth+ eBJzwS/piqWL+1gbGK+IdzFyckgImEic2fmbFcQWEljBKDHlnUgXIxeQ/YVRYsGJCYwQzmdG ie//prDBdMxY9poJomM5o8TRz8wQRS8ZJe6dnwKU4OBgE9CSaOxkB6kREUiX+D79HRNIDbPA HSaJpkMvGEESwgKREodfbAAbyiKgKrF2zz+wOK+ApUTv8TvsEMvkJWZe+g5mcwpYSbxe1QpV IyhxcuYTFhCbGaimeetssCMkBDZzSqw/vZcZotlF4sf6lSwQtrDEq+NboIbKSPzfOZ8Jwq6W eHrjN1RzC6NE/871bCAfSAhYS/SdyQExm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UerJDpYuTgYBPQkmjs ZAcJiwjkSnxe+QOohIuDWeANk8SXJZPAZgoLhEv0/P8OVsQioCqxds8/sJm8ApYSvcfvsEPM l5eYeQmihlPASuL1qlZGiF2WEme/3WCHqBeUODnzCQuIzQxU37x1NvMERoFZSFKzkKQWMDKt YhRJLS3OTc8tNtIrTswtLs1L10vOz93ECIzcbcd+btnBuPLVR71DjEwcjIcYJTiYlUR4WQyl k4V4UxIrq1KL8uOLSnNSiw8xmgLdPZFZSjQ5H5g68kriDc0MTA1NzCwNTC3NjJXEeT0LOhKF BNITS1KzU1MLUotg+pg4OKUamDZZXnHcZ8xcKr2+sbe3XGLW7O+Hve8x/ZLb7OF+kD+o7Mvs krwzRxOFuS7uuScvPpMrc9/1HQ8/hx4K7b66MHvFg9rbE0Sa/i77+X/2Z3a1jY/5rVKc39Vv P71c8Mjp+LhQtU+bKxK5rCe8/2+wVuvF4aYpE9atfPLd7euvpcs23Pty4/enaCOT6wwVVlfT 7k9U8PSLl4xdG3FJs/bV9Kovy3RKJrQLfP4WvUJ7e8Wso59K76//8yx+ZeGbKycu1jk8zb/J 6j5j2taKbe1XN5jNPCGWEBfcxmKosHYJ/+5Mx/cfFtoJ3evzLnlw3i1kz/o9H1YLRKZI3hX6 Kh9qomo26bfqd7Fzh1NecBw13FDWrsRSnJFoqMVcVJwIAIZeR6plAwAA X-CMS-MailID: 20220912082212eucas1p1032064dd2ac1638d7d18be7e6fe5344e X-Msg-Generator: CA X-RootMTR: 20220912082212eucas1p1032064dd2ac1638d7d18be7e6fe5344e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082212eucas1p1032064dd2ac1638d7d18be7e6fe5344e References: <20220912082204.51189-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 Reviewed-by: Bart Van Assche Signed-off-by: Pankaj Raghav Reviewed-by: Johannes Thumshirn Reviewed-by: Chaitanya Kulkarni --- 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 1f154f92f4c2..3b24125d8594 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 Mon Sep 12 08:21:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973437 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 5653EC6FA86 for ; Mon, 12 Sep 2022 08:23:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbiILIXP (ORCPT ); Mon, 12 Sep 2022 04:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbiILIWa (ORCPT ); Mon, 12 Sep 2022 04:22:30 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FC882DABA for ; Mon, 12 Sep 2022 01:22:28 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082217euoutp02f05f34b66fa065db3369a8024e0d827e~UD0GwSSd52358323583euoutp02Q for ; Mon, 12 Sep 2022 08:22:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082217euoutp02f05f34b66fa065db3369a8024e0d827e~UD0GwSSd52358323583euoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970937; bh=2l9t4o2MFdGXGYEr9szOD+OY2x6nysmCjdo7iJiFJ2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TMlrjNNPkddzrkJ5nrzK5gU4f4mYfpP9F+QxuRXwRSPcDGZROw/GjgDd0uwMGWOJo 1+BhWi5mZzSkeZA9fp+wEE23PDgvobfJO9Nc4Ca0PFZswvV1/kttRe60Ge272z/CYY cTM/YH/BNFGVK4hn1iywkhDi4420xWJg6WMZEtyA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220912082214eucas1p1fe9e48688d1aefa40607bc4cc9294b9a~UD0EFzgI90906209062eucas1p1B; Mon, 12 Sep 2022 08:22:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id B2.56.07817.63CEE136; Mon, 12 Sep 2022 09:22:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082213eucas1p239d6095dab9b042f05efd3a6e82bac9c~UD0DkP-K02081220812eucas1p2P; Mon, 12 Sep 2022 08:22:13 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220912082213eusmtrp1ae03dc8384dea2e319579ddbafd34d1e~UD0DjXLuz1362513625eusmtrp1G; Mon, 12 Sep 2022 08:22:13 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-c9-631eec360d9a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id AF.2F.07473.53CEE136; Mon, 12 Sep 2022 09:22:13 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220912082213eusmtip23aaa9f11837ef80f79a5eabca7495574~UD0DIzWiX2847028470eusmtip2Q; Mon, 12 Sep 2022 08:22:13 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v13 07/13] zonefs: allow non power of 2 zoned devices Date: Mon, 12 Sep 2022 10:21:58 +0200 Message-Id: <20220912082204.51189-8-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPKsWRmVeSWpSXmKPExsWy7djP87pmb+SSDT62ClqsP3WM2WL13X42 i2kffjJb/D57ntli77vZrBY3D+xkstizaBKTxcrVR5ksnqyfxWzxt+sek8XeW9oWl3fNYbOY v+wpu8WEtq/MFjcmPGW0+Ly0hd1izc2nLBYnbkk7CHlcvuLtsXPWXXaPy2dLPTat6mTz2Lyk 3mP3zQY2j52t91k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MailID: 20220912082213eucas1p239d6095dab9b042f05efd3a6e82bac9c X-Msg-Generator: CA X-RootMTR: 20220912082213eucas1p239d6095dab9b042f05efd3a6e82bac9c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082213eucas1p239d6095dab9b042f05efd3a6e82bac9c References: <20220912082204.51189-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 Reviewed-by: Johannes Thumshirn Reviewed-by: Chaitanya Kulkarni --- 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 Mon Sep 12 08:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973442 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 87558ECAAA1 for ; Mon, 12 Sep 2022 08:23:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230403AbiILIXr (ORCPT ); Mon, 12 Sep 2022 04:23:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230282AbiILIWs (ORCPT ); Mon, 12 Sep 2022 04:22:48 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A14D2F019 for ; Mon, 12 Sep 2022 01:22:40 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082217euoutp02640d4e5a568fb68fca5e7ba374bd9516~UD0HPMovq2458624586euoutp02D for ; Mon, 12 Sep 2022 08:22:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082217euoutp02640d4e5a568fb68fca5e7ba374bd9516~UD0HPMovq2458624586euoutp02D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970937; bh=iRbpzjINH/0PPLjaid0CzUjvnsaLFxGjPtxuxfcTQWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CxBbwE4II+AFvZV/uzDF6jzuNsqqIS4H0nwOU3BQnEoNeV9/A/ykh1hNxqYKhOZp+ ZBKxzSTTWygxa+Nlts+GcMaZvw6/SF5V1jLiRrfrHN6Dza9ndDbrUHac9pWkr312dA nwyOnXkhe3oZD/XSzJqq3zJ5CFZAYbFkBvtMrOac= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082215eucas1p20d6aa1ec8ff1a6e145de06afcb2fd104~UD0FXe4LO0125901259eucas1p2K; Mon, 12 Sep 2022 08:22:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 05.A3.19378.73CEE136; Mon, 12 Sep 2022 09:22:15 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220912082214eucas1p1a5796db60e6972eace43c3ab6976248c~UD0EsLnG_0912009120eucas1p1x; Mon, 12 Sep 2022 08:22:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220912082214eusmtrp1977e05345de0d80a215460772cec7d12~UD0ErJayw1362513625eusmtrp1I; Mon, 12 Sep 2022 08:22:14 +0000 (GMT) X-AuditID: cbfec7f5-a4dff70000014bb2-60-631eec372945 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F1.3F.07473.63CEE136; Mon, 12 Sep 2022 09:22:14 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220912082214eusmtip21c2b4c578bcbcb433092971e84d434eb~UD0ESMPO52680426804eusmtip2P; Mon, 12 Sep 2022 08:22:14 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v13 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Mon, 12 Sep 2022 10:21:59 +0200 Message-Id: <20220912082204.51189-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEKsWRmVeSWpSXmKPExsWy7djP87rmb+SSDd4sVbdYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlXFj 0VqWgkbeildTlrM0MN7h6mLk4JAQMJH41BPdxcjJISSwglFiTad3FyMXkP2FUeJ/w2ZGCOcz o8SspotMIFUgDY//d7BBJJYzSvQ/WAlV9ZJR4sCkFywgY9kEtCQaO9lBGkQE0iW+T3/HBFLD LH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09UenzfJebQf6GYK4InSsynKLy1JVcjILy6xVYo2 tDDSM7S00DMysdQzNDaPtTIyVdK3s0lJzcksSy3St0vQy7ixaC1LQSNvxaspy1kaGO9wdTFy ckgImEg8/t/B1sXIxSEksJRR4svT7cwQCQmJ2wubGCFsYYk/17qgip4zSvT17AQq4uBgE9CS aOxkB6kREciV+LzyB1gNs8AbJokNd9YzgSSEBYIknm1cDDaURUBV4ta762BxXgFLidblnUwQ C+QlZl76DjaIU8BK4vWqVrDFQkA1Z7/dYIeoF5Q4OfMJC4jNDFTfvHU28wRGgVlIUrOQpBYw Mq1iFEktLc5Nzy021CtOzC0uzUvXS87P3cQIjN5tx35u3sE479VHvUOMTByMhxglOJiVRHhZ DKWThXhTEiurUovy44tKc1KLDzGaAt09kVlKNDkfmD7ySuINzQxMDU3MLA1MLc2MlcR5PQs6 EoUE0hNLUrNTUwtSi2D6mDg4pRqYJs8wmWZTeigx2T3f1URF+4rwl3kpM/i5JZe0T14j5PVc mLsufnpzR/HrRO6r7Qu/KB0/x35xw4V9HzdLn7pfXTcj8+8x9efeb9cFMrZ9TUziY/brdIya 8qDXdHpY8oEZKov73Gb/evz6D9/6DxNjM9XPNM07MvtIceyNXc/z+loWl5fzfu++feLZgoid Cm+ZrEUNa/ieRhlsjn35NPRxzLfb0yMsJe6lxiYsrlUudHOVn3PdpVTcIdRHyL1Dz+fPS+Xk /OW/Z1yarH9Y9NEdacO/WROiLda2L+7k5mgILJje0CI4QX12xpwe88PWwQlPrBla2P+lZ37R e/137fvgfpXadTs/+e7TfSK65c4hJZbijERDLeai4kQAGQ1PmGcDAAA= X-CMS-MailID: 20220912082214eucas1p1a5796db60e6972eace43c3ab6976248c X-Msg-Generator: CA X-RootMTR: 20220912082214eucas1p1a5796db60e6972eace43c3ab6976248c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082214eucas1p1a5796db60e6972eace43c3ab6976248c References: <20220912082204.51189-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Luis Chamberlain dm-zoned relies on the assumption that the zone size is a power-of-2(po2) and the zone capacity is same as the zone size. Ensure only po2 devices can be used as dm-zoned target until a native support for zoned devices with non-po2 zone size is added. Reviewed-by: Hannes Reinecke Reviewed-by: Damien Le Moal Reviewed-by: Bart Van Assche Reviewed-by: Mike Snitzer Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav Reviewed-by: Johannes Thumshirn --- 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 Mon Sep 12 08:22:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973438 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 86E36C6FA83 for ; Mon, 12 Sep 2022 08:23:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230380AbiILIXg (ORCPT ); Mon, 12 Sep 2022 04:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbiILIWo (ORCPT ); Mon, 12 Sep 2022 04:22:44 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27EF42F01D for ; Mon, 12 Sep 2022 01:22:41 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082228euoutp01ee9ee730a4316235c697f1e07c3adea6~UD0RW6oAG1529315293euoutp01z for ; Mon, 12 Sep 2022 08:22:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220912082228euoutp01ee9ee730a4316235c697f1e07c3adea6~UD0RW6oAG1529315293euoutp01z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970948; bh=GhIDPZWMIafgE/mAZSnmKlimhg+oN7vlIbCtEzY8HQk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AV9yORWBrycSC01OVCnrzGIp/7Bu8LSn42rQfrrEpM0mqaWIo/aa+jy6ukslgqtcm b0nWX9uWyhxKWy8PMqQsEtYx/QMAQlJ3hlgGNjpTWbLKZIsFifUR3bpfSWNY9Ikpz5 21rjyosSDyMfWEc3udRZdrpwJDZpYX/SQyBUdDlY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082216eucas1p217f198775cbabf54dbb8af06c3a07c73~UD0Gdw1oP2081220812eucas1p2V; Mon, 12 Sep 2022 08:22:16 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 7D.98.29727.83CEE136; Mon, 12 Sep 2022 09:22:16 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220912082216eucas1p1d3068e7578a88007515c2f4f5ebcc2a8~UD0FqyqF71768417684eucas1p1V; Mon, 12 Sep 2022 08:22:16 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220912082216eusmtrp278adcdd0eae8192ad23f86c36bcfd1d7~UD0Fp6fEE3116631166eusmtrp2H; Mon, 12 Sep 2022 08:22:16 +0000 (GMT) X-AuditID: cbfec7f2-205ff7000001741f-0d-631eec381941 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CE.33.10862.73CEE136; Mon, 12 Sep 2022 09:22:15 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220912082215eusmtip1f09a8a5eff3926ebd36906443d538437~UD0FVcuxy1289112891eusmtip1d; Mon, 12 Sep 2022 08:22:15 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v13 09/13] dm-zone: use generic helpers to calculate offset from zone start Date: Mon, 12 Sep 2022 10:22:00 +0200 Message-Id: <20220912082204.51189-10-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 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dc1Nfli1dKhK8vbq779LUw7/nLrNaXlL8XHjf5s2bw8T29S6YkqUrbG3H8CnD /bz0XemOjZkScz76RbAqFTx6ekJzqcSVv3LC53uc9N+bdr79Wjjrz4e+C273Z70987WmtyDp 2HOL9n+7A4Qk99z/pXK3cAfno/orvzXvMZS4RDee1o89snN98JtZWTaT9h2b+5ahpfKFk2vJ g/cnua7wqfP+vpPx4V3cu4sXzrczKrEUZyQaajEXFScCALp6AFFnAwAA X-CMS-MailID: 20220912082216eucas1p1d3068e7578a88007515c2f4f5ebcc2a8 X-Msg-Generator: CA X-RootMTR: 20220912082216eucas1p1d3068e7578a88007515c2f4f5ebcc2a8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082216eucas1p1d3068e7578a88007515c2f4f5ebcc2a8 References: <20220912082204.51189-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 Reviewed-by: Bart Van Assche Reviewed-by: Mike Snitzer Reviewed-by: Johannes Thumshirn --- 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 Mon Sep 12 08:22:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973440 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 6945BECAAA1 for ; Mon, 12 Sep 2022 08:23:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230399AbiILIXo (ORCPT ); Mon, 12 Sep 2022 04:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbiILIWr (ORCPT ); Mon, 12 Sep 2022 04:22:47 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA472F386 for ; Mon, 12 Sep 2022 01:22:41 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082228euoutp0197573f01d46763f4f76c3a3f44f263db~UD0RlopNc1428914289euoutp01X for ; Mon, 12 Sep 2022 08:22:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220912082228euoutp0197573f01d46763f4f76c3a3f44f263db~UD0RlopNc1428914289euoutp01X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970948; bh=TpfC5qsHCn42VD0VfMrShkUip45l4QnJQo5SdQLOwtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZPoYBx2dKfdCinH2zMCwcqWzTFokBq8qrH9UUQBXq4wUNW8Kf0Xuuf92lC0AkldG T5CTEw7JiJnxKb99dRwV+ptMlCvxVKtVziDnZkUNktSOj0AfFqJEFaccF187RyLCt+ 92x007/LPdEoUwNUc/lZFQ9PwuBMxBcFeRn6Vag8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082217eucas1p2f7bf2d8409887d0b45bb91d5e0838a8b~UD0HPCGjb2080820808eucas1p2G; Mon, 12 Sep 2022 08:22:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D7.A3.19378.93CEE136; Mon, 12 Sep 2022 09:22:17 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220912082217eucas1p15e4ba29d1438990db4acf5c3f6ca5d4f~UD0Gx0szG1088110881eucas1p1_; Mon, 12 Sep 2022 08:22:17 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220912082217eusmtrp2054a1249e949edbdccfec0c6c6024005~UD0Gw9xSo3116631166eusmtrp2M; Mon, 12 Sep 2022 08:22:17 +0000 (GMT) X-AuditID: cbfec7f5-a35ff70000014bb2-6b-631eec39b733 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 01.43.10862.93CEE136; Mon, 12 Sep 2022 09:22:17 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220912082216eusmtip12dbcb83e6c6a0b4a645929a361eb1f31~UD0GZZdty0898808988eusmtip1i; Mon, 12 Sep 2022 08:22:16 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav Subject: [PATCH v13 10/13] dm-table: allow zoned devices with non power-of-2 zone sizes Date: Mon, 12 Sep 2022 10:22:01 +0200 Message-Id: <20220912082204.51189-11-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHKsWRmVeSWpSXmKPExsWy7djP87qWb+SSDXbfULVYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDIevLnKUvCO t2LP7CamBsaZ3F2MnBwSAiYSq5YuZe5i5OIQEljBKPHv9ldGCOcLo8T9eYdYQKqEBD4zSkxf 5QjTcWv7RiaIouWMEl93NrNDOC8ZJT682QTUwcHBJqAl0djJDtIgIpAu8X36O7AGZoFtTBL3 H75gBkkIC0RKTPvbwARiswioSsyb3swIYvMKWEk8OryVGWKbvMTMS9/BBnECxV+vaoWqEZQ4 OfMJ2HXMQDXNW2dD1W/mlHg7RQjCdpHo7jvHBGELS7w6voUdwpaR+L9zPlS8WuLpjd9g/0sI tDBK9O9czwbygISAtUTfmRwQk1lAU2L9Ln2IckeJ13enM0F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J4u+rFcwgCWGBcInb6w+D2SwCqhLzpjeDzeQVsJJ4dHgrM8R8 eYmZl76DDeIEir9e1coIsctS4uy3G+wQ9YISJ2c+AbuNGai+eets5gmMArOQpGYhSS1gZFrF KJJaWpybnltspFecmFtcmpeul5yfu4kRGLHbjv3csoNx5auPeocYmTgYDzFKcDArifCyGEon C/GmJFZWpRblxxeV5qQWH2I0Bbp7IrOUaHI+MGXklcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJ pCeWpGanphakFsH0MXFwSjUw7cmqNvL9e3jp6Sfnexp9apbMenLnXMI+mbK3XsvmsuU/DfsX MUXB/Sf3EnatbOUzgryLme8v5n2/1GWOF+vuJ6Gpf34svCrVs9LQIYy3UPbcnZMzMrfP13oc 4qfapeomteDY586pC5q7ZV/ufrbbJSKwWfBtgdGcBTdOWkifmaWjfeL/5aj8Y1cN82Y63ec7 eLFl5tw90w/sv6v/b93U75rH/3atE/5jE/9Tqundg43fkh4/V5wqVqxTt9T+80INja9eS+z3 Hmm/GvLw/TXRzOO8JtdTORqXbX0seX1lZk+1fsWfQ4KlZYI1mfyJAWtPc516f9HM4vnNHZn1 PCmu+2ed2fbx2p8I1oIr93dru79UYinOSDTUYi4qTgQAPQVwpmEDAAA= X-CMS-MailID: 20220912082217eucas1p15e4ba29d1438990db4acf5c3f6ca5d4f X-Msg-Generator: CA X-RootMTR: 20220912082217eucas1p15e4ba29d1438990db4acf5c3f6ca5d4f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082217eucas1p15e4ba29d1438990db4acf5c3f6ca5d4f References: <20220912082204.51189-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 Reviewed-by: Mike Snitzer Reviewed-by: Johannes Thumshirn --- 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 e42016359a77..38b83c383e8f 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)) { DMERR("%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)) { DMERR("%s: len=%llu not aligned to h/w zone size %u of %pg", dm_device_name(ti->table->md), (unsigned long long)len, @@ -1647,8 +1647,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 Mon Sep 12 08:22:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973444 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 B9EC1ECAAD5 for ; Mon, 12 Sep 2022 08:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbiILIXv (ORCPT ); Mon, 12 Sep 2022 04:23:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbiILIWu (ORCPT ); Mon, 12 Sep 2022 04:22:50 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA8092F03E for ; Mon, 12 Sep 2022 01:22:41 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082229euoutp02f6cb6f345773cfb7abbb91c9852eeaea~UD0R6pJ6D2713727137euoutp02F for ; Mon, 12 Sep 2022 08:22:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082229euoutp02f6cb6f345773cfb7abbb91c9852eeaea~UD0R6pJ6D2713727137euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970949; bh=VLoCFLXBp82iOTzKgyetXtUrw6dZfbKcf6Fwvb6vl3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtBoq1dFD9tkwkS5uOBCHvsnFB/AWGgatj+1zkCf+AlMW1jDPO9sPPelSv/UQRUsM 7JO924ESD0rtq3rsMpoLldSOjeGpfbiZwULPMEHJGF/GZNljKMa+wEET2UcR4DkW4L usQCeJRV9cQZv2pyWRETQUSLdzxjB0oQ1MPlTNVQ= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082218eucas1p25aec09241db9eba6d129d00870d39881~UD0IVRA_d2083820838eucas1p2b; Mon, 12 Sep 2022 08:22:18 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 31.A8.29727.A3CEE136; Mon, 12 Sep 2022 09:22:18 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082218eucas1p23b4bcf6d76947724b9a7468a4b82a7f6~UD0H3RlcH2085220852eucas1p2X; Mon, 12 Sep 2022 08:22:18 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220912082218eusmtrp1990f88d4f6be66802adc81c7f14a6e5a~UD0H2XOxU1362613626eusmtrp1J; Mon, 12 Sep 2022 08:22:18 +0000 (GMT) X-AuditID: cbfec7f2-21dff7000001741f-1b-631eec3a28a6 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 16.3F.07473.A3CEE136; Mon, 12 Sep 2022 09:22:18 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220912082218eusmtip2ca44631e327ca0164a0583a8af1664a1~UD0HkB02t2962029620eusmtip2r; Mon, 12 Sep 2022 08:22:18 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav Subject: [PATCH v13 11/13] dm: call dm_zone_endio after the target endio callback for zoned devices Date: Mon, 12 Sep 2022 10:22:02 +0200 Message-Id: <20220912082204.51189-12-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPKsWRmVeSWpSXmKPExsWy7djPc7pWb+SSDWacNbZYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZP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/rYPODfVWKZp7e+b9mceXPZPp+Y9sq6nEf9012WFx51OQ323Nbdlx0i /CM4tn4SfWhQ6M395OQONiWW4oxEQy3mouJEAJx94GNhAwAA X-CMS-MailID: 20220912082218eucas1p23b4bcf6d76947724b9a7468a4b82a7f6 X-Msg-Generator: CA X-RootMTR: 20220912082218eucas1p23b4bcf6d76947724b9a7468a4b82a7f6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082218eucas1p23b4bcf6d76947724b9a7468a4b82a7f6 References: <20220912082204.51189-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-po2zoned target as it modifies bi_sector in the endio callback. Call dm_zone_endio for zoned devices after calling the target's endio function. Reviewed-by: Mike Snitzer 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 7c35dea88ed1..874e1dc9fc26 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 Mon Sep 12 08:22:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973441 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 8E7BCECAAD5 for ; Mon, 12 Sep 2022 08:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230188AbiILIXq (ORCPT ); Mon, 12 Sep 2022 04:23:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbiILIWs (ORCPT ); Mon, 12 Sep 2022 04:22:48 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E6C2F392 for ; Mon, 12 Sep 2022 01:22:41 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082221euoutp023ab97f4e5ef0b402ed267b2614461345~UD0K7PIB12672726727euoutp02H for ; Mon, 12 Sep 2022 08:22:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082221euoutp023ab97f4e5ef0b402ed267b2614461345~UD0K7PIB12672726727euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970941; bh=WU1oSYYifuddX9yyjx4QFQJb3f/txF5tBxB5+RepGko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ipIQozPnSN7Wv/n9k8gEXbNJs4lR6f6Y+mL3KdD+V600SJ+m873bWDyd9Wd3V7Wyc 9jdEsXitreiKp3faSrYGhTdJ4Cz7GSLTrn3f8lu0EzwbZv6AXf+gEHMifpZr5VIhlz QxctGOoWfa/JV8bkEsgH7iAY0TWnmrn0rSyhykuc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220912082220eucas1p1402aa614a51566e2ee2e71ffbf935a8f~UD0JXW-uL1769017690eucas1p1V; Mon, 12 Sep 2022 08:22:20 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 09.56.07817.B3CEE136; Mon, 12 Sep 2022 09:22:19 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082219eucas1p28467ed150230da8a65e4c957975fe438~UD0I7Dey-2083820838eucas1p2f; Mon, 12 Sep 2022 08:22:19 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220912082219eusmtrp266415810c8995ef489f25a93864d6eae~UD0I6NLGZ3116631166eusmtrp2T; Mon, 12 Sep 2022 08:22:19 +0000 (GMT) X-AuditID: cbfec7f4-893ff70000011e89-e0-631eec3b1050 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 63.43.10862.B3CEE136; Mon, 12 Sep 2022 09:22:19 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220912082219eusmtip1336c390f7f0bc0eb05deaa3e17686406~UD0ImHDEQ1320313203eusmtip1n; Mon, 12 Sep 2022 08:22:19 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav Subject: [PATCH v13 12/13] dm: introduce DM_EMULATED_ZONES target feature flag Date: Mon, 12 Sep 2022 10:22:03 +0200 Message-Id: <20220912082204.51189-13-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAKsWRmVeSWpSXmKPExsWy7djP87rWb+SSDdbfsrRYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLT4vbWG3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAniiuGxSUnMyy1KL9O0SuDJ+XX3AXHBK rOL/+jbmBsa/Ql2MnBwSAiYSW9/vYOxi5OIQEljBKDH573I2COcLo8SXja+gnM+MEmubZ7LB tOzcdYMJIrGcUeL2m21Q/S8ZJWZvWgKU4eBgE9CSaOxkB2kQEUiX+D79HVgDs8A2Jon7D18w gySEBQIkVn85CDaVRUBVYtfjKWANvAJWEk+2zoXaJi8x89J3sDgnUPz1qlZGiBpBiZMzn7CA 2MxANc1bZzODLJAQWM0p8WfZUiaIZheJ/Quns0DYwhKvjm9hh7BlJP7vnA9VUy3x9MZvqOYW Ron+nevZQD6QELCW6DuTA2IyC2hKrN+lD1HuKHF632Z2iAo+iRtvBSFO4JOYtG06M0SYV6Kj DRq8ShI7fz6BWiohcblpDtQxHhJrFt5gn8CoOAvJM7OQPDMLYe8CRuZVjOKppcW56anFRnmp 5XrFibnFp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Q1C0lqASPTKkaR1NLi 3PTcYiO94sTc4tK8dL3k/NxNjMB43Xbs55YdjCtffdQ7xMjEwXiIUYKDWUmEl8VQOlmINyWx siq1KD++qDQntfgQoynQ3ROZpUST84EJI68k3tDMwNTQxMzSwNTSzFhJnNezoCNRSCA9sSQ1 OzW1ILUIpo+Jg1OqgWlf9+4Eo3qWWWsvOcrFxV17yrzlZ9xNfaP0A+wnH4U/trFenaJy6IhL UMyqr9HXRM/HqNyYpbzsmPAc8bfzTs7fcLpz39Tg7D/Zwdw6D7fwNkyfflMlyYn3Y7Lq5s/u 2z9wv36XId284uGdaULta2ryTsifkeyOqtirPFVs7qFDlg8Sb//pZsrZX6co13LlRddxVhnP SXcs5i6btPileUCa8uby/KWmn6oOnn526OqF+zW2bqtY20988li4pfn6W+//xVd/NcuudPbn OeO0q0yf5UnkxG32M+c8+LFm2UcLC5ltj3bwvDy+bPmnBcmpD/dH5z8siGNlm7Nwxdfp1yKP Psj8mFwVYOV5bnv5ju9CU5RYijMSDbWYi4oTAcuK/MhgAwAA X-CMS-MailID: 20220912082219eucas1p28467ed150230da8a65e4c957975fe438 X-Msg-Generator: CA X-RootMTR: 20220912082219eucas1p28467ed150230da8a65e4c957975fe438 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082219eucas1p28467ed150230da8a65e4c957975fe438 References: <20220912082204.51189-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Introduce a new target feature flag: DM_EMULATED_ZONES for targets with a different number of sectors per zone (aka zone size) than the underlying device zone size. This target feature flag is introduced as the existing zoned targets assume that the target and the underlying device have the same zone size. The new target: dm-po2zoned will use this new target feature flag as it emulates the zone boundary that is different from the underlying zoned device. Signed-off-by: Pankaj Raghav Reviewed-by: Damien Le Moal Reviewed-by: Mike Snitzer --- 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 38b83c383e8f..8324bd660f09 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1619,13 +1619,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; } @@ -1650,7 +1657,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 f8e3a96b97b0..8504da98e829 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 Mon Sep 12 08:22:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12973443 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 877C7C6FA83 for ; Mon, 12 Sep 2022 08:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbiILIXt (ORCPT ); Mon, 12 Sep 2022 04:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiILIWt (ORCPT ); Mon, 12 Sep 2022 04:22:49 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96FAF2F644 for ; Mon, 12 Sep 2022 01:22:42 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220912082229euoutp0278e9fb70b77916dbdbb4ba614c06a7d9~UD0SGg2iJ2358323583euoutp02W for ; Mon, 12 Sep 2022 08:22:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220912082229euoutp0278e9fb70b77916dbdbb4ba614c06a7d9~UD0SGg2iJ2358323583euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662970949; bh=ftkn+rR0lj4Sy/gskDw+21f79zgrAIwN+OnLaJGKrK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vl8lU1VGpJkXqAOCU1L/nhF/GP6U10I0FhIY2eZRfiFSxOpYzYxvKRtNAlETjYwn4 NlB0Wda9qSvZaHv8460Q9Yhm971DUm64INn09QCo7Nj8sDUVeqFNI5J99Qg1Az9/Fe MHIh6poFkfNmGrVUyJHmofhh7YQqoU/TObg+yB0I= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220912082221eucas1p2de725c04e5a886be72e457a910c1bf27~UD0KkmiuA2080020800eucas1p2I; Mon, 12 Sep 2022 08:22:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C2.A8.29727.D3CEE136; Mon, 12 Sep 2022 09:22:21 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220912082220eucas1p24605fdcf22aedc4c40d5303da8f17ad5~UD0J9MezM2081220812eucas1p2i; Mon, 12 Sep 2022 08:22:20 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220912082220eusmtrp2fc7aee3f5acceee3f20a1779396b031f~UD0J8SZqo3116631166eusmtrp2W; Mon, 12 Sep 2022 08:22:20 +0000 (GMT) X-AuditID: cbfec7f2-21dff7000001741f-21-631eec3db4dc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 35.43.10862.C3CEE136; Mon, 12 Sep 2022 09:22:20 +0100 (BST) Received: from localhost (unknown [106.210.248.191]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220912082220eusmtip13a754fbe294b2d7e3ff4976e1d4fa77e~UD0Jj_EIH1380413804eusmtip1C; Mon, 12 Sep 2022 08:22:20 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, agk@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org Cc: linux-kernel@vger.kernel.org, Johannes.Thumshirn@wdc.com, linux-nvme@lists.infradead.org, pankydev8@gmail.com, matias.bjorling@wdc.com, linux-block@vger.kernel.org, bvanassche@acm.org, gost.dev@samsung.com, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, Pankaj Raghav , Johannes Thumshirn , Damien Le Moal Subject: [PATCH v13 13/13] dm: add power-of-2 target for zoned devices with non power-of-2 zone sizes Date: Mon, 12 Sep 2022 10:22:04 +0200 Message-Id: <20220912082204.51189-14-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912082204.51189-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEKsWRmVeSWpSXmKPExsWy7djP87q2b+SSDaY95bVYf+oYs8Xqu/1s FtM+/GS2+H32PLNFa/s3Jou972azWtw8sJPJYs+iSUwWK1cfZbJ4sn4Ws8XfrntA2VvaFpd3 zWGzmL/sKbvFhLavzBafl7awW6y5+ZTF4sQtaQchj8tXvD12zrrL7nH5bKnHplWdbB6bl9R7 7L7ZwOaxs/U+q8f7fVfZPPq2rGL02Hy62uPzJjmP9gPdTAE8UVw2Kak5mWWpRfp2CVwZ/yYF FtyprZi2u4GtgfFlchcjJ4eEgInE3RfbmLsYuTiEBFYwSux70s4O4XxhlJiy5xkThPOZUeLp iX52mJbPX5tYIBLLGSX6ujaAJYQEXjJKvPwd0MXIwcEmoCXR2AkWFhFIl/g+/R3YIGaBicwS j15uYASpEQZKbFgeBlLDIqAq8fh+JxOIzStgJbH+1DJmiF3yEjMvfQebwwkUf72qlRGiRlDi 5MwnLCA2M1BN89bZYC9ICKznlLjTuIEJotlFomftFihbWOLV8S1QD8hI/N85HypeLfH0xm+o 5hZGif6d69lAjpMQsJboO5MDYjILaEqs36UPUe4o0TDtJzNEBZ/EjbeCECfwSUzaNh0qzCvR 0SYEUa0ksfPnE6ilEhKXm+awQNgeEsvvzmGdwKg4C8kzs5A8Mwth7wJG5lWM4qmlxbnpqcWG eanlesWJucWleel6yfm5mxiByfD0v+OfdjDOffVR7xAjEwfjIUYJDmYlEV4WQ+lkId6UxMqq 1KL8+KLSnNTiQ4zSHCxK4rzJmRsShQTSE0tSs1NTC1KLYLJMHJxS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eyCwlmpwPTB15JfGGZgamhiZmlgamlmbGSuK8ngUdiUIC 6YklqdmpqQWpRTB9TBycUg1MRkYignad2ieSd1oEzromyPT4ojOf4IG6zb/U1yecWfj7HXvq V17TFE25Z3ZPbm7Yx715251GF/UN8oJ3Jp1NnfL36XzWhqAMa5+Eu68f2Ws2+8za1qEjk+yt rmj/wv9+bo1hXE/fJfkXbHYri08xfy5wWfb+vPu6/4vqpT2nnyvXFHSy4/6sEBN7YNOT26/u N0if3eDLkVw/d6nw51afEj5l11lzRCSO3mu5Iu7xUkLYobSSYYVkqQTH111r57qkmkWe+7T0 0Vrf7RNvyjxuuPu3ize27cjP+mrNO4L5K82jVlnfbNt4zOTLh63aGdNZ42f3FFl18kglNatb vdl0b937dGGZmIvOS6YsW+6mxFKckWioxVxUnAgAANycVmUDAAA= X-CMS-MailID: 20220912082220eucas1p24605fdcf22aedc4c40d5303da8f17ad5 X-Msg-Generator: CA X-RootMTR: 20220912082220eucas1p24605fdcf22aedc4c40d5303da8f17ad5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220912082220eucas1p24605fdcf22aedc4c40d5303da8f17ad5 References: <20220912082204.51189-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Only zoned devices with power-of-2(po2) number of sectors per zone(zone size) were supported in linux but now non power-of-2(npo2) zone sizes support has been added to the block layer. Filesystems such as F2FS and btrfs have support for zoned devices with po2 zone size assumption. Before adding native support for npo2 zone sizes, it was suggested to create a dm target for npo2 zone size device to appear as a po2 zone size target so that file systems can initially work without any explicit changes. The design of this target is very simple: remap the device zone size to the zone capacity and change the zone size to be the nearest power of 2 value. For e.g., a device with a zone size/capacity of 3M will have an equivalent target layout as follows: Device layout :- zone capacity = 3M zone size = 3M |--------------|-------------| 0 3M 6M Target layout :- zone capacity=3M zone size = 4M |--------------|---|--------------|---| 0 3M 4M 7M 8M The area between target's zone capacity and zone size will be emulated in the target. The read IOs that fall in the emulated gap area will return 0 filled bio and all the other IOs in that area will result in an error. If a read IO span across the emulated area boundary, then the IOs are split across them. All other IO operations that span across the emulated area boundary will result in an error. The target can be easily created as follows: dmsetup create