Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4720565ioa; Wed, 27 Apr 2022 09:37:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzc6Kczk8L6zqrreZSsBUc6TpvODZKUl19sV6KbSLrMRwhJDZBkfuXbWnE0Oas6rvWlGjR X-Received: by 2002:a63:5755:0:b0:3ab:a0ef:9227 with SMTP id h21-20020a635755000000b003aba0ef9227mr6289620pgm.541.1651077457363; Wed, 27 Apr 2022 09:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077457; cv=none; d=google.com; s=arc-20160816; b=m+N2Qx1C1HAFuEzb7T7X2tTS8nRFni9EljJCWtN318j7nMB37AUkH7G2jfOcLMnjPv j7UlEQajKm+y8LdHxmILIuWuGgjfrvVet7yg/bp+QvDDK4GwLpfMUSRIMjAdJhGzwIBw Q2rwxxYnSTUvaZMYAPrkSwM25MhJS48rT+qQ7a3IldeD5B2gOXnWysAutW4Zo9oHKzN7 gQ3+6af3pKQbpxHhpBKrKiCebHYichMH3ZuZTz5ITbUo6OeACLuXJBy3WBdkIh4twJBG w0TFAoyp4F3x3MgGRf12+QgZNEgkS+QZ/JDjdyE3FxBBRisG9+gQrs6vJQqKdcEIlrBE y8Gw== 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=T09TdKd+PKEo6/XUyeNORY3qJAIzmSkSW/V2uBW8/x8=; b=Ob/9FdYHHgNzgcLlYrIyjXW8W3WDJ5n0WvSa1n1rWw7Xq4NRmMUI76UYnJ/chzk/MI 0Lh8IFgT1XO+2d3WwE0wPEdW//LLfygeZ/DApeqY4wUjW4PAtxw8SRtNJFWv38JY4Sm1 ZggQFGJ29h3wGlCYKyWEgl06e4r3Mi+PqPdvDWnMIA4WJI/PUfB+G/fCIQf2bgD3QQG6 JUVUX2hZ0b/VWQtLEpqLbZNuL4svwDbfxx8KnIAKSxn7CS7o1N+OG7jjydxHGCzC8BYg RxNzxqM0Cr63s8/wvdUPYJwezl1etlN9mv8719tnJMAzgXPKEQTSTJarSEiQ9kONSuR+ 5xNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="XvvkE/3L"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i68-20020a639d47000000b003aa810be6aasi2065162pgd.85.2022.04.27.09.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:37:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="XvvkE/3L"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2FE934ABC77; Wed, 27 Apr 2022 09:07:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241780AbiD0QJz (ORCPT + 99 others); Wed, 27 Apr 2022 12:09:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241836AbiD0QHb (ORCPT ); Wed, 27 Apr 2022 12:07:31 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E5FD3D6CE1 for ; Wed, 27 Apr 2022 09:03:23 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220427160315euoutp0249137e97aa680e7c77b5c49333a11e17~pzFL7-ZPk1400814008euoutp02H for ; Wed, 27 Apr 2022 16:03:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220427160315euoutp0249137e97aa680e7c77b5c49333a11e17~pzFL7-ZPk1400814008euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651075395; bh=T09TdKd+PKEo6/XUyeNORY3qJAIzmSkSW/V2uBW8/x8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XvvkE/3L93M0ztjxYphRVPfQl3magsan30V9vvdhTP7mRxFlNLj1mjzC6AlyeLw9D egBm9E1bwBN3Fpab3MnE8f1gc9fX+pdSSLpj/wkCXRe98K+GYu5s6ONn8p1sbDP6PN t4b79Il3zRxkovf/IvCAhnueJaHPdSjBfydterzw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220427160313eucas1p28f302518de9cf124f9194cc8d376fd43~pzFKbY0Jn2334023340eucas1p2s; Wed, 27 Apr 2022 16:03:13 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C1.E7.10009.14969626; Wed, 27 Apr 2022 17:03:13 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676~pzFJ-Gzll2489024890eucas1p1n; Wed, 27 Apr 2022 16:03:13 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220427160313eusmtrp2cea78a3137da11659e89a20f8b5be479~pzFJ_NFx82598325983eusmtrp2p; Wed, 27 Apr 2022 16:03:13 +0000 (GMT) X-AuditID: cbfec7f2-e7fff70000002719-93-62696941346b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5E.81.09522.04969626; Wed, 27 Apr 2022 17:03:12 +0100 (BST) Received: from localhost (unknown [106.210.248.162]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220427160312eusmtip1ae2f42acfa009ab15e75927ef0532d22~pzFJnZ99a1317113171eusmtip1M; Wed, 27 Apr 2022 16:03:12 +0000 (GMT) From: Pankaj Raghav To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com, sagi@grimberg.me, damien.lemoal@opensource.wdc.com, dsterba@suse.com, johannes.thumshirn@wdc.com Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, clm@fb.com, gost.dev@samsung.com, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com, jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org, kch@nvidia.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, linux-block@vger.kernel.org, Pankaj Raghav Subject: [PATCH 16/16] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Wed, 27 Apr 2022 18:02:55 +0200 Message-Id: <20220427160255.300418-17-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA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5jS8kriDc0MTA1NzCwNTC3NjJXEeT0LOhKFBNITS1KzU1MLUotg+pg4OKUamOoNztk7 676Vqz9ou6rw0tv1akJitqWbtj5JydrfKbNS7pTm13VZmWtnX80QzUgviwhx+f3njLLFRY4H jus3m76TDZhgq6r+UPdQkuSxF7I3Zcwf3M17EnTt2zJPO9mQLFPZw3oZlwr7ZVi6uDnXvMs2 Wxa0IffyTJUuqaayzraXsiaq269fZ/inmPLOu8n/eTr7t097n/vxftx9T0v1LJf242WN58+m SjQ7Nd7scpjsoOQ7WZ9dwfHHeqO3cY1nzVYZ5T+dK6I3ycX+YP08SYNW7d7iz4xzeOabMp/t jprluMSX1+T2XuHk96+iPz+a3B5yquyNt/+Xusthrvxz76zynMgj9TUtJHbX1z1NSizFGYmG WsxFxYkA506w3bEDAAA= X-CMS-MailID: 20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220427160313eucas1p1feecf74ec15c8c3d9250444710fd1676 References: <20220427160255.300418-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- drivers/md/dm-zone.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c index 57daa86c19cf..221e0aa0f1a7 100644 --- a/drivers/md/dm-zone.c +++ b/drivers/md/dm-zone.c @@ -231,6 +231,18 @@ 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; + char bname[BDEVNAME_SIZE]; + + zone_sectors = bdev_zone_sectors(bdev); + + if (!is_power_of_2(zone_sectors)) { + DMWARN("%s: %s only power of two zone size supported\n", + dm_device_name(md), + bdevname(bdev, bname)); + return 1; + } /* * Check if something changed. If yes, cleanup the current resources -- 2.25.1