Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp354262iog; Wed, 15 Jun 2022 03:44:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tJXAcDG511/oYt+v98VY6QMzupmQ5vx70DeNkGieELogZwsoeED8w9lG1SzBnuuyAJXpEJ X-Received: by 2002:a17:90b:1c8f:b0:1b8:c6dc:ca61 with SMTP id oo15-20020a17090b1c8f00b001b8c6dcca61mr9433982pjb.13.1655289876454; Wed, 15 Jun 2022 03:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655289876; cv=none; d=google.com; s=arc-20160816; b=EGjb1MkuTfkwOW/EGcDHCYAHQvxTUv3DFRUdfm2kovrdSv20em0EQu7VlZgTextYCL PA/a5/1G0vOhZ1uBj40nepYVD33XxiOQTdNAdnUSFOtKqTvRLjU4zOwyAw1gUNgHpOHj 3vqJ0CrG16JVT2upIvcMdHrt1HTx8Z3pZeQzrSuay1xdjZWb2DURrZZYcySvxEJsID/N /NDqHHtqrGNVzStg4vgmXgwbo0fFTfutWftCMYQeIdNyacCBfSU6FwLyFXfURkXAaI4Q S7UZCa2g8jGPN2ukYpAoBVIbL7FWC7zQDCkcZdnSNdOjDRzuU7WpDlpMv5QCl2JZ/vxl /Bpw== 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=bwZDXQMCqMHhu3ZuVm0AocKjdjGbQSZlDWP1ndwgqcc=; b=DrXiWaBGEFSRvzAxCdviBQf1thXtmobKQe2C2vGqhfyZ3wBcD1jmeFtuk74gtO+Xik L5/TL8InXGQwYgCHKkGwVseEVisU7Nrf6e1jOs9vuxuizrOOlGtnepLJ1UBT346qR2Vz g9GSZa13bAFhYxXcAP03Mpa/lI7luH6r4b8AMzY0vcp5eZE0Tx0TdB/TFw4qlSyJqUrh iFyriV/h95ZpGXQ3ahfTFEqmWBVzNic26NH2fzM/xi+EYrnB9JGISUv9wsETNzA5Vs71 rXzJB50NllP0IuLVI93HzxFFaT2UyK22A5p5KMrnBbDneMdcuUZEtGbPDgs0/jEd8xK2 E+EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=IsnRcezj; 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 i69-20020a638748000000b004052d62fd09si12468129pge.78.2022.06.15.03.44.24; Wed, 15 Jun 2022 03:44:36 -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=IsnRcezj; 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 S242859AbiFOKUZ (ORCPT + 99 others); Wed, 15 Jun 2022 06:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239671AbiFOKUM (ORCPT ); Wed, 15 Jun 2022 06:20:12 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 118A34BFF2 for ; Wed, 15 Jun 2022 03:19:55 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220615101953euoutp0216a2cff7bf6991ab17e89ef82170376f~4xAYvB8lU2943629436euoutp02D for ; Wed, 15 Jun 2022 10:19:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220615101953euoutp0216a2cff7bf6991ab17e89ef82170376f~4xAYvB8lU2943629436euoutp02D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1655288393; bh=bwZDXQMCqMHhu3ZuVm0AocKjdjGbQSZlDWP1ndwgqcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IsnRcezjOXiALz83wEzrvdnlRnY+kZXZoQVFFEWvYvw9evcptXtOsuvwqnMJSYc0P 8IIlnoqCRamVvxdHGftchVRgmOuQt0530yccfh5h8RPRuyp1OqdjjesqSGh4Cl9Ia9 x3jSn9zK07ksmxSos9HsltT1N96m03ezesyOhA6k= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220615101951eucas1p18d84bd7b38d6657a6c512bd382ceedf6~4xAW0wNp51438314383eucas1p1I; Wed, 15 Jun 2022 10:19:51 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 39.77.10067.742B9A26; Wed, 15 Jun 2022 11:19:51 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec~4xAWbmb-F2114221142eucas1p2b; Wed, 15 Jun 2022 10:19:51 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220615101951eusmtrp2c759d4ee173fff60b6c81fb090bf1131~4xAWarPxE0361403614eusmtrp2l; Wed, 15 Jun 2022 10:19:51 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-9e-62a9b247678f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 07.24.09038.742B9A26; Wed, 15 Jun 2022 11:19:51 +0100 (BST) Received: from localhost (unknown [106.210.248.244]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220615101950eusmtip1b23a4a7a289c85a785fe400b913c2e54~4xAVmPX1i1152711527eusmtip1J; Wed, 15 Jun 2022 10:19:50 +0000 (GMT) From: Pankaj Raghav To: hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, axboe@kernel.dk Cc: bvanassche@acm.org, linux-kernel@vger.kernel.org, jiangbo.365@bytedance.com, hare@suse.de, pankydev8@gmail.com, dm-devel@redhat.com, jonathan.derrick@linux.dev, gost.dev@samsung.com, dsterba@suse.com, jaegeuk@kernel.org, linux-nvme@lists.infradead.org, Johannes.Thumshirn@wdc.com, linux-block@vger.kernel.org, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v7 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Wed, 15 Jun 2022 12:19:15 +0200 Message-Id: <20220615101920.329421-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220615101920.329421-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBKsWRmVeSWpSXmKPExsWy7djP87rum1YmGdyfpG+x+m4/m8W0Dz+Z LX6fPc9ssffdbFaLCz8amSxuHtjJZLFn0SQmi5WrjzJZPFk/i9mi58AHFou/XfeAYi0PgYpv aVtc3jWHzWL+sqfsFjcmPGW0+Ly0hd1izc2nLBZtG78yOgh7XL7i7fHvxBo2j52z7rJ7XD5b 6rFpVSebx8KGqcwem5fUe+y+2QCUa73P6vF+31U2j74tqxg91m+5yuKx+XS1x+dNch7tB7qZ AvijuGxSUnMyy1KL9O0SuDJ+3znDVvCLu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ailID: 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220615101951eucas1p238eb45e563bd9645af81bf16c56d98ec References: <20220615101920.329421-1-p.raghav@samsung.com> X-Spam-Status: No, score=-8.3 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-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 0ec5d8b9b..ad4228db5 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(zoned_dev->zone_nr_sectors)) { + ti->error = "Zone size not power of 2"; + return -EINVAL; + } } if (reg_dev) { -- 2.25.1