diff options
Diffstat (limited to 'fs/gfs2/sys.c')
-rw-r--r-- | fs/gfs2/sys.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index a7cbfbd340c7..446329728d52 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kobject.h> | 16 | #include <linux/kobject.h> |
17 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
18 | #include <linux/gfs2_ondisk.h> | 18 | #include <linux/gfs2_ondisk.h> |
19 | #include <linux/genhd.h> | ||
19 | 20 | ||
20 | #include "gfs2.h" | 21 | #include "gfs2.h" |
21 | #include "incore.h" | 22 | #include "incore.h" |
@@ -319,12 +320,6 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | |||
319 | return ret; | 320 | return ret; |
320 | } | 321 | } |
321 | 322 | ||
322 | static ssize_t lkid_show(struct gfs2_sbd *sdp, char *buf) | ||
323 | { | ||
324 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | ||
325 | return sprintf(buf, "%u\n", ls->ls_id); | ||
326 | } | ||
327 | |||
328 | static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf) | 323 | static ssize_t lkfirst_show(struct gfs2_sbd *sdp, char *buf) |
329 | { | 324 | { |
330 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; | 325 | struct lm_lockstruct *ls = &sdp->sd_lockstruct; |
@@ -389,7 +384,6 @@ static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) | |||
389 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); | 384 | GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); |
390 | GDLM_ATTR(block, 0644, block_show, block_store); | 385 | GDLM_ATTR(block, 0644, block_show, block_store); |
391 | GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store); | 386 | GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store); |
392 | GDLM_ATTR(id, 0444, lkid_show, NULL); | ||
393 | GDLM_ATTR(jid, 0444, jid_show, NULL); | 387 | GDLM_ATTR(jid, 0444, jid_show, NULL); |
394 | GDLM_ATTR(first, 0444, lkfirst_show, NULL); | 388 | GDLM_ATTR(first, 0444, lkfirst_show, NULL); |
395 | GDLM_ATTR(first_done, 0444, first_done_show, NULL); | 389 | GDLM_ATTR(first_done, 0444, first_done_show, NULL); |
@@ -401,7 +395,6 @@ static struct attribute *lock_module_attrs[] = { | |||
401 | &gdlm_attr_proto_name.attr, | 395 | &gdlm_attr_proto_name.attr, |
402 | &gdlm_attr_block.attr, | 396 | &gdlm_attr_block.attr, |
403 | &gdlm_attr_withdraw.attr, | 397 | &gdlm_attr_withdraw.attr, |
404 | &gdlm_attr_id.attr, | ||
405 | &gdlm_attr_jid.attr, | 398 | &gdlm_attr_jid.attr, |
406 | &gdlm_attr_first.attr, | 399 | &gdlm_attr_first.attr, |
407 | &gdlm_attr_first_done.attr, | 400 | &gdlm_attr_first_done.attr, |
@@ -519,7 +512,14 @@ static struct attribute_group lock_module_group = { | |||
519 | 512 | ||
520 | int gfs2_sys_fs_add(struct gfs2_sbd *sdp) | 513 | int gfs2_sys_fs_add(struct gfs2_sbd *sdp) |
521 | { | 514 | { |
515 | struct super_block *sb = sdp->sd_vfs; | ||
522 | int error; | 516 | int error; |
517 | char ro[20]; | ||
518 | char spectator[20]; | ||
519 | char *envp[] = { ro, spectator, NULL }; | ||
520 | |||
521 | sprintf(ro, "RDONLY=%d", (sb->s_flags & MS_RDONLY) ? 1 : 0); | ||
522 | sprintf(spectator, "SPECTATOR=%d", sdp->sd_args.ar_spectator ? 1 : 0); | ||
523 | 523 | ||
524 | sdp->sd_kobj.kset = gfs2_kset; | 524 | sdp->sd_kobj.kset = gfs2_kset; |
525 | error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL, | 525 | error = kobject_init_and_add(&sdp->sd_kobj, &gfs2_ktype, NULL, |
@@ -535,9 +535,17 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp) | |||
535 | if (error) | 535 | if (error) |
536 | goto fail_tune; | 536 | goto fail_tune; |
537 | 537 | ||
538 | kobject_uevent(&sdp->sd_kobj, KOBJ_ADD); | 538 | error = sysfs_create_link(&sdp->sd_kobj, |
539 | &disk_to_dev(sb->s_bdev->bd_disk)->kobj, | ||
540 | "device"); | ||
541 | if (error) | ||
542 | goto fail_lock_module; | ||
543 | |||
544 | kobject_uevent_env(&sdp->sd_kobj, KOBJ_ADD, envp); | ||
539 | return 0; | 545 | return 0; |
540 | 546 | ||
547 | fail_lock_module: | ||
548 | sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); | ||
541 | fail_tune: | 549 | fail_tune: |
542 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); | 550 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); |
543 | fail_reg: | 551 | fail_reg: |
@@ -549,12 +557,12 @@ fail: | |||
549 | 557 | ||
550 | void gfs2_sys_fs_del(struct gfs2_sbd *sdp) | 558 | void gfs2_sys_fs_del(struct gfs2_sbd *sdp) |
551 | { | 559 | { |
560 | sysfs_remove_link(&sdp->sd_kobj, "device"); | ||
552 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); | 561 | sysfs_remove_group(&sdp->sd_kobj, &tune_group); |
553 | sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); | 562 | sysfs_remove_group(&sdp->sd_kobj, &lock_module_group); |
554 | kobject_put(&sdp->sd_kobj); | 563 | kobject_put(&sdp->sd_kobj); |
555 | } | 564 | } |
556 | 565 | ||
557 | |||
558 | static int gfs2_uevent(struct kset *kset, struct kobject *kobj, | 566 | static int gfs2_uevent(struct kset *kset, struct kobject *kobj, |
559 | struct kobj_uevent_env *env) | 567 | struct kobj_uevent_env *env) |
560 | { | 568 | { |
@@ -563,6 +571,8 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj, | |||
563 | 571 | ||
564 | add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); | 572 | add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); |
565 | add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); | 573 | add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); |
574 | if (!sdp->sd_args.ar_spectator) | ||
575 | add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid); | ||
566 | if (gfs2_uuid_valid(uuid)) { | 576 | if (gfs2_uuid_valid(uuid)) { |
567 | add_uevent_var(env, "UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-" | 577 | add_uevent_var(env, "UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-" |
568 | "%02X%02X-%02X%02X%02X%02X%02X%02X", | 578 | "%02X%02X-%02X%02X%02X%02X%02X%02X", |
@@ -578,7 +588,6 @@ static struct kset_uevent_ops gfs2_uevent_ops = { | |||
578 | .uevent = gfs2_uevent, | 588 | .uevent = gfs2_uevent, |
579 | }; | 589 | }; |
580 | 590 | ||
581 | |||
582 | int gfs2_sys_init(void) | 591 | int gfs2_sys_init(void) |
583 | { | 592 | { |
584 | gfs2_kset = kset_create_and_add("gfs2", &gfs2_uevent_ops, fs_kobj); | 593 | gfs2_kset = kset_create_and_add("gfs2", &gfs2_uevent_ops, fs_kobj); |