Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4706850iob; Sun, 8 May 2022 22:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8zJw6ZjLQW4LQuIcPLfy5oC6cIohZqAIAbJPCxuUwoN9YRcZhGoFjKlZdbPyTec8ETDIr X-Received: by 2002:a17:90a:9ea:b0:1dc:1c48:eda with SMTP id 97-20020a17090a09ea00b001dc1c480edamr24394996pjo.38.1652075060675; Sun, 08 May 2022 22:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652075060; cv=none; d=google.com; s=arc-20160816; b=FyxgLqMO3dqvMLaoHDdQE0d0XjZRAsf1W96YQ21H1gdbEf8sx5Or0G9UqAKeorONLd Vaz2BIbPyzSxSQKx3G091S+AMD8L/wBQnW0jEQBBTHUM7vHbGH+BdHgm9ASQDfr+ShcA f7vEgCQq/knyobzfkzX8s8KlSlkRzD0nD/9xN6H6/oAsCb1ySlLA9aybtiWT70s/ZXNV GL8yHG8znTqS2oHdB231tRzYQ7FQ3lRZsm6XHfnRdkIDclQnfZ0CYfnYHd82GITWebbG qd/FXwYK0BIlUCFHbMoyTHVpRYQrf5pDjoec11I/4IHXi0Gs/32NcRc3l4JSshQyRZ6p KwoA== 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=2XMubIyolz4ZLTc9DAEWfdq40b874mLFKF8nTtEYP/I=; b=G9mzsYYiIA+NKN74SbOk29pWNy8h8rZ5TKbGSz4uzrji3A1whuzLCB3nqDKvYGgJz6 +FPfPgIC8W3Lu09P/ytFgr+mojMTPvupANOiKyBCyp9GwtF0EV5OFCZR9c13viLx2owP P2BKntrD7cKEI9K4NLHplFClnDvv733iwf/LgIeULagyp7+ty5q7xNjn2iQO8v/WPL/q bhte4OANYR0xTkUQA161HCc5Us3QnuiZlKvsU3zy2I4ErByShWo1HoW3b8CuBZBwRxmO nZy0mQkwtb68orjTe2DjM14/ppKtjm8ufd9QKse2OUrNNZeFM1IO82IVqO3F7fhMsGoL ozBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=E0wnMNi6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id v8-20020a170902b7c800b0015b0d64802dsi9541107plz.68.2022.05.08.22.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 22:44:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=E0wnMNi6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 AA99215ECE3; Sun, 8 May 2022 22:43:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380163AbiEENzs (ORCPT + 99 others); Thu, 5 May 2022 09:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380278AbiEENzG (ORCPT ); Thu, 5 May 2022 09:55:06 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AFD057B3A for ; Thu, 5 May 2022 06:51:15 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220505135114euoutp01485591c70decf4eaf43d362549cb35b7~sOcNNTvWA3116431164euoutp013 for ; Thu, 5 May 2022 13:51:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220505135114euoutp01485591c70decf4eaf43d362549cb35b7~sOcNNTvWA3116431164euoutp013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651758674; bh=2XMubIyolz4ZLTc9DAEWfdq40b874mLFKF8nTtEYP/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E0wnMNi6o6VpqVWeerR6H0o4DPAoZnjnpW4WdtH8WgqR2fuYbJdIzXE0ZwbJBNffm AXXjY54NSLxOLP/1YOBgGrwJKIh1NwvUSyN58Y6hV01sSLGE1TNmwlQsoJdt7g8kg/ egWp6SEMujttwatGdcFud817L/dI6iq0xrP2HgTY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220505135112eucas1p1f5543b0d1b522e3f7a73821940c9d5ed~sOcLiaiOK1070010700eucas1p1J; Thu, 5 May 2022 13:51:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B3.0D.10009.056D3726; Thu, 5 May 2022 14:51:12 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220505135111eucas1p218b79f4b1e54bb3a24d2ec189ec445d1~sOcKzFSGC0041400414eucas1p29; Thu, 5 May 2022 13:51:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220505135111eusmtrp131b2472d47e1950f5d2b04b938f6ee9e~sOcKyPmFR1310613106eusmtrp1j; Thu, 5 May 2022 13:51:11 +0000 (GMT) X-AuditID: cbfec7f2-e7fff70000002719-52-6273d6501c0d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CD.6A.09404.F46D3726; Thu, 5 May 2022 14:51:11 +0100 (BST) Received: from localhost (unknown [106.210.248.170]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220505135111eusmtip25f1e0efa88e3a562d73f5ea4b94fbc5f~sOcKeCtqw1486514865eusmtip2I; Thu, 5 May 2022 13:51:11 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, dsterba@suse.com, jaegeuk@kernel.org, bvanassche@acm.org, hare@suse.de Cc: jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, matias.bjorling@wdc.com, gost.dev@samsung.com, pankydev8@gmail.com, Luis Chamberlain , Pankaj Raghav , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 11/11] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Thu, 5 May 2022 15:47:11 +0200 Message-Id: <20220505134710.132630-12-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220505134710.132630-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA01SbUxTZxjlve/t7W23NtdK5jsomHXMBIxFXOPupjFua7K7OTOZP7ZpjLZw RTZaSSsbG2YpguVDtNXNbZbilA2krbNY+RDxo2syoK2Mhs7ZmoFA2mSSiWAxUt3YWi5m/jvP Oed5z3OSl4SSGV4aWazdx+q0qhIZIcS7+uK/rtryu169+nv/87TT1wdpx4iJoL+ZjkP68eAQ pK9MNfLowFwlRof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ylBdPd5xfl7Pc96vtV0bJw2vsaJZbijERDLeai4kQAYjOhCXQD AAA= X-CMS-MailID: 20220505135111eucas1p218b79f4b1e54bb3a24d2ec189ec445d1 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220505135111eucas1p218b79f4b1e54bb3a24d2ec189ec445d1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220505135111eucas1p218b79f4b1e54bb3a24d2ec189ec445d1 References: <20220505134710.132630-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 3e7b1fe15..27dc4ddf2 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