diff options
author | Chris Mason <clm@fb.com> | 2016-01-25 19:43:13 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-01-25 19:43:13 -0500 |
commit | 6b5aa88c861cf0e4156e490009e2018d4fc81109 (patch) | |
tree | 5a8735c21895edc590517bce47ae1645341cdbfa /fs | |
parent | a6111d11b8b5364d02ea2e881c81ce39d004eb32 (diff) | |
parent | 14e46e04958df740c6c6a94849f176159a333f13 (diff) |
Merge branch 'fix/fst-sysfs' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.5
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/free-space-tree.c | 7 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 4 | ||||
-rw-r--r-- | fs/btrfs/super.c | 4 | ||||
-rw-r--r-- | fs/btrfs/sysfs.c | 32 | ||||
-rw-r--r-- | fs/btrfs/sysfs.h | 5 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 2 |
6 files changed, 53 insertions, 1 deletions
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index 393e36bd5845..94e887f5ec4e 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "locking.h" | 23 | #include "locking.h" |
24 | #include "free-space-tree.h" | 24 | #include "free-space-tree.h" |
25 | #include "transaction.h" | 25 | #include "transaction.h" |
26 | #include "sysfs.h" | ||
26 | 27 | ||
27 | static int __add_block_group_free_space(struct btrfs_trans_handle *trans, | 28 | static int __add_block_group_free_space(struct btrfs_trans_handle *trans, |
28 | struct btrfs_fs_info *fs_info, | 29 | struct btrfs_fs_info *fs_info, |
@@ -1169,6 +1170,9 @@ int btrfs_create_free_space_tree(struct btrfs_fs_info *fs_info) | |||
1169 | } | 1170 | } |
1170 | 1171 | ||
1171 | btrfs_set_fs_compat_ro(fs_info, FREE_SPACE_TREE); | 1172 | btrfs_set_fs_compat_ro(fs_info, FREE_SPACE_TREE); |
1173 | btrfs_sysfs_feature_update(fs_info, | ||
1174 | BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE, FEAT_COMPAT_RO); | ||
1175 | |||
1172 | fs_info->creating_free_space_tree = 0; | 1176 | fs_info->creating_free_space_tree = 0; |
1173 | 1177 | ||
1174 | ret = btrfs_commit_transaction(trans, tree_root); | 1178 | ret = btrfs_commit_transaction(trans, tree_root); |
@@ -1237,6 +1241,9 @@ int btrfs_clear_free_space_tree(struct btrfs_fs_info *fs_info) | |||
1237 | return PTR_ERR(trans); | 1241 | return PTR_ERR(trans); |
1238 | 1242 | ||
1239 | btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE); | 1243 | btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE); |
1244 | btrfs_sysfs_feature_update(fs_info, | ||
1245 | BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE, FEAT_COMPAT_RO); | ||
1246 | |||
1240 | fs_info->free_space_root = NULL; | 1247 | fs_info->free_space_root = NULL; |
1241 | 1248 | ||
1242 | ret = clear_free_space_tree(trans, free_space_root); | 1249 | ret = clear_free_space_tree(trans, free_space_root); |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 83c9ad3f2621..1568f57a3376 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1459,6 +1459,8 @@ int btrfs_defrag_file(struct inode *inode, struct file *file, | |||
1459 | 1459 | ||
1460 | if (range->compress_type == BTRFS_COMPRESS_LZO) { | 1460 | if (range->compress_type == BTRFS_COMPRESS_LZO) { |
1461 | btrfs_set_fs_incompat(root->fs_info, COMPRESS_LZO); | 1461 | btrfs_set_fs_incompat(root->fs_info, COMPRESS_LZO); |
1462 | btrfs_sysfs_feature_update(root->fs_info, | ||
1463 | BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO, FEAT_INCOMPAT); | ||
1462 | } | 1464 | } |
1463 | 1465 | ||
1464 | ret = defrag_count; | 1466 | ret = defrag_count; |
@@ -4067,6 +4069,8 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) | |||
4067 | btrfs_free_path(path); | 4069 | btrfs_free_path(path); |
4068 | 4070 | ||
4069 | btrfs_set_fs_incompat(root->fs_info, DEFAULT_SUBVOL); | 4071 | btrfs_set_fs_incompat(root->fs_info, DEFAULT_SUBVOL); |
4072 | btrfs_sysfs_feature_update(root->fs_info, | ||
4073 | BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL, FEAT_INCOMPAT); | ||
4070 | btrfs_end_transaction(trans, root); | 4074 | btrfs_end_transaction(trans, root); |
4071 | out: | 4075 | out: |
4072 | mnt_drop_write_file(file); | 4076 | mnt_drop_write_file(file); |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index a8e049ae933d..49b424103c32 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -58,6 +58,7 @@ | |||
58 | #include "dev-replace.h" | 58 | #include "dev-replace.h" |
59 | #include "free-space-cache.h" | 59 | #include "free-space-cache.h" |
60 | #include "backref.h" | 60 | #include "backref.h" |
61 | #include "sysfs.h" | ||
61 | #include "tests/btrfs-tests.h" | 62 | #include "tests/btrfs-tests.h" |
62 | 63 | ||
63 | #include "qgroup.h" | 64 | #include "qgroup.h" |
@@ -485,6 +486,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
485 | btrfs_clear_opt(info->mount_opt, NODATACOW); | 486 | btrfs_clear_opt(info->mount_opt, NODATACOW); |
486 | btrfs_clear_opt(info->mount_opt, NODATASUM); | 487 | btrfs_clear_opt(info->mount_opt, NODATASUM); |
487 | btrfs_set_fs_incompat(info, COMPRESS_LZO); | 488 | btrfs_set_fs_incompat(info, COMPRESS_LZO); |
489 | btrfs_sysfs_feature_update(root->fs_info, | ||
490 | BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO, | ||
491 | FEAT_INCOMPAT); | ||
488 | no_compress = 0; | 492 | no_compress = 0; |
489 | } else if (strncmp(args[0].from, "no", 2) == 0) { | 493 | } else if (strncmp(args[0].from, "no", 2) == 0) { |
490 | compress_type = "no"; | 494 | compress_type = "no"; |
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index e0ac85949067..6986886243bf 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c | |||
@@ -202,6 +202,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(extended_iref, EXTENDED_IREF); | |||
202 | BTRFS_FEAT_ATTR_INCOMPAT(raid56, RAID56); | 202 | BTRFS_FEAT_ATTR_INCOMPAT(raid56, RAID56); |
203 | BTRFS_FEAT_ATTR_INCOMPAT(skinny_metadata, SKINNY_METADATA); | 203 | BTRFS_FEAT_ATTR_INCOMPAT(skinny_metadata, SKINNY_METADATA); |
204 | BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES); | 204 | BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES); |
205 | BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE); | ||
205 | 206 | ||
206 | static struct attribute *btrfs_supported_feature_attrs[] = { | 207 | static struct attribute *btrfs_supported_feature_attrs[] = { |
207 | BTRFS_FEAT_ATTR_PTR(mixed_backref), | 208 | BTRFS_FEAT_ATTR_PTR(mixed_backref), |
@@ -213,6 +214,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = { | |||
213 | BTRFS_FEAT_ATTR_PTR(raid56), | 214 | BTRFS_FEAT_ATTR_PTR(raid56), |
214 | BTRFS_FEAT_ATTR_PTR(skinny_metadata), | 215 | BTRFS_FEAT_ATTR_PTR(skinny_metadata), |
215 | BTRFS_FEAT_ATTR_PTR(no_holes), | 216 | BTRFS_FEAT_ATTR_PTR(no_holes), |
217 | BTRFS_FEAT_ATTR_PTR(free_space_tree), | ||
216 | NULL | 218 | NULL |
217 | }; | 219 | }; |
218 | 220 | ||
@@ -780,6 +782,36 @@ failure: | |||
780 | return error; | 782 | return error; |
781 | } | 783 | } |
782 | 784 | ||
785 | |||
786 | /* | ||
787 | * Change per-fs features in /sys/fs/btrfs/UUID/features to match current | ||
788 | * values in superblock. Call after any changes to incompat/compat_ro flags | ||
789 | */ | ||
790 | void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, | ||
791 | u64 bit, enum btrfs_feature_set set) | ||
792 | { | ||
793 | struct btrfs_fs_devices *fs_devs; | ||
794 | struct kobject *fsid_kobj; | ||
795 | u64 features; | ||
796 | int ret; | ||
797 | |||
798 | if (!fs_info) | ||
799 | return; | ||
800 | |||
801 | features = get_features(fs_info, set); | ||
802 | ASSERT(bit & supported_feature_masks[set]); | ||
803 | |||
804 | fs_devs = fs_info->fs_devices; | ||
805 | fsid_kobj = &fs_devs->fsid_kobj; | ||
806 | |||
807 | /* | ||
808 | * FIXME: this is too heavy to update just one value, ideally we'd like | ||
809 | * to use sysfs_update_group but some refactoring is needed first. | ||
810 | */ | ||
811 | sysfs_remove_group(fsid_kobj, &btrfs_feature_attr_group); | ||
812 | ret = sysfs_create_group(fsid_kobj, &btrfs_feature_attr_group); | ||
813 | } | ||
814 | |||
783 | static int btrfs_init_debugfs(void) | 815 | static int btrfs_init_debugfs(void) |
784 | { | 816 | { |
785 | #ifdef CONFIG_DEBUG_FS | 817 | #ifdef CONFIG_DEBUG_FS |
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index 9c09522125a6..d7da1a4c2f6c 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h | |||
@@ -56,7 +56,7 @@ static struct btrfs_feature_attr btrfs_attr_##_name = { \ | |||
56 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ | 56 | #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \ |
57 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) | 57 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature) |
58 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ | 58 | #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \ |
59 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature) | 59 | BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT_RO, feature) |
60 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ | 60 | #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \ |
61 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) | 61 | BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature) |
62 | 62 | ||
@@ -90,4 +90,7 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, | |||
90 | struct kobject *parent); | 90 | struct kobject *parent); |
91 | int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs); | 91 | int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs); |
92 | void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); | 92 | void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs); |
93 | void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, | ||
94 | u64 bit, enum btrfs_feature_set set); | ||
95 | |||
93 | #endif /* _BTRFS_SYSFS_H_ */ | 96 | #endif /* _BTRFS_SYSFS_H_ */ |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 366b335946fa..5b505f61929e 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -4469,6 +4469,8 @@ static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type) | |||
4469 | return; | 4469 | return; |
4470 | 4470 | ||
4471 | btrfs_set_fs_incompat(info, RAID56); | 4471 | btrfs_set_fs_incompat(info, RAID56); |
4472 | btrfs_sysfs_feature_update(info, BTRFS_FEATURE_INCOMPAT_RAID56, | ||
4473 | FEAT_INCOMPAT); | ||
4472 | } | 4474 | } |
4473 | 4475 | ||
4474 | #define BTRFS_MAX_DEVS(r) ((BTRFS_LEAF_DATA_SIZE(r) \ | 4476 | #define BTRFS_MAX_DEVS(r) ((BTRFS_LEAF_DATA_SIZE(r) \ |