]> sourceware.org Git - lvm2.git/commitdiff
Add free_orphan_vg
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 13 Feb 2012 11:03:59 +0000 (11:03 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 13 Feb 2012 11:03:59 +0000 (11:03 +0000)
Move commod code to destroy orphan VG into free_orphan_vg() function.
Use orphan vgmem for creation of PV lists.
Remove some free_pv_fid() calls (FIXME: check all of them)
FIXME: Check whether we could merge release_vg back again for all VGs.

WHATS_NEW
lib/format1/format1.c
lib/format_pool/format_pool.c
lib/format_text/format-text.c
lib/metadata/metadata.c
lib/metadata/vg.c
lib/metadata/vg.h
tools/pvcreate.c
tools/vgconvert.c

index a26e50d02ffa5ce16ae38f51a1b0fdedfc83e5b8..c09d08a6756629a17070e6a1b383a283c08941c3 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.92 - 
 ====================================
+  Add free_orphan_vg.
   Skip pv/vg_set_fid processing if the fid is same.
   Check for foreach loop errors in _vg_read_orphans() (2.02.91).
   Clean error paths for format instance creation (2.02.91).
index 30b79b5aaef4ac63da06a6b6b1dea3ddad90c4d4..0c59a7e3255c0097b19d6848f8d375e5cc61acd3 100644 (file)
@@ -546,12 +546,8 @@ static void _format1_destroy_instance(struct format_instance *fid)
 
 static void _format1_destroy(struct format_type *fmt)
 {
-       /* FIXME out of place, but the main (cmd) pool has been already
-        * destroyed and touching the fid (also via release_vg) will crash the
-        * program */
-       dm_hash_destroy(fmt->orphan_vg->hostnames);
-       dm_pool_destroy(fmt->orphan_vg->fid->mem);
-       dm_pool_destroy(fmt->orphan_vg->vgmem);
+       if (fmt->orphan_vg)
+               free_orphan_vg(fmt->orphan_vg);
 
        dm_free(fmt);
 }
index 1e742eaf0d6af3a95d2e6b41af7d052356ad4041..4e0600e9956e703e330a97845220925f52274732 100644 (file)
@@ -259,12 +259,8 @@ static void _pool_destroy_instance(struct format_instance *fid)
 
 static void _pool_destroy(struct format_type *fmt)
 {
-       /* FIXME out of place, but the main (cmd) pool has been already
-        * destroyed and touching the fid (also via release_vg) will crash the
-        * program */
-       dm_hash_destroy(fmt->orphan_vg->hostnames);
-       dm_pool_destroy(fmt->orphan_vg->fid->mem);
-       dm_pool_destroy(fmt->orphan_vg->vgmem);
+       if (fmt->orphan_vg)
+               free_orphan_vg(fmt->orphan_vg);
 
        dm_free(fmt);
 }
index 717db7491df2dc773d950771cbdba6090de76934..12e7a2ead1f6f572eb5efb971011200677e1fb43 100644 (file)
@@ -1541,13 +1541,8 @@ static void _free_raws(struct dm_list *raw_list)
 
 static void _text_destroy(struct format_type *fmt)
 {
-       /* FIXME out of place, but the main (cmd) pool has been already
-        * destroyed and touching the fid (also via release_vg) will crash the
-        * program */
-       dm_hash_destroy(fmt->orphan_vg->fid->metadata_areas_index);
-       dm_hash_destroy(fmt->orphan_vg->hostnames);
-       dm_pool_destroy(fmt->orphan_vg->fid->mem);
-       dm_pool_destroy(fmt->orphan_vg->vgmem);
+       if (fmt->orphan_vg)
+               free_orphan_vg(fmt->orphan_vg);
 
        if (fmt->private) {
                _free_dirs(&((struct mda_lists *) fmt->private)->dirs);
index 005f17d44646bfbc38926def4c7f504e7fe628aa..7def88513412e2b592b6032ebee80351d92597c5 100644 (file)
@@ -1551,7 +1551,6 @@ struct physical_volume * pvcreate_single(struct cmd_context *cmd,
        return pv;
 
 bad:
-       free_pv_fid(pv);
        return NULL;
 }
 
@@ -1575,6 +1574,7 @@ static struct physical_volume *_alloc_pv(struct dm_pool *mem, struct device *dev
 
 /**
  * pv_create - initialize a physical volume for use with a volume group
+ * created PV belongs to Orphan VG.
  *
  * @fmt: format type
  * @dev: PV device to initialize
@@ -1609,9 +1609,10 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
                                  unsigned metadataignore)
 {
        const struct format_type *fmt = cmd->fmt;
-       struct dm_pool *mem = fmt->cmd->mem;
+       struct dm_pool *mem = fmt->orphan_vg->vgmem;
        struct physical_volume *pv = _alloc_pv(mem, dev);
        unsigned mda_index;
+       struct pv_list *pvl;
 
        if (!pv)
                return_NULL;
@@ -1650,7 +1651,6 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
                goto bad;
        }
 
-       struct pv_list *pvl;
        if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
                log_error("pv_list allocation in pv_create failed");
                goto bad;
@@ -1687,8 +1687,9 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
        return pv;
 
       bad:
-       free_pv_fid(pv);
-       dm_pool_free(mem, pv);
+       // FIXME: detach from orphan in error path
+       //free_pv_fid(pv);
+       //dm_pool_free(mem, pv);
        return NULL;
 }
 
index 42cb48cfb5582dc3b93f63c8d322bf6595efe790..bae22dc8f4e93f508c2097ac20c66d06296db5bc 100644 (file)
@@ -90,6 +90,18 @@ void release_vg(struct volume_group *vg)
        _free_vg(vg);
 }
 
+/*
+ * FIXME out of place, but the main (cmd) pool has been already
+ * destroyed and touching the fid (also via release_vg) will crash the
+ * program
+ *
+ * For now quick wrapper to allow destroy of orphan vg
+ */
+void free_orphan_vg(struct volume_group *vg)
+{
+       _free_vg(vg);
+}
+
 char *vg_fmt_dup(const struct volume_group *vg)
 {
        if (!vg->fid || !vg->fid->fmt)
index f0437113dee429b9b11168c5c9d32d12bcc20502..f876968c3bb21065ec32df51450f528fcc844878 100644 (file)
@@ -121,6 +121,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
  * by vg_create() or vg_read_internal() to free it when no longer required.
  */
 void release_vg(struct volume_group *vg);
+void free_orphan_vg(struct volume_group *vg);
 
 char *vg_fmt_dup(const struct volume_group *vg);
 char *vg_name_dup(const struct volume_group *vg);
index da3862d536a75b4db011bf82f17c9ab0310fb51b..761fb18f3e85fdfb8dc2c6c9865b20dce4983a70 100644 (file)
@@ -117,7 +117,6 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
                        ret = ECMD_FAILED;
                }
 
-               free_pv_fid(pv);
                unlock_vg(cmd, VG_ORPHANS);
                if (sigint_caught())
                        return ret;
index 76da0d836e08726eb45c2f7ff92e02baed2072f3..0a8b9bf50e01e2d2f3863c84a0573e974df26d06 100644 (file)
@@ -146,7 +146,6 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
                                  pv_dev_name(pv));
                        log_error("Use pvcreate and vgcfgrestore to repair "
                                  "from archived metadata.");
-                       free_pv_fid(pv);
                        return ECMD_FAILED;
                }
 
@@ -157,13 +156,10 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
                                  pv_dev_name(pv));
                        log_error("Use pvcreate and vgcfgrestore to repair "
                                  "from archived metadata.");
-                       free_pv_fid(pv);
                        return ECMD_FAILED;
                }
                log_verbose("Physical volume \"%s\" successfully created",
                            pv_dev_name(pv));
-
-               free_pv_fid(pv);
        }
 
        log_verbose("Deleting existing metadata for VG %s", vg_name);
This page took 0.056706 seconds and 5 git commands to generate.