mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cache: Properly rename origin LV tree when adding "_corig"
When creating a cache LV with a RAID origin, we need to ensure that the sub-LVs of that origin properly change their names to include the "_corig" extention of the top-level LV. We do this by first performing a 'lv_rename_update' before making the call to 'insert_layer_for_lv'.
This commit is contained in:
parent
fea8abe56a
commit
962a40b981
@ -1,5 +1,6 @@
|
||||
Version 2.02.107 -
|
||||
==================================
|
||||
When converting RAID origin to cache LV, properly rename sub-LVs.
|
||||
Use RemoveOnStop for lvm2-lvmetad.socket systemd unit.
|
||||
Add thin-generic configuration profile for generic thin settings.
|
||||
Fix crash when reporting of empty labels on pvs.
|
||||
|
@ -91,6 +91,8 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool,
|
||||
struct cmd_context *cmd = pool->vg->cmd;
|
||||
struct logical_volume *cache_lv;
|
||||
struct lv_segment *seg;
|
||||
int origin_name_len = strlen(origin->name);
|
||||
char origin_name[origin_name_len + 7]; /* + "_corig" and NULL */
|
||||
|
||||
if (!lv_is_cache_pool(pool)) {
|
||||
log_error(INTERNAL_ERROR
|
||||
@ -122,8 +124,23 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool,
|
||||
if (!(segtype = get_segtype_from_string(cmd, "cache")))
|
||||
return_NULL;
|
||||
|
||||
/*
|
||||
* insert_layer_for_lv does not rename the sub-LVs when adding
|
||||
* the suffix. So, we rename everything here and then change
|
||||
* only the top-level LV back before adding the layer.
|
||||
*/
|
||||
sprintf(origin_name, "%s_corig", origin->name);
|
||||
if (!lv_rename_update(cmd, origin, origin_name, 0)) {
|
||||
log_error("Failed to rename origin LV, %s", origin->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
origin_name[origin_name_len] = '\0';
|
||||
if (!(origin->name = dm_pool_strdup(origin->vg->vgmem, origin_name)))
|
||||
return_0;
|
||||
|
||||
cache_lv = origin;
|
||||
if (!insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig"))
|
||||
if (!(origin = insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig")))
|
||||
return_NULL;
|
||||
|
||||
seg = first_seg(cache_lv);
|
||||
|
44
test/shell/lvconvert-cache.sh
Normal file
44
test/shell/lvconvert-cache.sh
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
. lib/inittest
|
||||
|
||||
aux have_cache 1 3 0 || skip
|
||||
|
||||
aux prepare_vg 5 80
|
||||
|
||||
# lvcreate origin, lvcreate cache-pool, and lvconvert to cache
|
||||
lvcreate -l 2 -n $lv1 $vg
|
||||
lvcreate --type cache-pool -l 1 -n ${lv1}_cachepool $vg
|
||||
lvconvert --type cache --cachepool $vg/${lv1}_cachepool $vg/$lv1
|
||||
dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
|
||||
lvremove -ff $vg
|
||||
|
||||
# Bug 1095843
|
||||
# lvcreate RAID1 origin, lvcreate cache-pool, and lvconvert to cache
|
||||
lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg
|
||||
lvcreate --type cache-pool -l 1 -n ${lv1}_cachepool $vg
|
||||
lvconvert --type cache --cachepool $vg/${lv1}_cachepool $vg/$lv1
|
||||
lvs -a $vg/${lv1}_corig_rimage_0 # ensure images are properly renamed
|
||||
dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
|
||||
lvremove -ff $vg
|
||||
|
||||
# lvcreate RAID1 origin, lvcreate RAID1 cache-pool, and lvconvert to cache
|
||||
lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg
|
||||
lvcreate --type raid1 -m 1 -l 2 -n ${lv1}_cachepool $vg
|
||||
lvconvert --type cache-pool --yes $vg/${lv1}_cachepool
|
||||
#should lvs -a $vg/${lv1}_cdata_rimage_0 # ensure images are properly renamed
|
||||
lvconvert --type cache --cachepool $vg/${lv1}_cachepool $vg/$lv1
|
||||
lvs -a $vg/${lv1}_corig_rimage_0 # ensure images are properly renamed
|
||||
dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
|
||||
lvremove -ff $vg
|
||||
|
||||
vgremove -f $vg
|
@ -69,14 +69,20 @@ lvremove -f $vg/cache_pool
|
||||
#lvcreate -H -l 2 $vg/cache_pool -n $lv1
|
||||
#lvremove -f $vg
|
||||
|
||||
if [ 1 -eq 0 ]; then
|
||||
# Bug 1110026
|
||||
# Create origin, then cache_pool and cache
|
||||
# FIXME: This case needs to use lvconvert
|
||||
lvcreate -l 2 -n $lv1 $vg
|
||||
lvconvert --type cache -l 1 $vg/$lv1 $mode
|
||||
dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
|
||||
lvcreate --type cache -l 1 $vg/$lv1
|
||||
#should dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
|
||||
lvremove -ff $vg
|
||||
|
||||
# Bug 1110026 & Bug 1095843
|
||||
# Create RAID1 origin, then cache_pool and cache
|
||||
lvcreate -l 2 -n $lv1 $vg
|
||||
lvcreate --type cache -l 1 $vg/$lv1
|
||||
#should lvs -a $vg/${lv1}_corig_rimage_0 # ensure images are properly renamed
|
||||
#should dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
|
||||
lvremove -ff $vg
|
||||
fi
|
||||
|
||||
# Shorthand CLI (origin exists, create cache_pool and cache)
|
||||
#lvcreate -l 1 -n $lv1 $vg
|
||||
|
Loading…
Reference in New Issue
Block a user