[PATCH 2/3] tgt-setup-lun: only delete new target on err when one was created

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



See https://bugzilla.redhat.com/show_bug.cgi?id=676337 .

This patch only deletes the new target if the target was created
by tgt-setup-lun.

Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
---
 scripts/tgt-setup-lun |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/scripts/tgt-setup-lun b/scripts/tgt-setup-lun
index 2685095..9fef7f9 100755
--- a/scripts/tgt-setup-lun
+++ b/scripts/tgt-setup-lun
@@ -120,6 +120,10 @@ find_vacant_lun()
 
 err_exit()
 {
+	if ((new_tgt == 0)); then
+		exit 1
+	fi
+
 	echo "Deleting new target, tid=$tid"
 	tgtadm --lld $lld_name --op delete --mode target --tid $tid
 	res=$?
@@ -196,6 +200,7 @@ if [ $? -eq 1 ]; then
 	fi
 	tid=$(tgtadm --lld $lld_name --op show --mode target | grep $tgt_name | cut -d" " -f2)
 	tid=${tid%:}
+	new_tgt=0
 else
 	find_vacant_tgt_id
 	tid=$?
@@ -209,6 +214,7 @@ else
 		echo "Error: failed to create target (name=$tgt_name, tid=$tid)"
 		exit 1
 	fi
+	new_tgt=1
 fi
 
 find_vacant_lun $tid
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux