Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2469533iob; Fri, 6 May 2022 03:44:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXQDrCe4MPMNDr/Wqr1eL9dMSlLiAcvusA/ww2oSLuaw/yt0DKP1mfTadaq2d7vZ9cCYen X-Received: by 2002:a05:6a00:a8b:b0:4cd:6030:4df3 with SMTP id b11-20020a056a000a8b00b004cd60304df3mr2990772pfl.40.1651833853332; Fri, 06 May 2022 03:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651833853; cv=none; d=google.com; s=arc-20160816; b=m6sGEhkn0DzQsUzvPYVZU/X17YH6eOpA/ael4sVwzkU3a6fyyFmnj+yFbdnFg9wuv/ UaEsKfY2C3vUZgv+UKcqlxuW2PQh1TVlOc9cTOHQu2ouqA3fAkJLB5iDjrb51M/zRFs/ 7rGR0EfPbcAZttV9ScVLCXMILQtvvc0jfWAweeSQW5JyPIzqj7ZppVc6ZYK94xX1UFlz 8rJEud5iGu0gsPcG0WhMR+EBNwhWkNNq4sBJKRUJaxoi+dNOh7fsBxhjCpMMsxB0cbOo z/PnMtUdIT2Gy7G0z0RpDQNCZUgK64jsPboXcgSbrgLJledoTXnspMaN6pfP15HN2+Mx emfA== 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=U9RzqUijJL5PmqUeIybgHDju5FpS85GPewMJfUjtd+U=; b=O2M4L+bSIIT7Is9Za5IVKuz5xo6OOLRS9OjPmu3G0LmXD9fTSOb3gTIj8lqlQH9RI/ u8wPsBUMWLIGXD/+EybLp0zetsMU3KyfYpTG31t/1bahmpZA3V26cg6iKPP+MhsJ+zzr auIFXfF7r18pRoF2Q6pLSaNn1PA7a6nw2DTMHLkB73nvYfp5mqJbS9bXGYe9JQguLsXg /VsacBQjGFZX+i6zw1a5YLPBYleuS3s0M8jjzsEnB+MTp9xmU2qfhowiQWvjcDCs4MZ1 BmT5BmgKiE34l5iPiCKGGVUOAUu6JcMVsNf3KMdwcgKi3dE7AGVuF6DFqHzZj8gs6XvX VIPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Qs9qCW4Y; 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 y65-20020a638a44000000b003c1fd25c990si3966426pgd.698.2022.05.06.03.43.59; Fri, 06 May 2022 03:44:13 -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=Qs9qCW4Y; 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 S1389907AbiEFIPu (ORCPT + 99 others); Fri, 6 May 2022 04:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389863AbiEFIPH (ORCPT ); Fri, 6 May 2022 04:15:07 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1634C67D39 for ; Fri, 6 May 2022 01:11:18 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220506081113euoutp014cc3680efdec8d553a66020211172f02~sdcoA5q_a2375323753euoutp014 for ; Fri, 6 May 2022 08:11:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220506081113euoutp014cc3680efdec8d553a66020211172f02~sdcoA5q_a2375323753euoutp014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651824673; bh=U9RzqUijJL5PmqUeIybgHDju5FpS85GPewMJfUjtd+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qs9qCW4Y+Q4e1UAU6M5BIUHoXT8MIfMhJ2DBWVtW4vVEY2S8YQH+65jRanPBEphrv Na1AuMYhagAXS8p8wH9MRi1f1rwD92KL8F6JVj1hSDKfcw6B7UxVUWtBk/fM88hSZg 5yoPm0/N0KfIvoNeTWIdS2ZjHDo4d+2tzBbOOBOE= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220506081112eucas1p1ccb815812e215df7e24c0a5b2fcb0ef2~sdcmW62-Z2880428804eucas1p1w; Fri, 6 May 2022 08:11:12 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id D7.3C.10260.F18D4726; Fri, 6 May 2022 09:11:11 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220506081111eucas1p11e4dd5a89ce49939bbea57433cea046f~sdcl8BE8U1786517865eucas1p1-; Fri, 6 May 2022 08:11:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220506081111eusmtrp23682ed30504d4143db35d09c66da86b3~sdcl60V3e2793127931eusmtrp2I; Fri, 6 May 2022 08:11:11 +0000 (GMT) X-AuditID: cbfec7f5-bddff70000002814-dd-6274d81f318e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A4.F2.09522.F18D4726; Fri, 6 May 2022 09:11:11 +0100 (BST) Received: from localhost (unknown [106.210.248.174]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220506081111eusmtip1db96962bcd6db0befbdd9570f5dd4da6~sdcllH23g2776127761eusmtip1Q; Fri, 6 May 2022 08:11:11 +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 05/11] btrfs: zoned: Cache superblock location in btrfs_zoned_device_info Date: Fri, 6 May 2022 10:10:59 +0200 Message-Id: <20220506081105.29134-6-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: H4sIAAAAAAAAA02SbUxTZxTH99x7e1u6lV1aSZ+gjlgz3NikYy7xUZdlGD/cDLZgFj4MCK7A FdhKwZbOF5ZJoTrlnS4yKIjiUF5a6aQoFighdVAUGYQXV9kKEmhEDMVN2CywMsvFzG+/c57/ /5z/SR4eLmwmg3hpiixGqZDJJSSfuNHrGdwZ7MhKfO+Bdg8y3enF0VpnL4kMzhISlT/x4EhX UsF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Um9q+K7f qnurmE8/OyZaaK+xnU3+08HX3UK2U28qrV++zWVaywq9QrGtrzp85zvcee+w4quzz997NtEp evsWhT+R22g38W2tteWqG6Jrn6UIK94xn8v1n/tDclpf67JpO8sDi3Zu/Pj6za/np3c2uzu6 KvxsznKdHLBFcRkvp6vV3J0Lnzztvqzz8dehv9ob/c0zw7P22lw6xjbjZnGkcqmdv4sSS3FG oqEWc1FxIgCrcDo1sAMAAA== X-CMS-MailID: 20220506081111eucas1p11e4dd5a89ce49939bbea57433cea046f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220506081111eucas1p11e4dd5a89ce49939bbea57433cea046f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220506081111eucas1p11e4dd5a89ce49939bbea57433cea046f 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 Instead of calculating the superblock location every time, cache the superblock zone location in btrfs_zoned_device_info struct and use it to locate the zone index. The functions such as btrfs_sb_log_location_bdev() and btrfs_reset_sb_log_zones() which work directly on block_device shall continue to use the sb_zone_number because btrfs_zoned_device_info struct might not have been initialized at that point. This patch will enable non power-of-2 zoned devices to not perform division to lookup superblock and its mirror location. Reviewed-by: Luis Chamberlain Signed-off-by: Pankaj Raghav --- fs/btrfs/zoned.c | 13 +++++++++---- fs/btrfs/zoned.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 06f22c021..e8c7cebb2 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -511,6 +511,11 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) max_active_zones - nactive); } + /* Cache the sb zone number */ + for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; ++i) { + zone_info->sb_zone_location[i] = + sb_zone_number(zone_info->zone_size_shift, i); + } /* Validate superblock log */ nr_zones = BTRFS_NR_SB_LOG_ZONES; for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { @@ -518,7 +523,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) u64 sb_wp; int sb_pos = BTRFS_NR_SB_LOG_ZONES * i; - sb_zone = sb_zone_number(zone_info->zone_size_shift, i); + sb_zone = zone_info->sb_zone_location[i]; if (sb_zone + 1 >= zone_info->nr_zones) continue; @@ -866,7 +871,7 @@ int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw, return 0; } - zone_num = sb_zone_number(zinfo->zone_size_shift, mirror); + zone_num = zinfo->sb_zone_location[mirror]; if (zone_num + 1 >= zinfo->nr_zones) return -ENOENT; @@ -883,7 +888,7 @@ static inline bool is_sb_log_zone(struct btrfs_zoned_device_info *zinfo, if (!zinfo) return false; - zone_num = sb_zone_number(zinfo->zone_size_shift, mirror); + zone_num = zinfo->sb_zone_location[mirror]; if (zone_num + 1 >= zinfo->nr_zones) return false; @@ -1011,7 +1016,7 @@ u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start, u32 sb_zone; u64 sb_pos; - sb_zone = sb_zone_number(shift, i); + sb_zone = zinfo->sb_zone_location[i]; if (!(end <= sb_zone || sb_zone + BTRFS_NR_SB_LOG_ZONES <= begin)) { have_sb = true; diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h index 10f31d1c8..694ab6d1e 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -27,6 +27,7 @@ struct btrfs_zoned_device_info { unsigned long *active_zones; struct blk_zone *zone_cache; struct blk_zone sb_zones[2 * BTRFS_SUPER_MIRROR_MAX]; + u32 sb_zone_location[BTRFS_SUPER_MIRROR_MAX]; }; #ifdef CONFIG_BLK_DEV_ZONED -- 2.25.1