1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Permit snapshots of mirrors. (brassow)

This commit is contained in:
Alasdair Kergon 2009-10-26 10:01:56 +00:00
parent 4424497f65
commit 984abde146
7 changed files with 42 additions and 22 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.54 - Version 2.02.54 -
===================================== =====================================
Permit snapshots of mirrors.
Cleanup mimagetmp LV if allocation fails for new lvconvert mimage. Cleanup mimagetmp LV if allocation fails for new lvconvert mimage.
Fix clvmd segfault when refresh_toolcontext fails. Fix clvmd segfault when refresh_toolcontext fails.
Remember to clear 'global lock held during cache refresh' state after use. Remember to clear 'global lock held during cache refresh' state after use.

View File

@ -551,16 +551,17 @@ int dev_manager_mirror_percent(struct dev_manager *dm,
{ {
char *name; char *name;
const char *dlid; const char *dlid;
const char *suffix = (lv_is_origin(lv)) ? "real" : NULL;
/* /*
* Build a name for the top layer. * Build a name for the top layer.
*/ */
if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, NULL))) if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, suffix)))
return_0; return_0;
/* FIXME dm_pool_free ? */ /* FIXME dm_pool_free ? */
if (!(dlid = build_dlid(dm, lv->lvid.s, NULL))) { if (!(dlid = build_dlid(dm, lv->lvid.s, suffix))) {
log_error("dlid build failed for %s", lv->name); log_error("dlid build failed for %s", lv->name);
return 0; return 0;
} }

View File

@ -480,7 +480,7 @@ int lvdisplay_full(struct cmd_context *cmd,
struct lvinfo info; struct lvinfo info;
int inkernel, snap_active = 0; int inkernel, snap_active = 0;
char uuid[64] __attribute((aligned(8))); char uuid[64] __attribute((aligned(8)));
struct lv_segment *snap_seg = NULL; struct lv_segment *snap_seg = NULL, *mirror_seg = NULL;
float snap_percent; /* fused, fsize; */ float snap_percent; /* fused, fsize; */
percent_range_t percent_range; percent_range_t percent_range;
@ -563,6 +563,13 @@ int lvdisplay_full(struct cmd_context *cmd,
display_size(cmd, (uint64_t) snap_seg->chunk_size)); display_size(cmd, (uint64_t) snap_seg->chunk_size));
} }
if (lv->status & MIRRORED) {
mirror_seg = first_seg(lv);
log_print("Mirrored volumes %" PRIu32, mirror_seg->area_count);
if (lv->status & CONVERTING)
log_print("LV type Mirror undergoing conversion");
}
log_print("Segments %u", dm_list_size(&lv->segments)); log_print("Segments %u", dm_list_size(&lv->segments));
/********* FIXME Stripes & stripesize for each segment /********* FIXME Stripes & stripesize for each segment

View File

@ -2936,11 +2936,12 @@ int lv_create_single(struct volume_group *vg,
"supported yet"); "supported yet");
return 0; return 0;
} }
if (org->status & MIRROR_IMAGE || if ((org->status & MIRROR_IMAGE) ||
org->status & MIRROR_LOG || (org->status & MIRROR_LOG)) {
org->status & MIRRORED) { log_error("Snapshots of mirror %ss "
log_error("Snapshots and mirrors may not yet " "are not supported",
"be mixed."); (org->status & MIRROR_LOG) ?
"log" : "image");
return 0; return 0;
} }

View File

@ -311,6 +311,11 @@ static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_
repstr[0] = 'p'; repstr[0] = 'p';
else if (lv->status & CONVERTING) else if (lv->status & CONVERTING)
repstr[0] = 'c'; repstr[0] = 'c';
else if (lv->status & VIRTUAL)
repstr[0] = 'v';
/* Origin takes precedence over Mirror */
else if (lv_is_origin(lv))
repstr[0] = 'o';
else if (lv->status & MIRRORED) { else if (lv->status & MIRRORED) {
if (lv->status & MIRROR_NOTSYNCED) if (lv->status & MIRROR_NOTSYNCED)
repstr[0] = 'M'; repstr[0] = 'M';
@ -323,10 +328,6 @@ static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_
repstr[0] = 'I'; repstr[0] = 'I';
else if (lv->status & MIRROR_LOG) else if (lv->status & MIRROR_LOG)
repstr[0] = 'l'; repstr[0] = 'l';
else if (lv->status & VIRTUAL)
repstr[0] = 'v';
else if (lv_is_origin(lv))
repstr[0] = 'o';
else if (lv_is_cow(lv)) else if (lv_is_cow(lv))
repstr[0] = 's'; repstr[0] = 's';
else else

View File

@ -713,6 +713,20 @@ static int _lvconvert_mirrors(struct cmd_context *cmd, struct logical_volume *lv
"LV: use lvchange --resync first."); "LV: use lvchange --resync first.");
return 0; return 0;
} }
/*
* We allow snapshots of mirrors, but for now, we
* do not allow up converting mirrors that are under
* snapshots. The layering logic is somewhat complex,
* and preliminary test show that the conversion can't
* seem to get the correct %'age of completion.
*/
if (lv_is_origin(lv)) {
log_error("Can't add additional mirror images to "
"mirrors that are under snapshots");
return 0;
}
/* /*
* Log addition/removal should be done before the layer * Log addition/removal should be done before the layer
* insertion to make the end result consistent with * insertion to make the end result consistent with
@ -891,12 +905,6 @@ static int lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_FAILED; return ECMD_FAILED;
} }
if (lv_is_origin(lv)) {
log_error("Can't convert logical volume \"%s\" under snapshot",
lv->name);
return ECMD_FAILED;
}
if (lv_is_cow(lv)) { if (lv_is_cow(lv)) {
log_error("Can't convert snapshot logical volume \"%s\"", log_error("Can't convert snapshot logical volume \"%s\"",
lv->name); lv->name);

View File

@ -411,14 +411,15 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
if (!(_move_lvs(vg_from, vg_to))) if (!(_move_lvs(vg_from, vg_to)))
goto_bad; goto_bad;
/* Move required snapshots across */ /* FIXME Separate the 'move' from the 'validation' to fix dev stacks */
if (!(_move_snapshots(vg_from, vg_to)))
goto_bad;
/* Move required mirrors across */ /* Move required mirrors across */
if (!(_move_mirrors(vg_from, vg_to))) if (!(_move_mirrors(vg_from, vg_to)))
goto_bad; goto_bad;
/* Move required snapshots across */
if (!(_move_snapshots(vg_from, vg_to)))
goto_bad;
/* Split metadata areas and check if both vgs have at least one area */ /* Split metadata areas and check if both vgs have at least one area */
if (!(vg_split_mdas(cmd, vg_from, vg_to)) && vg_from->pv_count) { if (!(vg_split_mdas(cmd, vg_from, vg_to)) && vg_from->pv_count) {
log_error("Cannot split: Nowhere to store metadata for new Volume Group"); log_error("Cannot split: Nowhere to store metadata for new Volume Group");