mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
thin: better thin snapshot error detection
While creating thin snapshot, we cannot use size argument.
This commit is contained in:
parent
1ef660be46
commit
1a6c892864
@ -235,35 +235,48 @@ static int _lvcreate_name_params(struct lvcreate_params *lp,
|
||||
static int _determine_snapshot_type(struct volume_group *vg,
|
||||
struct lvcreate_params *lp)
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
struct logical_volume *lv, *pool_lv = NULL;
|
||||
|
||||
if (!(lvl = find_lv_in_vg(vg, lp->origin))) {
|
||||
if (!(lv = find_lv(vg, lp->origin))) {
|
||||
log_error("Snapshot origin LV %s not found in Volume group %s.",
|
||||
lp->origin, vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lv_is_cache(lvl->lv)) {
|
||||
if (lv_is_cache(lv)) {
|
||||
log_error("Snapshot of cache LV is not yet supported.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lp->pool) {
|
||||
if (!(pool_lv = find_lv(vg, lp->pool))) {
|
||||
log_error("Thin pool volume %s not found in Volume group %s.",
|
||||
lp->pool, vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lv_is_thin_pool(pool_lv)) {
|
||||
log_error("Logical volume %s is not a thin pool volume.",
|
||||
display_lvname(pool_lv));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
|
||||
if (seg_is_thin(lp)) {
|
||||
if (lv_is_thin_volume(lv) && !lp->pool)
|
||||
lp->pool = first_seg(lv)->pool_lv->name;
|
||||
|
||||
if (seg_is_thin(lp) || lp->pool) {
|
||||
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
|
||||
return_0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!lv_is_thin_volume(lvl->lv)) {
|
||||
log_error("Please specify either size or extents with snapshots.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
|
||||
return_0;
|
||||
|
||||
lp->pool = first_seg(lvl->lv)->pool_lv->name;
|
||||
} else if (lp->pool) {
|
||||
log_error("Cannot specify size with thin pool snapshot.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user