Print error if VG already exist.
PATCH 1/1 Print error if VG already exist.
This test have to be moved because of new vg read error handling.
--- tools/vgcreate.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
tools/vgcreate.c +7 -2
@@ -55,8 +55,13 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)/* Create the new VG */ vg =vg_create (cmd, vp_new.vg_name); -if (vg_read_error (vg)) - goto_bad; +if (vg_read_error (vg)) { +if (vg_read_error (vg) ==FAILED_EXIST ) +log_error ("A volume group called %s already exists." , vp_new.vg_name); +else +log_error ("Can't get lock for %s" , vp_new.vg_name); + goto bad; + } if (!vg_set_extent_size(vg, vp_new.extent_size) || !vg_set_max_lv(vg, vp_new.max_lv) ||
Signature · 1 line
1.6.5.3
PATCH 1/1 Print error if VG already exist.
Quoted 17 lines · Milan Broz
This test have to be moved because of new vg read error handling.
Signed-off-by Milan Broz <[email protected]>--- tools/vgcreate.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)tools/vgcreate.c +0
-2@@ -55,8 +55,13 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)/* Create the new VG */ vg =vg_create (cmd, vp_new.vg_name); -if (vg_read_error (vg)) - goto_bad;
tools/vgcreate.c int vgcreate(struct cmd_context *cmd, int argc, char **argv) · line 67
Quoted 10 lines
tools/vgcreate.c +7
-0+if (vg_read_error (vg)) { +if (vg_read_error (vg) ==FAILED_EXIST ) +log_error ("A volume group called %s already exists." , vp_new.vg_name); +else +log_error ("Can't get lock for %s" , vp_new.vg_name); + goto bad; + } if (!vg_set_extent_size(vg, vp_new.extent_size) || !vg_set_max_lv(vg, vp_new.max_lv) ||
Ack.
Some more cleanup probably warranted but another time and there are already FIXMEs in the code.
PATCH 1/1 Print error if VG already exist.
In reply to Milan BrozQuoted 5 lines · Milan Broz
This test have to be moved because of new vg read error handling.
(quoted diff) +0
-0@@ -55,8 +55,13 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) /* Create the new VG */
Review int vgcreate(struct cmd_context *cmd, int argc, char **argv) · line 64
Quoted 10 lines
(quoted diff) +7
-2vg = vg_create(cmd, vp_new.vg_name); - if (vg_read_error(vg)) - goto_bad; + if (vg_read_error(vg)) { + if (vg_read_error(vg) == FAILED_EXIST) + log_error("A volume group called %s already exists.", vp_new.vg_name); + else + log_error("Can't get lock for %s", vp_new.vg_name); + goto bad; + }
This is suspicious. In vg_create:
if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
log_error("A volume group called '%s' already exists.", vg_name);
unlock_and_release_vg(cmd, vg, vg_name);
return _vg_make_handle(cmd, NULL, FAILED_EXIST);
}So the code you are adding should not be needed, at least not for the EXIST case.
Hmm. Ok, I see that the code is actually broken, since what fails is already vg_lock_newname. I'd argue that it should be vg_lock_newname that should be printing this, not vgcreate. Like this:
metadata/metadata.c +1 -0
@@ -3507,6 +3507,7 @@ uint32_t vg_lock_newname(struct cmd_cont/* Found vgname so cannot reserve. */ unlock_vg (cmd, vgname); +log_error ("A volume group called '%s' already exists." , vg_name);return FAILED_EXIST ; }
Yours,
Petr.
PATCH 1/1 Print error if VG already exist.
Quoted 36 lines · Petr Rockai
Quoted 5 lines · Milan Broz
This test have to be moved because of new vg read error handling.
(quoted diff) +0
-0@@ -55,8 +55,13 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) /* Create the new VG */Review int vgcreate(struct cmd_context *cmd, int argc, char **argv) · line 64
Quoted 10 lines
(quoted diff) +7
-2vg = vg_create(cmd, vp_new.vg_name); - if (vg_read_error(vg)) - goto_bad; + if (vg_read_error(vg)) { + if (vg_read_error(vg) == FAILED_EXIST) + log_error("A volume group called %s already exists.", vp_new.vg_name); + else + log_error("Can't get lock for %s", vp_new.vg_name); + goto bad; + }This is suspicious. In
vg_create:if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) { log_error("A volume group called '%s' already exists.", vg_name); unlock_and_release_vg(cmd, vg, vg_name); return _vg_make_handle(cmd, NULL, FAILED_EXIST); }So the code you are adding should not be needed, at least not for the EXIST case.
Hmm. Ok, I see that the code is actually broken, since what fails is already
vg_lock_newname. I'd argue that it should bevg_lock_newnamethat should be printing this, not vgcreate. Like this:diff -u -p -r1.299
metadata.c
metadata/metadata.c uint32_t vg_lock_newname(struct cmd_cont · line 3513
Quoted 7 lines
metadata/metadata.c +1
-0@@ -3507,6 +3507,7 @@ uint32_t vg_lock_newname(struct cmd_cont/* Found vgname so cannot reserve. */ unlock_vg (cmd, vgname); +log_error ("A volume group called '%s' already exists." , vg_name);return FAILED_EXIST ; }
Unfortunately this will add extraneous messages / errors to some vgsplit operations as a check for existence is not always a command error. Plus vg_lock_newname only returns codes in the other paths and it would be good to stay consistent (log_error() in all error paths or none of them and let caller decide).