Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: use BTRFS_FS_UPDATE_UUID_TREE_GEN flag for UUID tree rescan check

The UUID tree rescan check in open_ctree() compares
fs_info->generation with the superblock's uuid_tree_generation.
This comparison is not reliable because fs_info->generation is
bumped at transaction start time in join_transaction(), while
uuid_tree_generation is only updated at commit time via
update_super_roots().

Between the early BTRFS_FS_UPDATE_UUID_TREE_GEN flag check and the
late rescan decision, mount operations such as file orphan cleanup
from an unclean shutdown start transactions without committing
them. This advances fs_info->generation past uuid_tree_generation
and produces a false-positive mismatch.

Use the BTRFS_FS_UPDATE_UUID_TREE_GEN flag directly instead. The
flag was already set earlier in open_ctree() when the generations
were known to match, and accurately represents "UUID tree is up to
date" without being affected by subsequent transaction starts.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chen <davechen@synology.com>
Signed-off-by: Robbie Ko <robbieko@synology.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Dave Chen and committed by
David Sterba
e70e3f85 e1194226

+1 -1
+1 -1
fs/btrfs/disk-io.c
··· 3660 3660 3661 3661 if (fs_info->uuid_root && 3662 3662 (btrfs_test_opt(fs_info, RESCAN_UUID_TREE) || 3663 - fs_info->generation != btrfs_super_uuid_tree_generation(disk_super))) { 3663 + !test_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags))) { 3664 3664 btrfs_info(fs_info, "checking UUID tree"); 3665 3665 ret = btrfs_check_uuid_tree(fs_info); 3666 3666 if (ret) {