* Re: [PATCH v5 4/4] btrfs: sysfs: export supported checksums
2019-08-30 11:36 ` [PATCH v5 4/4] btrfs: sysfs: export supported checksums Johannes Thumshirn
@ 2019-08-30 15:03 ` David Sterba
2019-08-31 4:15 ` kbuild test robot
2019-08-31 4:50 ` kbuild test robot
2 siblings, 0 replies; 10+ messages in thread
From: David Sterba @ 2019-08-30 15:03 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: David Sterba, Linux BTRFS Mailinglist
On Fri, Aug 30, 2019 at 01:36:11PM +0200, Johannes Thumshirn wrote:
> From: David Sterba <dsterba@suse.com>
I did not write the patch.
> Export supported checksum algorithms via sysfs.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
And 'git am' complains that there are two s-o-b lines.
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
>
> ---
> Changes to v2:
> - Prevent possible overflow of sysfs attribute
> Changes to v1:
> - Removed btrfs_checksums_store() function (Nik)
> - Renamed sysfs file to supported_checksums
> ---
> fs/btrfs/sysfs.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index f6d3c80f2e28..cae9c99253c7 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -246,6 +246,24 @@ static umode_t btrfs_feature_visible(struct kobject *kobj,
> return mode;
> }
>
> +static ssize_t btrfs_supported_checksums_show(struct kobject *kobj,
> + struct kobj_attribute *a,
> + char *buf)
> +{
> + ssize_t ret = 0;
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
We'll need one more helper to return the number of csums, btrfs_csums is
not visible in sysfs.c anymore (aka it does not compile).
> + ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s%s",
> + (i == 0 ? "" : ", "),
I've checked some sysfs files what's commonly used for a value separator
and there are more examples of ' ', though ', ' is also there. I'd
prefer to use a single letter separator.
> + btrfs_csums[i].name);
> +
> + }
> +
> + ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
> + return ret;
> +}
> +
> BTRFS_FEAT_ATTR_INCOMPAT(mixed_backref, MIXED_BACKREF);
> BTRFS_FEAT_ATTR_INCOMPAT(default_subvol, DEFAULT_SUBVOL);
> BTRFS_FEAT_ATTR_INCOMPAT(mixed_groups, MIXED_GROUPS);
> @@ -259,6 +277,14 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
> BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
> BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
>
> +static struct btrfs_feature_attr btrfs_attr_features_checksums_name = {
> + .kobj_attr = __INIT_KOBJ_ATTR(supported_checksums, S_IRUGO,
> + btrfs_supported_checksums_show,
> + NULL),
> + .feature_set = FEAT_INCOMPAT,
> + .feature_bit = 0,
> +};
> +
> static struct attribute *btrfs_supported_feature_attrs[] = {
> BTRFS_FEAT_ATTR_PTR(mixed_backref),
> BTRFS_FEAT_ATTR_PTR(default_subvol),
> @@ -272,6 +298,9 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
> BTRFS_FEAT_ATTR_PTR(no_holes),
> BTRFS_FEAT_ATTR_PTR(metadata_uuid),
> BTRFS_FEAT_ATTR_PTR(free_space_tree),
> +
> + &btrfs_attr_features_checksums_name.kobj_attr.attr,
This belongs to the static features, ie. the same scheme as
rmdir_subvol. The two lists are merged together in sysfs directory, but
should be defined separately as they represent different type of
features.
> +
> NULL
> };
>
> --
> 2.16.4
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v5 4/4] btrfs: sysfs: export supported checksums
2019-08-30 11:36 ` [PATCH v5 4/4] btrfs: sysfs: export supported checksums Johannes Thumshirn
2019-08-30 15:03 ` David Sterba
@ 2019-08-31 4:15 ` kbuild test robot
2019-08-31 4:50 ` kbuild test robot
2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2019-08-31 4:15 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: kbuild-all, David Sterba, Linux BTRFS Mailinglist,
Johannes Thumshirn
[-- Attachment #1: Type: text/plain, Size: 9390 bytes --]
Hi Johannes,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc6 next-20190830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/btrfs-turn-checksum-type-define-into-a-enum/20190831-103832
config: x86_64-lkp (attached as .config)
compiler: gcc-7 (Debian 7.4.0-11) 7.4.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
In file included from arch/x86/include/asm/percpu.h:45:0,
from arch/x86/include/asm/current.h:6,
from include/linux/sched.h:12,
from fs/btrfs/sysfs.c:6:
fs/btrfs/sysfs.c: In function 'btrfs_supported_checksums_show':
>> fs/btrfs/sysfs.c:192:29: error: 'btrfs_csums' undeclared (first use in this function); did you mean 'btrfs_chunk'?
for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
^
include/linux/kernel.h:47:33: note: in definition of macro 'ARRAY_SIZE'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~
fs/btrfs/sysfs.c:192:29: note: each undeclared identifier is reported only once for each function it appears in
for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
^
include/linux/kernel.h:47:33: note: in definition of macro 'ARRAY_SIZE'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~
In file included from include/linux/kernel.h:16:0,
from arch/x86/include/asm/percpu.h:45,
from arch/x86/include/asm/current.h:6,
from include/linux/sched.h:12,
from fs/btrfs/sysfs.c:6:
include/linux/build_bug.h:16:45: error: bit-field '<anonymous>' width not an integer constant
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
^
include/linux/compiler.h:357:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
^~~~~~~~~~~~~~~~~
include/linux/kernel.h:47:59: note: in expansion of macro '__must_be_array'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~~~~~~~~~~~~~
>> fs/btrfs/sysfs.c:192:18: note: in expansion of macro 'ARRAY_SIZE'
for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
^~~~~~~~~~
vim +192 fs/btrfs/sysfs.c
> 6 #include <linux/sched.h>
7 #include <linux/slab.h>
8 #include <linux/spinlock.h>
9 #include <linux/completion.h>
10 #include <linux/kobject.h>
11 #include <linux/bug.h>
12 #include <linux/debugfs.h>
13
14 #include "ctree.h"
15 #include "disk-io.h"
16 #include "transaction.h"
17 #include "sysfs.h"
18 #include "volumes.h"
19 #include "space-info.h"
20
21 static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj);
22 static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj);
23
24 static u64 get_features(struct btrfs_fs_info *fs_info,
25 enum btrfs_feature_set set)
26 {
27 struct btrfs_super_block *disk_super = fs_info->super_copy;
28 if (set == FEAT_COMPAT)
29 return btrfs_super_compat_flags(disk_super);
30 else if (set == FEAT_COMPAT_RO)
31 return btrfs_super_compat_ro_flags(disk_super);
32 else
33 return btrfs_super_incompat_flags(disk_super);
34 }
35
36 static void set_features(struct btrfs_fs_info *fs_info,
37 enum btrfs_feature_set set, u64 features)
38 {
39 struct btrfs_super_block *disk_super = fs_info->super_copy;
40 if (set == FEAT_COMPAT)
41 btrfs_set_super_compat_flags(disk_super, features);
42 else if (set == FEAT_COMPAT_RO)
43 btrfs_set_super_compat_ro_flags(disk_super, features);
44 else
45 btrfs_set_super_incompat_flags(disk_super, features);
46 }
47
48 static int can_modify_feature(struct btrfs_feature_attr *fa)
49 {
50 int val = 0;
51 u64 set, clear;
52 switch (fa->feature_set) {
53 case FEAT_COMPAT:
54 set = BTRFS_FEATURE_COMPAT_SAFE_SET;
55 clear = BTRFS_FEATURE_COMPAT_SAFE_CLEAR;
56 break;
57 case FEAT_COMPAT_RO:
58 set = BTRFS_FEATURE_COMPAT_RO_SAFE_SET;
59 clear = BTRFS_FEATURE_COMPAT_RO_SAFE_CLEAR;
60 break;
61 case FEAT_INCOMPAT:
62 set = BTRFS_FEATURE_INCOMPAT_SAFE_SET;
63 clear = BTRFS_FEATURE_INCOMPAT_SAFE_CLEAR;
64 break;
65 default:
66 pr_warn("btrfs: sysfs: unknown feature set %d\n",
67 fa->feature_set);
68 return 0;
69 }
70
71 if (set & fa->feature_bit)
72 val |= 1;
73 if (clear & fa->feature_bit)
74 val |= 2;
75
76 return val;
77 }
78
79 static ssize_t btrfs_feature_attr_show(struct kobject *kobj,
80 struct kobj_attribute *a, char *buf)
81 {
82 int val = 0;
83 struct btrfs_fs_info *fs_info = to_fs_info(kobj);
84 struct btrfs_feature_attr *fa = to_btrfs_feature_attr(a);
85 if (fs_info) {
86 u64 features = get_features(fs_info, fa->feature_set);
87 if (features & fa->feature_bit)
88 val = 1;
89 } else
90 val = can_modify_feature(fa);
91
92 return snprintf(buf, PAGE_SIZE, "%d\n", val);
93 }
94
95 static ssize_t btrfs_feature_attr_store(struct kobject *kobj,
96 struct kobj_attribute *a,
97 const char *buf, size_t count)
98 {
99 struct btrfs_fs_info *fs_info;
100 struct btrfs_feature_attr *fa = to_btrfs_feature_attr(a);
101 u64 features, set, clear;
102 unsigned long val;
103 int ret;
104
105 fs_info = to_fs_info(kobj);
106 if (!fs_info)
107 return -EPERM;
108
109 if (sb_rdonly(fs_info->sb))
110 return -EROFS;
111
112 ret = kstrtoul(skip_spaces(buf), 0, &val);
113 if (ret)
114 return ret;
115
116 if (fa->feature_set == FEAT_COMPAT) {
117 set = BTRFS_FEATURE_COMPAT_SAFE_SET;
118 clear = BTRFS_FEATURE_COMPAT_SAFE_CLEAR;
119 } else if (fa->feature_set == FEAT_COMPAT_RO) {
120 set = BTRFS_FEATURE_COMPAT_RO_SAFE_SET;
121 clear = BTRFS_FEATURE_COMPAT_RO_SAFE_CLEAR;
122 } else {
123 set = BTRFS_FEATURE_INCOMPAT_SAFE_SET;
124 clear = BTRFS_FEATURE_INCOMPAT_SAFE_CLEAR;
125 }
126
127 features = get_features(fs_info, fa->feature_set);
128
129 /* Nothing to do */
130 if ((val && (features & fa->feature_bit)) ||
131 (!val && !(features & fa->feature_bit)))
132 return count;
133
134 if ((val && !(set & fa->feature_bit)) ||
135 (!val && !(clear & fa->feature_bit))) {
136 btrfs_info(fs_info,
137 "%sabling feature %s on mounted fs is not supported.",
138 val ? "En" : "Dis", fa->kobj_attr.attr.name);
139 return -EPERM;
140 }
141
142 btrfs_info(fs_info, "%s %s feature flag",
143 val ? "Setting" : "Clearing", fa->kobj_attr.attr.name);
144
145 spin_lock(&fs_info->super_lock);
146 features = get_features(fs_info, fa->feature_set);
147 if (val)
148 features |= fa->feature_bit;
149 else
150 features &= ~fa->feature_bit;
151 set_features(fs_info, fa->feature_set, features);
152 spin_unlock(&fs_info->super_lock);
153
154 /*
155 * We don't want to do full transaction commit from inside sysfs
156 */
157 btrfs_set_pending(fs_info, COMMIT);
158 wake_up_process(fs_info->transaction_kthread);
159
160 return count;
161 }
162
163 static umode_t btrfs_feature_visible(struct kobject *kobj,
164 struct attribute *attr, int unused)
165 {
166 struct btrfs_fs_info *fs_info = to_fs_info(kobj);
167 umode_t mode = attr->mode;
168
169 if (fs_info) {
170 struct btrfs_feature_attr *fa;
171 u64 features;
172
173 fa = attr_to_btrfs_feature_attr(attr);
174 features = get_features(fs_info, fa->feature_set);
175
176 if (can_modify_feature(fa))
177 mode |= S_IWUSR;
178 else if (!(features & fa->feature_bit))
179 mode = 0;
180 }
181
182 return mode;
183 }
184
185 static ssize_t btrfs_supported_checksums_show(struct kobject *kobj,
186 struct kobj_attribute *a,
187 char *buf)
188 {
189 ssize_t ret = 0;
190 int i;
191
> 192 for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
193 ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s%s",
194 (i == 0 ? "" : ", "),
195 btrfs_csums[i].name);
196
197 }
198
199 ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
200 return ret;
201 }
202
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28161 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v5 4/4] btrfs: sysfs: export supported checksums
2019-08-30 11:36 ` [PATCH v5 4/4] btrfs: sysfs: export supported checksums Johannes Thumshirn
2019-08-30 15:03 ` David Sterba
2019-08-31 4:15 ` kbuild test robot
@ 2019-08-31 4:50 ` kbuild test robot
2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2019-08-31 4:50 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: kbuild-all, David Sterba, Linux BTRFS Mailinglist,
Johannes Thumshirn
[-- Attachment #1: Type: text/plain, Size: 9398 bytes --]
Hi Johannes,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc6 next-20190830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/btrfs-turn-checksum-type-define-into-a-enum/20190831-103832
config: i386-randconfig-a003-201934 (attached as .config)
compiler: gcc-6 (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from arch/x86/include/asm/percpu.h:45:0,
from arch/x86/include/asm/current.h:6,
from include/linux/sched.h:12,
from fs/btrfs/sysfs.c:6:
fs/btrfs/sysfs.c: In function 'btrfs_supported_checksums_show':
>> fs/btrfs/sysfs.c:192:29: error: 'btrfs_csums' undeclared (first use in this function)
for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
^
include/linux/kernel.h:47:33: note: in definition of macro 'ARRAY_SIZE'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~
fs/btrfs/sysfs.c:192:29: note: each undeclared identifier is reported only once for each function it appears in
for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
^
include/linux/kernel.h:47:33: note: in definition of macro 'ARRAY_SIZE'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~
In file included from include/linux/kernel.h:16:0,
from arch/x86/include/asm/percpu.h:45,
from arch/x86/include/asm/current.h:6,
from include/linux/sched.h:12,
from fs/btrfs/sysfs.c:6:
include/linux/build_bug.h:16:45: error: bit-field '<anonymous>' width not an integer constant
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
^
include/linux/compiler.h:357:28: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
^~~~~~~~~~~~~~~~~
include/linux/kernel.h:47:59: note: in expansion of macro '__must_be_array'
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
^~~~~~~~~~~~~~~
fs/btrfs/sysfs.c:192:18: note: in expansion of macro 'ARRAY_SIZE'
for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
^~~~~~~~~~
vim +/btrfs_csums +192 fs/btrfs/sysfs.c
> 6 #include <linux/sched.h>
7 #include <linux/slab.h>
8 #include <linux/spinlock.h>
9 #include <linux/completion.h>
10 #include <linux/kobject.h>
11 #include <linux/bug.h>
12 #include <linux/debugfs.h>
13
14 #include "ctree.h"
15 #include "disk-io.h"
16 #include "transaction.h"
17 #include "sysfs.h"
18 #include "volumes.h"
19 #include "space-info.h"
20
21 static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj);
22 static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj);
23
24 static u64 get_features(struct btrfs_fs_info *fs_info,
25 enum btrfs_feature_set set)
26 {
27 struct btrfs_super_block *disk_super = fs_info->super_copy;
28 if (set == FEAT_COMPAT)
29 return btrfs_super_compat_flags(disk_super);
30 else if (set == FEAT_COMPAT_RO)
31 return btrfs_super_compat_ro_flags(disk_super);
32 else
33 return btrfs_super_incompat_flags(disk_super);
34 }
35
36 static void set_features(struct btrfs_fs_info *fs_info,
37 enum btrfs_feature_set set, u64 features)
38 {
39 struct btrfs_super_block *disk_super = fs_info->super_copy;
40 if (set == FEAT_COMPAT)
41 btrfs_set_super_compat_flags(disk_super, features);
42 else if (set == FEAT_COMPAT_RO)
43 btrfs_set_super_compat_ro_flags(disk_super, features);
44 else
45 btrfs_set_super_incompat_flags(disk_super, features);
46 }
47
48 static int can_modify_feature(struct btrfs_feature_attr *fa)
49 {
50 int val = 0;
51 u64 set, clear;
52 switch (fa->feature_set) {
53 case FEAT_COMPAT:
54 set = BTRFS_FEATURE_COMPAT_SAFE_SET;
55 clear = BTRFS_FEATURE_COMPAT_SAFE_CLEAR;
56 break;
57 case FEAT_COMPAT_RO:
58 set = BTRFS_FEATURE_COMPAT_RO_SAFE_SET;
59 clear = BTRFS_FEATURE_COMPAT_RO_SAFE_CLEAR;
60 break;
61 case FEAT_INCOMPAT:
62 set = BTRFS_FEATURE_INCOMPAT_SAFE_SET;
63 clear = BTRFS_FEATURE_INCOMPAT_SAFE_CLEAR;
64 break;
65 default:
66 pr_warn("btrfs: sysfs: unknown feature set %d\n",
67 fa->feature_set);
68 return 0;
69 }
70
71 if (set & fa->feature_bit)
72 val |= 1;
73 if (clear & fa->feature_bit)
74 val |= 2;
75
76 return val;
77 }
78
79 static ssize_t btrfs_feature_attr_show(struct kobject *kobj,
80 struct kobj_attribute *a, char *buf)
81 {
82 int val = 0;
83 struct btrfs_fs_info *fs_info = to_fs_info(kobj);
84 struct btrfs_feature_attr *fa = to_btrfs_feature_attr(a);
85 if (fs_info) {
86 u64 features = get_features(fs_info, fa->feature_set);
87 if (features & fa->feature_bit)
88 val = 1;
89 } else
90 val = can_modify_feature(fa);
91
92 return snprintf(buf, PAGE_SIZE, "%d\n", val);
93 }
94
95 static ssize_t btrfs_feature_attr_store(struct kobject *kobj,
96 struct kobj_attribute *a,
97 const char *buf, size_t count)
98 {
99 struct btrfs_fs_info *fs_info;
100 struct btrfs_feature_attr *fa = to_btrfs_feature_attr(a);
101 u64 features, set, clear;
102 unsigned long val;
103 int ret;
104
105 fs_info = to_fs_info(kobj);
106 if (!fs_info)
107 return -EPERM;
108
109 if (sb_rdonly(fs_info->sb))
110 return -EROFS;
111
112 ret = kstrtoul(skip_spaces(buf), 0, &val);
113 if (ret)
114 return ret;
115
116 if (fa->feature_set == FEAT_COMPAT) {
117 set = BTRFS_FEATURE_COMPAT_SAFE_SET;
118 clear = BTRFS_FEATURE_COMPAT_SAFE_CLEAR;
119 } else if (fa->feature_set == FEAT_COMPAT_RO) {
120 set = BTRFS_FEATURE_COMPAT_RO_SAFE_SET;
121 clear = BTRFS_FEATURE_COMPAT_RO_SAFE_CLEAR;
122 } else {
123 set = BTRFS_FEATURE_INCOMPAT_SAFE_SET;
124 clear = BTRFS_FEATURE_INCOMPAT_SAFE_CLEAR;
125 }
126
127 features = get_features(fs_info, fa->feature_set);
128
129 /* Nothing to do */
130 if ((val && (features & fa->feature_bit)) ||
131 (!val && !(features & fa->feature_bit)))
132 return count;
133
134 if ((val && !(set & fa->feature_bit)) ||
135 (!val && !(clear & fa->feature_bit))) {
136 btrfs_info(fs_info,
137 "%sabling feature %s on mounted fs is not supported.",
138 val ? "En" : "Dis", fa->kobj_attr.attr.name);
139 return -EPERM;
140 }
141
142 btrfs_info(fs_info, "%s %s feature flag",
143 val ? "Setting" : "Clearing", fa->kobj_attr.attr.name);
144
145 spin_lock(&fs_info->super_lock);
146 features = get_features(fs_info, fa->feature_set);
147 if (val)
148 features |= fa->feature_bit;
149 else
150 features &= ~fa->feature_bit;
151 set_features(fs_info, fa->feature_set, features);
152 spin_unlock(&fs_info->super_lock);
153
154 /*
155 * We don't want to do full transaction commit from inside sysfs
156 */
157 btrfs_set_pending(fs_info, COMMIT);
158 wake_up_process(fs_info->transaction_kthread);
159
160 return count;
161 }
162
163 static umode_t btrfs_feature_visible(struct kobject *kobj,
164 struct attribute *attr, int unused)
165 {
166 struct btrfs_fs_info *fs_info = to_fs_info(kobj);
167 umode_t mode = attr->mode;
168
169 if (fs_info) {
170 struct btrfs_feature_attr *fa;
171 u64 features;
172
173 fa = attr_to_btrfs_feature_attr(attr);
174 features = get_features(fs_info, fa->feature_set);
175
176 if (can_modify_feature(fa))
177 mode |= S_IWUSR;
178 else if (!(features & fa->feature_bit))
179 mode = 0;
180 }
181
182 return mode;
183 }
184
185 static ssize_t btrfs_supported_checksums_show(struct kobject *kobj,
186 struct kobj_attribute *a,
187 char *buf)
188 {
189 ssize_t ret = 0;
190 int i;
191
> 192 for (i = 0; i < ARRAY_SIZE(btrfs_csums); i++) {
193 ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s%s",
194 (i == 0 ? "" : ", "),
195 btrfs_csums[i].name);
196
197 }
198
199 ret += snprintf(buf + ret, PAGE_SIZE - ret, "\n");
200 return ret;
201 }
202
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32126 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread