1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-02-24 17:57:48 +03:00

writecache: require inactive LV to attach

Prevent attaching writecache to an active LV until
we can determine the block size of the fs on the LV,
and use that to enforce an appropriate writecache
block size.  Changing the block size under a mounted
fs can cause panic/corruption.
This commit is contained in:
David Teigland 2020-03-09 11:18:10 -05:00
parent c9526e859e
commit a5b1b52903

View File

@ -5603,6 +5603,16 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
goto bad;
}
/*
* To permit this we need to check the block size of the fs using lv
* (recently in libblkid) so that we can use a matching writecache
* block size. We also want to do that if the lv is inactive.
*/
if (lv_is_active(lv)) {
log_error("LV %s must be inactive to attach writecache.", display_lvname(lv));
goto bad;
}
/* fast LV shouldn't generally be active by itself, but just in case. */
if (lv_info(cmd, lv_fast, 1, NULL, 0, 0)) {
log_error("LV %s must be inactive to attach.", display_lvname(lv_fast));
@ -5643,15 +5653,6 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
memcpy(&lockd_fast_id, &lv_fast->lvid.id[1], sizeof(struct id));
}
/*
* TODO: use libblkid to get the sector size of lv. If it doesn't
* match the block_size we are using for the writecache, then warn that
* an existing file system on lv may become unmountable with the
* writecache attached because of the changing sector size. If this
* happens, then use --splitcache, and reattach the writecache using a
* writecache block_size value matching the sector size of lv.
*/
if (!_writecache_zero(cmd, lv_fast)) {
log_error("LV %s could not be zeroed.", display_lvname(lv_fast));
return ECMD_FAILED;