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 LHCHSWL7xfdgk4QFQiQuLpnCCGKzCKhK3Hp3HSzOK2Ap0bq8E2qbvMTMS9/BBnEKWEm8XtXK CFEjKHFy5hMWEJsZqKZ562xmkAUSAps5JbpetjJDNLtIvPgxix3CFpZ4dXwLlC0jcXpyDwuE XS3x9MZvqOYWoHd2rmeDBIy1RN+ZHBCTWUBTYv0ufYhyR4mNC1ZDVfBJ3HgrCHECn8SkbdOZ IcK8Eh1tQhDVShI7fz6BWiohcblpDgtEiYfEtBO2ExgVZyH5ZRaSX2YhrF3AyLyKUTy1tDg3 PbXYOC+1XK84Mbe4NC9dLzk/dx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5Nzy021CtOzC0uzUvXS87P3cQIjN5tx35u3sE479VHvUOMTByMhxglOJiVRHhZ 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); }