1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-19 14:04:17 +03:00

cachevol: move flag setting after taking archive

Before 'archive()' is called, lvm2 must not touch/modify metadata.
So move setting  CACHE_VOL related flags past this point.

Also make sure reading of cache segtype always restores this
flag properly (even if compatible flag would be lost).
This commit is contained in:
Zdenek Kabelac 2019-10-16 21:22:20 +02:00
parent f63e20ebcc
commit dab4a2c893
3 changed files with 20 additions and 16 deletions

View File

@ -504,9 +504,6 @@ static int _cache_text_import(struct lv_segment *seg,
seg->lv->status |= strstr(seg->lv->name, "_corig") ? LV_PENDING_DELETE : 0;
if (!attach_pool_lv(seg, pool_lv, NULL, NULL, NULL))
return_0;
if (!_settings_text_import(seg, sn))
return_0;
@ -547,6 +544,7 @@ static int _cache_text_import(struct lv_segment *seg,
if (!id_read_format(seg->data_id, uuid))
return SEG_LOG_ERROR("Couldn't format data_id in");
}
pool_lv->status |= LV_CACHE_VOL; /* Mark as cachevol LV */
} else {
/* Do not call this when LV is cache_vol. */
/* load order is unknown, could be cache origin or pool LV, so check for both */
@ -554,6 +552,9 @@ static int _cache_text_import(struct lv_segment *seg,
_fix_missing_defaults(first_seg(pool_lv));
}
if (!attach_pool_lv(seg, pool_lv, NULL, NULL, NULL))
return_0;
return 1;
}

View File

@ -106,8 +106,20 @@ int attach_pool_lv(struct lv_segment *seg,
seg->origin = origin;
seg->lv->status |= seg_is_cache(seg) ? CACHE : THIN_VOLUME;
if (seg_is_cache(seg))
lv_set_hidden(pool_lv); /* Used cache-pool is hidden */
if (seg_is_cache(seg)) {
lv_set_hidden(pool_lv); /* Used cache-pool/cachevol is hidden */
if (lv_is_cache_vol(pool_lv))
/*
* This flag is added to the segtype name so that old versions of lvm
* (if they happen to be used with new metadata with a cache LV using a
* cachevol) will report an error when they see the unknown
* cache+CACHE_USES_CACHEVOL segment type. Otherwise the old version
* would expect to find a cache pool and fail.
*/
seg->lv->status |= LV_CACHE_USES_CACHEVOL;
}
if (origin && !add_seg_to_segs_using_this_lv(origin, seg))
return_0;

View File

@ -3475,6 +3475,8 @@ static int _cache_vol_attach(struct cmd_context *cmd,
if (!archive(vg))
goto_out;
lv_fast->status |= LV_CACHE_VOL; /* Mark as cachevol LV */
/*
* Changes the vg struct to match the desired state.
*
@ -4271,17 +4273,6 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
if (!lv_rename_update(cmd, cachevol_lv, cvol_name, 0))
return_0;
/*
* This flag is added to the segtype name so that old versions of lvm
* (if they happen to be used with new metadata with a cache LV using a
* cachevol) will report an error when they see the unknown
* cache+CACHE_USES_CACHEVOL segment type. Otherwise the old version
* would expect to find a cache pool and fail.
*/
lv->status |= LV_CACHE_USES_CACHEVOL;
cachevol_lv->status |= LV_CACHE_VOL;
/* Attach the cache to the main LV. */
if (!_cache_vol_attach(cmd, lv, cachevol_lv))