This patch has iscsid/iscsiadm pass the non-negotiated settings (abort
tmo, persistent ip, target name, chap, etc) before we send the iscsi
login pdu. This fixes a issue where when login takes a long time and you
run iscsiadm -m session you get errors due to the targetname/ip not
being set yet. This also sets the discovery sess param (should have done
that in a second patch but for testing this makes it easier).

For offloaded drivers that do the login process in the fw, like qla4xxx,
setup_offload_login_phase should not change behavior.

Lalit and Vikas, I do not have a qla4xxx card anymore. Could you test
this patch real quick before I merge it? Just run the discovery command
and login/logout and a quick cable unplug then plug back in test to make
sure I did not add a regression for your driver.

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at http://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/usr/discovery.c b/usr/discovery.c
index afce6c0..635ec8d 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -1403,6 +1403,17 @@ redirect_reconnect:
        iscsi_copy_operational_params(&session->conn[0], &config->session_conf,
                                      &config->conn_conf);
 
+       if (t->caps & CAP_TEXT_NEGO) {
+               log_debug(2, "%s discovery set params\n", __FUNCTION__);
+               rc = iscsi_session_set_params(conn);
+               if (rc) {
+                       log_error("Could not set iscsi params for conn %d:%d "
+                                 "(err %d)\n", session->id, conn->id, rc);
+                       rc = ISCSI_ERR_INTERNAL;
+                       goto login_failed;
+               }
+       }
+
        if ((session->t->caps & CAP_LOGIN_OFFLOAD))
                goto start_conn;
 
@@ -1509,8 +1520,8 @@ redirect_reconnect:
                return 0;
 
 start_conn:
