LCOV - code coverage report
Current view: top level - fs/btrfs - fs.c (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc3-achx @ Mon Jul 31 20:08:12 PDT 2023 Lines: 45 60 75.0 %
Date: 2023-07-31 20:08:12 Functions: 3 4 75.0 %

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

Generated by: LCOV version 1.14