Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp746059ioo; Thu, 26 May 2022 13:56:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNUFNcfH8UNEHf+2ncMR5EzjjxplmUhM0Q04F1unrPxkHEAF62+YqXcL41HMitkokTClUZ X-Received: by 2002:a17:907:8a25:b0:6fe:ff5b:81f8 with SMTP id sc37-20020a1709078a2500b006feff5b81f8mr15156427ejc.184.1653598573961; Thu, 26 May 2022 13:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653598573; cv=none; d=google.com; s=arc-20160816; b=W3jjXoXiASOKezAYkmaTss33o5r4K8dH45KXrAkuD7mRz5+0QhhPYxUber1s1urnuJ QKr9uKWdJTWEKSo6MaPD+UfgXhrsK1d4Ozo1JaL1QchzQVhSOqBCchaeioasOEDf46WR rrObCPvnmxBGKP8gEtnrZxR673ZVUSQ1/JykJh9h87zytubyLVbhcUR9p27oVsn0tv2f wRdG/nmni8k0EqHbX6QvY1HwtYsQxvbiCG18NBhfF6gI3meNuUvIWu/i6h4DD21VkjCs OyFv4xvo5YxIMSNVgbiV/ZWzA2cRYNgyF00DM6+51pDZM2u0gta00wAL1K8zmz21wELK Rzjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=tYOWZPnjW65XI4l1LBGIm3u73JaE/GHPi+tZ/3A+qe8=; b=PDd4t1eyuQoiCCEGXKBSRAKxsh0xJ8a6TD25uHykYyaYAKc9NbrU+UQd3J+EAjtXjk ZqYEf6m4rzIJmnPWZerIkDgNmzHecW2jvDGNIGgqZ9M2f8SU4Ceko7bzUkOAeda8uwL4 VhdcEC/Dp89cKgLW7eY7qGhiPiJ6V9jKUJNApUui7r+k59Jex0F6iqsRQ4SLHvlqAGwY y1L3Q/vYtrn+Yh6naS771QWQ2VqDVU3AwNHksLleouafLSmyddCDzR9yqCXQe+hI82oh S57JKZlFQf2KKjWO0UoAFXbrIWXL9OCV2osGC1SA/H1LKz2EAvp0yGfSPZSloBz2pWMG 5pZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=O6Qu77Ih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg14-20020a170907970e00b006fa79f86c4csi2701320ejc.494.2022.05.26.13.55.46; Thu, 26 May 2022 13:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=O6Qu77Ih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245306AbiEYPu3 (ORCPT + 99 others); Wed, 25 May 2022 11:50:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245388AbiEYPuM (ORCPT ); Wed, 25 May 2022 11:50:12 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CFE8AF323 for ; Wed, 25 May 2022 08:50:11 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220525155009euoutp0142891e5a306f6d61f8e8ac9efbf4cd74~yY9wJ-Gj20505805058euoutp01x for ; Wed, 25 May 2022 15:50:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220525155009euoutp0142891e5a306f6d61f8e8ac9efbf4cd74~yY9wJ-Gj20505805058euoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653493809; bh=tYOWZPnjW65XI4l1LBGIm3u73JaE/GHPi+tZ/3A+qe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6Qu77Ihzkt1GlD+/w1r6xsFi0DjhWf0LS8zQ02zrZFUAQJQSkLNGON7uOAQkzL8Q D2u5pYxAI/iMQTb4XxWU9rhFAB89YAJnksRXjL7ogJ/A37COGSEge2szTP5PRYSVij AUlAa0yF2biAZ7CZqPWAoL8W9LB3wrQB4eFgW9f4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220525155008eucas1p21392109a809e41d5bb99c4abd0256de8~yY9uxB_mn0700707007eucas1p2J; Wed, 25 May 2022 15:50:08 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id EF.FF.10260.0305E826; Wed, 25 May 2022 16:50:08 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220525155007eucas1p1b7fc82f9e42be028e8f00109d55e6a62~yY9uK4vp20770307703eucas1p1D; Wed, 25 May 2022 15:50:07 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220525155007eusmtrp18bb3a95ccc378c2b11588ec51e84a10d~yY9uKGJTE1510315103eusmtrp1K; Wed, 25 May 2022 15:50:07 +0000 (GMT) X-AuditID: cbfec7f5-bddff70000002814-e4-628e503011b6 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id AF.17.09522.F205E826; Wed, 25 May 2022 16:50:07 +0100 (BST) Received: from localhost (unknown [106.210.248.20]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220525155007eusmtip1f0d8c7ef887e2d198cd3b081ecc69235~yY9t1swVE1835018350eusmtip1F; Wed, 25 May 2022 15:50:07 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, damien.lemoal@opensource.wdc.com, snitzer@redhat.com, Johannes.Thumshirn@wdc.com, hch@lst.de, hare@suse.de Cc: dsterba@suse.com, dm-devel@redhat.com, jiangbo.365@bytedance.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, gost.dev@samsung.com, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v6 7/8] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Wed, 25 May 2022 17:49:56 +0200 Message-Id: <20220525154957.393656-8-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525154957.393656-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLKsWRmVeSWpSXmKPExsWy7djPc7oGAX1JBk92C1qsvtvPZvH77Hlm i73vZrNaXPjRyGRx88BOJos9iyYxWaxcfZTJ4sn6WcwWPQc+sFj87brHZLH3lrbF5V1z2Czm L3vKbnFjwlNGi89LW9gt2jZ+ZXQQ8Ph3Yg2bx+WzpR6bVnWyeWxeUu+x+2YDm8fO1vusHu/3 XWXz6NuyitFj/ZarLB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2NJ1wuWgkeCFVfe r2JqYDzO18XIySEhYCKxY+k0ti5GLg4hgRWMEs+v74JyvjBK7Pq3iAnC+cwocXHia6AMB1jL /Y28EPHljBKLX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WzpR6bVnWyeWxeUu+x+2YDm8fO1vusHu/3 XWXz6NuyitFj/ZarLB6bT1d7fN4k59F+oJspgCdKz6Yov7QkVSEjv7jEVina0MJIz9DSQs/I xFLP0Ng81srIVEnfziYlNSezLLVI3y5BL2NJ1wuWgkeCFVfer2JqYDzO18XIwSEhYCJxfyNv FyMnh5DAUkaJtrUiILaEgITE7YVNjBC2sMSfa11sXYxcQDXPGCW6l/9kB+llE9CSaOxkB4mL CHQySszZ1wrmMAssZ5LYfLKPGaRbWMBfouXMMSYQm0VAVeLMysdsIDavgJXE/QVboDbIS8y8 9J0dxOYUsJaYv/8zM8RFVhJf73xlhagXlDg58wkLiM0MVN+8dTbzBEaBWUhSs5CkFjAyrWIU SS0tzk3PLTbUK07MLS7NS9dLzs/dxAiM1W3Hfm7ewTjv1Ue9Q4xMHIyHGCU4mJVEeC887U0S 4k1JrKxKLcqPLyrNSS0+xGgKdPdEZinR5HxgssgriTc0MzA1NDGzNDC1NDNWEuf1LOhIFBJI TyxJzU5NLUgtgulj4uCUamDSKX5zfkJJl16syLXyyb5/dPxP9WltURf8sFly00HtcE/huJbe +p/1j1fVuOs8k3WafuvG7TuGXxUs79W8vOuoGrqVifenyTqNRwu7btx8Xh3ja/h5dkpDSu2T 2xkhFcH/rN8xbds98+J0M+n8zGsnDQXD48L8+f/N6bnQ9VTx1t6VYqU1Hak/M/W53vB1/knf sfSlWNOz6OM9BySlegOf3/Ge8Dv5e3XRzvz8V5VS99/fC/ZbnPP7G69a1oeUVJ9+xhVi/ZVq iudvPGN59DQitSioIVqy/WTo9/71GiGvNdoy4jaKLn/m8tJvInvFmrWi6eeuZB1Z/T5dJ2VB ycp/anOknO4lL7gnsNlzSrcSS3FGoqEWc1FxIgBTZtA4XgMAAA== X-CMS-MailID: 20220525155007eucas1p1b7fc82f9e42be028e8f00109d55e6a62 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220525155007eucas1p1b7fc82f9e42be028e8f00109d55e6a62 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220525155007eucas1p1b7fc82f9e42be028e8f00109d55e6a62 References: <20220525154957.393656-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luis Chamberlain Today dm-zoned relies on the assumption that you have a zone size with a power of 2. Even though the block layer today enforces this requirement, these devices do exist and so provide a stop-gap measure to ensure these devices cannot be used by mistake Reviewed-by: Hannes Reinecke Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/md/dm-zone.c | 10 ++++++++++ drivers/md/dm-zoned-target.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 57daa86c19cf..41188091fe6b 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -231,6 +231,16 @@ static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t) struct request_queue *q = md->queue; unsigned int noio_flag; int ret; + struct block_device *bdev = md->disk->part0; + sector_t zone_sectors; + + zone_sectors = bdev_zone_sectors(bdev); + + if (!is_power_of_2(zone_sectors)) { + DMWARN("%s: %pg only power of two zone size supported", + dm_device_name(md), bdev); + return -EINVAL; + } /* * Check if something changed. If yes, cleanup the current resources diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index cac295cc8840..e4cef1b1b46c 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 = blk_queue_zone_sectors(q); + if (!is_power_of_2(zone_nr_sectors)) { + ti->error = "Zone size not power of 2"; + return -EINVAL; + } zoned_dev->zone_nr_sectors = zone_nr_sectors; zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk); @@ -806,6 +810,10 @@ static int dmz_fixup_devices(struct dm_target *ti) q = bdev_get_queue(zoned_dev->bdev); zoned_dev->zone_nr_sectors = blk_queue_zone_sectors(q); zoned_dev->nr_zones = blkdev_nr_zones(zoned_dev->bdev->bd_disk); + if (!is_power_of_2(zone_nr_sectors)) { + ti->error = "Zone size not power of 2"; + return -EINVAL; + } } if (reg_dev) { -- 2.25.1