public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW tools/pvcreate.c
@ 2008-07-21 19:26 wysochanski
0 siblings, 0 replies; 2+ messages in thread
From: wysochanski @ 2008-07-21 19:26 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: wysochanski@sourceware.org 2008-07-21 19:26:33
Modified files:
. : WHATS_NEW
tools : pvcreate.c
Log message:
Refactor pvcreate to divide parameter parsing & validation from create logic.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.932&r2=1.933
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
--- LVM2/WHATS_NEW 2008/07/17 03:16:59 1.932
+++ LVM2/WHATS_NEW 2008/07/21 19:26:33 1.933
@@ -1,5 +1,6 @@
Version 2.02.40 -
================================
+ Refactor pvcreate to divide parameter parsing & validation from create logic.
Check for label_write() failure in _text_pv_write().
Add pvcreate tests and update vgsplit tests to handle lvm1 and lvm2 metadata.
Fix pvchange -M1 -u to preserve existing extent locations when there's a VG.
--- LVM2/tools/pvcreate.c 2008/06/24 20:10:32 1.63
+++ LVM2/tools/pvcreate.c 2008/07/21 19:26:33 1.64
@@ -275,57 +275,84 @@
return ECMD_FAILED;
}
-int pvcreate(struct cmd_context *cmd, int argc, char **argv)
+/*
+ * Intial sanity checking of command-line arguments and fill in parameters
+ * for pvcreate command. More comprehensive validation is done in
+ * pvcreate_validate_params().
+ */
+static int pvcreate_fill_params(struct cmd_context *cmd,
+ int argc, char **argv,
+ struct pvcreate_params *pp)
{
- int i, r;
- int ret = ECMD_PROCESSED;
- struct pvcreate_params pp;
-
if (!argc) {
log_error("Please enter a physical volume path");
- return EINVALID_CMD_LINE;
+ return 0;
}
if (arg_count(cmd, restorefile_ARG) && !arg_count(cmd, uuidstr_ARG)) {
log_error("--uuid is required with --restorefile");
- return EINVALID_CMD_LINE;
+ return 0;
}
if (arg_count(cmd, uuidstr_ARG) && argc != 1) {
log_error("Can only set uuid on one volume at once");
- return EINVALID_CMD_LINE;
+ return 0;
}
if (arg_count(cmd, yes_ARG) && !arg_count(cmd, force_ARG)) {
log_error("Option y can only be given with option f");
- return EINVALID_CMD_LINE;
+ return 0;
}
if (arg_int_value(cmd, labelsector_ARG, 0) >= LABEL_SCAN_SECTORS) {
log_error("labelsector must be less than %lu",
LABEL_SCAN_SECTORS);
- return EINVALID_CMD_LINE;
+ return 0;
}
if (!(cmd->fmt->features & FMT_MDAS) &&
(arg_count(cmd, metadatacopies_ARG) ||
arg_count(cmd, metadatasize_ARG))) {
log_error("Metadata parameters only apply to text format");
- return EINVALID_CMD_LINE;
+ return 0;
}
if (arg_count(cmd, metadatacopies_ARG) &&
arg_int_value(cmd, metadatacopies_ARG, -1) > 2) {
log_error("Metadatacopies may only be 0, 1 or 2");
- return EINVALID_CMD_LINE;
+ return 0;
}
if (arg_count(cmd, zero_ARG))
- pp.zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
+ pp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
else if (arg_count(cmd, restorefile_ARG) || arg_count(cmd, uuidstr_ARG))
- pp.zero = 0;
+ pp->zero = 0;
else
- pp.zero = 1;
+ pp->zero = 1;
+
+ return 1;
+}
+
+
+static int pvcreate_validate_params(struct cmd_context *cmd,
+ struct pvcreate_params *pp)
+{
+ return 1;
+}
+
+int pvcreate(struct cmd_context *cmd, int argc, char **argv)
+{
+ int i, r;
+ int ret = ECMD_PROCESSED;
+ struct pvcreate_params pp;
+
+ if (!pvcreate_fill_params(cmd, argc, argv, &pp)) {
+ return EINVALID_CMD_LINE;
+ }
+
+ if (!pvcreate_validate_params(cmd, &pp)) {
+ return EINVALID_CMD_LINE;
+ }
for (i = 0; i < argc; i++) {
r = pvcreate_single(cmd, argv[i], &pp);
^ permalink raw reply [flat|nested] 2+ messages in thread
* LVM2 ./WHATS_NEW tools/pvcreate.c
@ 2008-01-09 0:18 mornfall
0 siblings, 0 replies; 2+ messages in thread
From: mornfall @ 2008-01-09 0:18 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall@sourceware.org 2008-01-09 00:18:37
Modified files:
. : WHATS_NEW
tools : pvcreate.c
Log message:
Prevent pvcreate from overwriting MDA-less PVs belonging to active VGs.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.752&r2=1.753
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59
--- LVM2/WHATS_NEW 2008/01/07 20:42:56 1.752
+++ LVM2/WHATS_NEW 2008/01/09 00:18:36 1.753
@@ -1,5 +1,6 @@
Version 2.02.30 -
===================================
+ Prevent pvcreate from overwriting MDA-less PVs belonging to active VGs.
Fix a segfault if using pvs with --all argument. (2.02.29)
Update --uuid argument description in man pages.
Fix vgreduce PV list processing not to process every PV in the VG. (2.02.29)
--- LVM2/tools/pvcreate.c 2007/11/22 01:25:06 1.58
+++ LVM2/tools/pvcreate.c 2008/01/09 00:18:36 1.59
@@ -14,6 +14,7 @@
*/
#include "tools.h"
+#include "metadata.h"
struct pvcreate_params {
int zero;
@@ -43,6 +44,17 @@
/* FIXME Use partial mode here? */
pv = pv_read(cmd, name, NULL, NULL, 0);
+ /*
+ * If a PV has no MDAs it may appear to be an orphan until the
+ * metadata is read off another PV in the same VG. Detecting
+ * this means checking every VG by scanning every PV on the
+ * system.
+ */
+ if (pv && is_orphan(pv)) {
+ (void) get_vgs(cmd, 1);
+ pv = pv_read(cmd, name, NULL, NULL, 0);
+ }
+
/* Allow partial & exported VGs to be destroyed. */
/* We must have -ff to overwrite a non orphan */
if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG) != 2) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-07-21 19:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-21 19:26 LVM2 ./WHATS_NEW tools/pvcreate.c wysochanski
-- strict thread matches above, loose matches on Subject: below --
2008-01-09 0:18 mornfall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).