summaryrefslogtreecommitdiffstats
path: root/tools/pvchange.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2005-05-24 17:38:26 +0000
committerAlasdair Kergon <agk@redhat.com>2005-05-24 17:38:26 +0000
commitbd236f658d9b876642d4347362627a44aa71bfde (patch)
tree2132a1d4e8feff29f761d55d3454a09e636bd1b0 /tools/pvchange.c
parent3f910647c3737af94cbe73729ceb70c9d9214bbc (diff)
downloadlvm2-bd236f658d9b876642d4347362627a44aa71bfde.tar.gz
lvm2-bd236f658d9b876642d4347362627a44aa71bfde.tar.xz
lvm2-bd236f658d9b876642d4347362627a44aa71bfde.zip
Fix non-orphan pvchange -u.
Diffstat (limited to 'tools/pvchange.c')
-rw-r--r--tools/pvchange.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 5a8cf6c8..1526a03b 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -24,9 +24,12 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
struct pv_list *pvl;
struct list mdas;
uint64_t sector;
+ uint32_t orig_pe_alloc_count;
const char *pv_name = dev_name(pv->dev);
const char *tag = NULL;
+ const char *orig_vg_name;
+ char uuid[64];
int consistent = 1;
int allocatable = 0;
@@ -178,6 +181,24 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
pv_name);
return 0;
}
+ if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
+ stack;
+ return 0;
+ }
+ log_verbose("Changing uuid of %s to %s.", pv_name, uuid);
+ if (*pv->vg_name) {
+ orig_vg_name = pv->vg_name;
+ orig_pe_alloc_count = pv->pe_alloc_count;
+ pv->vg_name = ORPHAN;
+ pv->pe_alloc_count = 0;
+ if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
+ log_error("pv_write with new uuid failed "
+ "for %s.", pv_name);
+ return 0;
+ }
+ pv->vg_name = orig_vg_name;
+ pv->pe_alloc_count = orig_pe_alloc_count;
+ }
}
log_verbose("Updating physical volume \"%s\"", pv_name);