Skip to content

Commit e70e3f8

Browse files
fcmaplekdave
authored andcommitted
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>
1 parent e119422 commit e70e3f8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3660,7 +3660,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
36603660

36613661
if (fs_info->uuid_root &&
36623662
(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))) {
36643664
btrfs_info(fs_info, "checking UUID tree");
36653665
ret = btrfs_check_uuid_tree(fs_info);
36663666
if (ret) {

0 commit comments

Comments
 (0)