summaryrefslogtreecommitdiff
path: root/tools/pvcreate.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2017-08-11 20:41:37 +0100
committerAlasdair G Kergon <agk@redhat.com>2017-08-11 20:41:37 +0100
commit42fa20d0d0136c1aeb3ccdf0654c64beeee05821 (patch)
tree1f77e459a32ca360578f91d683f0f4fd26791241 /tools/pvcreate.c
parent4fa5add6b1bd4d7f7313f2950021a09e4130ad08 (diff)
downloadlvm2-42fa20d0d0136c1aeb3ccdf0654c64beeee05821.tar.gz
pvcreate: Use maximum metadata area size with --restorefile
If the PV was originally created with a larger-than-default metadata area the restored one wasn't and might not even be large enough to hold the metadata!
Diffstat (limited to 'tools/pvcreate.c')
-rw-r--r--tools/pvcreate.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 0fe5ad576..9dc50e431 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -135,6 +135,15 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
if (!pvcreate_params_from_args(cmd, &pp))
return EINVALID_CMD_LINE;
+ /*
+ * If --metadatasize was not given with --restorefile, set it to pe_start.
+ * Later code treats this as a maximum size and reduces it to fit.
+ */
+ if (!arg_is_set(cmd, metadatasize_ARG) && arg_is_set(cmd, restorefile_ARG))
+ pp.pva.pvmetadatasize = pp.pva.pe_start;
+
+ /* FIXME Also needs to check any 2nd metadata area isn't inside the data area! */
+
pp.pv_count = argc;
pp.pv_names = argv;