[packages/open-iscsi] - removed rh/fedora's idmb_rec_write refactoring, broken, causes segfaults - rel 3

baggins baggins at pld-linux.org
Fri Apr 4 13:27:14 CEST 2014


commit 75c46b011d7485a4b5676d824c7f3cdea2076f49
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Fri Apr 4 13:26:38 2014 +0200

    - removed rh/fedora's idmb_rec_write refactoring, broken, causes segfaults
    - rel 3

 0043-idmb_rec_write-check-for-tpgt-first.patch     |  55 -------
 ...c_write-seperate-old-and-new-style-writes.patch | 180 ---------------------
 ..._rec_write-pick-tpgt-from-existing-record.patch |  87 ----------
 open-iscsi.spec                                    |   8 +-
 4 files changed, 1 insertion(+), 329 deletions(-)
---
diff --git a/open-iscsi.spec b/open-iscsi.spec
index 71bbf3d..c3e6e5f 100644
--- a/open-iscsi.spec
+++ b/open-iscsi.spec
@@ -7,7 +7,7 @@ Summary:	iSCSI - SCSI over IP
 Summary(pl.UTF-8):	iSCSI - SCSI po IP
 Name:		open-iscsi
 Version:	%{ver}.%{subver}
-Release:	2
+Release:	3
 License:	GPL v2
 Group:		Networking/Daemons
 Source0:	http://www.open-iscsi.org/bits/%{name}-%{ver}-%{subver}.tar.gz
@@ -19,10 +19,7 @@ Source4:	iscsiuio.logrotate
 Patch0:		%{name}-git.patch
 Patch1:		%{name}-build.patch
 Patch2:		%{name}-systemd.patch
-Patch31:	0043-idmb_rec_write-check-for-tpgt-first.patch
 Patch32:	0044-iscsid-add-initrd-option-to-set-run-from-initrd-hint.patch
-Patch33:	0045-idbm_rec_write-seperate-old-and-new-style-writes.patch
-Patch34:	0046-idbw_rec_write-pick-tpgt-from-existing-record.patch
 Patch35:	0047-iscsiadm-iscsid-newroot-command-to-survive-switch_ro.patch
 Patch36:	0047-iscsiuio-systemd-socket-activation-support.patch
 Patch37:	0048-iscsiadm-param-parsing-for-advanced-node-creation.patch
@@ -76,10 +73,7 @@ informacji o protokole iSCSI znajduje się w standardach IETF na
 %prep
 %setup -q -n %{name}-%{ver}-%{subver}
 %patch0 -p1
-%patch31 -p1
 %patch32 -p1
-%patch33 -p1
-%patch34 -p1
 %patch35 -p1
 %patch36 -p1
 %patch37 -p1
