Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4721233ioa; Wed, 27 Apr 2022 09:38:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFS/mPILUFz3i/KuLVasLEzXaNUe7cuM02qVziF2gVWyxOwDGZSi9lfpBKc6emh0LVnW3K X-Received: by 2002:a17:90b:3b90:b0:1da:49fe:d040 with SMTP id pc16-20020a17090b3b9000b001da49fed040mr2760060pjb.9.1651077516598; Wed, 27 Apr 2022 09:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077516; cv=none; d=google.com; s=arc-20160816; b=OMwZ45XfgirqsG80ECq8ovgOysJTjSKohvDjluuyDJ42dtJDsh5EKSmbrMFDP37z0w RMgLlLJyelLPynSt3j/wv0Zg+5jg66/irIYHkq/OmWjnv4QLGiNt+AIeSTEpmXiTt+DG Cyg5qdi2eqocmgdFJezM6H/9JlHL3oGaqbp1cSh/l9OS4ik2nP99zpeKbEMZN0lEiqaB ueFJroS0vOdC7I7j+G8xCeQXqMtvmIRWTrucTQx6SyV5Y/7Xl7SJI3QtKKfbq8IKc8Z3 muwh0FvsTMpTQ44naXr3aDE/LT6iQj3BiN/OAi06lE0JrJQh1ezG0Sc1xwIdFLpYZssU JSUg== 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=QWDCdGpeRI5X2tzwrJf3syqVSb5HHkyW+8hRafR+UIA=; b=o4ovqe97KMDN4pSjC0gUA2FYYH33AIzPaXs+IrjgSQ0IHJrgFhFjhazEZhoSOcOUCe 7tn97Fg8DWOSjeu89r9LiCrsGcuoDybZVj8TFnWe/wBCKzTfkIbrTiKVLmpwWE4FeOoZ sRpTNXhorxdZxUF11kSzJ9X5JYfwUT0D3qWXq1rnyl60Xc6UGfibFVWdoUXWx7iUYSbo jbwrPP3dpZOmw1shscL1eAlsJGZossCgWUKdYBn2dgGdNZyHqEa8pAmpIgwr0bf4OATS 34B62IsdJN2hy7ZrjG1ruG9GkTX3G7wRC7cBE7u+CV7LLNUyomajiUcc48hkQrsPsxs/ JTsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=bPfWJzsB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id mi7-20020a17090b4b4700b001d95ccfbacdsi6007872pjb.96.2022.04.27.09.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:38:36 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=bPfWJzsB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55ACC457FAE; Wed, 27 Apr 2022 09:08:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242087AbiD0QIh (ORCPT + 99 others); Wed, 27 Apr 2022 12:08:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241566AbiD0QGz (ORCPT ); Wed, 27 Apr 2022 12:06:55 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81EF73D124C for ; Wed, 27 Apr 2022 09:03:13 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20220427160306euoutp0228ec723604b41216627c1d19fad47099~pzFDb99Py1615616156euoutp02F for ; Wed, 27 Apr 2022 16:03:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20220427160306euoutp0228ec723604b41216627c1d19fad47099~pzFDb99Py1615616156euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651075386; bh=QWDCdGpeRI5X2tzwrJf3syqVSb5HHkyW+8hRafR+UIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bPfWJzsBS6dlxu5+0QG6kEPvIkakPBIJcV0eK7Dt7oryxSX+rkbg+BLhaDe5I+EnY kTRFGlDb1aQFefVPO/k4npsq0Z/Wuwx/7ApWyR5I54THKstGf6iaW7qUlcLtKsZPlx QYDssMhTFROO7osDbmOUA8u4rJS4rLUsnoqlUrHI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20220427160304eucas1p2132f5d8996bb4be8c720545503199880~pzFBzwJqs2337723377eucas1p2a; Wed, 27 Apr 2022 16:03:04 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 90.14.09887.83969626; Wed, 27 Apr 2022 17:03:04 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e~pzFBSE8tz0330203302eucas1p1Q; Wed, 27 Apr 2022 16:03:03 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220427160303eusmtrp242409ff9824954bbde9684e0ce2d4e12~pzFBRNRlD2598325983eusmtrp2l; Wed, 27 Apr 2022 16:03:03 +0000 (GMT) X-AuditID: cbfec7f4-471ff7000000269f-55-62696938c9ff Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 74.81.09522.73969626; Wed, 27 Apr 2022 17:03:03 +0100 (BST) Received: from localhost (unknown [106.210.248.162]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220427160303eusmtip204431c6f8fcfa88dcd1d0a173a580914~pzFA_seRx2538025380eusmtip2M; Wed, 27 Apr 2022 16:03:03 +0000 (GMT) From: Pankaj Raghav To: jaegeuk@kernel.org, axboe@kernel.dk, snitzer@kernel.org, hch@lst.de, mcgrof@kernel.org, naohiro.aota@wdc.com, sagi@grimberg.me, damien.lemoal@opensource.wdc.com, dsterba@suse.com, johannes.thumshirn@wdc.com Cc: linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, clm@fb.com, gost.dev@samsung.com, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, josef@toxicpanda.com, jonathan.derrick@linux.dev, agk@redhat.com, kbusch@kernel.org, kch@nvidia.com, linux-nvme@lists.infradead.org, dm-devel@redhat.com, bvanassche@acm.org, jiangbo.365@bytedance.com, linux-fsdevel@vger.kernel.org, matias.bjorling@wdc.com, linux-block@vger.kernel.org, Pankaj Raghav Subject: [PATCH 07/16] btrfs: zoned: Cache superblock location in btrfs_zoned_device_info Date: Wed, 27 Apr 2022 18:02:46 +0200 Message-Id: <20220427160255.300418-8-p.raghav@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427160255.300418-1-p.raghav@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02SfUxbVRjGc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YyVxXs+CjkQhgfTEktTs1NSC1CKYPiYOTqkGJs6X V9cdyO1yCFG+ufLA+h/ijtW79e3tag/yHDpgLaCcMU9d69uH/PudEdIv469UB/ed6N1bdeIm c+6MBbWvNWqtusRMGFQ25H+/n3tG2Lhto+SU3bP3e72SfiHhvfDc27TJhrVfZjVKLczw++LA WSG1NfPitQXOu/v5q6Z3dvuHeh5569pebMrAX3qbWcuprrVqef4PS3/T/r9ZjT8jpWcuYVo+ y/b07V/Pfk+IFTtwv69g9z6r3tepy0+U6dhX/lreVzvB1e6Vz9KJLKKzqq5POs121tKvrPyF dMXtBz8fXYuas0ZMX3Vi8MXr0z+m8NjfCDo752qoienP+wyPOk1urNkzu3nzqUUf9i21MlBi Kc5INNRiLipOBABGrugrsQMAAA== X-CMS-MailID: 20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220427160303eucas1p1c7d1b743e9ecf77b4f203bdeccbe382e References: <20220427160255.300418-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE 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 1b1b310c3c51..6f76942d0ea5 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -512,6 +512,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++) { @@ -519,7 +524,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; @@ -867,7 +872,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; @@ -884,7 +889,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; @@ -1012,7 +1017,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 cbf016a7bb5d..49317524e9a6 100644 --- a/fs/btrfs/zoned.h +++ b/fs/btrfs/zoned.h @@ -31,6 +31,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