10 #include <linux/sched.h>
14 #include <linux/module.h>
16 #include <asm/uaccess.h>
41 return a->
show ? a->
show(sdp, buf) : 0;
45 const char *
buf,
size_t len)
49 return a->
store ? a->
store(sdp, buf, len) : len;
52 static const struct sysfs_ops gfs2_attr_ops = {
53 .show = gfs2_attr_show,
54 .store = gfs2_attr_store,
58 static struct kset *gfs2_kset;
71 static int gfs2_uuid_valid(
const u8 *
uuid)
75 for (i = 0; i < 16; i++) {
87 if (!gfs2_uuid_valid(uuid))
103 static ssize_t freeze_store(
struct gfs2_sbd *sdp,
const char *buf,
size_t len)
124 fs_warn(sdp,
"freeze %d error %d", n, error);
135 static ssize_t withdraw_store(
struct gfs2_sbd *sdp,
const char *buf,
size_t len)
144 "GFS2: fsid=%s: withdrawing from cluster at user's request\n",
149 static ssize_t statfs_sync_store(
struct gfs2_sbd *sdp,
const char *buf,
175 static ssize_t quota_refresh_user_store(
struct gfs2_sbd *sdp,
const char *buf,
187 return error ? error : len;
190 static ssize_t quota_refresh_group_store(
struct gfs2_sbd *sdp,
const char *buf,
202 return error ? error : len;
205 static ssize_t demote_rq_store(
struct gfs2_sbd *sdp,
const char *buf,
size_t len)
211 unsigned long long glnum;
218 rv =
sscanf(buf,
"%u:%llu %15s", &gltype, &glnum,
223 if (
strcmp(mode,
"EX") == 0)
225 else if ((
strcmp(mode,
"CW") == 0) || (
strcmp(mode,
"DF") == 0))
227 else if ((
strcmp(mode,
"PR") == 0) || (
strcmp(mode,
"SH") == 0))
241 fs_info(sdp,
"demote interface used\n");
251 #define GFS2_ATTR(name, mode, show, store) \
252 static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
257 GFS2_ATTR(freeze, 0644, freeze_show, freeze_store);
258 GFS2_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
261 GFS2_ATTR(quota_refresh_user, 0200,
NULL, quota_refresh_user_store);
262 GFS2_ATTR(quota_refresh_group, 0200,
NULL, quota_refresh_group_store);
265 static struct attribute *gfs2_attrs[] = {
267 &gfs2_attr_fsname.attr,
268 &gfs2_attr_uuid.attr,
269 &gfs2_attr_freeze.attr,
270 &gfs2_attr_withdraw.attr,
271 &gfs2_attr_statfs_sync.attr,
272 &gfs2_attr_quota_sync.attr,
273 &gfs2_attr_quota_refresh_user.attr,
274 &gfs2_attr_quota_refresh_group.attr,
275 &gfs2_attr_demote_rq.attr,
279 static void gfs2_sbd_release(
struct kobject *kobj)
287 .release = gfs2_sbd_release,
288 .default_attrs = gfs2_attrs,
289 .sysfs_ops = &gfs2_attr_ops,
311 ret =
sprintf(buf,
"%d\n", val);
315 static ssize_t block_store(
struct gfs2_sbd *sdp,
const char *buf,
size_t len)
341 static ssize_t lkfirst_store(
struct gfs2_sbd *sdp,
const char *buf,
size_t len)
346 rv =
sscanf(buf,
"%u", &first);
347 if (rv != 1 || first > 1)
365 return rv ? rv : len;
395 static ssize_t recover_store(
struct gfs2_sbd *sdp,
const char *buf,
size_t len)
400 rv =
sscanf(buf,
"%u", &jid);
411 return rv ? rv : len;
431 static ssize_t jid_store(
struct gfs2_sbd *sdp,
const char *buf,
size_t len)
436 rv =
sscanf(buf,
"%d", &jid);
450 if (sdp->
sd_args.ar_spectator && jid > 0)
458 return rv ? rv : len;
461 #define GDLM_ATTR(_name,_mode,_show,_store) \
462 static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
466 GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
467 GDLM_ATTR(jid, 0644, jid_show, jid_store);
468 GDLM_ATTR(first, 0644, lkfirst_show, lkfirst_store);
474 static struct attribute *lock_module_attrs[] = {
475 &gdlm_attr_proto_name.attr,
476 &gdlm_attr_block.attr,
477 &gdlm_attr_withdraw.attr,
479 &gdlm_attr_first.attr,
480 &gdlm_attr_first_done.attr,
481 &gdlm_attr_recover.attr,
482 &gdlm_attr_recover_done.attr,
483 &gdlm_attr_recover_status.attr,
494 sdp->
sd_tune.gt_quota_scale_num,
495 sdp->
sd_tune.gt_quota_scale_den);
498 static ssize_t quota_scale_store(
struct gfs2_sbd *sdp,
const char *buf,
507 if (
sscanf(buf,
"%u %u", &x, &y) != 2 || !y)
518 int check_zero,
const char *buf,
size_t len)
528 if (check_zero && !x)
537 #define TUNE_ATTR_3(name, show, store) \
538 static struct gfs2_attr tune_attr_##name = __ATTR(name, 0644, show, store)
540 #define TUNE_ATTR_2(name, store) \
541 static ssize_t name##_show(struct gfs2_sbd *sdp, char *buf) \
543 return snprintf(buf, PAGE_SIZE, "%u\n", sdp->sd_tune.gt_##name); \
545 TUNE_ATTR_3(name, name##_show, store)
547 #define TUNE_ATTR(name, check_zero) \
548 static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\
550 return tune_set(sdp, &sdp->sd_tune.gt_##name, check_zero, buf, len); \
552 TUNE_ATTR_2(name, name##_store)
562 TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);
564 static struct attribute *tune_attrs[] = {
565 &tune_attr_quota_warn_period.attr,
566 &tune_attr_quota_quantum.attr,
567 &tune_attr_max_readahead.attr,
568 &tune_attr_complain_secs.attr,
569 &tune_attr_statfs_slow.attr,
570 &tune_attr_quota_simul_sync.attr,
571 &tune_attr_statfs_quantum.attr,
572 &tune_attr_quota_scale.attr,
573 &tune_attr_new_files_jdata.attr,
583 .name =
"lock_module",
584 .attrs = lock_module_attrs,
593 char *envp[] = {
ro, spectator,
NULL };
594 int sysfs_frees_sdp = 0;
597 sprintf(spectator,
"SPECTATOR=%d", sdp->
sd_args.ar_spectator ? 1 : 0);
616 &disk_to_dev(sb->
s_bdev->bd_disk)->kobj,
619 goto fail_lock_module;
630 fs_err(sdp,
"error %d adding sysfs files", error);
658 if (gfs2_uuid_valid(uuid))
664 .uevent = gfs2_uevent,