]> sourceware.org Git - lvm2.git/commitdiff
Move ORPHAN_VG lock outside pvcreate_single.
authorDave Wysochanski <dwysocha@redhat.com>
Sun, 26 Jul 2009 01:54:20 +0000 (01:54 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Sun, 26 Jul 2009 01:54:20 +0000 (01:54 +0000)
The implicit pvcreate require either moving the ORPHAN_VG lock outside
pvcreate_single or somehow having the function know or detect whether
the ORPHAN_VG lock is already held.

Author: Dave Wysochanski <dwysocha@redhat.com>

lib/metadata/metadata.c
tools/pvcreate.c

index aa25b3a4159cc01bfd70aaa1fea24a7bcf10a20a..4031ea68c72c1f52883e8dd99ef79fe4a4b3a198 100644 (file)
@@ -1142,11 +1142,6 @@ pv_t * pvcreate_single(struct cmd_context *cmd, const char *pv_name,
                }
        }
 
-       if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
-               log_error("Can't get lock for orphan PVs");
-               return NULL;
-       }
-
        if (!pvcreate_check(cmd, pv_name, pp))
                goto error;
 
@@ -1203,11 +1198,9 @@ pv_t * pvcreate_single(struct cmd_context *cmd, const char *pv_name,
 
        log_print("Physical volume \"%s\" successfully created", pv_name);
 
-       unlock_vg(cmd, VG_ORPHANS);
        return pv;
 
       error:
-       unlock_vg(cmd, VG_ORPHANS);
        return NULL;
 }
 
index e21fe943760b8554f56ef425d7f067d46c60f60c..8595339b3df6bf319410eeb9ab96ff8166f8816a 100644 (file)
@@ -171,9 +171,15 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
        }
 
        for (i = 0; i < argc; i++) {
+               if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
+                       log_error("Can't get lock for orphan PVs");
+                       return ECMD_FAILED;
+               }
+
                if (!pvcreate_single(cmd, argv[i], &pp))
                        ret = ECMD_FAILED;
 
+               unlock_vg(cmd, VG_ORPHANS);
                if (sigint_caught())
                        return ret;
        }
This page took 0.045766 seconds and 5 git commands to generate.