summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2020-03-09 11:18:10 -0500
committerDavid Teigland <teigland@redhat.com>2020-03-09 11:18:10 -0500
commita5b1b52903fe3c71e8515f5592ab10d69896b5e7 (patch)
tree04aaa44afc3775b295e2054bba1b6def1335b8b3
parentc9526e859eba5a406e49853d59041a3497154fa8 (diff)
downloadlvm2-a5b1b52903fe3c71e8515f5592ab10d69896b5e7.tar.gz
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.
-rw-r--r--tools/lvconvert.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 68bd75cb5..f6d9a29f6 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -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;