This introduces a new 'multiple' flag to the session_rec_t, which if set
instructs iscsid to bypass the check which would normally prevent
multiple sessions from a single iface record, allowing multiple sessions
to be created.

The commandline syntax to actually set this flag will be introduced in a
later commit.

Copyright (c) 2011 Dell Inc.
Signed-off-by: Jim Ramsay <[email protected]>
---
 usr/config.h       |    3 +++
 usr/idbm.c         |    1 +
 usr/initiator.c    |    8 ++++++--
 usr/iscsiadm.c     |    2 +-
 usr/session_mgmt.c |    7 +++++--
 5 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/usr/config.h b/usr/config.h
index 579c8ec..245e933 100644
--- a/usr/config.h
+++ b/usr/config.h
@@ -195,6 +195,9 @@ typedef struct session_rec {
        struct iscsi_session_operational_config iscsi;
        struct session_info*                    info;
        unsigned                                sid;
+       /* This is a flag passed to iscsid.  If set, multiple sessions are
+        * allowed to be initiated on this record */
+       unsigned char                           multiple;
 } session_rec_t;
 
 #define ISCSI_TRANSPORT_NAME_MAXLEN 16
diff --git a/usr/idbm.c b/usr/idbm.c
index 83876ec..42a7486 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2414,6 +2414,7 @@ void idbm_node_setup_defaults(node_rec_t *rec)
        rec->session.timeo.replacement_timeout = DEF_REPLACEMENT_TIMEO;
        rec->session.info = NULL;
        rec->session.sid = 0;
+       rec->session.multiple = 0;
        idbm_setup_session_defaults(&rec->session.iscsi);
 
        for (i=0; i<ISCSI_CONN_MAX; i++) {
diff --git a/usr/initiator.c b/usr/initiator.c
index c004406..185324c 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -1644,8 +1644,12 @@ session_login_task(node_rec_t *rec, queue_task_t *qtask)
        struct iscsi_transport *t;
        int rc;
 
-       if (session_is_running(rec))
-               return ISCSI_ERR_SESS_EXISTS;
+       if (session_is_running(rec)) {
+               if (rec->session.multiple)
+                       log_debug(2, "Adding a new multiple of an existing 
session");
+               else
+                       return ISCSI_ERR_SESS_EXISTS;
+       }
 
        t = iscsi_sysfs_get_transport_by_name(rec->iface.transport_name);
        if (!t)
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 06a088b..26e485c 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -531,7 +531,7 @@ static int login_portals(struct node_rec *pattern_rec)
        rc = err;
        /* if there is an err but some recs then try to login to what we have */
 
-       err = iscsi_login_portals(NULL, &nr_found, 1, &rec_list,
+       err = iscsi_login_portals(pattern_rec, &nr_found, 1, &rec_list,
                                  iscsi_login_portal);
        if (err)
                log_error("Could not log into all portals");
diff --git a/usr/session_mgmt.c b/usr/session_mgmt.c
index 0bfa205..ee9b32d 100644
--- a/usr/session_mgmt.c
+++ b/usr/session_mgmt.c
@@ -102,10 +102,13 @@ int iscsi_login_portal(void *data, struct list_head 
*list, struct node_rec *rec)
 {
        struct iscsid_async_req *async_req = NULL;
        int rc = 0, fd;
+       struct node_rec *pattern_rec = data;
+       rec->session.multiple = pattern_rec->session.multiple;
 
-       log_info("Logging in to [iface: %s, target: %s, portal: %s,%d]",
+       log_info("Logging in to [iface: %s, target: %s, portal: %s,%d]%s",
                 rec->iface.name, rec->name, rec->conn[0].address,
-                rec->conn[0].port);
+                rec->conn[0].port,
+                (rec->session.multiple ? " (multiple)" : ""));
 
        if (list) {
                async_req = calloc(1, sizeof(*async_req));
-- 
1.7.5.3


-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to