Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3007435iob; Mon, 16 May 2022 10:56:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbA5GwQPFsowrSe1hoFP88IAYE3x7qcc1r7lUPdX6d/gnqfnPIpb8KqTmjpn4/Ownv3Zd6 X-Received: by 2002:a05:6402:2752:b0:41c:b898:19a6 with SMTP id z18-20020a056402275200b0041cb89819a6mr14513937edd.30.1652723765981; Mon, 16 May 2022 10:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652723765; cv=none; d=google.com; s=arc-20160816; b=GNsarjfZQiPnjTcJxJrpQ8C2OA+Fh63SmU4YFpahv9F05Q5LQhMei3tyULpmIz/gGa yKAvEUIRn0pT2PoVDID0bWzeRiiOXSZnhYnHerAnk4ANaYG4w+WKGplBBO1p6amiAaqM LdTwpcsd0VKVZ5WgXgjdL4qZeByf52PzEw5eXY67kP6mh+38O6YdBLwaDCj9mdCWGu2w xMg2Udjz7aQAsklBU/fdDHN1UkLOXQaiqklTWLxoYrPXY6CzWJQKj6VHYZCQSX38YdHz z1zYTm16b5GYuOdIbl227KUrKnm/pXLyLr07TxyQT+8APNtgpZ6C5aPxK3HtgaNaiLpK EZow== 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=6O6R+aWzFD0tH6pBlgRqy5ygmaD7SLpLHM9qftmpwuQ=; b=AUe/iAfWnAlYbhUOG63+oMGatF/hGdpoCt2u91cQvx1W3op7QMhuiEr3vlfR1CHQ4N KLxnwu+m7sQxTjGCsUxmVTE3SoefzM5SQt7gmjfmmCqW4jUrktz7dPGStB8okvzrjOew +hrnQcmcAA1M0CWttpUt7gbEHZK+kesFNmmxbZKVc8D7TfFtNW6EPBWXXy6INhb8JNBx 1+8iGVXJMmhqMeTfx61ASGUiSb6jyr4tiYCDcBnupid6JJh2DulYQdGmWzB5sO6yxk/H bA57YzUnoZge9KO+fjJU/4sPOpD4sffVD4rA78RCVk6M3r9QFBH739JK25a+4U4Jz2hf ULlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Fh6lUpOx; 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 sa39-20020a1709076d2700b006e8990303bcsi8789ejc.375.2022.05.16.10.55.37; Mon, 16 May 2022 10:56:05 -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=Fh6lUpOx; 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 S238493AbiEPQ44 (ORCPT + 99 others); Mon, 16 May 2022 12:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343876AbiEPQy4 (ORCPT ); Mon, 16 May 2022 12:54:56 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0CCB3CA4C for ; Mon, 16 May 2022 09:54:39 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220516165438euoutp028a693eb8709bd8940648f056d66e29b7~vpCe0pfg82798927989euoutp02X for ; Mon, 16 May 2022 16:54:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220516165438euoutp028a693eb8709bd8940648f056d66e29b7~vpCe0pfg82798927989euoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1652720078; bh=6O6R+aWzFD0tH6pBlgRqy5ygmaD7SLpLHM9qftmpwuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fh6lUpOxEz1L5R0lDXKJogWDFAtYMYr19gWlbSAHU966Zw8+vMGblv2wuPQAu7a5U RPyQtPr0FqsXu3HlSnG97HoIFCkN3dhmm2J3ok64Z/gmmFkIebT+VLWVGYrIW4wgRg wCETrHorIbHw+GZ7QiTP96Jl1l5jjipFf9NzVwYk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220516165437eucas1p15eb77c4c9a68927fe7695a2e5830dcb7~vpCdkUKeT1545715457eucas1p1f; Mon, 16 May 2022 16:54:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 66.E6.10260.DC182826; Mon, 16 May 2022 17:54:37 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220516165436eucas1p178d079302dae3a9fca696b13b0390deb~vpCdOIri62560525605eucas1p1b; Mon, 16 May 2022 16:54:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220516165436eusmtrp28837a89a06654af7c04d36f8d5949f97~vpCdNanu61030710307eusmtrp26; Mon, 16 May 2022 16:54:36 +0000 (GMT) X-AuditID: cbfec7f5-bddff70000002814-5f-628281cdd3f8 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 23.10.09404.CC182826; Mon, 16 May 2022 17:54:36 +0100 (BST) Received: from localhost (unknown [106.210.248.7]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220516165436eusmtip27c52763e39356a08b7d9cbb75f4140dd~vpCc05sQp3184631846eusmtip2E; Mon, 16 May 2022 16:54:36 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, damien.lemoal@opensource.wdc.com, pankydev8@gmail.com, dsterba@suse.com, hch@lst.de Cc: linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, jiangbo.365@bytedance.com, linux-block@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com, Luis Chamberlain , Hannes Reinecke Subject: [PATCH v4 13/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Mon, 16 May 2022 18:54:16 +0200 Message-Id: <20220516165416.171196-14-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516165416.171196-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNKsWRmVeSWpSXmKPExsWy7djP87pnG5uSDLb9FbJYfbefzeL32fPM FnvfzWa1uPCjkcni5oGdTBZ7Fk1isli5+iiTRc+BDywWe29pW1x6vILdYs/ekywWl3fNYbOY v+wpu8WNCU8ZLT4vbWG3WHPzKYuDgMe/E2vYPHbOusvucflsqcemVZ1sHpuX1HvsvtkAFG69 z+rxft9VNo++LasYPdZvucrisfl0tcfnTXIBPFFcNimpOZllqUX6dglcGT277jEVzOCquHX2 AGsD4yqOLkZODgkBE4npK7YydzFycQgJrGCUOPphLRuE84VR4tflmUwQzmdGiVNPTrDAtOyZ fBkqsZxRonXqK3YI5zmjRMOWaYxdjBwcbAJaEo2d7CANIg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IBPFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYm lnqGxuaxVkamSvp2NimpOZllqUX6dgl6GT277jEVzOCquHX2AGsD4yqOLkZODgkBE4k9ky8z dTFycQgJLGWUOLjjKQtEQkLi9sImRghbWOLPtS42iKKnjBInJxwHSnBwsAloSTR2soPUiAgU SMzp3wLWyyxwnkli/3p3EFtYIFBi0rZmJhCbRUBVovP1M1YQm1fAWuLVitesEPPlJWZe+s4O MpITKL66ixskLCRgJfH1yS12iHJBiZMzn0CNl5do3jqbeQKjwCwkqVlIUgsYmVYxiqSWFuem 5xYb6RUn5haX5qXrJefnbmIERuq2Yz+37GBc+eqj3iFGJg7GQ4wSHMxKIrwGFQ1JQrwpiZVV qUX58UWlOanFhxhNgc6eyCwlmpwPTBV5JfGGZgamhiZmlgamlmbGSuK8ngUdiUIC6Yklqdmp qQWpRTB9TBycUg1Mk6fvdjfa5ON/83dYHLet8aHDRgZJm/7YMf6cwtBzuV9CcP2hI984F6z/ seXGjM/F12TvZ65qnTA74+361NWKzd1vUmt975ZEH01/uWZJ6bX7DEdaLcJcd29JOizBtSrp /ZxYBjkRM9OMFQYs7780Rlw1CcpKK14we0//w40XXTsfr6lyDPmRmXv+6+q8JsuPd7iq890/ NKztO32j2k/8xM/V/+43BTOsWGIi95gla1/szVtnXB6FxSsd47z/WPRCpMyzahaujsfW23oZ FLZ0GJYLeLIIOs7s2Z5f0ST/oPfmzT8XwhN95j1bnOKeecU2YY39l+OzpF49miMRb77ok5qX ycEXx+bd+KtxtLG5XYmlOCPRUIu5qDgRAFdHucBdAwAA X-CMS-MailID: 20220516165436eucas1p178d079302dae3a9fca696b13b0390deb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220516165436eucas1p178d079302dae3a9fca696b13b0390deb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220516165436eucas1p178d079302dae3a9fca696b13b0390deb References: <20220516165416.171196-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.4 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=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 Reviewed-by: Hannes Reinecke 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 3e7b1fe15..f0c588c02 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", + dm_device_name(md), + bdevname(bdev, bname)); + return -EINVAL; + } /* * Check if something changed. If yes, cleanup the current resources -- 2.25.1