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

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).
This commit is contained in:
Zdenek Kabelac 2023-07-04 13:29:00 +02:00
parent 558890ad0e
commit 9bbbc1b265

View File

@ -1249,6 +1249,7 @@ int cache_set_params(struct lv_segment *seg,
int wipe_cache_pool(struct logical_volume *cache_pool_lv) int wipe_cache_pool(struct logical_volume *cache_pool_lv)
{ {
int r; int r;
struct logical_volume *cache_data_lv;
/* Only unused cache-pool could be activated and wiped */ /* 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)) { 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; 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; cache_pool_lv->status |= LV_TEMPORARY;
if (!activate_lv(cache_pool_lv->vg->cmd, cache_pool_lv)) { if (!activate_lv(cache_pool_lv->vg->cmd, cache_pool_lv)) {
log_error("Aborting. Failed to activate cache pool %s.", log_error("Aborting. Failed to activate cache pool %s.",