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

cache: support cached origin for snapshot

Enable  'lvcreate/lvconvert -s' for cached LV.
and supported operations:

Create a snapshot of cached LV

Split/Join snapshot LV to cached origin LV.
This commit is contained in:
Zdenek Kabelac 2016-12-19 14:08:56 +01:00
parent eb3f83357a
commit 0c56eb8f43
4 changed files with 18 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
Enable usage of cached volumes as snapshot origin LV.
Fix displayed lv name when splitting snapshot (2.02.146).
Warn about command not making metadata backup just once per command.
Enable usage of cached volume as thin volume's external origin.

View File

@ -322,7 +322,7 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv)
if (lv_is_cache_type(origin_lv) ||
lv_is_mirror_type(origin_lv) ||
lv_is_thin_volume(origin_lv) || lv_is_thin_pool_metadata(origin_lv) ||
lv_is_origin(origin_lv) || lv_is_merging_origin(origin_lv) ||
lv_is_merging_origin(origin_lv) ||
lv_is_cow(origin_lv) || lv_is_merging_cow(origin_lv) ||
lv_is_virtual(origin_lv)) {
log_error("Cache is not supported with %s segment type of the original logical volume %s.",

View File

@ -7428,7 +7428,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
if (lv_is_cache_type(origin_lv)) {
if (lv_is_cache_type(origin_lv) && !lv_is_cache(origin_lv)) {
log_error("Snapshots of cache type volume %s "
"is not supported.", display_lvname(origin_lv));
return NULL;

View File

@ -2336,7 +2336,7 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
return_0;
if (lv_is_locked(org) ||
lv_is_cache_type(org) ||
(lv_is_cache_type(org) && !lv_is_cache(org)) ||
lv_is_thin_type(org) ||
lv_is_pvmove(org) ||
lv_is_mirrored(org) ||
@ -3770,6 +3770,16 @@ static int _convert_cache_volume_thin_pool(struct cmd_context *cmd, struct logic
return 1;
}
/*
* Convert/Recombine cacheLV to be an origin for snapshot
* lvconvert --type snapshot cacheLV snapshotLV
*/
static int _convert_cache_volume_snapshot(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_snapshot(cmd, lv, lp);
}
/*
* Split a cache volume from a cache pool LV.
* lvconvert --splitcache LV
@ -4311,6 +4321,10 @@ static int _convert_cache_volume(struct cmd_context *cmd, struct logical_volume
arg_is_set(cmd, thinpool_ARG))
return _convert_cache_volume_thin_pool(cmd, lv, lp);
if (!strcmp(lp->type_str, SEG_TYPE_NAME_SNAPSHOT) ||
arg_is_set(cmd, snapshot_ARG))
return _convert_cache_volume_snapshot(cmd, lv, lp);
/* The --thinpool alternative for --type thin-pool is not preferred, so not shown. */
log_error("Operation not permitted on cache LV %s.", display_lvname(lv));