Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2064147ioo; Mon, 23 May 2022 09:17:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQjQzym3iMJkvvjOQh25TNDL5Wm4CtTNz7au/8ot9AAjkleY/PY05oh/Jw32KRtoxa3bgF X-Received: by 2002:a17:902:d582:b0:161:c681:c326 with SMTP id k2-20020a170902d58200b00161c681c326mr21410146plh.84.1653322676178; Mon, 23 May 2022 09:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653322676; cv=none; d=google.com; s=arc-20160816; b=E2rzeMks8hwnGgPV9D3TF8BeRH5ZHX7yVCI/FrH6Eq1WsIgPo5xancVx4hWw3XUkOS d7aQpp8J3UWcZfXlETdvlFWbZ7KValHYu8ARB/gzgKvBcGM6M8UGwxI/sGkHe/mzHGZ4 y2aLTG+mbIBT+y8EpmyWB1+Tx8qV3uVl1FlTl0s7i6fPf5nA/Rb82CWkIrTa098R1hLk bgu2Fp7cbMidCOrOe32E6af+/wzxjQDqM7CxZZJS6URDW+rTYwFvOanUcyKEAHnsMpnM byoLKlqZvqa24umHpvpMdBFix9ueaKqGIx+5f3j/6OiBg5Plt/WQgbRX/W3UQV59NODJ KDXA== 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=aLBSqS5uAesNMicTZHySwg8Swibu7HOYfUS7gR9bn94=; b=UtMcBfb+pb41pryNXewWw3Lbk/bG+8xBSEE8akLNInZrRl5kF8UtMW8CMJUP5HxEHm F4KK3EYvQA5ggdmJS6A/ygdS3CeMqY3NdqFQouSeb10/HVWb8lmny5lns7L05Xa8LLqf ps8kq3WwPi52mOUa9LNs+VxSLYH40GdKlRhA8veqsYMyJvtlXMgVAVUnOO5GT0VhMRUX oNUyyGqHUbtKmvC3SKOJCQuVbutoIxcAf5L3awJwd/jlSYVIJz/PUJg3J3QwMAMUgp/s 2NdGpuHRcJY3qNDCK4XMBDoanSACn6i8twaiK6hy8qxaC5fGWls9STki3AUCfvDhh/x1 1fvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=M7lHHDcn; 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 r16-20020a632b10000000b003fa52e23cc6si5364262pgr.875.2022.05.23.09.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 09:17:56 -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=M7lHHDcn; 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 5FD4A544CC; Mon, 23 May 2022 09:17:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238433AbiEWQRA (ORCPT + 99 others); Mon, 23 May 2022 12:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238613AbiEWQQR (ORCPT ); Mon, 23 May 2022 12:16:17 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B76D532EEB for ; Mon, 23 May 2022 09:16:16 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220523161615euoutp0202f9261c4d8efa1b171bd3fea2298c21~xyB9wB50-1808118081euoutp02k for ; Mon, 23 May 2022 16:16:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220523161615euoutp0202f9261c4d8efa1b171bd3fea2298c21~xyB9wB50-1808118081euoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1653322575; bh=aLBSqS5uAesNMicTZHySwg8Swibu7HOYfUS7gR9bn94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7lHHDcnMiHGeh+Q+8z/MXZKknjJVpgVsRtdLQE4Nxm2DWJaInn0kZx11CyAKk9yO eaH5hMz9wMUsjETfoUO5Wr79yWkRrpdt8vxyLMwq2vAiGcYSPY7xbZHASug5xPWyM6 MlGlBQMrI4tEs1on9cIkGnHBU2NZ/Y8T5nrEGG3A= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220523161613eucas1p14eb4dfeeca85d1b74be3a853a80b3897~xyB8L9OR_1546315463eucas1p1V; Mon, 23 May 2022 16:16:13 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 5E.7E.09887.D43BB826; Mon, 23 May 2022 17:16:13 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220523161613eucas1p256b21b1a631324b4814465decf3958ce~xyB7qut2W0957009570eucas1p2d; Mon, 23 May 2022 16:16:13 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220523161613eusmtrp2c000f1ed1707206c2a22768a34db555b~xyB7p7UDg0219002190eusmtrp2W; Mon, 23 May 2022 16:16:13 +0000 (GMT) X-AuditID: cbfec7f4-45bff7000000269f-28-628bb34de617 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 71.29.09404.D43BB826; Mon, 23 May 2022 17:16:13 +0100 (BST) Received: from localhost (unknown [106.210.248.20]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220523161612eusmtip1e2e71268148d672b0c1860ca258f8832~xyB7VIab71408314083eusmtip1g; Mon, 23 May 2022 16:16:12 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, hch@lst.de, snitzer@redhat.com, damien.lemoal@opensource.wdc.com, hare@suse.de, Johannes.Thumshirn@wdc.com Cc: linux-nvme@lists.infradead.org, dm-devel@redhat.com, dsterba@suse.com, jiangbo.365@bytedance.com, linux-kernel@vger.kernel.org, gost.dev@samsung.com, linux-block@vger.kernel.org, jaegeuk@kernel.org, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v5 7/7] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Mon, 23 May 2022 18:16:01 +0200 Message-Id: <20220523161601.58078-8-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220523161601.58078-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Sf0wTZxzG895dr0dD2VkdfCPTbV2EUGfLnISTkQUiSy5biNPELJQYqXjD BqikBxsbcYPxU1z40f1sYWIYagGxlVal7dywCXaMMQhNJ2Vxm9puRFEghWFHhFFOM/97vu/z ed/n+yQvhct+E22mtLpSTq/TFMlJCXH5enhsR7bt5OHk1XEV03uzmWSWR8dw5uqDNhEz/rAK Y/yDDoz5rtOAMd29QxgTsJhw5tPBOYJ51Pg7xl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eucas1p256b21b1a631324b4814465decf3958ce X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220523161613eucas1p256b21b1a631324b4814465decf3958ce X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220523161613eucas1p256b21b1a631324b4814465decf3958ce References: <20220523161601.58078-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.6 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,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 57daa86c19cf..f87a1eda8252 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