From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09CF828E23 for ; Wed, 20 Sep 2023 12:42:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BCF9C433C8; Wed, 20 Sep 2023 12:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695213770; bh=eVTltBm92bpieE8i7TUOQdBzDMqYhaEdsr85W+aLCJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NUbxsuuQseNpd8LL69F+bO/0uRv2QhwYMoHeKJnK3jnLrjHh3J0hcpk6LtEAFZ2Xq Vj/dtSppFDqnoMnbRoHnXtwWkQkmWSGhWYfLWqtu5s3i911bYq4NqRsiMo/NypI/bt T/O2dpMDD3R7y/FnkK074SsnYRw47ONN+gKR4wfk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Thumshirn , "Guilherme G. Piccoli" , Anand Jain , David Sterba , Sasha Levin Subject: [PATCH 5.4 352/367] btrfs: add a helper to read the superblock metadata_uuid Date: Wed, 20 Sep 2023 13:32:09 +0200 Message-ID: <20230920112907.601726775@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112858.471730572@linuxfoundation.org> References: <20230920112858.471730572@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anand Jain [ Upstream commit 4844c3664a72d36cc79752cb651c78860b14c240 ] In some cases, we need to read the FSID from the superblock when the metadata_uuid is not set, and otherwise, read the metadata_uuid. So, add a helper. Reviewed-by: Johannes Thumshirn Tested-by: Guilherme G. Piccoli Signed-off-by: Anand Jain Reviewed-by: David Sterba Signed-off-by: David Sterba Stable-dep-of: 6bfe3959b0e7 ("btrfs: compare the correct fsid/metadata_uuid in btrfs_validate_super") Signed-off-by: Sasha Levin --- fs/btrfs/volumes.c | 8 ++++++++ fs/btrfs/volumes.h | 1 + 2 files changed, 9 insertions(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0d4afeacb237b..f9192dcb9208b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -895,6 +895,14 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, return -EINVAL; } +u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb) +{ + bool has_metadata_uuid = (btrfs_super_incompat_flags(sb) & + BTRFS_FEATURE_INCOMPAT_METADATA_UUID); + + return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; +} + /* * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices * being created with a disk that has already completed its fsid change. diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index fd8fdaa4b0cdf..762c0a3754982 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -582,5 +582,6 @@ const char *btrfs_bg_type_to_raid_name(u64 flags); int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info); bool btrfs_pinned_by_swapfile(struct btrfs_fs_info *fs_info, void *ptr); +u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb); #endif -- 2.40.1