mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-31 14:50:37 +03:00
Do not allow merging over mounted logical volumes.
When preserving origin, check that the snapshot is not mounted.
This commit is contained in:
parent
154b64d7a5
commit
3869eff08d
@ -1058,6 +1058,7 @@ static int lvconvert_merge(struct cmd_context *cmd,
|
||||
int r = 0;
|
||||
struct logical_volume *origin = origin_from_cow(lv);
|
||||
struct lv_segment *cow_seg = find_cow(lv);
|
||||
struct lvinfo info;
|
||||
|
||||
/* Check if merge is possible */
|
||||
if (cow_seg->status & SNAPSHOT_MERGE) {
|
||||
@ -1070,6 +1071,27 @@ static int lvconvert_merge(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent merge with open device(s) as it would likely lead
|
||||
* to application/filesystem failure.
|
||||
*
|
||||
* FIXME testing open_count is racey; snapshot-merge target's
|
||||
* constructor and DM should prevent appropriate devices from
|
||||
* being open.
|
||||
*/
|
||||
if (lv_info(cmd, origin, &info, 1, 0)) {
|
||||
if (info.open_count) {
|
||||
log_error("Can't merge over open origin volume");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (lv_info(cmd, lv, &info, 1, 0)) {
|
||||
if (info.open_count) {
|
||||
log_error("Can't merge when snapshot is open");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
init_snapshot_merge(cow_seg, origin);
|
||||
|
||||
/* store vg on disk(s) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user