c2d5d21
From 24a4d8156786dfd91dcc17b2472653e963ebd028 Mon Sep 17 00:00:00 2001
c2d5d21
From: Chris Leech <cleech@redhat.com>
c2d5d21
Date: Tue, 13 Aug 2013 10:59:44 -0700
c2d5d21
Subject: idmb_rec_write, check for tpgt first
c2d5d21
c2d5d21
Factor out the check for a tpgt to a single place, before going crazy on
c2d5d21
the rec files.  Makes flow of this function easier to follow, and preps
c2d5d21
for splitting it up.
c2d5d21
---
c2d5d21
 usr/idbm.c | 18 +++++-------------
c2d5d21
 1 file changed, 5 insertions(+), 13 deletions(-)
c2d5d21
c2d5d21
diff --git a/usr/idbm.c b/usr/idbm.c
c2d5d21
index 1e4f8c8..0a88699 100644
c2d5d21
--- a/usr/idbm.c
c2d5d21
+++ b/usr/idbm.c
c2d5d21
@@ -1849,6 +1849,10 @@ static int idbm_rec_write(node_rec_t *rec)
c2d5d21
 	if (rc)
c2d5d21
 		goto free_portal;
c2d5d21
 
c2d5d21
+	if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
c2d5d21
+		/* drop down to old style portal as config */
c2d5d21
+		goto open_conf;
c2d5d21
+
c2d5d21
 	rc = stat(portal, &statb);
c2d5d21
 	if (rc) {
c2d5d21
 		rc = 0;
c2d5d21
@@ -1857,23 +1861,11 @@ static int idbm_rec_write(node_rec_t *rec)
c2d5d21
 		 * set the tgpt. In new versions you must pass all the info in
c2d5d21
 		 * from the start
c2d5d21
 		 */
c2d5d21
-		if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
c2d5d21
-			/* drop down to old style portal as config */
c2d5d21
-			goto open_conf;
c2d5d21
-		else
c2d5d21
-			goto mkdir_portal;
c2d5d21
+		goto mkdir_portal;
c2d5d21
 	}
c2d5d21
 
c2d5d21
 	if (!S_ISDIR(statb.st_mode)) {
c2d5d21
 		/*
c2d5d21
-		 * older iscsiadm versions had you create the config then set
c2d5d21
-		 * set the tgpt. In new versions you must pass all the info in
c2d5d21
-		 * from the start
c2d5d21
-		 */
c2d5d21
-		if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
c2d5d21
-			/* drop down to old style portal as config */
c2d5d21
-			goto open_conf;
c2d5d21
-		/*
c2d5d21
 		 * Old style portal as a file, but with tpgt. Let's update it.
c2d5d21
 		 */
c2d5d21
 		if (unlink(portal)) {
c2d5d21
-- 
c2d5d21
1.8.1.4
c2d5d21