Skip to content

Commit 8b0e7b2

Browse files
teiglandswhiteho
authored andcommitted
[DLM] wait for config check during join [6/6]
Joining the lockspace should wait for the initial round of inter-node config checks to complete before returning. This way, if there's a configuration mismatch between the joining node and the existing nodes, the join can fail and return an error to the application. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 79d72b5 commit 8b0e7b2

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

‎fs/dlm/dlm_internal.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ struct dlm_ls {
472472

473473
wait_queue_head_t ls_uevent_wait; /* user part of join/leave */
474474
int ls_uevent_result;
475+
struct completion ls_members_done;
476+
int ls_members_result;
475477

476478
struct miscdevice ls_device;
477479

‎fs/dlm/lockspace.c‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,24 @@ static int do_uevent(struct dlm_ls *ls, int in)
197197
else
198198
kobject_uevent(&ls->ls_kobj, KOBJ_OFFLINE);
199199

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+
200205
error = wait_event_interruptible(ls->ls_uevent_wait,
201206
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+
202210
if (error)
203211
goto out;
204212

205213
error = ls->ls_uevent_result;
206214
out:
215+
if (error)
216+
log_error(ls, "group %s failed %d %d", in ? "join" : "leave",
217+
error, ls->ls_uevent_result);
207218
return error;
208219
}
209220

@@ -490,6 +501,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
490501

491502
init_waitqueue_head(&ls->ls_uevent_wait);
492503
ls->ls_uevent_result = 0;
504+
init_completion(&ls->ls_members_done);
505+
ls->ls_members_result = -1;
493506

494507
ls->ls_recoverd_task = NULL;
495508
mutex_init(&ls->ls_recoverd_active);
@@ -540,17 +553,32 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
540553
/* let kobject handle freeing of ls if there's an error */
541554
do_unreg = 1;
542555

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+
543562
error = do_uevent(ls, 1);
544563
if (error)
545564
goto out_stop;
546565

566+
wait_for_completion(&ls->ls_members_done);
567+
error = ls->ls_members_result;
568+
if (error)
569+
goto out_members;
570+
547571
dlm_create_debug_file(ls);
548572

549573
log_debug(ls, "join complete");
550574

551575
*lockspace = ls;
552576
return 0;
553577

578+
out_members:
579+
do_uevent(ls, 0);
580+
dlm_clear_members(ls);
581+
kfree(ls->ls_node_array);
554582
out_stop:
555583
dlm_recoverd_stop(ls);
556584
out_delist:
@@ -588,6 +616,8 @@ int dlm_new_lockspace(char *name, int namelen, void **lockspace,
588616
error = new_lockspace(name, namelen, lockspace, flags, lvblen);
589617
if (!error)
590618
ls_count++;
619+
else if (!ls_count)
620+
threads_stop();
591621
out:
592622
mutex_unlock(&ls_lock);
593623
return error;

‎fs/dlm/member.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
233233
*neg_out = neg;
234234

235235
error = ping_members(ls);
236+
if (!error || error == -EPROTO) {
237+
/* new_lockspace() may be waiting to know if the config
238+
is good or bad */
239+
ls->ls_members_result = error;
240+
complete(&ls->ls_members_done);
241+
}
236242
if (error)
237243
goto out;
238244

‎fs/dlm/rcom.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ static int check_config(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid)
9090
log_error(ls, "version mismatch: %x nodeid %d: %x",
9191
DLM_HEADER_MAJOR | DLM_HEADER_MINOR, nodeid,
9292
rc->rc_header.h_version);
93-
return -EINVAL;
93+
return -EPROTO;
9494
}
9595

9696
if (rf->rf_lvblen != ls->ls_lvblen ||
9797
rf->rf_lsflags != ls->ls_exflags) {
9898
log_error(ls, "config mismatch: %d,%x nodeid %d: %d,%x",
9999
ls->ls_lvblen, ls->ls_exflags,
100100
nodeid, rf->rf_lvblen, rf->rf_lsflags);
101-
return -EINVAL;
101+
return -EPROTO;
102102
}
103103
return 0;
104104
}

0 commit comments

Comments
 (0)