1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvconvert: uncache handles missing PV

Allow to process with --uncache when some PVs are missing in VG.

So it's now possible to --uncache cached LV if the cache-pool
has missing PV.
This commit is contained in:
Zdenek Kabelac 2016-03-08 10:47:27 +01:00
parent 29d1533a49
commit 569ba79abf
2 changed files with 46 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.146 -
=================================
Support --uncache with missing PVs.
Tidy report field names, headings and widths.
Add vgscan --notifydbus to send a dbus notification.
Add dbus notification from commands after a PV/VG/LV changes state.

View File

@ -1997,6 +1997,9 @@ static int _lvconvert_uncache(struct cmd_context *cmd,
struct logical_volume *lv,
struct lvconvert_params *lp)
{
struct lv_segment *seg;
struct logical_volume *remove_lv;
if (lv_is_thin_pool(lv))
lv = seg_lv(first_seg(lv), 0); /* cached _tdata ? */
@ -2006,10 +2009,49 @@ static int _lvconvert_uncache(struct cmd_context *cmd,
return 0;
}
if (!lv_remove_single(cmd, first_seg(lv)->pool_lv, (force_t) lp->force, 0))
seg = first_seg(lv);
if (lv_is_partial(seg_lv(seg, 0))) {
log_warn("WARNING: Cache origin logical volume %s is missing.",
display_lvname(seg_lv(seg, 0)));
remove_lv = lv; /* When origin is missing, drop everything */
} else
remove_lv = seg->pool_lv;
if (lv_is_partial(seg_lv(first_seg(seg->pool_lv), 0)))
log_warn("WARNING: Cache pool data logical volume %s is missing.",
display_lvname(seg_lv(first_seg(seg->pool_lv), 0)));
if (lv_is_partial(first_seg(seg->pool_lv)->metadata_lv))
log_warn("WARNING: Cache pool metadata logical volume %s is missing.",
display_lvname(first_seg(seg->pool_lv)->metadata_lv));
/* TODO: Check for failed cache as well to get prompting? */
if (lv_is_partial(lv)) {
if (strcmp("writethrough", get_cache_mode_name(first_seg(seg->pool_lv)))) {
if (!lp->force) {
log_error("Conversion aborted.");
log_error("Cannot uncache writethrough cache volume %s without --force.",
display_lvname(lv));
return 0;
}
log_warn("WARNING: Uncaching of partially missing writethrough cache volume %s might destroy your data.",
display_lvname(first_seg(seg->pool_lv)->metadata_lv));
}
if (!lp->yes &&
yes_no_prompt("Do you really want to uncache %s? with missing LVs [y/n]: ",
display_lvname(lv)) == 'n') {
log_error("Conversion aborted.");
return 0;
}
}
if (!lvremove_single(cmd, remove_lv, NULL))
return_0;
log_print_unless_silent("Logical volume %s is not cached.", display_lvname(lv));
if (remove_lv != lv)
log_print_unless_silent("Logical volume %s is not cached.", display_lvname(lv));
return 1;
}
@ -3421,7 +3463,7 @@ static int lvconvert_single(struct cmd_context *cmd, struct lvconvert_params *lp
int saved_ignore_suspended_devices = ignore_suspended_devices();
uint32_t lockd_state = 0;
if (lp->repair) {
if (lp->repair || lp->uncache) {
init_ignore_suspended_devices(1);
cmd->handles_missing_pvs = 1;
}