From: Hannes Reinecke <hare@xxxxxxx> config/iscsi doesn't need to exist, yet the module can be loaded. (nab: Fix shutdown_lio_mod() to add missing 'if -ne' investor to work properly, and add some code to scripts/rc.target) Signed-off-by: Hannes Reinecke <hare@xxxxxxx> Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxxxxxxxx> --- lio-py/lio_node.py | 17 +++++++++-------- scripts/rc.target | 2 +- scripts/rc.target.suse | 5 +++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lio-py/lio_node.py b/lio-py/lio_node.py index d1e562e..c7082e8 100755 --- a/lio-py/lio_node.py +++ b/lio-py/lio_node.py @@ -1198,10 +1198,9 @@ def lio_target_set_tpg_param(option, opt_str, value, parser): def lio_target_unload(option, opt_str, value, parser): - if not os.path.isdir(lio_root): - lio_err("Unable to access lio_root: " + lio_root) - - iqn_root = os.listdir(lio_root) + iqn_root = "" + if os.path.isdir(lio_root): + iqn_root = os.listdir(lio_root) # Loop through LIO-Target IQN list for iqn in iqn_root: @@ -1224,10 +1223,12 @@ def lio_target_unload(option, opt_str, value, parser): __lio_target_del_iqn(None, None, iqn, None, 0) - rmdir_op = "rmdir " + lio_root - ret = os.system(rmdir_op) - if ret: - print "Unable to release lio_root: " + lio_root + + if iqn_root: + rmdir_op = "rmdir " + lio_root + ret = os.system(rmdir_op) + if ret: + print "Unable to remove lio_root: " + lio_root rmmod_op = "rmmod iscsi_target_mod" ret = os.system(rmmod_op) diff --git a/scripts/rc.target b/scripts/rc.target index 7ad75a3..d5243e2 100644 --- a/scripts/rc.target +++ b/scripts/rc.target @@ -282,7 +282,7 @@ function shutdown_fabrics() { } function shutdown_lio_mod () { - if [ ! -d /sys/kernel/config/target/iscsi/ ]; then + if -ne lsmod | grep -q iscsi_target_mod ; then return 0 fi diff --git a/scripts/rc.target.suse b/scripts/rc.target.suse index 5e49f8f..a3806fa 100644 --- a/scripts/rc.target.suse +++ b/scripts/rc.target.suse @@ -214,7 +214,7 @@ function shutdown_fabrics() { } function shutdown_lio_mod () { - if [ -d /sys/kernel/config/target/iscsi/ ]; then + if -ne lsmod | grep -q iscsi_target_mod ; then echo -n $"Unloading LIO-Target/ConfigFS fabric: " ${LIO_NODE} --unload rc_status -v @@ -229,10 +229,11 @@ function unload_tcm_mod() { echo -n $"Unloading target_core_mod/ConfigFS core: " $TCM_NODE --unload - sleep 1 RETVAL=$? if [ $RETVAL != 0 ] ; then rc_failed 1 + else + sleep 1 fi rc_status -v fi -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html