Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2762929iob; Fri, 6 May 2022 09:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW/BYNdu8PZIQ1JGcXxXoE/0h3AcMmaJ+bNmYuxTUDK648jUkcPIgSOmdsaogZU2iT6yTu X-Received: by 2002:a17:90b:3b8e:b0:1dc:94f2:1bc3 with SMTP id pc14-20020a17090b3b8e00b001dc94f21bc3mr13421874pjb.193.1651855934681; Fri, 06 May 2022 09:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651855934; cv=none; d=google.com; s=arc-20160816; b=sYigns9xvu32ATRaixuKUFeagHk/GuhvMzNqcsFLo470eBalYTs9vf2Q/4jFx3/jJ9 v4T5YUZBV/gXh8boNHvhoVYr4KVcpoKdjIS2pS8iP2cMm0PRrbUGLoMjhkM1U2AzBu92 Efa7cCV2aUlUshwNWiBX5RWEzsOlOnaS623D9t/1dgjLs1kV74ffRuHaaknMFq+1cxi3 XAeUycdZXn4VI9TbBoBHdWclNBk7g7IeSx7GIlMoqrxZKSFejgmdo9pkdCSLG9712ciU UjPP8myzwYEzRxex+ZwOvZkT8Ct8Q9g6IHsG1q2hmezZ7wT9HhCUxgOSNxmCMz6wWPkp STMg== 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=OUOs5yoREFPm133MftqN/52v0OJCiB1b6vGYcsnZpfg=; b=uUb0UbdT+giv3M88h3IU9AQIeAonxQkT32CO8c6SdVBnvR76CHlKSSKYys7FVsqhpg eQ5mMXvkSTvloifny7jEb5hpKP/UDMy6zKecoICT5I5JLzU1XEG5nhLWSO3lA+6Pj3sl +DSyRVavhIZnA4OvhJNnV6Qu8Jnqty5kl1xIWdtQ4PwgrD8DKUyzd2gkCSXWuOqPVcb3 WLGkjAJtm5OQv/u/yi1X/7OO+mLlzndpXBkrdO2MFJJWqj67L0EhHBcWuTH9cbbMrpWT j7WBnVWh/7Udape2qjRiNrPrzbYnuYsBCGp7w+EldNFeQxXwEn9Gqd5qzQ8b8JbVSJQc vGag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="uw/z6ktZ"; 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 k6-20020a056a00134600b00510538e14f6si5882988pfu.364.2022.05.06.09.51.54; Fri, 06 May 2022 09:52:14 -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="uw/z6ktZ"; 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 S1380315AbiEENzd (ORCPT + 99 others); Thu, 5 May 2022 09:55:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380242AbiEENyy (ORCPT ); Thu, 5 May 2022 09:54:54 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6536557109 for ; Thu, 5 May 2022 06:51:11 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220505135110euoutp02159af01b44679b91e30d9bd2b7a604c7~sOcJa7q5q0099100991euoutp02O for ; Thu, 5 May 2022 13:51:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220505135110euoutp02159af01b44679b91e30d9bd2b7a604c7~sOcJa7q5q0099100991euoutp02O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651758670; bh=OUOs5yoREFPm133MftqN/52v0OJCiB1b6vGYcsnZpfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uw/z6ktZDEetNfF04XYyIz4VfwwvEUOgly6aTcV3WrahzMVh2n8A8Vzh6qc2r32uB /ctoSuUTS69txG46Bu2tEF3RvO4pXU+XF5n+wHwyhAty9kpI+aC9wAsR81RciIuBVv z+APW0xdtsBJurULIbie7N+tmWgN6zZipyVE8sHU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220505135108eucas1p1f497195530c192725734360b68b241fd~sOcH5PivL0606806068eucas1p1V; Thu, 5 May 2022 13:51:08 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id AD.FC.10009.C46D3726; Thu, 5 May 2022 14:51:08 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20220505135108eucas1p295ecfd1113baa72d7522416a761a983c~sOcHZVNdK3188131881eucas1p2o; Thu, 5 May 2022 13:51:08 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220505135108eusmtrp27da582a3255e196cafcfad4d7d6cfedc~sOcHYhC4I2662626626eusmtrp28; Thu, 5 May 2022 13:51:08 +0000 (GMT) X-AuditID: cbfec7f2-e95ff70000002719-43-6273d64cf082 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F2.03.09522.B46D3726; Thu, 5 May 2022 14:51:07 +0100 (BST) Received: from localhost (unknown [106.210.248.170]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220505135107eusmtip1ff787df647b476670b2a8f0579b4cd21~sOcHG4JsC2664626646eusmtip1h; Thu, 5 May 2022 13:51:07 +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, Pankaj Raghav , Luis Chamberlain , Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/11] btrfs: zoned: relax the alignment constraint for zoned devices Date: Thu, 5 May 2022 15:47:08 +0200 Message-Id: <20220505134710.132630-9-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: H4sIAAAAAAAAA+NgFvrGKsWRmVeSWpSXmKPExsWy7djP87o+14qTDBYelLdYfbefzWLah5/M FpP6Z7Bb/D57ntniwo9GJoubB3YyWexZNInJYuXqo0wWT9bPYrboOfCBxWJly0Nmiz8PDS0u PV7BbnF51xw2iwltX5ktbkx4ymjxeWkLu8Wam09ZHIQ8Ll/x9vh3Yg2bx8Tmd+weO2fdZfe4 fLbUY9OqTjaPhQ1TmT1232xg89jZep/Vo2/LKkaP9VuusnhsPl3tMWHzRlaPz5vkPNoPdDMF 8Edx2aSk5mSWpRbp2yVwZez7u4W54LFAxcYlt9kbGO/ydjFyckgImEismHWNvYuRi0NIYAWj xJuPC9hAEkICXxglnt2Tg0h8ZpQ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IQ8Ll/x9vh3Yg2bx8Tmd+weO2fdZfe4 fLbUY9OqTjaPhQ1TmT1232xg89jZep/Vo2/LKkaP9VuusnhsPl3tMWHzRlaPz5vkPNoPdDMF 8Efp2RTll5akKmTkF5fYKkUbWhjpGVpa6BmZWOoZGpvHWhmZKunb2aSk5mSWpRbp2yXoZez7 u4W54LFAxcYlt9kbGO/ydjFyckgImEhsfXCWqYuRi0NIYCmjxJZVR5ghEhIStxc2MULYwhJ/ rnWxQRQ9Z5S423qBpYuRg4NNQEuisZMdJC4iMJVR4sJ2kDgXB7PANSaJhoe72EC6hQUiJD48 vcgCYrMIqEpcfvaPCcTmFbCSmL3+IdQGeYmZl76zg9icAtYSczofsoLYQkA1Ex++Y4OoF5Q4 OfMJ2BxmoPrmrbOZJzAKzEKSmoUktYCRaRWjSGppcW56brGhXnFibnFpXrpecn7uJkZghG87 9nPzDsZ5rz7qHWJk4mA8xCjBwawkwuu8tCBJiDclsbIqtSg/vqg0J7X4EKMp0N0TmaVEk/OB KSavJN7QzMDU0MTM0sDU0sxYSZzXs6AjUUggPbEkNTs1tSC1CKaPiYNTqoFprVKvd0bIWktb vjuHixwuPJRKsP25/7fhAr3o0icMtuKljVXVy3oTal3cX0zcrVjP5bx012LDFdpe69Z8WC9e aH9YI2+vqsmFu4KXvnr/Umj68PKWd+P/xvPhnsnZ/8/V2nw883jvie7Gb7UGpx8/Lnt6OOl5 dGxX9BzTyUtdYkOm3D0hUqBUvXv95SxVHYtJz8X01jbf0a53Kz9bbqqUIc/iGcx7yZfv3PTO ICZr7R0H/P4wbmB49jHq+1PR44tCTXRtzogZBN8RZHBVV/ff1Ni6pufAUTEJnT+Gh9zqDsam SarUi25Qz12ofedu7dtT6meMNr3fueL+qxf7mffsytsuY1TDsEOC8ajF0jIlluKMREMt5qLi RAC0jTRDeQMAAA== X-CMS-MailID: 20220505135108eucas1p295ecfd1113baa72d7522416a761a983c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220505135108eucas1p295ecfd1113baa72d7522416a761a983c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220505135108eucas1p295ecfd1113baa72d7522416a761a983c References: <20220505134710.132630-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, 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 Checks were in place to return error when a non power-of-2 zoned devices is detected. Remove those checks as non power-of-2 zoned devices are now supported. Relax the zone size constraint to align with a sane default of 1MB. This 1M default has been chosen as the minimum alignment requirement for zone sizes to make sure zones align with sectorsize in different architectures. Reviewed-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- fs/btrfs/zoned.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 3023c871e..a6b15fbe1 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -54,6 +54,13 @@ */ #define BTRFS_MAX_ZONE_SIZE SZ_8G +/* + * A minimum alignment of 1MB is chosen for zoned devices as their zone sizes + * can be non power of 2. This is to make sure the zones correctly align to the + * sectorsize. + */ +#define BTRFS_ZONED_MIN_ALIGN_SECTORS ((u64)SZ_1M >> SECTOR_SHIFT) + #define SUPER_INFO_SECTORS ((u64)BTRFS_SUPER_INFO_SIZE >> SECTOR_SHIFT) static inline bool sb_zone_is_full(const struct blk_zone *zone) @@ -394,8 +401,8 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) zone_sectors = bdev_zone_sectors(bdev); } - /* Check if it's power of 2 (see is_power_of_2) */ - ASSERT(zone_sectors != 0 && (zone_sectors & (zone_sectors - 1)) == 0); + ASSERT(zone_sectors != 0 && + IS_ALIGNED(zone_sectors, BTRFS_ZONED_MIN_ALIGN_SECTORS)); zone_info->zone_size = zone_sectors << SECTOR_SHIFT; /* We reject devices with a zone size larger than 8GB */ @@ -834,9 +841,11 @@ int btrfs_sb_log_location_bdev(struct block_device *bdev, int mirror, int rw, ASSERT(rw == READ || rw == WRITE); - if (!is_power_of_2(bdev_zone_sectors(bdev))) - return -EINVAL; nr_sectors = bdev_nr_sectors(bdev); + + if (!IS_ALIGNED(nr_sectors, BTRFS_ZONED_MIN_ALIGN_SECTORS)) + return -EINVAL; + nr_zones = bdev_zone_no(bdev, nr_sectors); sb_zone = sb_zone_number(bdev, mirror); -- 2.25.1