From 65cb8efd16f636a42f6ce13b29d86298f10667aa Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 21 Dec 2018 20:49:36 +0100 Subject: [PATCH] lvconvert: writecache fix return code Detach function return 0 for error and 1 for success. Add missing log errors from failing deactivation. Add missing log error from failing synchronization. --- tools/lvconvert.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/lvconvert.c b/tools/lvconvert.c index f6f94c0fa..17d745434 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -5165,7 +5165,7 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd, } if (!archive(lv->vg)) - goto_bad; + return_0; /* * Activate LV internally since the LV needs to be active to flush. @@ -5180,17 +5180,23 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd, return 0; } - sync_local_dev_names(cmd); + if (!sync_local_dev_names(cmd)) { + log_error("Failed to sync local devices before detaching LV %s.", + display_lvname(lv)); + return 0; + } if (!lv_writecache_message(lv, "flush")) { log_error("Failed to flush writecache for %s.", display_lvname(lv)); - deactivate_lv(cmd, lv); + if (!deactivate_lv(cmd, lv)) + log_error("Failed to deactivate %s.", display_lvname(lv)); return 0; } if (!_get_writecache_kernel_error(cmd, lv, &kernel_error)) { log_error("Failed to get writecache error status for %s.", display_lvname(lv)); - deactivate_lv(cmd, lv); + if (!deactivate_lv(cmd, lv)) + log_error("Failed to deactivate %s.", display_lvname(lv)); return 0; } @@ -5219,10 +5225,7 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd, log_print_unless_silent("Logical volume %s write cache has been detached.", display_lvname(lv)); - return ECMD_PROCESSED; -bad: - return ECMD_FAILED; - + return 1; } static int _get_one_writecache_setting(struct cmd_context *cmd, struct writecache_settings *settings, -- 2.43.5