1 // SPDX-License-Identifier: GPL-2.0 2 3 #include "messages.h" 4 #include "ctree.h" 5 #include "fs.h" 6 7 void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag, 8 const char *name) 9 { 10 struct btrfs_super_block *disk_super; 11 u64 features; 12 13 disk_super = fs_info->super_copy; 14 features = btrfs_super_incompat_flags(disk_super); 15 if (!(features & flag)) { 16 spin_lock(&fs_info->super_lock); 17 features = btrfs_super_incompat_flags(disk_super); 18 if (!(features & flag)) { 19 features |= flag; 20 btrfs_set_super_incompat_flags(disk_super, features); 21 btrfs_info(fs_info, 22 "setting incompat feature flag for %s (0x%llx)", 23 name, flag); 24 } 25 spin_unlock(&fs_info->super_lock); 26 } 27 } 28 29 void __btrfs_clear_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag, 30 const char *name) 31 { 32 struct btrfs_super_block *disk_super; 33 u64 features; 34 35 disk_super = fs_info->super_copy; 36 features = btrfs_super_incompat_flags(disk_super); 37 if (features & flag) { 38 spin_lock(&fs_info->super_lock); 39 features = btrfs_super_incompat_flags(disk_super); 40 if (features & flag) { 41 features &= ~flag; 42 btrfs_set_super_incompat_flags(disk_super, features); 43 btrfs_info(fs_info, 44 "clearing incompat feature flag for %s (0x%llx)", 45 name, flag); 46 } 47 spin_unlock(&fs_info->super_lock); 48 } 49 } 50 51 void __btrfs_set_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag, 52 const char *name) 53 { 54 struct btrfs_super_block *disk_super; 55 u64 features; 56 57 disk_super = fs_info->super_copy; 58 features = btrfs_super_compat_ro_flags(disk_super); 59 if (!(features & flag)) { 60 spin_lock(&fs_info->super_lock); 61 features = btrfs_super_compat_ro_flags(disk_super); 62 if (!(features & flag)) { 63 features |= flag; 64 btrfs_set_super_compat_ro_flags(disk_super, features); 65 btrfs_info(fs_info, 66 "setting compat-ro feature flag for %s (0x%llx)", 67 name, flag); 68 } 69 spin_unlock(&fs_info->super_lock); 70 } 71 } 72 73 void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag, 74 const char *name) 75 { 76 struct btrfs_super_block *disk_super; 77 u64 features; 78 79 disk_super = fs_info->super_copy; 80 features = btrfs_super_compat_ro_flags(disk_super); 81 if (features & flag) { 82 spin_lock(&fs_info->super_lock); 83 features = btrfs_super_compat_ro_flags(disk_super); 84 if (features & flag) { 85 features &= ~flag; 86 btrfs_set_super_compat_ro_flags(disk_super, features); 87 btrfs_info(fs_info, 88 "clearing compat-ro feature flag for %s (0x%llx)", 89 name, flag); 90 } 91 spin_unlock(&fs_info->super_lock); 92 } 93 } 94