userfaultfd: waitqueue: add nr wake parameter to __wake_up_locked_key
[linux/fpc-iii.git] / fs / xfs / xfs_sysfs.c
blobaa03670851d86574cc542a2eccb1b5c4607e4ca5
1 /*
2 * Copyright (c) 2014 Red Hat, Inc.
3 * All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "xfs.h"
20 #include "xfs_sysfs.h"
21 #include "xfs_log_format.h"
22 #include "xfs_log.h"
23 #include "xfs_log_priv.h"
25 struct xfs_sysfs_attr {
26 struct attribute attr;
27 ssize_t (*show)(char *buf, void *data);
28 ssize_t (*store)(const char *buf, size_t count, void *data);
31 static inline struct xfs_sysfs_attr *
32 to_attr(struct attribute *attr)
34 return container_of(attr, struct xfs_sysfs_attr, attr);
37 #define XFS_SYSFS_ATTR_RW(name) \
38 static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RW(name)
39 #define XFS_SYSFS_ATTR_RO(name) \
40 static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RO(name)
42 #define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr
45 * xfs_mount kobject. This currently has no attributes and thus no need for show
46 * and store helpers. The mp kobject serves as the per-mount parent object that
47 * is identified by the fsname under sysfs.
50 struct kobj_type xfs_mp_ktype = {
51 .release = xfs_sysfs_release,
54 #ifdef DEBUG
55 /* debug */
57 STATIC ssize_t
58 log_recovery_delay_store(
59 const char *buf,
60 size_t count,
61 void *data)
63 int ret;
64 int val;
66 ret = kstrtoint(buf, 0, &val);
67 if (ret)
68 return ret;
70 if (val < 0 || val > 60)
71 return -EINVAL;
73 xfs_globals.log_recovery_delay = val;
75 return count;
78 STATIC ssize_t
79 log_recovery_delay_show(
80 char *buf,
81 void *data)
83 return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.log_recovery_delay);
85 XFS_SYSFS_ATTR_RW(log_recovery_delay);
87 static struct attribute *xfs_dbg_attrs[] = {
88 ATTR_LIST(log_recovery_delay),
89 NULL,
92 STATIC ssize_t
93 xfs_dbg_show(
94 struct kobject *kobject,
95 struct attribute *attr,
96 char *buf)
98 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
100 return xfs_attr->show ? xfs_attr->show(buf, NULL) : 0;
103 STATIC ssize_t
104 xfs_dbg_store(
105 struct kobject *kobject,
106 struct attribute *attr,
107 const char *buf,
108 size_t count)
110 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
112 return xfs_attr->store ? xfs_attr->store(buf, count, NULL) : 0;
115 static struct sysfs_ops xfs_dbg_ops = {
116 .show = xfs_dbg_show,
117 .store = xfs_dbg_store,
120 struct kobj_type xfs_dbg_ktype = {
121 .release = xfs_sysfs_release,
122 .sysfs_ops = &xfs_dbg_ops,
123 .default_attrs = xfs_dbg_attrs,
126 #endif /* DEBUG */
128 /* xlog */
130 STATIC ssize_t
131 log_head_lsn_show(
132 char *buf,
133 void *data)
135 struct xlog *log = data;
136 int cycle;
137 int block;
139 spin_lock(&log->l_icloglock);
140 cycle = log->l_curr_cycle;
141 block = log->l_curr_block;
142 spin_unlock(&log->l_icloglock);
144 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block);
146 XFS_SYSFS_ATTR_RO(log_head_lsn);
148 STATIC ssize_t
149 log_tail_lsn_show(
150 char *buf,
151 void *data)
153 struct xlog *log = data;
154 int cycle;
155 int block;
157 xlog_crack_atomic_lsn(&log->l_tail_lsn, &cycle, &block);
158 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, block);
160 XFS_SYSFS_ATTR_RO(log_tail_lsn);
162 STATIC ssize_t
163 reserve_grant_head_show(
164 char *buf,
165 void *data)
167 struct xlog *log = data;
168 int cycle;
169 int bytes;
171 xlog_crack_grant_head(&log->l_reserve_head.grant, &cycle, &bytes);
172 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
174 XFS_SYSFS_ATTR_RO(reserve_grant_head);
176 STATIC ssize_t
177 write_grant_head_show(
178 char *buf,
179 void *data)
181 struct xlog *log = data;
182 int cycle;
183 int bytes;
185 xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &bytes);
186 return snprintf(buf, PAGE_SIZE, "%d:%d\n", cycle, bytes);
188 XFS_SYSFS_ATTR_RO(write_grant_head);
190 static struct attribute *xfs_log_attrs[] = {
191 ATTR_LIST(log_head_lsn),
192 ATTR_LIST(log_tail_lsn),
193 ATTR_LIST(reserve_grant_head),
194 ATTR_LIST(write_grant_head),
195 NULL,
198 static inline struct xlog *
199 to_xlog(struct kobject *kobject)
201 struct xfs_kobj *kobj = to_kobj(kobject);
202 return container_of(kobj, struct xlog, l_kobj);
205 STATIC ssize_t
206 xfs_log_show(
207 struct kobject *kobject,
208 struct attribute *attr,
209 char *buf)
211 struct xlog *log = to_xlog(kobject);
212 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
214 return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
217 STATIC ssize_t
218 xfs_log_store(
219 struct kobject *kobject,
220 struct attribute *attr,
221 const char *buf,
222 size_t count)
224 struct xlog *log = to_xlog(kobject);
225 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
227 return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
230 static struct sysfs_ops xfs_log_ops = {
231 .show = xfs_log_show,
232 .store = xfs_log_store,
235 struct kobj_type xfs_log_ktype = {
236 .release = xfs_sysfs_release,
237 .sysfs_ops = &xfs_log_ops,
238 .default_attrs = xfs_log_attrs,