From 0443d00ff1efdb5af05def774a4961563377dbd0 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 14 Oct 2019 15:51:35 -0500 Subject: [PATCH] allow activating known LVs when other LVs have unknown segtypes When a VG contains some LVs with unknown segtypes, the user should still be allowed to activate other LVs in the VG that are understood. $ lvs foo WARNING: Unrecognised flag CACHE_USES_CACHEVOL in segment type cache+CACHE_USES_CACHEVOL. WARNING: Unrecognised segment type cache+CACHE_USES_CACHEVOL LV VG Attr LSize lvol0 foo -wi------- 4.00m other foo vwi---u--- 48.00m $ lvcreate -l1 foo WARNING: Unrecognised flag CACHE_USES_CACHEVOL in segment type cache+CACHE_USES_CACHEVOL. WARNING: Unrecognised segment type cache+CACHE_USES_CACHEVOL Cannot change VG foo with unknown segments in it! Cannot process volume group foo $ lvchange -ay foo/lvol0 WARNING: Unrecognised flag CACHE_USES_CACHEVOL in segment type cache+CACHE_USES_CACHEVOL. WARNING: Unrecognised segment type cache+CACHE_USES_CACHEVOL $ lvchange -ay foo/other WARNING: Unrecognised flag CACHE_USES_CACHEVOL in segment type cache+CACHE_USES_CACHEVOL. WARNING: Unrecognised segment type cache+CACHE_USES_CACHEVOL Refusing activation of LV foo/other containing an unrecognised segment. $ lvs foo WARNING: Unrecognised flag CACHE_USES_CACHEVOL in segment type cache+CACHE_USES_CACHEVOL. WARNING: Unrecognised segment type cache+CACHE_USES_CACHEVOL LV VG Attr LSize lvol0 foo -wi-a----- 4.00m other foo vwi---u--- 48.00m --- lib/metadata/metadata.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index b09f4b35e..3174ae0e8 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -5065,12 +5065,12 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name, const failure |= FAILED_NOT_ENABLED; goto_bad; } + } - if (!cmd->handles_unknown_segments && vg_has_unknown_segments(vg)) { - log_error("Cannot change VG %s with unknown segments in it!", vg->name); - failure |= FAILED_NOT_ENABLED; /* FIXME new failure code here? */ - goto_bad; - } + if (writing && !cmd->handles_unknown_segments && vg_has_unknown_segments(vg)) { + log_error("Cannot change VG %s with unknown segments in it!", vg->name); + failure |= FAILED_NOT_ENABLED; /* FIXME new failure code here? */ + goto_bad; } /* -- 2.43.5