1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00

Add old_uuid field to struct physical_volume so we can still reference a PV

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!)
This commit is contained in:
Peter Rajnoha 2011-02-21 12:31:28 +00:00
parent 6bdc80743e
commit 51aed1992f
3 changed files with 7 additions and 5 deletions

View 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 text_fid_pv_context *fid_pv_tc;
struct format_instance *fid = pv->fid; struct format_instance *fid = pv->fid;
const char *pvid = (const char *) (*pv->old_id.uuid ? &pv->old_id : &pv->id);
struct label *label; struct label *label;
int64_t label_sector; int64_t label_sector;
struct lvmcache_info *info; 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. * just pass the right format_instance in.
*/ */
for (mda_index = 0; mda_index < FMT_TEXT_MAX_MDAS_PER_PV; mda_index++) { 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, if (!(mda = fid_get_mda_indexed(fid, pvid, ID_LEN, mda_index)))
ID_LEN, mda_index)))
continue; continue;
mdac = (struct mda_context *) mda->metadata_locn; 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 volume_group *vg)
{ {
struct format_instance *fid = pv->fid; 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; unsigned mda_index;
struct metadata_area *pv_mda; struct metadata_area *pv_mda;
struct mda_context *pv_mdac; struct mda_context *pv_mdac;
@ -1879,7 +1879,7 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
unsigned mda_ignored) unsigned mda_ignored)
{ {
struct format_instance *fid = pv->fid; 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 pe_start, pe_end;
uint64_t alignment, alignment_offset; uint64_t alignment, alignment_offset;
uint64_t disk_size; uint64_t disk_size;
@ -2099,7 +2099,7 @@ static int _text_pv_resize(const struct format_type *fmt,
uint64_t size) uint64_t size)
{ {
struct format_instance *fid = pv->fid; 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 metadata_area *mda;
struct mda_context *mdac; struct mda_context *mdac;
uint64_t size_reduction; uint64_t size_reduction;

View File

@ -22,6 +22,7 @@ struct volume_group;
struct physical_volume { struct physical_volume {
struct id id; struct id id;
struct id old_id; /* Set during pvchange -u. */
struct device *dev; struct device *dev;
const struct format_type *fmt; const struct format_type *fmt;
struct format_instance *fid; struct format_instance *fid;

View File

@ -120,6 +120,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
if (arg_count(cmd, uuid_ARG)) { if (arg_count(cmd, uuid_ARG)) {
/* --uuid: Change PV ID randomly */ /* --uuid: Change PV ID randomly */
memcpy(&pv->old_id, &pv->id, sizeof(pv->id));
if (!id_create(&pv->id)) { if (!id_create(&pv->id)) {
log_error("Failed to generate new random UUID for %s.", log_error("Failed to generate new random UUID for %s.",
pv_name); pv_name);