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

thin: lock fs when converting to external origin

Ensure suspend is locking fs, when converting LV to external origin.
This commit is contained in:
Zdenek Kabelac 2024-03-04 11:51:56 +01:00
parent edc91caffb
commit 386f0bfb4f

View File

@ -2193,16 +2193,23 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
/* FIXME Consider aborting here */
stack;
if (!laopts->origin_only &&
(lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
lockfs = 1;
/* Converting non-thin LV to thin external origin ? */
if (!lv_is_thin_volume(lv) && lv_is_thin_volume(lv_pre))
lockfs = 1; /* Sync before conversion */
/* Require fs synchronization when taking a thin snapshot */
if (laopts->origin_only && lv_is_thin_volume(lv) && lv_is_thin_volume(lv_pre))
lockfs = 1;
/* Require fs synchronization when taking a thick snapshot */
else if (!laopts->origin_only &&
(lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
lockfs = 1;
/* Require fs synchronization when converting a non-thin LV to a thin LV or
* a non/thin LV with/out external origin to a thin LV with external origin LV. */
else if (!laopts->origin_only &&
lv_is_thin_volume(lv_pre) && /* new LV is a Thin */
(!lv_is_thin_volume(lv) || /* and either the existing LV is NOT a Thin */
(first_seg(lv_pre)->external_lv && /* or the existing LV IS Thin and the new LV is Thin with the external origin */
(!first_seg(lv)->external_lv || /* and check if existing Thin is either without the external origin */
memcmp(&first_seg(lv_pre)->external_lv->lvid.id[1], /* or it uses a different external origin */
&first_seg(lv)->external_lv->lvid.id[1], ID_LEN) != 0))))
lockfs = 1;
if (!lv_is_locked(lv) && lv_is_locked(lv_pre) &&
(pvmove_lv = find_pvmove_lv_in_lv(lv_pre))) {