* [PATCH] Always return error when locking of VG fail.
@ 2009-04-08 15:02 Milan Broz
0 siblings, 0 replies; only message in thread
From: Milan Broz @ 2009-04-08 15:02 UTC (permalink / raw)
To: lvm-devel
Always return error when locking of VG fail.
Currently code allows quietly skip vg if locking failed
when processing PVs/LVs on cmdline.
Unfortunately there are situation when this can cause
problems - several tools uses LCK_NONBLOCK flags
(and flock can return EWOULDBLOCK) also locking can fail
for example because system is out of memory.
For example, some lvm command hold lock for vg,
another tries to remove this vg:
# vgremove vg ; echo $?
/var/lock/lvm/V_vg: flock failed: Resource temporarily unavailable
Can't lock volume group vg: skipping
0
This should return an error code instead.
Patch fixes it by using ECMD_FAIL if locking of VG fails.
Side effect is that some commands now return error code
when some VG is skipped. (IMHO it is correct.)
For example, installation depends on return code of these calls,
see also https://bugzilla.redhat.com/show_bug.cgi?id=492642
Signed-off-by: Milan Broz <mbroz@redhat.com>
---
tools/toollib.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 0bc3e40..8a3065b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -285,6 +285,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
continue; /* FIXME Unnecessary? */
if (!lock_vol(cmd, vgname, lock_type)) {
log_error("Can't lock %s: skipping", vgname);
+ ret_max = ECMD_FAILED;
continue;
}
if (lock_type & LCK_WRITE)
@@ -442,7 +443,7 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
if (!lock_vol(cmd, vg_name, lock_type)) {
log_error("Can't lock volume group %s: skipping", vg_name);
- return ret_max;
+ return ECMD_FAILED;
}
log_verbose("Finding volume group \"%s\"", vg_name);
@@ -745,6 +746,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
dm_list_iterate_items(sll, vgnames) {
if (!lock_vol(cmd, sll->str, lock_type)) {
log_error("Can't lock %s: skipping", sll->str);
+ ret_max = ECMD_FAILED;
continue;
}
if (!(vg = vg_read_internal(cmd, sll->str, NULL, &consistent))) {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-04-08 15:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-08 15:02 [PATCH] Always return error when locking of VG fail Milan Broz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.