]> sourceware.org Git - lvm2.git/commitdiff
Add CORRECT_INCONSISTENT and FAIL_INCONSISTENT flags to vg_lock_and_read
authorDave Wysochanski <dwysocha@redhat.com>
Mon, 23 Jul 2007 21:03:42 +0000 (21:03 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Mon, 23 Jul 2007 21:03:42 +0000 (21:03 +0000)
lib/metadata/metadata-exported.h
lib/metadata/metadata.c
tools/pvmove.c
tools/vgextend.c
tools/vgmerge.c
tools/vgsplit.c

index 24f8bdfb9dc9e964fa01536feafe496601c3b53f..7cfec7bf7a891510a68ac2f8e3d73070c3ca11da 100644 (file)
@@ -83,6 +83,10 @@ struct pv_segment;
 #define FMT_RESIZE_PV          0x00000080U     /* Supports pvresize? */
 #define FMT_UNLIMITED_STRIPESIZE 0x00000100U   /* Unlimited stripe size? */
 
+/* LVM2 external library flags */
+#define CORRECT_INCONSISTENT    0x00000001U /* Correct inconsistent metadata */
+#define FAIL_INCONSISTENT       0x00000002U /* Fail if metadata inconsistent */
+
 /* Ordered list - see lv_manip.c */
 typedef enum {
        ALLOC_INVALID,
@@ -293,7 +297,8 @@ int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
             struct list *mdas, int64_t label_sector);
 int is_orphan(pv_t *pv);
 vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
-                      uint32_t lock_flags, uint32_t status_flags);
+                      uint32_t lock_flags, uint32_t status_flags,
+                      uint32_t misc_flags);
 
 /* pe_start and pe_end relate to any existing data so that new metadata
 * areas can avoid overlap */
index 29940c232c71cefab12a7993fb696da547f9b56d..de42ed39a9938e8e21b270bd4f849cf1f515cb57 100644 (file)
@@ -1798,23 +1798,29 @@ int vg_check_status(struct volume_group *vg, uint32_t status)
  * @vg_name - name of the volume group to lock and read
  * @lock_flags - locking flags to use
  * @status_flags - status flags to check
+ * @misc_flags - function modifier flags
  *
  * Returns:
  * NULL - failure
  * non-NULL - success; volume group handle
  */
 vg_t *vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
-                      uint32_t lock_flags, uint32_t status_flags)
+                      uint32_t lock_flags, uint32_t status_flags,
+                      uint32_t misc_flags)
 {
        struct volume_group *vg;
        int consistent = 1;
-       
+
+       if (!(misc_flags & CORRECT_INCONSISTENT))
+               consistent = 0;
+
        if (!lock_vol(cmd, vg_name, lock_flags)) {
                log_error("Can't get lock for %s", vg_name);
                return NULL;
        }
 
-       if (!(vg = vg_read(cmd, vg_name, NULL, &consistent)) || !consistent) {
+       if (!(vg = vg_read(cmd, vg_name, NULL, &consistent)) ||
+           ((misc_flags & FAIL_INCONSISTENT) && !consistent)) {
                log_error("Volume group \"%s\" not found", vg_name);
                unlock_vg(cmd, vg_name);
                return NULL;
index 33d1c42b41a088fdd75fbf192d11c5eaf2b03499..4b6fdc2ef5fd7f3e2f0840df3d484adad4e71757 100644 (file)
@@ -55,7 +55,8 @@ static struct volume_group *_get_vg(struct cmd_context *cmd, const char *vgname)
        dev_close_all();
 
        if (!(vg = vg_lock_and_read(cmd, vgname, LCK_VG_WRITE,
-                                   CLUSTERED | EXPORTED_VG | LVM_WRITE)))
+                                   CLUSTERED | EXPORTED_VG | LVM_WRITE,
+                                   CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
                 return NULL;
 
        return vg;
index 8f8009588c13e23bbcccbc0d3cfbbf481a5231b5..9ac98e2b04eb36c07d277124e6f15a17c75f8a8a 100644 (file)
@@ -49,7 +49,8 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
        log_verbose("Checking for volume group \"%s\"", vg_name);
        if (!(vg = vg_lock_and_read(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK,
                                    CLUSTERED | EXPORTED_VG | 
-                                   LVM_WRITE | RESIZEABLE_VG))) {
+                                   LVM_WRITE | RESIZEABLE_VG,
+                                   CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
                 unlock_vg(cmd, ORPHAN);
                return ECMD_FAILED;
         }
index e44f05eadbf2cd5e28806d0a3f39fec092ffbd7e..218e38dec9350db64cd3b1606c64237df2456c27 100644 (file)
@@ -30,13 +30,15 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
 
        log_verbose("Checking for volume group \"%s\"", vg_name_to);
        if (!(vg_to = vg_lock_and_read(cmd, vg_name_to, LCK_VG_WRITE,
-                                   CLUSTERED | EXPORTED_VG | LVM_WRITE)))
+                                      CLUSTERED | EXPORTED_VG | LVM_WRITE,
+                                      CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
                 return ECMD_FAILED;
 
        log_verbose("Checking for volume group \"%s\"", vg_name_from);
        if (!(vg_from = vg_lock_and_read(cmd, vg_name_from,
                                         LCK_VG_WRITE | LCK_NONBLOCK,
-                                        CLUSTERED | EXPORTED_VG | LVM_WRITE))) {
+                                        CLUSTERED | EXPORTED_VG | LVM_WRITE,
+                                        CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
                unlock_vg(cmd, vg_name_to);
                return ECMD_FAILED;
        }
index 805f5f212df4a267bbdf687f76f964dff846ff40..ccc9dc3fe877c6667dc0ca949fd83420701fcd85 100644 (file)
@@ -242,7 +242,8 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
        log_verbose("Checking for volume group \"%s\"", vg_name_from);
        if (!(vg_to = vg_lock_and_read(cmd, vg_name_from, LCK_VG_WRITE,
                                       CLUSTERED | EXPORTED_VG |
-                                      RESIZEABLE_VG | LVM_WRITE)))
+                                      RESIZEABLE_VG | LVM_WRITE,
+                                      CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
                 return ECMD_FAILED;
 
        log_verbose("Checking for volume group \"%s\"", vg_name_to);
This page took 0.038895 seconds and 5 git commands to generate.