Always return error when locking of VG fail.
PATCH 1/1 Always return error when locking of VG fail.
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
--- tools/toollib.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
tools/toollib.c +3 -1
@@ -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))) {