From patchwork Wed Aug 3 09:47: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: 12935336 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 9E072C19F2A for ; Wed, 3 Aug 2022 09:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237617AbiHCJs0 (ORCPT ); Wed, 3 Aug 2022 05:48:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236046AbiHCJsR (ORCPT ); Wed, 3 Aug 2022 05:48:17 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2763C16E for ; Wed, 3 Aug 2022 02:48:15 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220803094813euoutp023df4f1d5644ec0003f33e8615c736fb6~HzLuhrIdC2038420384euoutp02c for ; Wed, 3 Aug 2022 09:48:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220803094813euoutp023df4f1d5644ec0003f33e8615c736fb6~HzLuhrIdC2038420384euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1659520093; bh=YUh2zeQE2RmUBXA7/4tWmxObmeVjkyPLOxi8ex3NZxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CMw9zF1OjPwosTdt09H260Wpb9aFfbmmJqYCBGL6Pp296oxb4eaG4/MoTC7eBiIFd w0jWf1XGKUmSBhW+LpOfpkJAPwGB9C19+gVKR81r8T8LyXN3iBUgJJ8gBRA38udPfx DuhGA76zBCAkHg8cx2pV646ZXx7gFkBkou+36Rjg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220803094811eucas1p28cd48175b9feac0080f9be506dd1b5b5~HzLspo2by1532415324eucas1p2S; Wed, 3 Aug 2022 09:48:11 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 08.FF.09664.B544AE26; Wed, 3 Aug 2022 10:48:11 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220803094811eucas1p17a2ac191899bba7938de6b9e3a55352f~HzLsBClpH3109631096eucas1p18; Wed, 3 Aug 2022 09:48:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220803094811eusmtrp1ba4f7f94f43e6937f2a29d964ceaf11c~HzLr5us1F2000320003eusmtrp1Y; Wed, 3 Aug 2022 09:48:11 +0000 (GMT) X-AuditID: cbfec7f2-d81ff700000025c0-8e-62ea445bc010 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 07.9B.09038.A544AE26; Wed, 3 Aug 2022 10:48:11 +0100 (BST) Received: from localhost (unknown [106.210.248.112]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220803094810eusmtip2b837e592c0d57ed90af9168ead84a75c~HzLrkbg3V1623616236eusmtip29; Wed, 3 Aug 2022 09:48:10 +0000 (GMT) From: Pankaj Raghav To: Johannes.Thumshirn@wdc.com, snitzer@kernel.org, axboe@kernel.dk, damien.lemoal@opensource.wdc.com, agk@redhat.com, hch@lst.de Cc: dm-devel@redhat.com, matias.bjorling@wdc.com, gost.dev@samsung.com, linux-kernel@vger.kernel.org, pankydev8@gmail.com, jaegeuk@kernel.org, hare@suse.de, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, bvanassche@acm.org, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v9 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Wed, 3 Aug 2022 11:47:56 +0200 Message-Id: <20220803094801.177490-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803094801.177490-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djPc7rRLq+SDM5+NrZYf+oYs8Xqu/1s FtM+/GS2+H32PLPF3nezWS1uHtjJZLFn0SQmi5WrjzJZPFk/i9nib9c9Jou9t7QtLu+aw2Yx f9lTdosJbV+ZLW5MeMpo8XlpC7vFmptPWSxO3JJ2EPK4fMXbY+esu+wel8+Wemxa1cnmsXlJ vcfumw1sHjtb77N6vN93lc2jb8sqRo/Np6s9Pm+S82g/0M0UwBPFZZOSmpNZllqkb5fAlXF8 +hmWgr3cFX/nvmdtYFzH2cXIySEhYCKxc9cV1i5GLg4hgRWMEpvO72OHcL4wSix9vxjK+cwo 8fT9RRaYlv0PH0G1LGeU2PtoEpTzklHi7OofQA4HB5uAlkRjJ1i3iEAzo8Tdvz1gRcwCB5gk Fr3+wQgySlggWGLqqx1MIA0sAqoSJ65EgoR5Bawkmg89Y4bYJi8x89J3dhCbU8BaYsq/f8wQ NYISJ2c+AbuIGaimeetsZpD5EgK7OSUe3z7LCNHsIvH14nGos4UlXh3fwg5hy0icntwDFa+W eHrjN1RzC6NE/871bCAHSQBt6zuTA2IyC2hKrN+lDxF1lOh94Qth8knceCsIcQGfxKRt05kh wrwSHW1CELOVJHb+fAK1U0LictMcqJ0eEltf3mWewKg4C8kvs5D8Mgth7QJG5lWM4qmlxbnp qcWGeanlesWJucWleel6yfm5mxiBCfH0v+OfdjDOffVR7xA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amVYwiqaXFuem5xUZ6xYm5xaV56XrJ+bmbGIGxu+3Yzy07GFe++qh3iJGJg/EQowQH s5II7x2X50lCvCmJlVWpRfnxRaU5qcWHGE2Bzp7ILCWanA9MHnkl8YZmBqaGJmaWBqaWZsZK 4ryeBR2JQgLpiSWp2ampBalFMH1MHJxSDUy8DglX0y5Os9431+SK32yn9srn2cviUpdsjzvU +Pm0pvmsys28b973PDlXf2V1bHqUiPOurFzhokVHlMq3RMSm9H97/HdRvVznunfmdcdqM+Zo qSZLPmqxPB951fb9ar+Lrz5YTl7w5NXkl4Hbiw6631adkyf+jlGJ42ez6DsfaS5BNY0ZiT88 NXsNVjxjSH+YH7rpzwGV+yGx/YcLHZsiMqpqV5znuBx8aOpa9x0vf8i6zzz9lJ9vGV9J8DOd uQw3dOS27eovfJUT7SZyJmjT1wn7rgZvc/rbKBQZYLdx5zNbZe5vJQxbeW8mJWzea/2j7kPt wjXF4i1blRNj9zou0WXfWFjwbMs1jYe+Oz8qsRRnJBpqMRcVJwIARSsy8WYDAAA= X-CMS-MailID: 20220803094811eucas1p17a2ac191899bba7938de6b9e3a55352f X-Msg-Generator: CA X-RootMTR: 20220803094811eucas1p17a2ac191899bba7938de6b9e3a55352f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220803094811eucas1p17a2ac191899bba7938de6b9e3a55352f References: <20220803094801.177490-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 non po2 support is added. Reviewed-by: Hannes Reinecke Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav Reviewed-by: Damien Le Moal --- 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); }