From 9bbbc1b26545d44f0ad393ab4a63ab3a68ca81c6 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 4 Jul 2023 13:29:00 +0200 Subject: [PATCH] cachepool: skip wipe for nonzeroeable segments Avoid activation when going to skip zeroing of 'error' segtype (so it's not erroring out). Also skip zeroing for 'zero' segtype LV (already being zero). --- lib/metadata/cache_manip.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c index 4c5b37b60..9e156995e 100644 --- a/lib/metadata/cache_manip.c +++ b/lib/metadata/cache_manip.c @@ -1249,6 +1249,7 @@ int cache_set_params(struct lv_segment *seg, int wipe_cache_pool(struct logical_volume *cache_pool_lv) { int r; + struct logical_volume *cache_data_lv; /* Only unused cache-pool could be activated and wiped */ if (lv_is_used_cache_pool(cache_pool_lv) || lv_is_cache_vol(cache_pool_lv)) { @@ -1257,6 +1258,16 @@ int wipe_cache_pool(struct logical_volume *cache_pool_lv) return 0; } + cache_data_lv = (lv_is_cache_pool(cache_pool_lv)) ? + seg_lv(first_seg(cache_pool_lv), 0) : cache_pool_lv; + + if (cache_data_lv && seg_cannot_be_zeroed(first_seg(cache_data_lv))) { + log_debug("Skipping wipe of %s volume with %s segtype.", + display_lvname(cache_data_lv), + first_seg(cache_data_lv)->segtype->name); + return 1; + } + cache_pool_lv->status |= LV_TEMPORARY; if (!activate_lv(cache_pool_lv->vg->cmd, cache_pool_lv)) { log_error("Aborting. Failed to activate cache pool %s.",