if (ls2->thread_stop) {
log_debug("add_lockspace_thread %s exists and stopping", ls->name);
rv = -EAGAIN;
+ } else if (!ls2->create_fail && !ls2->create_done) {
+ log_debug("add_lockspace_thread %s exists and starting", ls->name);
+ rv = -ESTARTING;
} else {
log_debug("add_lockspace_thread %s exists", ls->name);
rv = -EEXIST;
pthread_mutex_lock(&lockspaces_mutex);
list_for_each_entry(ls, &lockspaces, list) {
- if (ls->start_client_id != client_id)
+ if (client_id && (ls->start_client_id != client_id))
continue;
if (!ls->create_done && !ls->create_fail) {
add_client_result(act);
} else if (act->op == LD_OP_START_WAIT) {
- act->result = count_lockspace_starting(act->client_id);
+ act->result = count_lockspace_starting(0);
if (!act->result)
add_client_result(act);
else
list_for_each_entry_safe(act, safe, &delayed_list, list) {
if (act->op == LD_OP_START_WAIT) {
log_debug("work delayed start_wait for client %u", act->client_id);
- act->result = count_lockspace_starting(act->client_id);
+ act->result = count_lockspace_starting(0);
if (!act->result) {
list_del(&act->list);
add_client_result(act);
* that the VG lockspace being started is new.
*/
-int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_init)
+int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_init, int *exists)
{
char uuid[64] __attribute__((aligned(8)));
daemon_reply reply;
log_debug("VG %s start error: already started", vg->name);
ret = 1;
break;
+ case -ESTARTING:
+ log_debug("VG %s start error: already starting", vg->name);
+ if (exists)
+ *exists = 1;
+ ret = 1;
+ break;
case -EARGS:
log_error("VG %s start failed: invalid parameters for %s", vg->name, vg->lock_type);
break;
* Depending on the problem that caused the rename to
* fail, it may make sense to not restart the VG here.
*/
- if (!lockd_start_vg(cmd, vg, 0))
+ if (!lockd_start_vg(cmd, vg, 0, NULL))
log_error("Failed to restart VG %s lockspace.", vg->name);
return 1;
}
}
}
- if (!lockd_start_vg(cmd, vg, 1))
+ if (!lockd_start_vg(cmd, vg, 1, NULL))
log_error("Failed to start VG %s lockspace.", vg->name);
return 1;
/* start and stop the lockspace for a vg */
-int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_init);
+int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_init, int *exists);
int lockd_stop_vg(struct cmd_context *cmd, struct volume_group *vg);
int lockd_start_wait(struct cmd_context *cmd);
{
const char *start_opt = arg_str_value(cmd, lockopt_ARG, NULL);
int auto_opt = 0;
+ int exists = 0;
int r;
if (!vg_is_shared(vg))
}
do_start:
- r = lockd_start_vg(cmd, vg, 0);
+ r = lockd_start_vg(cmd, vg, 0, &exists);
if (r)
vp->lock_start_count++;
+ else if (exists)
+ vp->lock_start_count++;
if (!strcmp(vg->lock_type, "sanlock"))
vp->lock_start_sanlock = 1;
if (vg_is_shared(vg)) {
const char *start_opt = arg_str_value(cmd, lockopt_ARG, NULL);
- if (!lockd_start_vg(cmd, vg, 1)) {
+ if (!lockd_start_vg(cmd, vg, 1, NULL)) {
log_error("Failed to start locking");
goto out;
}