From patchwork Tue Aug 16 13:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 12944919 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 4AE04C25B0E for ; Tue, 16 Aug 2022 13:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235605AbiHPNP7 (ORCPT ); Tue, 16 Aug 2022 09:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235558AbiHPNPu (ORCPT ); Tue, 16 Aug 2022 09:15:50 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0BDE53D03 for ; Tue, 16 Aug 2022 06:15:49 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220816131548euoutp014ab5ce162778f8fd8bbb585399763e26~L1ZrbE79h0140001400euoutp01J for ; Tue, 16 Aug 2022 13:15:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220816131548euoutp014ab5ce162778f8fd8bbb585399763e26~L1ZrbE79h0140001400euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1660655748; bh=tSSBnG0aDQsGLDWCBqD+ZIZXJV/OR5HHGZmAzSOHsrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZjT6BcVWK/M/RWCJkvFVgEPS9WBA7XQd4IwGqlZTIslskr2TxhChMjBtUaUsG89d2 YvCiuEAYzQ1CcjFvFD61i7k/HQZb0PjLKt06ZlEB9mZt1ZYUjNgX350FKoEsIRNr/F 2Gv24/HW6SVWQxATyZN4RJAbhjcAn7bAmnt4W4rM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220816131546eucas1p1f3c231b04a31e7cc32176cfc05e83c72~L1ZphtR6j0141901419eucas1p1T; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 90.C7.10067.2889BF26; Tue, 16 Aug 2022 14:15:46 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c~L1ZpI_Gr_0139801398eucas1p1V; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220816131546eusmtrp2d9086ae758fb09eea5925b027df021b1~L1ZpIK9aC0621306213eusmtrp2Q; Tue, 16 Aug 2022 13:15:46 +0000 (GMT) X-AuditID: cbfec7f4-dc1ff70000002753-1e-62fb98822633 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 03.31.09038.2889BF26; Tue, 16 Aug 2022 14:15:46 +0100 (BST) Received: from localhost (unknown [106.210.248.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220816131545eusmtip2999fba249cde6ce2fe24d4c98362b6c3~L1Zox9x-f1650116501eusmtip2g; Tue, 16 Aug 2022 13:15:45 +0000 (GMT) From: Pankaj Raghav To: damien.lemoal@opensource.wdc.com, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, agk@redhat.com Cc: pankydev8@gmail.com, gost.dev@samsung.com, matias.bjorling@wdc.com, hare@suse.de, bvanassche@acm.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com, linux-nvme@lists.infradead.org, jaegeuk@kernel.org, Johannes.Thumshirn@wdc.com, linux-block@vger.kernel.org, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v11 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Tue, 16 Aug 2022 15:15:31 +0200 Message-Id: <20220816131536.189406-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220816131536.189406-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIKsWRmVeSWpSXmKPExsWy7djPc7pNM34nGXz8oWKx/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2Ne u0TBPJ6KOQ1fWRoYW7i6GDk5JARMJK6vPsnUxcjFISSwglHi0+MvrBDOF0aJnXemMoFUCQl8 ZpT4u0gXpmPpidPMEEXLGSV+Nn5ghSh6wSix4JVqFyMHB5uAlkRjJztIWEQgXWJKy0sWEJtZ 4A6TROcHRRBbWCBEYu7l82BxFgFViW+LJoHZvAJWEteX/mOB2CUvMfPSd7A5nALWEv8aVkHV CEqcnPkEaqa8RPPW2WD3SAhs55T4sOoMG0Szi8T2j1uZIGxhiVfHt7BD2DIS/3fOh4pXSzy9 8RuquYVRon/nejaQBySAtvWdyQExmQU0Jdbv0ocod5TYefkEK0QFn8SNt4IQJ/BJTNo2nRki zCvR0SYEUa0ksfPnE6ilEhKXm+ZAfeUhcf79a5YJjIqzkDwzC8kzsxD2LmBkXsUonlpanJue WmyUl1quV5yYW1yal66XnJ+7iRGYCk//O/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AKzEKSmoUk tYCRaRWjSGppcW56brGRXnFibnFpXrpecn7uJkZg5G479nPLDsaVrz7qHWJk4mA8xCjBwawk wiv44keSEG9KYmVValF+fFFpTmrxIUZToLsnMkuJJucDU0deSbyhmYGpoYmZpYGppZmxkjiv Z0FHopBAemJJanZqakFqEUwfEwenVANTyEcWuxBfy6TpO6Pl/of4TFtWrS277sy/w40zew7f iN79+ulim5RPDFYcSzPtl27JudYRwKf6xC17yrl1Cy2W3SlPDi94vl5moXnzlCuHlcVW8Zju 2q/hzdm+tWyT9o9zb0/pW3uw7PGon35q7UqPRcuXd9l/85UpCf60oP7vPhGNB6u936ud9Wuy OtS5fY2fyxsTabv/cuvjPibbBBQ5JvxO2hBqLHFst3dgkmJ277d9h2Xizzw53B+bUBvsIHgi KEXp4axYp7o/rdNi9Zp4wxenrraPaN8gqh5qfju33DEuKmuhav+XJNGuFSWHknUCpFqdV//K /NZovUAkw+x2q7R0g9CSpbULCl/PjFViKc5INNRiLipOBAAvOmjGZQMAAA== X-CMS-MailID: 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c X-Msg-Generator: CA X-RootMTR: 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220816131546eucas1p190ff39f4a53b379b873ea83029370f4c References: <20220816131536.189406-1-p.raghav@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Luis Chamberlain dm-zoned relies on the assumption that the zone size is a power-of-2(po2) and the zone capacity is same as the zone size. Ensure only po2 devices can be used as dm-zoned target until a native support for zoned devices with non-po2 zone size is added. Reviewed-by: Hannes Reinecke Reviewed-by: Damien Le Moal Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/md/dm-zoned-target.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c index 95b132b52f33..9325bf5dee81 100644 --- a/drivers/md/dm-zoned-target.c +++ b/drivers/md/dm-zoned-target.c @@ -792,6 +792,10 @@ static int dmz_fixup_devices(struct dm_target *ti) return -EINVAL; } zone_nr_sectors = bdev_zone_sectors(bdev); + if (!is_power_of_2(zone_nr_sectors)) { + ti->error = "Zone size is not a power-of-2 number of sectors"; + return -EINVAL; + } zoned_dev->zone_nr_sectors = zone_nr_sectors; zoned_dev->nr_zones = bdev_nr_zones(bdev); } @@ -804,6 +808,10 @@ static int dmz_fixup_devices(struct dm_target *ti) return -EINVAL; } zoned_dev->zone_nr_sectors = bdev_zone_sectors(bdev); + if (!is_power_of_2(zoned_dev->zone_nr_sectors)) { + ti->error = "Zone size is not a power-of-2 number of sectors"; + return -EINVAL; + } zoned_dev->nr_zones = bdev_nr_zones(bdev); }