Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3747135rwa; Tue, 23 Aug 2022 09:25:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR7l2b71nQEQADxH5aphE3EjHMHHV8AcVyERgndO01OK7pT7E9DxGbW5c8ljUbhG/JMj5NHw X-Received: by 2002:a63:392:0:b0:41d:acb:3ce4 with SMTP id 140-20020a630392000000b0041d0acb3ce4mr20317197pgd.343.1661271925366; Tue, 23 Aug 2022 09:25:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661271925; cv=none; d=google.com; s=arc-20160816; b=J6TQk2Jt7CKLBwhkcbmREQSSJMXZZbHy+0lRJe9tZckrONwCyqMydihChecuU4Foly /QwbBSc0oJmauBYSTfS8als1GasN1xGavIFEW/o6mpuiVdz0VApEre3GkWqKAVHC/L8T vMhXSjaYEEzUfbZXV2r+ODZuOMgbqyyx2+kEjSnEy/ZuVGG5+LPK/A+PL27CVNusUiWL OBo8gc8yDWH0QVaOV0if7kMh+jt2VBrOLNNjFzOlzQ8+gctq6OltFVVMNs7mxaZhsDbS t+aCB4R4hi1UdzafG2+ERrogDkui2tcB6fQHoikVqAwpFhpn/utzYCyEDYCxngRTXNnt 9kuQ== 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=tSSBnG0aDQsGLDWCBqD+ZIZXJV/OR5HHGZmAzSOHsrA=; b=LrIz67GPWk6NEWVkTIeK1N3HJ1FnGxXhs7cV7QGxHy2/QaYd8V3SCEalTm1zStsNH4 B3b1ydFC19RSNaULol+PAbbKxkCAlGJw5Du3TtB9Odx/NPd3ncbI/dB1yw2PqvG5275d toLRsyYzR1njjZm8V5iFfziFI/UItDD9ihAaDAhG7iB+rOBJivHyX53BBkt79Qd3ZZYo BVEN0dPujai+m1DFkRxhye9YBZ2l6fbpF0aXKAejYFPFG4cjzAM6tvf9iPJDcL4OJnNR alxm8/4dthrpwj5Y1p82k9BBkYQMl+q7D6UkscBRnOPlTPaePM5bodZaTFsQGIlCjaeu zCYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ZRBcRdkM; 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 v10-20020a63610a000000b0040e64eee87fsi2454027pgb.722.2022.08.23.09.25.14; Tue, 23 Aug 2022 09:25:25 -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=ZRBcRdkM; 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 S244614AbiHWQQq (ORCPT + 99 others); Tue, 23 Aug 2022 12:16:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244473AbiHWQQR (ORCPT ); Tue, 23 Aug 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 7C93932E0AA for ; Tue, 23 Aug 2022 05:37:44 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220823121913euoutp0290e796a9e725b608a9da9953683316c2~N_JREu5MZ2224522245euoutp02L for ; Tue, 23 Aug 2022 12:19:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220823121913euoutp0290e796a9e725b608a9da9953683316c2~N_JREu5MZ2224522245euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661257153; bh=tSSBnG0aDQsGLDWCBqD+ZIZXJV/OR5HHGZmAzSOHsrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZRBcRdkMzCkdVW8n6VARvkwBx44WtiAd6g0dr8nBBnoM4rURt630eqwWlBIiyNbOX OOjLhOueuxlgBkoj8+bK3YDjwAxJ1RUtmaVvCoAGhl9RBeEbLqOFn3MaCF+3XGFpAe lGzbkC7/7EuZEPGJWfJ5ejM+dvuL+4OBwfCIbrt8= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220823121910eucas1p206e6e5c5cbb03ac40a9e7b55978a31a9~N_JOrpiCL1807618076eucas1p2G; Tue, 23 Aug 2022 12:19:10 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id DE.82.29727.EB5C4036; Tue, 23 Aug 2022 13:19:10 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220823121909eucas1p113c0c29f7e28d0ee3e1161f7da243baf~N_JN-u-W01882018820eucas1p1U; Tue, 23 Aug 2022 12:19:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220823121909eusmtrp150c510413ffc810768faee3cc512696f~N_JN_6pIf1042010420eusmtrp1H; Tue, 23 Aug 2022 12:19:09 +0000 (GMT) X-AuditID: cbfec7f2-21dff7000001741f-8f-6304c5bede52 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D5.81.10862.DB5C4036; Tue, 23 Aug 2022 13:19:09 +0100 (BST) Received: from localhost (unknown [106.210.248.52]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220823121909eusmtip100fdaff39bbf167292206c172f54e8a0~N_JNsdKjr0901809018eusmtip1I; Tue, 23 Aug 2022 12:19:09 +0000 (GMT) From: Pankaj Raghav To: agk@redhat.com, snitzer@kernel.org, axboe@kernel.dk, damien.lemoal@opensource.wdc.com, hch@lst.de Cc: pankydev8@gmail.com, Johannes.Thumshirn@wdc.com, linux-block@vger.kernel.org, dm-devel@redhat.com, hare@suse.de, jaegeuk@kernel.org, linux-kernel@vger.kernel.org, matias.bjorling@wdc.com, gost.dev@samsung.com, bvanassche@acm.org, linux-nvme@lists.infradead.org, Luis Chamberlain , Pankaj Raghav Subject: [PATCH v12 08/13] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Tue, 23 Aug 2022 14:18:54 +0200 Message-Id: <20220823121859.163903-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220823121859.163903-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCKsWRmVeSWpSXmKPExsWy7djP87r7jrIkG9w5qGSx/tQxZovVd/vZ LKZ9+Mls8fvseWaLve9ms1rcPLCTyWLPoklMFitXH2WyeLJ+FrPF3657TBZ7b2lbXN41h81i /rKn7BYT2r4yW9yY8JTR4vPSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCeKyyYlNSezLLVI3y6BK2Ne u0TBPJ6KOQ1fWRoYW7i6GDk5JARMJBpu7GDrYuTiEBJYwSjx+cAvVg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PSFnaLNTefslicuCXtIORx+Yq3x85Zd9k9Lp8t9di0qpPNY/OS eo/dNxvYPHa23mf1eL/vKptH35ZVjB6bT1d7fN4k59F+oJspgCdKz6Yov7QkVSEjv7jEVina 0MJIz9DSQs/IxFLP0Ng81srIVEnfziYlNSezLLVI3y5BL2Neu0TBPJ6KOQ1fWRoYW7i6GDk5 JARMJFasesfYxcjFISSwlFHi2+UPrBAJCYnbC5sYIWxhiT/Xutggip4xStx6uZK5i5GDg01A S6Kxkx2kRkQgV+Lw5glMIDXMAm+YJC5PP8cCkhAWCJJoufMUbCiLgKrEn+3TwYbyClhJfNzY zwSxQF5i5qXvYIM4Bawl5i09BVYjBFQz/9YnNoh6QYmTM5+AzWQGqm/eOpt5AqPALCSpWUhS CxiZVjGKpJYW56bnFhvpFSfmFpfmpesl5+duYgTG7rZjP7fsYFz56qPeIUYmDsZDjBIczEoi vNUXGZKFeFMSK6tSi/Lji0pzUosPMZoC3T2RWUo0OR+YPPJK4g3NDEwNTcwsDUwtzYyVxHk9 CzoShQTSE0tSs1NTC1KLYPqYODilGpiE5fziTq3lK96pmJv7QO//uS8JS4+ked890X65eaXO H7Pr6z4sMZJvzlJdO9fN+xDHleIujuaT2qE6Zw+7H91bE7T93tJfpY/mXDoV9rHw77xdut95 HE4fjrBv+/z96ybp1rW6q/wOfGo9H5rcvOt8hczb/Jm2B8+ZMU+X1Ur3fBbCEx0+9waj3eNc sS/G0+cpTDH+czBo9+bVP8WKD3BFrJgmuHej8JOyuXOfzHOtXbe9b8Fuffd/ntfO6SeFtvJE lDPf3H9f8q4du7PCnuqQ7dbV0Q6b5C29TlpfMWVIkou+5HAxtlNj3vuO1Y0zdtbUhJyp43zj 4dF7bdfEhlJxt45ZW34WX3785frnV5x6SizFGYmGWsxFxYkA7sABNWYDAAA= X-CMS-MailID: 20220823121909eucas1p113c0c29f7e28d0ee3e1161f7da243baf X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220823121909eucas1p113c0c29f7e28d0ee3e1161f7da243baf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220823121909eucas1p113c0c29f7e28d0ee3e1161f7da243baf References: <20220823121859.163903-1-p.raghav@samsung.com> X-Spam-Status: No, score=-7.1 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 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 support for zoned devices with non-po2 zone size is added. Reviewed-by: Hannes Reinecke Reviewed-by: Damien Le Moal 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..9325bf5dee81 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 a power-of-2 number of sectors"; + 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 a power-of-2 number of sectors"; + return -EINVAL; + } zoned_dev->nr_zones = bdev_nr_zones(bdev); } -- 2.25.1