summaryrefslogtreecommitdiff
path: root/tools/lvchange.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-04-05 15:05:32 -0500
committerDavid Teigland <teigland@redhat.com>2017-04-05 16:46:38 -0500
commit7ccb4825c7c5f40e93afea065100105f3d5f3551 (patch)
tree11ce8a102df2abf20738513cad79a30bb7ee5e02 /tools/lvchange.c
parentc9bc1c1c8ccd624762b59a46689467573bc2933e (diff)
downloadlvm2-7ccb4825c7c5f40e93afea065100105f3d5f3551.tar.gz
lvchange/lvconvert: fix missing lvmlockd LV locks
lvchange/lvconvert operations that do not require the LV to already be active need to acquire a transient LV lock before changing/converting the LV to ensure the LV is not active on another host. If the LV is already active, a persistent LV lock already exists on the host and the transient LV lock request is a no-op. Some lvmlockd locks in lvchange were lost in the cmd def changes. The lvmlockd locks in lvconvert seem to have been missed from the start.
Diffstat (limited to 'tools/lvchange.c')
-rw-r--r--tools/lvchange.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/tools/lvchange.c b/tools/lvchange.c
index a35891e8f..660570aa3 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1056,16 +1056,9 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
int i, opt_enum;
uint32_t mr = 0;
- /*
- * If a persistent lv lock already exists from activation
- * (with the needed mode or higher), this will be a no-op.
- * Otherwise, the lv lock will be taken as non-persistent
- * and released when this command exits.
- */
- if (!lockd_lv(cmd, lv, "ex", 0)) {
- stack;
- return ECMD_FAILED;
- }
+ /* If LV is inactive here, ensure it's not active elsewhere. */
+ if (!lockd_lv(cmd, lv, "ex", 0))
+ return_ECMD_FAILED;
/* First group of options which allow for one metadata commit/update for the whole group */
for (i = 0; i < cmd->command->ro_count; i++) {
@@ -1451,6 +1444,10 @@ static int _lvchange_resync_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
+ /* If LV is inactive here, ensure it's not active elsewhere. */
+ if (!lockd_lv(cmd, lv, "ex", 0))
+ return_ECMD_FAILED;
+
if (!_lvchange_resync(cmd, lv))
return_ECMD_FAILED;
@@ -1502,6 +1499,10 @@ static int _lvchange_syncaction_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
+ /* If LV is inactive here, ensure it's not active elsewhere. */
+ if (!lockd_lv(cmd, lv, "ex", 0))
+ return_ECMD_FAILED;
+
if (!lv_raid_message(lv, arg_str_value(cmd, syncaction_ARG, NULL)))
return_ECMD_FAILED;
@@ -1532,6 +1533,10 @@ static int _lvchange_rebuild_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
+ /* If LV is inactive here, ensure it's not active elsewhere. */
+ if (!lockd_lv(cmd, lv, "ex", 0))
+ return_ECMD_FAILED;
+
if (!_lvchange_rebuild(lv))
return_ECMD_FAILED;
@@ -1601,6 +1606,10 @@ static int _lvchange_persistent_single(struct cmd_context *cmd,
{
uint32_t mr = 0;
+ /* If LV is inactive here, ensure it's not active elsewhere. */
+ if (!lockd_lv(cmd, lv, "ex", 0))
+ return_ECMD_FAILED;
+
if (!_lvchange_persistent(cmd, lv, &mr))
return_ECMD_FAILED;