]> sourceware.org Git - lvm2.git/commitdiff
Add old_uuid field to struct physical_volume so we can still reference a PV
authorPeter Rajnoha <prajnoha@redhat.com>
Mon, 21 Feb 2011 12:31:28 +0000 (12:31 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Mon, 21 Feb 2011 12:31:28 +0000 (12:31 +0000)
with its old UUID when we're changig it (the cache as well as metadata area
index has the old uuid that we need to use to access the information!)

lib/format_text/format-text.c
lib/metadata/pv.h
tools/pvchange.c

index 4d387e31f69019a8b14260da874c929e04eae738..c5f58301aff8cd11c5b36ae05c264f4f2b8eb4ca 100644 (file)
@@ -1260,6 +1260,7 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
 {
        struct text_fid_pv_context *fid_pv_tc;
        struct format_instance *fid = pv->fid;
+       const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id);
        struct label *label;
        int64_t label_sector;
        struct lvmcache_info *info;
@@ -1303,8 +1304,7 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
         * just pass the right format_instance in.
         */
        for (mda_index = 0; mda_index < FMT_TEXT_MAX_MDAS_PER_PV; mda_index++) {
-               if (!(mda = fid_get_mda_indexed(fid, (const char *) &pv->id,
-                                                       ID_LEN, mda_index)))
+               if (!(mda = fid_get_mda_indexed(fid, pvid, ID_LEN, mda_index)))
                        continue;
 
                mdac = (struct mda_context *) mda->metadata_locn;
@@ -1644,7 +1644,7 @@ static int _text_pv_setup(const struct format_type *fmt,
                          struct volume_group *vg)
 {
        struct format_instance *fid = pv->fid;
-       const char *pvid = (const char *) &pv->id;
+       const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id);
        unsigned mda_index;
        struct metadata_area *pv_mda;
        struct mda_context *pv_mdac;
@@ -1879,7 +1879,7 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
                                      unsigned mda_ignored)
 {
        struct format_instance *fid = pv->fid;
-       const char *pvid = (char *) &pv->id;
+       const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id);
        uint64_t pe_start, pe_end;
        uint64_t alignment, alignment_offset;
        uint64_t disk_size;
@@ -2099,7 +2099,7 @@ static int _text_pv_resize(const struct format_type *fmt,
                           uint64_t size)
 {
        struct format_instance *fid = pv->fid;
-       const char *pvid = (const char *) &pv->id;
+       const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id);
        struct metadata_area *mda;
        struct mda_context *mdac;
        uint64_t size_reduction;
index a9efcfe108038228149a900918f070199d28c297..af636103403dbbb8d1f60c110bca64d577c41dfa 100644 (file)
@@ -22,6 +22,7 @@ struct volume_group;
 
 struct physical_volume {
        struct id id;
+       struct id old_id;               /* Set during pvchange -u. */
        struct device *dev;
        const struct format_type *fmt;
        struct format_instance *fid;
index 0ffe7df4397757d75cf1572100f92f8451b57799..254cf91324a368ce46674aa2096500de9625d5e1 100644 (file)
@@ -120,6 +120,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
 
        if (arg_count(cmd, uuid_ARG)) {
                /* --uuid: Change PV ID randomly */
+               memcpy(&pv->old_id, &pv->id, sizeof(pv->id));
                if (!id_create(&pv->id)) {
                        log_error("Failed to generate new random UUID for %s.",
                                  pv_name);
This page took 0.036999 seconds and 5 git commands to generate.