-       log_debug(2, "%s discovery set params\n", __FUNCTION__);
-       rc = iscsi_session_set_params(conn);
+       log_debug(2, "%s discovery set neg params\n", __FUNCTION__);
+       rc = iscsi_session_set_neg_params(conn);
        if (rc) {
                log_error("Could not set iscsi params for conn %d:%d (err "
                          "%d)\n", session->id, conn->id, rc);
diff --git a/usr/initiator.c b/usr/initiator.c
index 79d1779..05a5b19 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -1048,12 +1048,7 @@ setup_full_feature_phase(iscsi_conn_t *conn)
 
        actor_delete(&conn->login_timer);
 
-       if (iscsi_session_set_params(conn)) {
-               iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
-               return;
-       }
-
-       if (iscsi_host_set_params(session)) {
+       if (iscsi_session_set_neg_params(conn)) {
                iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
                return;
        }
@@ -1507,6 +1502,11 @@ static void setup_offload_login_phase(iscsi_conn_t *conn)
                return;
        }
 
+       if (iscsi_session_set_neg_params(conn)) {
+               iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
+               return;
+       }
+
        if (iscsi_host_set_params(session)) {
                iscsi_login_eh(conn, c->qtask, ISCSI_ERR_LOGIN);
                return;
@@ -1618,6 +1618,16 @@ static void session_conn_poll(void *data)
                        return;
                }
 
+               if (iscsi_session_set_params(conn)) {
+                       iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
+                       return;
+               }
+
+               if (iscsi_host_set_params(session)) {
+                       iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
+                       return;
+               }
+
                if (iscsi_login_begin(session, c)) {
                        iscsi_login_eh(conn, qtask, ISCSI_ERR_LOGIN);
                        return;
diff --git a/usr/initiator.h b/usr/initiator.h
index 680640c..c34625b 100644
--- a/usr/initiator.h
+++ b/usr/initiator.h
@@ -344,6 +344,7 @@ extern void free_initiator(void);
 extern void iscsi_initiator_init(void);
 
 /* initiator code common to discovery and normal sessions */
+extern int iscsi_session_set_neg_params(struct iscsi_conn *conn);
 extern int iscsi_session_set_params(struct iscsi_conn *conn);
 extern int iscsi_host_set_params(struct iscsi_session *session);
 extern int iscsi_host_set_net_params(struct iface_rec *iface,
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index e2e87a1..109e8d7 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -345,9 +345,9 @@ void iscsi_session_init_params(struct iscsi_session 
*session)
        }
 }
 
-#define MAX_SESSION_PARAMS 35
+#define MAX_SESSION_NEG_PARAMS 16
 
-int iscsi_session_set_params(struct iscsi_conn *conn)
+int iscsi_session_set_neg_params(struct iscsi_conn *conn)
 {
        struct iscsi_session *session = conn->session;
        int i, rc;
@@ -357,7 +357,7 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
                int type;
                void *value;
                int conn_only;
-       } conntbl[MAX_SESSION_PARAMS] = {
+       } conntbl[MAX_SESSION_NEG_PARAMS] = {
                {
                        .param = ISCSI_PARAM_MAX_RECV_DLENGTH,
                        .value = &conn->max_recv_dlength,
@@ -434,15 +434,58 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
                        .type = ISCSI_INT,
                        .conn_only = 1,
                }, {
-                       .param = ISCSI_PARAM_TARGET_NAME,
-                       .conn_only = 0,
-                       .type = ISCSI_STRING,
-                       .value = session->target_name,
-               }, {
                        .param = ISCSI_PARAM_TPGT,
                        .value = &session->portal_group_tag,
                        .type = ISCSI_INT,
                        .conn_only = 0,
+               },
+       };
+
+       iscsi_session_init_params(session);
+
+       /* Entered full-feature phase! */
+       for (i = 0; i < MAX_SESSION_NEG_PARAMS; i++) {
+               if (conn->id != 0 && !conntbl[i].conn_only)
+                       continue;
+
+               if (!(session->param_mask & (1ULL << conntbl[i].param)))
+                       continue;
+
+               rc = ipc->set_param(session->t->handle, session->id,
+                                  conn->id, conntbl[i].param, conntbl[i].value,
+                                  conntbl[i].type);
+               if (rc && rc != -ENOSYS) {
+                       log_error("can't set operational parameter %d for "
+                                 "connection %d:%d, retcode %d (%d)",
+                                 conntbl[i].param, session->id, conn->id,
+                                 rc, errno);
+                       return EPERM;
+               }
+
+               print_param_value(conntbl[i].param, conntbl[i].value,
+                                 conntbl[i].type);
+       }
+
+       return 0;
+}
+
+#define MAX_SESSION_PARAMS 20
+
+int iscsi_session_set_params(struct iscsi_conn *conn)
+{
+       struct iscsi_session *session = conn->session;
+       int i, rc;
+       struct connparam {
+               int param;
+               int type;
+               void *value;
+               int conn_only;
+       } conntbl[MAX_SESSION_PARAMS] = {
+               {
+                       .param = ISCSI_PARAM_TARGET_NAME,
+                       .conn_only = 0,
+                       .type = ISCSI_STRING,
+                       .value = session->target_name,
                }, {
                        .param = ISCSI_PARAM_PERSISTENT_ADDRESS,
                        .value = session->nrec.conn[conn->id].address,
@@ -512,22 +555,32 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
                        .param = ISCSI_PARAM_IFACE_NAME,
                        .value = session->nrec.iface.name,
                        .type = ISCSI_STRING,
+                       .conn_only = 0,
                }, {
                        .param = ISCSI_PARAM_INITIATOR_NAME,
                        .value = session->initiator_name,
                        .type = ISCSI_STRING,
+                       .conn_only = 0,
                }, {
                        .param = ISCSI_PARAM_BOOT_ROOT,
                        .value = session->nrec.session.boot_root,
                        .type = ISCSI_STRING,
+                       .conn_only = 0,
                }, {
                        .param = ISCSI_PARAM_BOOT_NIC,
                        .value = session->nrec.session.boot_nic,
                        .type = ISCSI_STRING,
+                       .conn_only = 0,
                }, {
                        .param = ISCSI_PARAM_BOOT_TARGET,
                        .value = session->nrec.session.boot_target,
                        .type = ISCSI_STRING,
+                       .conn_only = 0,
+               }, {
+                       .param = ISCSI_PARAM_DISCOVERY_SESS,
+                       .value = &session->type,
+                       .type = ISCSI_INT,
+                       .conn_only = 0,
                },
        };
 

Reply via email to