mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Allow to activate snapshot
Add extra code to active and deactivate related snapshots and origin when user specifies snapshot logical volume as lvchange parameter. Before patch: $> lvs -a LV VG Attr LSize Pool Origin Snap% Move Log Copy% Convert lvol0 mvg owi-a-s- 1.00k lvol1 mvg swi-a-s- 16.00k lvol0 0.00 lvol2 mvg swi-a-s- 16.00k lvol0 0.00 $> lvchange -an mvg/lvol2; echo $? Can't change snapshot logical volume "lvol2". 5 After patch: $> lvchange -an mvg/lvol2 Change of snapshot lvol2 will also change its origin lvol0 and 1 other snapshot(s). Proceed? [y/n]: n Logical volume lvol2 not changed. $> lvchange -y -an mvg/lvol2; echo $? 0 $> lvs -a LV VG Attr LSize Pool Origin Snap% Move Log Copy% Convert lvol0 mvg owi---s- 1.00k lvol1 mvg swi---s- 16.00k lvol0 lvol2 mvg swi---s- 16.00k lvol0
This commit is contained in:
parent
e858ac1546
commit
e8a40f6571
@ -1,6 +1,7 @@
|
|||||||
Version 2.02.89 -
|
Version 2.02.89 -
|
||||||
==================================
|
==================================
|
||||||
Skip non-virtual origins for availability change for lvchange.
|
Allow changing availability state of snapshots.
|
||||||
|
Skip non-virtual snapshots for availability change for lvchange with vg name.
|
||||||
Adjusted mirror region size only for mirrors and raids.
|
Adjusted mirror region size only for mirrors and raids.
|
||||||
Reorder prompt conditions for removal of active volumes.
|
Reorder prompt conditions for removal of active volumes.
|
||||||
Avoid 'mda inconsistency' by properly registering UNLABELLED_PV flag (2.02.86).
|
Avoid 'mda inconsistency' by properly registering UNLABELLED_PV flag (2.02.86).
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of LVM2.
|
* This file is part of LVM2.
|
||||||
*
|
*
|
||||||
@ -125,6 +125,9 @@ static int lvchange_availability(struct cmd_context *cmd,
|
|||||||
|
|
||||||
activate = arg_uint_value(cmd, available_ARG, 0);
|
activate = arg_uint_value(cmd, available_ARG, 0);
|
||||||
|
|
||||||
|
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)))
|
||||||
|
lv = origin_from_cow(lv);
|
||||||
|
|
||||||
if (activate == CHANGE_ALN) {
|
if (activate == CHANGE_ALN) {
|
||||||
log_verbose("Deactivating logical volume \"%s\" locally",
|
log_verbose("Deactivating logical volume \"%s\" locally",
|
||||||
lv->name);
|
lv->name);
|
||||||
@ -515,6 +518,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
int doit = 0, docmds = 0;
|
int doit = 0, docmds = 0;
|
||||||
int dmeventd_mode, archived = 0;
|
int dmeventd_mode, archived = 0;
|
||||||
struct logical_volume *origin;
|
struct logical_volume *origin;
|
||||||
|
char snaps_msg[128];
|
||||||
|
|
||||||
if (!(lv->vg->status & LVM_WRITE) &&
|
if (!(lv->vg->status & LVM_WRITE) &&
|
||||||
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
|
||||||
@ -534,11 +538,24 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)) &&
|
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin = origin_from_cow(lv)) &&
|
||||||
arg_count(cmd, available_ARG)) {
|
arg_count(cmd, available_ARG)) {
|
||||||
log_error("Can't change snapshot logical volume \"%s\"",
|
if (origin->origin_count < 2)
|
||||||
lv->name);
|
snaps_msg[0] = '\0';
|
||||||
return ECMD_FAILED;
|
else if (dm_snprintf(snaps_msg, sizeof(snaps_msg),
|
||||||
|
" and %u other snapshot(s)",
|
||||||
|
origin->origin_count - 1) < 0) {
|
||||||
|
log_error("Failed to prepare message.");
|
||||||
|
return ECMD_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!arg_count(cmd, yes_ARG) &&
|
||||||
|
(yes_no_prompt("Change of snapshot %s will also change its"
|
||||||
|
" origin %s%s. Proceed? [y/n]: ", lv->name,
|
||||||
|
origin->name, snaps_msg) == 'n')) {
|
||||||
|
log_error("Logical volume %s not changed.", lv->name);
|
||||||
|
return ECMD_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lv->status & PVMOVE) {
|
if (lv->status & PVMOVE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user