Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4698597iob; Sun, 8 May 2022 22:26:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWvs+THlkjyprIwg3rEqORh8l1WMx1N+5x3XVycm4kCFgZaDsJhEgMxQ0tmQxxMgyaaExJ X-Received: by 2002:a05:6a00:26c3:b0:50d:d619:e4c6 with SMTP id p3-20020a056a0026c300b0050dd619e4c6mr14379720pfw.13.1652073992748; Sun, 08 May 2022 22:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652073992; cv=none; d=google.com; s=arc-20160816; b=LxYJQVmR1rJUASRhBKHzyBOu3Fs3LYnjy3/2aeyjLkXMu4IT8lU8eUfRPorEsu+WY3 RLkKg8aI8OfiZt9Ecm9KYzF1os70sOby49rElkRZgsq5DDuAMOTl3fhOZcHkvezGRLmm HIEF3xv5DZUYz95qirKEHADIho9ok+Wm7Yq81MjT6cgaVPID1zsJkgs1hhRGj+yMulPJ w2RaxpCQdKUbAYk1B1DKfcbrF3b4wCGy7QXP48YV/j2AyhHgOUIeER3R3///6m+/nNBS HPKEQnJMNeEvKAaZ1As9giLwiZLTqmSWl287rQfSgb7zRooc45V/PAJa/qzQ9YZoUNtY S3Xw== 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=MRJZU+VZp7+luJVrancLtsmQUB9TusjdK07uLYBfVQxZef9SIiVVgEevCHDLbxOGYI LCRG7kv8YmFtbNsuDVkOHgNZVgGSV+Q08TApULhjTmwddXOKX0eVxjR2lzzUaQqxBQrp 1Bok6l2vcezDxZsux/U2Z6I8hXLrYx134GV2DlqbUXdMBvDHSxNay6whU/49BWtUZ8Do MO0nDCzTTCCp/JeWP95oMlylehk6x9yIq8xd5SOU6uBZJ802O11FLzaLAr5o4wH5/Fwt 8P8tJGpFIShLQuJyo97RzdGRtziv4dNeef/bYku5+VzSCcIo4FQBIaGJMv3HcXY5jKcR jm/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=dajDSPIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r5-20020a63fc45000000b003ab2440ce56si12367459pgk.207.2022.05.08.22.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 22:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=dajDSPIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 ABD55154FBC; Sun, 8 May 2022 22:24:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380237AbiEENzO (ORCPT + 99 others); Thu, 5 May 2022 09:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380176AbiEENyt (ORCPT ); Thu, 5 May 2022 09:54:49 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2137E57152 for ; Thu, 5 May 2022 06:51:08 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20220505135106euoutp016d4d252032490a708909e55e91d8ef82~sOcGYCApU3179931799euoutp01T for ; Thu, 5 May 2022 13:51:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20220505135106euoutp016d4d252032490a708909e55e91d8ef82~sOcGYCApU3179931799euoutp01T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1651758667; bh=U9RzqUijJL5PmqUeIybgHDju5FpS85GPewMJfUjtd+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dajDSPIm+J5ZIlke5/YV9e8QtQCHo+mRazznUYNKVqub4GTahcH24RVAWtIN3XTTr kEuH25BZUVHkGr+i2wLWwr/c0qxTKqzzLjjf0IGjHfbc2I393T/VvxubI/SKTvWAdt TSNTWYUkTrn8q0meFwbt3RqgQ6c9MthUoow5rSFg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20220505135104eucas1p1f7413241441378ad3d8a2fcbfb72bd5d~sOcEh4oMU0188401884eucas1p1X; Thu, 5 May 2022 13:51:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 19.FC.10009.846D3726; Thu, 5 May 2022 14:51:04 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20220505135104eucas1p1bed3e1e47255518296b4cb15ec0c042b~sOcD8lxBw1068810688eucas1p1D; Thu, 5 May 2022 13:51:04 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220505135104eusmtrp1758e1912f2f38f38511d760a6d5554ac~sOcD7cTl01310613106eusmtrp1O; Thu, 5 May 2022 13:51:04 +0000 (GMT) X-AuditID: cbfec7f2-e95ff70000002719-37-6273d6484bb4 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 84.6A.09404.846D3726; Thu, 5 May 2022 14:51:04 +0100 (BST) Received: from localhost (unknown [106.210.248.170]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220505135103eusmtip1f8faf002ab4e89d5bdd4994a68da949b~sOcDjxkyl0093500935eusmtip1H; Thu, 5 May 2022 13:51:03 +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 05/11] btrfs: zoned: Cache superblock location in btrfs_zoned_device_info Date: Thu, 5 May 2022 15:47:05 +0200 Message-Id: <20220505134710.132630-6-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: H4sIAAAAAAAAA02SfUxTZxTGfe+9vbdtqFxaEl5xbqMLJrgBEvfxjk7ncH/cxMRtMVnGyGBF b4BZSm2tOnCjjAJSCNSiTrrK2Ijho12KgIayZTTEKisirp0MxmjtBEQo+IENMpTNclnmf79z zvO8zznJy8fFIV4sP095iFUr5QopKSQuXl4aSmSGNdlb+z0IWcdrSXT63hKOTLVnKLQ8OISj 649KMDTqdGDop+9NGGq1ujA0YTfjqN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Fn Lk05titzc5Jx2fefCzWOLdP7J3fg6sRVfO0cG0NP7VpXusDlV1jBoatHvScpsRRnJBpqMRcV JwIA3qSA/ngDAAA= X-CMS-MailID: 20220505135104eucas1p1bed3e1e47255518296b4cb15ec0c042b X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20220505135104eucas1p1bed3e1e47255518296b4cb15ec0c042b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20220505135104eucas1p1bed3e1e47255518296b4cb15ec0c042b References: <20220505134710.132630-1-p.raghav@samsung.com> X-Spam-Status: No, score=-2.6 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,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