From 077b46e014088161a16c54c19bace8f52ee9b5e4 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 10 Jul 2023 15:43:49 +0200 Subject: [PATCH] lv_manip: fix move_lv_segments moved bits For proper functionality of insert_layer_for_lv we need to move more bits to layerd LV. Add some missing new types and correct usage of caller, so the new LV type is set after the movement. --- lib/metadata/cache_manip.c | 2 +- lib/metadata/integrity_manip.c | 2 +- lib/metadata/lv_manip.c | 12 +++++++++++- tools/lvconvert.c | 8 +++----- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c index efcba2a1c..a0094b039 100644 --- a/lib/metadata/cache_manip.c +++ b/lib/metadata/cache_manip.c @@ -421,7 +421,7 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv, if (!(segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_CACHE))) return_NULL; - if (!insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig")) + if (!insert_layer_for_lv(cmd, cache_lv, 0, "_corig")) return_NULL; seg = first_seg(cache_lv); diff --git a/lib/metadata/integrity_manip.c b/lib/metadata/integrity_manip.c index 6b507f7e9..bfe91aaa7 100644 --- a/lib/metadata/integrity_manip.c +++ b/lib/metadata/integrity_manip.c @@ -677,7 +677,7 @@ int lv_add_integrity_to_raid(struct logical_volume *lv, struct integrity_setting * but gets a new integrity segment, in place of the segments * that were moved to lv_iorig. */ - if (!insert_layer_for_lv(cmd, lv_image, INTEGRITY, "_iorig")) + if (!insert_layer_for_lv(cmd, lv_image, 0, "_iorig")) goto_bad; lv_image->status |= INTEGRITY; diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 8a4fe8848..385903539 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -8213,7 +8213,17 @@ int move_lv_segments(struct logical_volume *lv_to, struct logical_volume *lv_from, uint64_t set_status, uint64_t reset_status) { - const uint64_t MOVE_BITS = (RAID | MIRROR | THIN_VOLUME | CACHE | LV_VDO); + const uint64_t MOVE_BITS = (CACHE | + CACHE_POOL | + INTEGRITY | + LV_CACHE_VOL | + LV_VDO | + LV_VDO_POOL | + MIRROR | + RAID | + THIN_POOL | + THIN_VOLUME | + WRITECACHE); struct lv_segment *seg; dm_list_iterate_items(seg, &lv_to->segments) diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 8410ebbb0..74c498260 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -5876,23 +5876,21 @@ static struct logical_volume *_lv_writecache_create(struct cmd_context *cmd, if (!(segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_WRITECACHE))) return_NULL; - lv->status |= WRITECACHE; - /* * "lv_wcorig" is a new LV with new id, but with the segments from "lv". * "lv" keeps the existing name and id, but gets a new writecache segment, * in place of the segments that were moved to lv_wcorig. */ - if (!(lv_wcorig = insert_layer_for_lv(cmd, lv, WRITECACHE, "_wcorig"))) + if (!(lv_wcorig = insert_layer_for_lv(cmd, lv, 0, "_wcorig"))) return_NULL; - lv_set_hidden(lv_fast); - + lv->status |= WRITECACHE; seg = first_seg(lv); seg->segtype = segtype; seg->writecache = lv_fast; + lv_set_hidden(lv_fast); /* writecache_block_size is in bytes */ seg->writecache_block_size = block_size_sectors * 512;