Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp485884imn; Wed, 27 Jul 2022 11:31:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tBUyppRF6ldt7dxfjHUb581Ott3nvkA/8PQS7zAxCeU9DE5R36qib//RxKeQKoN8MYQ00x X-Received: by 2002:a17:907:72cc:b0:72b:6912:5435 with SMTP id du12-20020a17090772cc00b0072b69125435mr17509805ejc.603.1658946713960; Wed, 27 Jul 2022 11:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658946713; cv=none; d=google.com; s=arc-20160816; b=l3l+ZpFjV54qJYQC9zHUJq0B0dIadZfJ0DapkC02Y5uOKN/kXXERFEBDeXiWjHD7b3 edPgvsnsAe4Oq+7QX+gB1YtCvrd1RcEplr5doJq9OX2QrucWo1lNd5VDIIwTFCL7MVrt LddfOBgfoejGzQmZfEqQcbeZQ+zs3x7aNMHuC0a/Y/K9fnRG5oop07lNU2KPpiSqhDVt jMrCIffbNNkKcH+ydl/tYEcfgGHMScrxVNHJ8ZVX08atXGiHK4cSUSyOzY9u7rJPRi7x yqWRMzstDVqJe00X4+r0UBMbxs4i2UIP8Q4N81nMWuw2BCtBmSCOhBPVRXiA9+rdDUnz 0h6A== 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=o6YdN6BuyNfKUhnJ4Ex4JoHzWc/k6rZ3Vga2E3H8xjE=; b=v9Sf4YI7Mo+YQqvg8pBe2dhFZwFZi5teJJeJIiHPXcFpH/eeLlTbXwx4YlVYI6QW1N Z3iCR0egn/QG1o4gRsCJO+3pyUyx3Y2Siucw/CyaGkywCBCEzzFhV/m6cguqnNyWdrCp AbZZbzCddSG+OD7c6zQF8OxllfxgdYq/6BSIWSVRF+rKAS10evvb2eTubN/Mg495Yt92 IVToznOq2kY6NrDJKHtAWf1XURjCbejz/jYuozEAp/jviOtWDyNRu3lOvgR+CurSIGd+ eTQzpY6bE67KgoBN1rR9h8anMTbLhVWJcbVhdkk4u6xmWD4VGsa/OUBNjIZpJFyQcWBO RebA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=n7jODNej; 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 nc7-20020a1709071c0700b0072b7c700b99si19465887ejc.662.2022.07.27.11.31.28; Wed, 27 Jul 2022 11:31:53 -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=n7jODNej; 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 S236028AbiG0QZQ (ORCPT + 99 others); Wed, 27 Jul 2022 12:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236220AbiG0QYT (ORCPT ); Wed, 27 Jul 2022 12:24:19 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E4CC4D160 for ; Wed, 27 Jul 2022 09:23:13 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220727162255euoutp010ccd4ea125d863d2379cd445f0d614de~FvDVwog9G2487524875euoutp01u for ; Wed, 27 Jul 2022 16:22:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220727162255euoutp010ccd4ea125d863d2379cd445f0d614de~FvDVwog9G2487524875euoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1658938975; bh=o6YdN6BuyNfKUhnJ4Ex4JoHzWc/k6rZ3Vga2E3H8xjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n7jODNejbm/XQCl/4CN4CwNIe51C11Ol4A8teABxLKfXVyyx9veY5MpQuSG6J3mcD g7A5KWpA+ytRsCjbdKzMDRw6zUdXdUdITBK6GXR54PpfAcmiKE8pkuSXu8zH1hhXPH gYlHnzI+8ooJJGcttzO3RS//IPDX7ohwHu1uHHoc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220727162254eucas1p233f05f6d0ebf6420e5c5a1ede6933299~FvDUgkQdX2220522205eucas1p24; Wed, 27 Jul 2022 16:22:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 36.E8.09580.E5661E26; Wed, 27 Jul 2022 17:22:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220727162253eucas1p1a5912e0494f6918504cc8ff15ad5d31f~FvDUBWZKL2552225522eucas1p1j; Wed, 27 Jul 2022 16:22:53 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220727162253eusmtrp22d668828082dcd16db4e000e6aa34a22~FvDUAjAdg0811608116eusmtrp2x; Wed, 27 Jul 2022 16:22:53 +0000 (GMT) X-AuditID: cbfec7f5-9c3ff7000000256c-e4-62e1665ea39d Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CB.1E.09095.D5661E26; Wed, 27 Jul 2022 17:22:53 +0100 (BST) Received: from localhost (unknown [106.210.248.8]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220727162253eusmtip153d4fe6af3d463321ed8ca423b743eac~FvDTsxnYN0064100641eusmtip1R; Wed, 27 Jul 2022 16:22:53 +0000 (GMT) From: Pankaj Raghav To: damien.lemoal@opensource.wdc.com, hch@lst.de, axboe@kernel.dk, snitzer@kernel.org, Johannes.Thumshirn@wdc.com Cc: matias.bjorling@wdc.com, gost.dev@samsung.com, linux-kernel@vger.kernel.org, hare@suse.de, linux-block@vger.kernel.org, pankydev8@gmail.com, bvanassche@acm.org, jaegeuk@kernel.org, dm-devel@redhat.com, linux-nvme@lists.infradead.org, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v8 07/11] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Wed, 27 Jul 2022 18:22:41 +0200 Message-Id: <20220727162245.209794-8-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220727162245.209794-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHKsWRmVeSWpSXmKPExsWy7djPc7pxaQ+TDNp3sFisvtvPZjHtw09m i99nzzNb7H03m9Xi5oGdTBZ7Fk1isli5+iiTxZP1s5gt/nbdY7LYe0vb4vKuOWwW85c9ZbeY 0PaV2eLGhKeMFp+XtrBbrLn5lMXixC1pB0GPy1e8PXbOusvucflsqcemVZ1sHpuX1HvsvtnA 5rGz9T6rx/t9V9k8+rasYvTYfLra4/MmOY/2A91MATxRXDYpqTmZZalF+nYJXBl9dy6wFkzl rrhw6ANTA2MXZxcjJ4eEgInEobV/WLsYuTiEBFYwSjQfnMQM4Xxh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G3WHPzKYvFiVvSDoIel694e+ycdZfd4/LZUo9NqzrZPDYvqffYfbOB zWNn631Wj/f7rrJ59G1Zxeix+XS1x+dNch7tB7qZAnii9GyK8ktLUhUy8otLbJWiDS2M9Awt LfSMTCz1DI3NY62MTJX07WxSUnMyy1KL9O0S9DL67lxgLZjKXXHh0AemBsYuzi5GTg4JAROJ 02+Xs3QxcnEICSxllFj58RQjREJC4vbCJihbWOLPtS42iKKnjBLX2l+ydjFycLAJaEk0drKD mCIClRJnv8iClDALnGOSWHnhNhNIr7BAoMS6hn42kBoWAVWJOx/VQMK8AlYSH5/OYoYYLy8x 89J3dhCbU8BaYvOUeWCtQkA1zx58ZIOoF5Q4OfMJC4jNDFTfvHU28wRGgVlIUrOQpBYwMq1i FEktLc5Nzy021CtOzC0uzUvXS87P3cQIjNdtx35u3sE479VHvUOMTByMhxglOJiVRHgTou8n CfGmJFZWpRblxxeV5qQWH2I0BTp7IrOUaHI+MGHklcQbmhmYGpqYWRqYWpoZK4nzehZ0JAoJ pCeWpGanphakFsH0MXFwSjUwbROfev/Onbu3ft9yjM3+2iC3zm56J/OMXXtMqhwaJHcKvLzo 7d65b3Lzd5N735utvj+xccndmHbkFtfTP/vvHwtesVhwW7RRcYb6r2tsh27IClUw7kziczz5 LcsghlMq0NGwK+RY+PU378IdfqyOMFG+maBiWnlBz1Xz+XfBW9k94cX/zxzeMDX5xiybm1NX bKqP4J3gqqWcezFIrS7wv+ODReXLnyrM7ZHqSTlwJ19kluxqf69iJ/mzlhtZ1jxLP1isWfM8 XfLD7sAbcwR0jJpPn91W8njhVCXzx3umHjtUGZLwyElmb+nVzPCuiRJhnI+YxDzKfe3DOE6u 1p+v/GfP7wq3mL5jRacrhKtNlViKMxINtZiLihMBuerqPWADAAA= X-CMS-MailID: 20220727162253eucas1p1a5912e0494f6918504cc8ff15ad5d31f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220727162253eucas1p1a5912e0494f6918504cc8ff15ad5d31f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220727162253eucas1p1a5912e0494f6918504cc8ff15ad5d31f References: <20220727162245.209794-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.7 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 autolearn=ham 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 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 non po2 support is added. Reviewed-by: Hannes Reinecke Signed-off-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- 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..16499b75c5ee 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 power of 2"; + 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 power of 2"; + return -EINVAL; + } zoned_dev->nr_zones = bdev_nr_zones(bdev); } -- 2.25.1