All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RAID: fix incorrect exit status from lvchange --syncaction
@ 2016-04-02  4:20 James Johnston
  0 siblings, 0 replies; only message in thread
From: James Johnston @ 2016-04-02  4:20 UTC (permalink / raw)
  To: lvm-devel

Hi,

This patch fixes a bug where lvchange --syncaction returns a successful exit
status even when it actually failed.

Test case:

$ lvchange --syncaction repair VG/DataCache
$ lvchange --syncaction repair VG/DataCache
  VG/DataCache is currently "repair".  Unable to switch to "repair".
$ echo $?
0

Since it gave an error, I'd expect the exit status to be non-zero.

>From 2f12e1f2aa933dca100a9dc505c1a6adfb7b99fd Mon Sep 17 00:00:00 2001
From: James Johnston <johnstonj.public@codenest.com>
Date: Sat, 2 Apr 2016 04:04:59 +0000
Subject: [PATCH] RAID: fix incorrect exit status from lvchange --syncaction

Some of the possible errors from lvchange don't return a non-zero
exit status: for example, if a repair is already in progress.

This is because lv_raid_message erroneously sets the return value to
success prematurely, and it's not subsequently reset to a failing
value.

Signed-off-by: James Johnston <johnstonj.public@codenest.com>
---
 lib/activate/activate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index a3b2379..1713b8c 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1013,7 +1013,7 @@ int lv_raid_message(const struct logical_volume *lv, const char *msg)
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
 		return_0;
 
-	if (!(r = dev_manager_raid_status(dm, lv, &status))) {
+	if (!dev_manager_raid_status(dm, lv, &status)) {
 		log_error("Failed to retrieve status of %s.",
 			  display_lvname(lv));
 		goto out;
-- 
1.9.5.msysgit.1




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-02  4:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-02  4:20 [PATCH] RAID: fix incorrect exit status from lvchange --syncaction James Johnston

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.