mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-11 21:14:07 +08:00
c7f13d428e
We have several fs wide related helpers in ctree.h. The bulk of these are the incompat flag test helpers, but there are things such as btrfs_fs_closing() and the read only helpers that also aren't directly related to the ctree code. Move these into a fs.h header, which will serve as the location for file system wide related helpers. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
93 lines
2.4 KiB
C
93 lines
2.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "ctree.h"
|
|
#include "fs.h"
|
|
|
|
void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
|
|
const char *name)
|
|
{
|
|
struct btrfs_super_block *disk_super;
|
|
u64 features;
|
|
|
|
disk_super = fs_info->super_copy;
|
|
features = btrfs_super_incompat_flags(disk_super);
|
|
if (!(features & flag)) {
|
|
spin_lock(&fs_info->super_lock);
|
|
features = btrfs_super_incompat_flags(disk_super);
|
|
if (!(features & flag)) {
|
|
features |= flag;
|
|
btrfs_set_super_incompat_flags(disk_super, features);
|
|
btrfs_info(fs_info,
|
|
"setting incompat feature flag for %s (0x%llx)",
|
|
name, flag);
|
|
}
|
|
spin_unlock(&fs_info->super_lock);
|
|
}
|
|
}
|
|
|
|
void __btrfs_clear_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag,
|
|
const char *name)
|
|
{
|
|
struct btrfs_super_block *disk_super;
|
|
u64 features;
|
|
|
|
disk_super = fs_info->super_copy;
|
|
features = btrfs_super_incompat_flags(disk_super);
|
|
if (features & flag) {
|
|
spin_lock(&fs_info->super_lock);
|
|
features = btrfs_super_incompat_flags(disk_super);
|
|
if (features & flag) {
|
|
features &= ~flag;
|
|
btrfs_set_super_incompat_flags(disk_super, features);
|
|
btrfs_info(fs_info,
|
|
"clearing incompat feature flag for %s (0x%llx)",
|
|
name, flag);
|
|
}
|
|
spin_unlock(&fs_info->super_lock);
|
|
}
|
|
}
|
|
|
|
void __btrfs_set_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
|
|
const char *name)
|
|
{
|
|
struct btrfs_super_block *disk_super;
|
|
u64 features;
|
|
|
|
disk_super = fs_info->super_copy;
|
|
features = btrfs_super_compat_ro_flags(disk_super);
|
|
if (!(features & flag)) {
|
|
spin_lock(&fs_info->super_lock);
|
|
features = btrfs_super_compat_ro_flags(disk_super);
|
|
if (!(features & flag)) {
|
|
features |= flag;
|
|
btrfs_set_super_compat_ro_flags(disk_super, features);
|
|
btrfs_info(fs_info,
|
|
"setting compat-ro feature flag for %s (0x%llx)",
|
|
name, flag);
|
|
}
|
|
spin_unlock(&fs_info->super_lock);
|
|
}
|
|
}
|
|
|
|
void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
|
|
const char *name)
|
|
{
|
|
struct btrfs_super_block *disk_super;
|
|
u64 features;
|
|
|
|
disk_super = fs_info->super_copy;
|
|
features = btrfs_super_compat_ro_flags(disk_super);
|
|
if (features & flag) {
|
|
spin_lock(&fs_info->super_lock);
|
|
features = btrfs_super_compat_ro_flags(disk_super);
|
|
if (features & flag) {
|
|
features &= ~flag;
|
|
btrfs_set_super_compat_ro_flags(disk_super, features);
|
|
btrfs_info(fs_info,
|
|
"clearing compat-ro feature flag for %s (0x%llx)",
|
|
name, flag);
|
|
}
|
|
spin_unlock(&fs_info->super_lock);
|
|
}
|
|
}
|