diff options
author | David Teigland <teigland@redhat.com> | 2019-01-16 10:41:43 -0600 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2019-01-16 10:49:04 -0600 |
commit | e158835a05963c8cb4166100c9d01e7ff3991c82 (patch) | |
tree | 82e82da1605ccc9027daeaafa20853c79aadfa8a /lib/locking | |
parent | 7b5abc3fb19c7569ad86107cfbf30f39ca261fed (diff) | |
download | lvm2-e158835a05963c8cb4166100c9d01e7ff3991c82.tar.gz |
lvmlockd: make lockstart wait for existing start
If there are two independent scripts doing:
vgchange --lockstart vg
lvchange -ay vg/lv
The first vgchange to do the lockstart will wait for
the lockstart to complete before returning.
The second vgchange to do the lockstart will see that
the start is already in progress (from the first) and
will do nothing. This means the second does not wait
for any lockstart to complete, and moves on to the
lvchange which may find the lockspace still starting
and fail.
To fix this, make the vgchange lockstart command
wait for any lockstart's in progress to complete.
Diffstat (limited to 'lib/locking')
-rw-r--r-- | lib/locking/lvmlockd.c | 12 | ||||
-rw-r--r-- | lib/locking/lvmlockd.h | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index 9fb7b364b..9b2d05015 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -1072,7 +1072,7 @@ void lockd_free_vg_final(struct cmd_context *cmd, struct volume_group *vg) * 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; @@ -1147,6 +1147,12 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_i 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; @@ -2668,7 +2674,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int * 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; } @@ -2708,7 +2714,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int } } - 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; diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h index 0a6ea9659..1fbf76531 100644 --- a/lib/locking/lvmlockd.h +++ b/lib/locking/lvmlockd.h @@ -63,7 +63,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int /* 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); |