mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lv: swap more lv properties
When using swap_lv_identifiers() we were basiclly exchanging 'names' and only according to the caller some more data were 'transfered'. However in most cases we should swap properties like 'hostname' as the creation information should be preserved. So let's do the function more universal.
This commit is contained in:
parent
457bd1392a
commit
7ae9662b4e
@ -43,12 +43,38 @@ int lvconvert_mirror_finish(struct cmd_context *cmd,
|
||||
int swap_lv_identifiers(struct cmd_context *cmd,
|
||||
struct logical_volume *a, struct logical_volume *b)
|
||||
{
|
||||
union lvid lvid;
|
||||
struct logical_volume tlv = *a;
|
||||
const char *aname = a->name, *bname = b->name;
|
||||
|
||||
lvid = a->lvid;
|
||||
a->lvid = b->lvid;
|
||||
b->lvid = lvid;
|
||||
b->lvid = tlv.lvid;
|
||||
|
||||
a->alloc = b->alloc;
|
||||
b->alloc = tlv.alloc;
|
||||
|
||||
a->read_ahead = b->read_ahead;
|
||||
b->read_ahead = tlv.read_ahead;
|
||||
|
||||
a->profile = b->profile;
|
||||
b->profile = tlv.profile;
|
||||
|
||||
a->major = b->major;
|
||||
b->major = tlv.major;
|
||||
|
||||
a->minor = b->minor;
|
||||
b->minor = tlv.minor;
|
||||
|
||||
a->timestamp = b->timestamp;
|
||||
b->timestamp = tlv.timestamp;
|
||||
|
||||
a->hostname = b->hostname;
|
||||
b->hostname = tlv.hostname;
|
||||
|
||||
/* swap tags */
|
||||
dm_list_init(&tlv.tags);
|
||||
dm_list_splice(&tlv.tags, &a->tags);
|
||||
dm_list_splice(&a->tags, &b->tags);
|
||||
dm_list_splice(&b->tags, &tlv.tags);
|
||||
|
||||
/* rename temporarily to 'unused' name */
|
||||
if (!lv_rename_update(cmd, a, "pmove_tmeta", 0))
|
||||
@ -63,25 +89,6 @@ int swap_lv_identifiers(struct cmd_context *cmd,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _move_lv_attributes(struct logical_volume *to, struct logical_volume *from)
|
||||
{
|
||||
/* Maybe move this code into thin_merge_finish() */
|
||||
to->status = from->status; // FIXME maybe some masking ?
|
||||
to->alloc = from->alloc;
|
||||
to->profile = from->profile;
|
||||
to->read_ahead = from->read_ahead;
|
||||
to->major = from->major;
|
||||
to->minor = from->minor;
|
||||
to->timestamp = from->timestamp;
|
||||
to->hostname = from->hostname;
|
||||
|
||||
/* Move tags */
|
||||
dm_list_init(&to->tags);
|
||||
dm_list_splice(&to->tags, &from->tags);
|
||||
|
||||
/* Anything else to preserve? */
|
||||
}
|
||||
|
||||
/* Finalise merging of lv into merge_lv */
|
||||
int thin_merge_finish(struct cmd_context *cmd,
|
||||
struct logical_volume *merge_lv,
|
||||
@ -93,8 +100,8 @@ int thin_merge_finish(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Preserve origins' attributes */
|
||||
_move_lv_attributes(lv, merge_lv);
|
||||
/* Preserve status */
|
||||
lv->status = merge_lv->status;
|
||||
|
||||
/* Removed LV has to be visible */
|
||||
if (!lv_remove_single(cmd, merge_lv, DONT_PROMPT, 1))
|
||||
|
Loading…
Reference in New Issue
Block a user