diff options
Diffstat (limited to 'fs/dlm/lockspace.c')
-rw-r--r-- | fs/dlm/lockspace.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index a3a50e67e4dd..c8f0c15ac166 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
@@ -197,13 +197,24 @@ static int do_uevent(struct dlm_ls *ls, int in) | |||
197 | else | 197 | else |
198 | kobject_uevent(&ls->ls_kobj, KOBJ_OFFLINE); | 198 | kobject_uevent(&ls->ls_kobj, KOBJ_OFFLINE); |
199 | 199 | ||
200 | log_debug(ls, "%s the lockspace group...", in ? "joining" : "leaving"); | ||
201 | |||
202 | /* dlm_controld will see the uevent, do the necessary group management | ||
203 | and then write to sysfs to wake us */ | ||
204 | |||
200 | error = wait_event_interruptible(ls->ls_uevent_wait, | 205 | error = wait_event_interruptible(ls->ls_uevent_wait, |
201 | test_and_clear_bit(LSFL_UEVENT_WAIT, &ls->ls_flags)); | 206 | test_and_clear_bit(LSFL_UEVENT_WAIT, &ls->ls_flags)); |
207 | |||
208 | log_debug(ls, "group event done %d %d", error, ls->ls_uevent_result); | ||
209 | |||
202 | if (error) | 210 | if (error) |
203 | goto out; | 211 | goto out; |
204 | 212 | ||
205 | error = ls->ls_uevent_result; | 213 | error = ls->ls_uevent_result; |
206 | out: | 214 | out: |
215 | if (error) | ||
216 | log_error(ls, "group %s failed %d %d", in ? "join" : "leave", | ||
217 | error, ls->ls_uevent_result); | ||
207 | return error; | 218 | return error; |
208 | } | 219 | } |
209 | 220 | ||
@@ -490,6 +501,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
490 | 501 | ||
491 | init_waitqueue_head(&ls->ls_uevent_wait); | 502 | init_waitqueue_head(&ls->ls_uevent_wait); |
492 | ls->ls_uevent_result = 0; | 503 | ls->ls_uevent_result = 0; |
504 | init_completion(&ls->ls_members_done); | ||
505 | ls->ls_members_result = -1; | ||
493 | 506 | ||
494 | ls->ls_recoverd_task = NULL; | 507 | ls->ls_recoverd_task = NULL; |
495 | mutex_init(&ls->ls_recoverd_active); | 508 | mutex_init(&ls->ls_recoverd_active); |
@@ -540,10 +553,21 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
540 | /* let kobject handle freeing of ls if there's an error */ | 553 | /* let kobject handle freeing of ls if there's an error */ |
541 | do_unreg = 1; | 554 | do_unreg = 1; |
542 | 555 | ||
556 | /* This uevent triggers dlm_controld in userspace to add us to the | ||
557 | group of nodes that are members of this lockspace (managed by the | ||
558 | cluster infrastructure.) Once it's done that, it tells us who the | ||
559 | current lockspace members are (via configfs) and then tells the | ||
560 | lockspace to start running (via sysfs) in dlm_ls_start(). */ | ||
561 | |||
543 | error = do_uevent(ls, 1); | 562 | error = do_uevent(ls, 1); |
544 | if (error) | 563 | if (error) |
545 | goto out_stop; | 564 | goto out_stop; |
546 | 565 | ||
566 | wait_for_completion(&ls->ls_members_done); | ||
567 | error = ls->ls_members_result; | ||
568 | if (error) | ||
569 | goto out_members; | ||
570 | |||
547 | dlm_create_debug_file(ls); | 571 | dlm_create_debug_file(ls); |
548 | 572 | ||
549 | log_debug(ls, "join complete"); | 573 | log_debug(ls, "join complete"); |
@@ -551,6 +575,10 @@ static int new_lockspace(char *name, int namelen, void **lockspace, | |||
551 | *lockspace = ls; | 575 | *lockspace = ls; |
552 | return 0; | 576 | return 0; |
553 | 577 | ||
578 | out_members: | ||
579 | do_uevent(ls, 0); | ||
580 | dlm_clear_members(ls); | ||
581 | kfree(ls->ls_node_array); | ||
554 | out_stop: | 582 | out_stop: |
555 | dlm_recoverd_stop(ls); | 583 | dlm_recoverd_stop(ls); |
556 | out_delist: | 584 | out_delist: |
@@ -588,6 +616,8 @@ int dlm_new_lockspace(char *name, int namelen, void **lockspace, | |||
588 | error = new_lockspace(name, namelen, lockspace, flags, lvblen); | 616 | error = new_lockspace(name, namelen, lockspace, flags, lvblen); |
589 | if (!error) | 617 | if (!error) |
590 | ls_count++; | 618 | ls_count++; |
619 | else if (!ls_count) | ||
620 | threads_stop(); | ||
591 | out: | 621 | out: |
592 | mutex_unlock(&ls_lock); | 622 | mutex_unlock(&ls_lock); |
593 | return error; | 623 | return error; |