Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3245334iob; Fri, 6 May 2022 23:48:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxucKVuDoYH45WYLPd4et4GdulVt7q4kYbVLR881OLE7jC5joo6T6RodKZO2yE9Hkm4M+cK X-Received: by 2002:a9d:58c3:0:b0:5e6:d8f7:c18c with SMTP id s3-20020a9d58c3000000b005e6d8f7c18cmr2331457oth.364.1651906109970; Fri, 06 May 2022 23:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651906109; cv=none; d=google.com; s=arc-20160816; b=zKisNHTcmUG8lC11sEw7Bu2G3aUSd/gZRDQ6z96GHhpQf7hhHsgEO/EkMj9ig2JLsm l0ANVe2OlupadJWHHjDUnUNZRlMgoBa6HI2lw05HgZ64YRP2y8YpK59TmMB4H6MNBjaU /srARSughK8+fi6s+4JZXvwcbmZTqKSIL/gA0r7uF2HbM/0zmeXCgOfGbZ0na0U+BimI u1VSEc65RzItxbu+rVn47Hvn41TIzIAfy5lXgtKzOFq9NFO/toAeA1dondMkvHTX5V8Y 9MkRSoh8XRv41R9Q5guXtQT+WEHn1YMR1OtnYyYLuk3640Fxl9Vtx/kDesy71gCW3Iz0 nvJg== 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=VQjYYb+h0vobbDh15vxQHBYma0qOwPtnNND2cTQkfTdaECE656i5D+/Jg4LuLBK0Hn wufacPYB9EtYUcxEHT/8CwOXyXEX3PxiEk//N1hSgK9PRiLueAiaSq9hiv/7ryd6xPb/ dXDCzQLaUnIv6bjAM0gO4dODIrJGD+tIP3AmX0rF2Uw7PsBEe0kEH8UbmPwpqtYIsma5 ehMmQkIFfRQ/i4DC5iY3ctL21skqYET7LMv99bghoQbRuX/q1VwIxTwSY0lBPeFFFrvM BksTVW0s/ZtyCGt7QYLFU73Iz4hFzGsfpHR0YYiwVr6+Tv78EYivD9uc2LWFps4zisvm rK2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ox2fxTOQ; 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 q3-20020acaf203000000b00325630e2540si4320670oih.203.2022.05.06.23.48.16; Fri, 06 May 2022 23:48:29 -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=ox2fxTOQ; 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 S1389975AbiEFIQK (ORCPT + 99 others); Fri, 6 May 2022 04:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389871AbiEFIPH (ORCPT ); Fri, 6 May 2022 04:15:07 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9579567D3F for ; Fri, 6 May 2022 01:11:19 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220506081117euoutp0281e0f5e7f4620a712dda948aeb914e63~sdcrKZ1I92333723337euoutp027 for ; Fri, 6 May 2022 08:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220506081117euoutp0281e0f5e7f4620a712dda948aeb914e63~sdcrKZ1I92333723337euoutp027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651824677; bh=OUOs5yoREFPm133MftqN/52v0OJCiB1b6vGYcsnZpfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ox2fxTOQi0JUjHEBmT3xShiTOMD2IrUcliRLqN4hpmQe0qP3cZT9cVMr7twwEwBhf X4VCDMst7t0sqEpLYa+bvvpY21brNNwnyAHEl+YeXso/Sll5qFA2GXWLRCQOqMfvOx qkZZpBomnfOtaPPgbSilhvbUDKYghi7x2wUNTaoA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220506081115eucas1p149ff9d68b993fc4a5063dd222afc58ef~sdcpXq2fr1708917089eucas1p1E; Fri, 6 May 2022 08:11:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 3C.3C.10260.328D4726; Fri, 6 May 2022 09:11:15 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220506081114eucas1p1a9d86eb429a6f68c29d1980891f49786~sdco8BQZr1692416924eucas1p1y; Fri, 6 May 2022 08:11:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220506081114eusmtrp1042f84b3b164a08add28bf24c817eece~sdco6cXhB3089330893eusmtrp1U; Fri, 6 May 2022 08:11:14 +0000 (GMT) X-AuditID: cbfec7f5-bddff70000002814-eb-6274d823e841 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 69.F2.09522.228D4726; Fri, 6 May 2022 09:11:14 +0100 (BST) Received: from localhost (unknown [106.210.248.174]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220506081114eusmtip2ca889afa28846abc5660f97364a054cd~sdcolMwDn2098320983eusmtip2B; Fri, 6 May 2022 08:11:14 +0000 (GMT) From: Pankaj Raghav To: jaegeuk@kernel.org, hare@suse.de, dsterba@suse.com, axboe@kernel.dk, hch@lst.de, damien.lemoal@opensource.wdc.com, snitzer@kernel.org Cc: Chris Mason , Josef Bacik , bvanassche@acm.org, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, Jens Axboe , gost.dev@samsung.com, jonathan.derrick@linux.dev, jiangbo.365@bytedance.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, Naohiro Aota , linux-kernel@vger.kernel.org, Johannes Thumshirn , Sagi Grimberg , Alasdair Kergon , linux-block@vger.kernel.org, Chaitanya Kulkarni , Keith Busch , linux-btrfs@vger.kernel.org, Pankaj Raghav , Luis Chamberlain Subject: [PATCH v3 08/11] btrfs: zoned: relax the alignment constraint for zoned devices Date: Fri, 6 May 2022 10:11:02 +0200 Message-Id: <20220506081105.29134-9-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220506081105.29134-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02SfUxTVxjGd3pvby/direF4Qk4dXWE4DIciOZsyGYXEq/ZZiRmGXOTWfAK ZKW6ls4PllgpdIUxWiCCFhKHVFY+uoKtzAp0pmZ8DFiBggE6JYSyhQ+RAc4xJhv1YuZ/z3nP 7znP8yaHxEQWIpTMkGcxCrlUJib4eHP7svu1bcNZKa8PGfjI+nM7hv5tbSdQ/V09gcrmlzFU or/IQyu9bgy1zVVwUd9f5zlo5JaDg1qvlHBQbf1PHOS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XWxOvr3617RaemOiSwPt9pZHb9d8HFJ/acdRxQUu0NW Ba//cvHD26JZ7ludgmPMPrx5+sPEXEf/ktz3Q5ODJ/+5tTm/0yrw7vZUTakkZuW1Ua/OPxG9 LdtbdljKd9Ka1w49/fOOafMWrCzs/G8bUa2TpfUxbG/HHuULB+aeW71LqXv+oYdxQS4dmzcq sRRnJBpqMRcVJwIAVe6YGbIDAAA= X-CMS-MailID: 20220506081114eucas1p1a9d86eb429a6f68c29d1980891f49786 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220506081114eucas1p1a9d86eb429a6f68c29d1980891f49786 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220506081114eucas1p1a9d86eb429a6f68c29d1980891f49786 References: <20220506081105.29134-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