diff --git a/0043-idmb_rec_write-check-for-tpgt-first.patch b/0043-idmb_rec_write-check-for-tpgt-first.patch
deleted file mode 100644
index cdc958a..0000000
--- a/0043-idmb_rec_write-check-for-tpgt-first.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From 24a4d8156786dfd91dcc17b2472653e963ebd028 Mon Sep 17 00:00:00 2001
-From: Chris Leech <cleech at redhat.com>
-Date: Tue, 13 Aug 2013 10:59:44 -0700
-Subject: idmb_rec_write, check for tpgt first
-
-Factor out the check for a tpgt to a single place, before going crazy on
-the rec files.  Makes flow of this function easier to follow, and preps
-for splitting it up.
----
- usr/idbm.c | 18 +++++-------------
- 1 file changed, 5 insertions(+), 13 deletions(-)
-
-diff --git a/usr/idbm.c b/usr/idbm.c
-index 1e4f8c8..0a88699 100644
---- a/usr/idbm.c
-+++ b/usr/idbm.c
-@@ -1849,6 +1849,10 @@ static int idbm_rec_write(node_rec_t *rec)
- 	if (rc)
- 		goto free_portal;
- 
-+	if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
-+		/* drop down to old style portal as config */
-+		goto open_conf;
-+
- 	rc = stat(portal, &statb);
- 	if (rc) {
- 		rc = 0;
-@@ -1857,23 +1861,11 @@ static int idbm_rec_write(node_rec_t *rec)
- 		 * set the tgpt. In new versions you must pass all the info in
- 		 * from the start
- 		 */
--		if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
--			/* drop down to old style portal as config */
--			goto open_conf;
--		else
--			goto mkdir_portal;
-+		goto mkdir_portal;
- 	}
- 
- 	if (!S_ISDIR(statb.st_mode)) {
- 		/*
--		 * older iscsiadm versions had you create the config then set
--		 * set the tgpt. In new versions you must pass all the info in
--		 * from the start
--		 */
--		if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
--			/* drop down to old style portal as config */
--			goto open_conf;
--		/*
- 		 * Old style portal as a file, but with tpgt. Let's update it.
- 		 */
- 		if (unlink(portal)) {
--- 
-1.8.1.4
-
diff --git a/0045-idbm_rec_write-seperate-old-and-new-style-writes.patch b/0045-idbm_rec_write-seperate-old-and-new-style-writes.patch
deleted file mode 100644
index d138233..0000000
--- a/0045-idbm_rec_write-seperate-old-and-new-style-writes.patch
+++ /dev/null
@@ -1,180 +0,0 @@
-From 954a9492b5ed1de5907ad2a7d7cc0ae6215d8fac Mon Sep 17 00:00:00 2001
-From: Chris Leech <cleech at redhat.com>
-Date: Tue, 13 Aug 2013 11:34:31 -0700
-Subject: idbm_rec_write, seperate old and new style writes
-
-Duplicates a small bit of code, but easier to understand and extened.
----
- usr/idbm.c | 116 +++++++++++++++++++++++++++++++++++++++++--------------------
- 1 file changed, 79 insertions(+), 37 deletions(-)
-
-diff --git a/usr/idbm.c b/usr/idbm.c
-index 0a88699..cb6ffd1 100644
---- a/usr/idbm.c
-+++ b/usr/idbm.c
-@@ -1808,7 +1808,7 @@ mkdir_portal:
- 	return f;
- }
- 
--static int idbm_rec_write(node_rec_t *rec)
-+static int idbm_rec_write_new(node_rec_t *rec)
- {
- 	struct stat statb;
- 	FILE *f;
-@@ -1820,38 +1820,8 @@ static int idbm_rec_write(node_rec_t *rec)
- 		log_error("Could not alloc portal\n");
- 		return ISCSI_ERR_NOMEM;
- 	}
--
--	snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR);
--	if (access(portal, F_OK) != 0) {
--		if (mkdir(portal, 0660) != 0) {
--			log_error("Could not make %s: %s\n", portal,
--				  strerror(errno));
--			rc = ISCSI_ERR_IDBM;
--			goto free_portal;
--		}
--	}
--
--	snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name);
--	if (access(portal, F_OK) != 0) {
--		if (mkdir(portal, 0660) != 0) {
--			log_error("Could not make %s: %s\n", portal,
--				  strerror(errno));
--			rc = ISCSI_ERR_IDBM;
--			goto free_portal;
--		}
--	}
--
- 	snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
- 		 rec->name, rec->conn[0].address, rec->conn[0].port);
--	log_debug(5, "Looking for config file %s", portal);
--
--	rc = idbm_lock();
--	if (rc)
--		goto free_portal;
--
--	if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
--		/* drop down to old style portal as config */
--		goto open_conf;
- 
- 	rc = stat(portal, &statb);
- 	if (rc) {
-@@ -1872,11 +1842,11 @@ static int idbm_rec_write(node_rec_t *rec)
- 			log_error("Could not convert %s: %s\n", portal,
- 				  strerror(errno));
- 			rc = ISCSI_ERR_IDBM;
--			goto unlock;
-+			goto free_portal;
- 		}
- 	} else {
- 		rc = ISCSI_ERR_INVAL;
--		goto unlock;
-+		goto free_portal;
- 	}	
- 
- mkdir_portal:
-@@ -1887,24 +1857,96 @@ mkdir_portal:
- 			log_error("Could not make dir %s: %s\n",
- 				  portal, strerror(errno));
- 			rc = ISCSI_ERR_IDBM;
--			goto unlock;
-+			goto free_portal;
- 		}
- 	}
- 
- 	snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR,
- 		 rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt,
- 		 rec->iface.name);
--open_conf:
-+/* open_conf: */
- 	f = fopen(portal, "w");
- 	if (!f) {
- 		log_error("Could not open %s: %sd\n", portal, strerror(errno));
- 		rc = ISCSI_ERR_IDBM;
--		goto unlock;
-+		goto free_portal;
- 	}
- 
- 	idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
- 	fclose(f);
--unlock:
-+free_portal:
-+	free(portal);
-+	return rc;
-+}
-+
-+static int idbm_rec_write_old(node_rec_t *rec)
-+{
-+	FILE *f;
-+	char *portal;
-+	int rc = 0;
-+
-+	portal = malloc(PATH_MAX);
-+	if (!portal) {
-+		log_error("Could not alloc portal\n");
-+		return ISCSI_ERR_NOMEM;
-+	}
-+	snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
-+		 rec->name, rec->conn[0].address, rec->conn[0].port);
-+
-+	f = fopen(portal, "w");
-+	if (!f) {
-+		log_error("Could not open %s: %sd\n", portal, strerror(errno));
-+		rc = ISCSI_ERR_IDBM;
-+		goto free_portal;
-+	}
-+	idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
-+	fclose(f);
-+free_portal:
-+	free(portal);
-+	return rc;
-+}
-+
-+static int idbm_rec_write(node_rec_t *rec)
-+{
-+	char *portal;
-+	int rc = 0;
-+
-+	portal = malloc(PATH_MAX);
-+	if (!portal) {
-+		log_error("Could not alloc portal\n");
-+		return ISCSI_ERR_NOMEM;
-+	}
-+
-+	snprintf(portal, PATH_MAX, "%s", NODE_CONFIG_DIR);
-+	if (access(portal, F_OK) != 0) {
-+		if (mkdir(portal, 0660) != 0) {
-+			log_error("Could not make %s: %s\n", portal,
-+				  strerror(errno));
-+			rc = ISCSI_ERR_IDBM;
-+			goto free_portal;
-+		}
-+	}
-+
-+	snprintf(portal, PATH_MAX, "%s/%s", NODE_CONFIG_DIR, rec->name);
-+	if (access(portal, F_OK) != 0) {
-+		if (mkdir(portal, 0660) != 0) {
-+			log_error("Could not make %s: %s\n", portal,
-+				  strerror(errno));
-+			rc = ISCSI_ERR_IDBM;
-+			goto free_portal;
-+		}
-+	}
-+
-+	rc = idbm_lock();
-+	if (rc)
-+		goto free_portal;
-+
-+	if (rec->tpgt == PORTAL_GROUP_TAG_UNKNOWN)
-+		/* old style portal as config */
-+		rc = idbm_rec_write_old(rec);
-+	else
-+		rc = idbm_rec_write_new(rec);
-+
- 	idbm_unlock();
- free_portal:
- 	free(portal);
--- 
-1.8.1.4
-
diff --git a/0046-idbw_rec_write-pick-tpgt-from-existing-record.patch b/0046-idbw_rec_write-pick-tpgt-from-existing-record.patch
deleted file mode 100644
index f69cef9..0000000
--- a/0046-idbw_rec_write-pick-tpgt-from-existing-record.patch
+++ /dev/null
@@ -1,87 +0,0 @@
-From ef61cd4912e90c8202598f2fa4e9f1842a5b5822 Mon Sep 17 00:00:00 2001
-From: Chris Leech <cleech at redhat.com>
-Date: Tue, 13 Aug 2013 12:39:07 -0700
-Subject: idbw_rec_write, pick tpgt from existing record
-
-On a static add (-m node -o new) without a user specified tpgt, looks
-for existing new style records with tpgt before creating an old style
-record without.  If one exists, take the tpgt from it an write an
-updated new style record instead.
----
- usr/idbm.c | 40 ++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 40 insertions(+)
-
-diff --git a/usr/idbm.c b/usr/idbm.c
-index cb6ffd1..0410079 100644
---- a/usr/idbm.c
-+++ b/usr/idbm.c
-@@ -27,6 +27,7 @@
- #include <errno.h>
- #include <dirent.h>
- #include <limits.h>
-+#include <glob.h>
- #include <sys/stat.h>
- #include <sys/file.h>
- 
-@@ -162,6 +163,8 @@ static struct idbm *db;
- 	_n++; \
- } while(0)
- 
-+static int idbm_remove_disc_to_node_link(node_rec_t *rec, char *portal);
-+
- static void
- idbm_recinfo_discovery(discovery_rec_t *r, recinfo_t *ri)
- {
-@@ -1884,12 +1887,49 @@ static int idbm_rec_write_old(node_rec_t *rec)
- 	FILE *f;
- 	char *portal;
- 	int rc = 0;
-+	glob_t globbuf;
-+	int i;
-+	int tpgt = PORTAL_GROUP_TAG_UNKNOWN;
- 
- 	portal = malloc(PATH_MAX);
- 	if (!portal) {
- 		log_error("Could not alloc portal\n");
- 		return ISCSI_ERR_NOMEM;
- 	}
-+
-+	/* check for newer portal dir with tpgt */
-+	snprintf(portal, PATH_MAX, "%s/%s/%s,%d,*", NODE_CONFIG_DIR,
-+		 rec->name, rec->conn[0].address, rec->conn[0].port);
-+	rc = glob(portal, GLOB_ONLYDIR, NULL, &globbuf);
-+	if (!rc) {
-+		if (globbuf.gl_pathc > 1)
-+			log_warning("multiple tpg records for portal "
-+				    "%s/%s:%d found", rec->name,
-+				    rec->conn[0].address, rec->conn[0].port);
-+		/* set pattern for sscanf matching of tpgt */
-+		snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%%u", NODE_CONFIG_DIR,
-+			 rec->name, rec->conn[0].address, rec->conn[0].port);
-+		for (i = 0; i < globbuf.gl_pathc; i++) {
-+			rc = sscanf(globbuf.gl_pathv[i], portal, &tpgt);
-+			if (rc == 1)
-+				break;
-+		}
-+		if (tpgt == PORTAL_GROUP_TAG_UNKNOWN)
-+			log_warning("glob match on existing records, "
-+				    "but no valid tpgt found");
-+	}
-+	globfree(&globbuf);
-+	rc = 0;
-+
-+	/* if a tpgt was selected from an old record, write entry in new format */
-+	if (tpgt != PORTAL_GROUP_TAG_UNKNOWN) {
-+		log_warning("using tpgt %u from existing record", tpgt);
-+		rec->tpgt = tpgt;
-+		rc = idbm_remove_disc_to_node_link(rec, portal);
-+		free(portal);
-+		return idbm_rec_write_new(rec);
-+	}
-+
- 	snprintf(portal, PATH_MAX, "%s/%s/%s,%d", NODE_CONFIG_DIR,
- 		 rec->name, rec->conn[0].address, rec->conn[0].port);
- 
--- 
-1.8.3.1
-
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/open-iscsi.git/commitdiff/75c46b011d7485a4b5676d824c7f3cdea2076f49



More information about the pld-cvs-commit mailing list