From patchwork Fri Jan 6 08:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Raghav X-Patchwork-Id: 40000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp714235wrt; Fri, 6 Jan 2023 00:38:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXvpOczpV1Pl0jRqu7Y4uEGAw3i/2JJmel7ci4LvanRl65c1BaoE0vcMlI1FA8kslhdapaeW X-Received: by 2002:aa7:d0d4:0:b0:461:ed76:cb45 with SMTP id u20-20020aa7d0d4000000b00461ed76cb45mr45422101edo.24.1672994323060; Fri, 06 Jan 2023 00:38:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672994323; cv=none; d=google.com; s=arc-20160816; b=DvGOhVcUnWSIlvVNhbyCLVbqBE1cAaREPFH8QpE81oIoiueIp7mGEBlQP22RgLjRwQ mB1x2k0KHXN2QZm7FWpjcFBrWVI//HHzgfhI0nyyfYn50zgZcR6tZj7IbtuXUWFBtohY kVy1Oxpx4s618cNduJ8WWrjZnw3CB1eQcekFPx2ne5ogQHXPqTNY2B22I2sxkTdWCl7D i7knsHqORLhZ6dagOSSsRZukYO9q+dpQcc9HvXpmFA/4NqG+QeJwRdpkLmQlwCEoQmmi e2BJfkgh/6A9YkvSt1qneZHQN5DiHE0ZxpXSSGk/cR0IlRnd1hKFABKO/cJ+L6e/LQIA BJ4A== 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=2fIGGCsma0+nVBZgfpMGxL+SDIiTbKkvsObjxRsUwIc=; b=JVECOdoo85Lfrymwwflk9bNtMRNGwgJQ8k7jo89rs3Z3U7uKxIzIRvSPFgjRo7LzEj mzYgCca4q/DXt8CLJkbW5og0TmbMGZQexKwAPYXcvAN2uiK1UZuW6NTXgwkI19JGW3Yw 9hDUtKVCQOUo83TMR9t4Xg4B/8rqCKu+ekro52DLEdO3aID9S3I52KeCUbId76HJ4SOx c8iK+tZPND6bQj6bOkDlO/7iX9YJd6j9AYeM1/eFAjr4gwFrd2ez166Y9MOkGBid/CRl phBI3Dz6s/2NKNDc6xVh24HcJDhQBDk6u0AIfpeQl2pIQNFyZoFM/jvgEMEwMFBBRWH/ xGjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MbiSJYvd; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402350800b0048589250850si1052254edd.11.2023.01.06.00.38.18; Fri, 06 Jan 2023 00:38:43 -0800 (PST) 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=MbiSJYvd; 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 S232411AbjAFIeU (ORCPT + 99 others); Fri, 6 Jan 2023 03:34:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232453AbjAFId2 (ORCPT ); Fri, 6 Jan 2023 03:33:28 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF45E67BDB for ; Fri, 6 Jan 2023 00:33:27 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230106083324euoutp02141e1482c206bc40f54e48d0e7b54851~3qy7JNW4D2168121681euoutp02s for ; Fri, 6 Jan 2023 08:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230106083324euoutp02141e1482c206bc40f54e48d0e7b54851~3qy7JNW4D2168121681euoutp02s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1672994004; bh=2fIGGCsma0+nVBZgfpMGxL+SDIiTbKkvsObjxRsUwIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MbiSJYvdvkNeL4z4kNKj9/QEI3bp7dNQ1PF9b3K7CyfS0JqDl7mSIdb6N/Sww2iXZ DEY7DMyMNWIuq9gWCNveg6wGbmAsIe0Uru26MamRaP2H4PR1bSY/6Ec8HZM50Ev/vC te0iWVFcPVJQAXl8InqQDOHQc1u4CDnwEF+KHTfY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230106083322eucas1p2971716b1ceb1cf2f5b90a0b696f8ac40~3qy51-6_o2329223292eucas1p2b; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id E7.43.43884.2DCD7B36; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0~3qy5cK3zL2329223292eucas1p2a; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230106083322eusmtrp14b2b106c1afd8945ed5347acbbf4cd5e~3qy5bgmoU2166121661eusmtrp1k; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) X-AuditID: cbfec7f5-25bff7000000ab6c-49-63b7dcd2ee91 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 0A.C6.23420.2DCD7B36; Fri, 6 Jan 2023 08:33:22 +0000 (GMT) Received: from localhost (unknown [106.210.248.66]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230106083321eusmtip292f5234c8251a10cc76fbb993a2024c1~3qy5MIvO82941329413eusmtip2E; Fri, 6 Jan 2023 08:33:21 +0000 (GMT) From: Pankaj Raghav To: axboe@kernel.dk Cc: kernel@pankajraghav.com, linux-kernel@vger.kernel.org, hare@suse.de, bvanassche@acm.org, snitzer@kernel.org, dm-devel@redhat.com, damien.lemoal@opensource.wdc.com, linux-nvme@lists.infradead.org, hch@lst.de, linux-block@vger.kernel.org, gost.dev@samsung.com, Luis Chamberlain , Johannes Thumshirn , Pankaj Raghav Subject: [PATCH 5/7] dm-zoned: ensure only power of 2 zone sizes are allowed Date: Fri, 6 Jan 2023 09:33:15 +0100 Message-Id: <20230106083317.93938-6-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106083317.93938-1-p.raghav@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKKsWRmVeSWpSXmKPExsWy7djP87qX7mxPNjj1U9Zi9d1+NotpH34y W/w+e57ZYu+72awWNw/sZLLYs2gSk8XK1UeZLP523WOyOPPyM4vF3lvaFpd3zWGzmL/sKbvF jQlPGS0+L21htzhxS9qB3+PyFW+Py2dLPTat6mTz2Lyk3mP3zQY2j52t91k9zq509Hi/7yqb R9+WVYwem09Xe3zeJOfRfqCbKYAnissmJTU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msg-Generator: CA X-RootMTR: 20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230106083322eucas1p2414f1f7f121fbbd7a0e5e1b1b622f5c0 References: <20230106083317.93938-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754261695402467394?= X-GMAIL-MSGID: =?utf-8?q?1754261695402467394?= 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 Reviewed-by: Bart Van Assche Reviewed-by: Mike Snitzer Reviewed-by: Johannes Thumshirn 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); }