diff options
Diffstat (limited to 'fs/xfs/xfs_sysfs.c')
-rw-r--r-- | fs/xfs/xfs_sysfs.c | 78 |
1 files changed, 68 insertions, 10 deletions
diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c index 641d625eb334..6ced4f143494 100644 --- a/fs/xfs/xfs_sysfs.c +++ b/fs/xfs/xfs_sysfs.c | |||
@@ -18,10 +18,13 @@ | |||
18 | 18 | ||
19 | #include "xfs.h" | 19 | #include "xfs.h" |
20 | #include "xfs_sysfs.h" | 20 | #include "xfs_sysfs.h" |
21 | #include "xfs_format.h" | ||
21 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | ||
22 | #include "xfs_log.h" | 24 | #include "xfs_log.h" |
23 | #include "xfs_log_priv.h" | 25 | #include "xfs_log_priv.h" |
24 | #include "xfs_stats.h" | 26 | #include "xfs_stats.h" |
27 | #include "xfs_mount.h" | ||
25 | 28 | ||
26 | struct xfs_sysfs_attr { | 29 | struct xfs_sysfs_attr { |
27 | struct attribute attr; | 30 | struct attribute attr; |
@@ -45,16 +48,6 @@ to_attr(struct attribute *attr) | |||
45 | 48 | ||
46 | #define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr | 49 | #define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr |
47 | 50 | ||
48 | /* | ||
49 | * xfs_mount kobject. This currently has no attributes and thus no need for show | ||
50 | * and store helpers. The mp kobject serves as the per-mount parent object that | ||
51 | * is identified by the fsname under sysfs. | ||
52 | */ | ||
53 | |||
54 | struct kobj_type xfs_mp_ktype = { | ||
55 | .release = xfs_sysfs_release, | ||
56 | }; | ||
57 | |||
58 | STATIC ssize_t | 51 | STATIC ssize_t |
59 | xfs_sysfs_object_show( | 52 | xfs_sysfs_object_show( |
60 | struct kobject *kobject, | 53 | struct kobject *kobject, |
@@ -83,6 +76,71 @@ static const struct sysfs_ops xfs_sysfs_ops = { | |||
83 | .store = xfs_sysfs_object_store, | 76 | .store = xfs_sysfs_object_store, |
84 | }; | 77 | }; |
85 | 78 | ||
79 | /* | ||
80 | * xfs_mount kobject. The mp kobject also serves as the per-mount parent object | ||
81 | * that is identified by the fsname under sysfs. | ||
82 | */ | ||
83 | |||
84 | static inline struct xfs_mount * | ||
85 | to_mp(struct kobject *kobject) | ||
86 | { | ||
87 | struct xfs_kobj *kobj = to_kobj(kobject); | ||
88 | |||
89 | return container_of(kobj, struct xfs_mount, m_kobj); | ||
90 | } | ||
91 | |||
92 | #ifdef DEBUG | ||
93 | |||
94 | STATIC ssize_t | ||
95 | fail_writes_store( | ||
96 | struct kobject *kobject, | ||
97 | const char *buf, | ||
98 | size_t count) | ||
99 | { | ||
100 | struct xfs_mount *mp = to_mp(kobject); | ||
101 | int ret; | ||
102 | int val; | ||
103 | |||
104 | ret = kstrtoint(buf, 0, &val); | ||
105 | if (ret) | ||
106 | return ret; | ||
107 | |||
108 | if (val == 1) | ||
109 | mp->m_fail_writes = true; | ||
110 | else if (val == 0) | ||
111 | mp->m_fail_writes = false; | ||
112 | else | ||
113 | return -EINVAL; | ||
114 | |||
115 | return count; | ||
116 | } | ||
117 | |||
118 | STATIC ssize_t | ||
119 | fail_writes_show( | ||
120 | struct kobject *kobject, | ||
121 | char *buf) | ||
122 | { | ||
123 | struct xfs_mount *mp = to_mp(kobject); | ||
124 | |||
125 | return snprintf(buf, PAGE_SIZE, "%d\n", mp->m_fail_writes ? 1 : 0); | ||
126 | } | ||
127 | XFS_SYSFS_ATTR_RW(fail_writes); | ||
128 | |||
129 | #endif /* DEBUG */ | ||
130 | |||
131 | static struct attribute *xfs_mp_attrs[] = { | ||
132 | #ifdef DEBUG | ||
133 | ATTR_LIST(fail_writes), | ||
134 | #endif | ||
135 | NULL, | ||
136 | }; | ||
137 | |||
138 | struct kobj_type xfs_mp_ktype = { | ||
139 | .release = xfs_sysfs_release, | ||
140 | .sysfs_ops = &xfs_sysfs_ops, | ||
141 | .default_attrs = xfs_mp_attrs, | ||
142 | }; | ||
143 | |||
86 | #ifdef DEBUG | 144 | #ifdef DEBUG |
87 | /* debug */ | 145 | /* debug */ |
88 | 146 | ||