summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/iscsid.conf14
-rw-r--r--usr/config.h1
-rw-r--r--usr/idbm.c2
-rw-r--r--usr/iscsi_settings.h3
-rw-r--r--usr/iscsiadm.c32
-rw-r--r--usr/util.c1
6 files changed, 42 insertions, 11 deletions
diff --git a/etc/iscsid.conf b/etc/iscsid.conf
index 78e6824..94dd758 100644
--- a/etc/iscsid.conf
+++ b/etc/iscsid.conf
@@ -92,6 +92,20 @@ node.conn[0].timeo.noop_out_interval = 10
# The value is in seconds and the default is 15 seconds.
node.conn[0].timeo.noop_out_timeout = 15
+
+#******
+# Retry
+#*******
+
+# To speficy the number of times iscsiadm should retry a login
+# to the target when we first login, modify the following line.
+# The default is 4. Valid values are any integer value. This only
+# affects the initial login. Setting it to a high value can slow
+# down the iscsi service startup. Setting it to a low value can
+# cause a session to not get logged into, if there are distuptions
+# during startup or if the network is not ready at that time.
+node.session.initial_login_retry_max = 4
+
#***************
# iSCSI settings
#***************
diff --git a/usr/config.h b/usr/config.h
index b0ad1e5..493be42 100644
--- a/usr/config.h
+++ b/usr/config.h
@@ -174,6 +174,7 @@ typedef struct session_rec {
int reopen_max;
int cmds_max;
int queue_depth;
+ int initial_login_retry_max;
struct iscsi_auth_config auth;
struct iscsi_session_timeout_config timeo;
struct iscsi_error_timeout_config err_timeo;
diff --git a/usr/idbm.c b/usr/idbm.c
index 179c0b3..b53a4d3 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -244,6 +244,8 @@ idbm_recinfo_node(node_rec_t *r, recinfo_t *ri)
"slp", "isns", "static", num);
__recinfo_int("node.session.initial_cmdsn", ri, r,
session.initial_cmdsn, IDBM_SHOW, num);
+ __recinfo_int("node.session.initial_login_retry_max", ri, r,
+ session.initial_login_retry_max, IDBM_SHOW, num);
__recinfo_int("node.session.cmds_max", ri, r,
session.cmds_max, IDBM_SHOW, num);
__recinfo_int("node.session.queue_depth", ri, r,
diff --git a/usr/iscsi_settings.h b/usr/iscsi_settings.h
index 5fed351..f1d7a1e 100644
--- a/usr/iscsi_settings.h
+++ b/usr/iscsi_settings.h
@@ -34,3 +34,6 @@
#define DEF_INI_MAX_BURST_LEN 16776192
#define DEF_INI_MAX_RECV_SEG_LEN 131072
#define DEF_INI_DISC_MAX_RECV_SEG_LEN 32768
+
+/* login retries */
+#define DEF_INITIAL_LOGIN_RETRIES_MAX 4
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 824d3d0..ece0f8a 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -478,22 +478,32 @@ for_each_session(struct node_rec *rec, sysfs_session_op_fn *fn)
static int login_portal(idbm_t *db, void *data, node_rec_t *rec)
{
- int rc;
+ int rc = 0, i;
printf("Login session [iface: %s, target: %s, portal: %s,%d]\n",
rec->iface.name, rec->name, rec->conn[0].address,
rec->conn[0].port);
- rc = session_login(rec);
- /* we raced with another app or instance of iscsiadm */
- if (rc == MGMT_IPC_ERR_EXISTS)
- rc = 0;
- if (rc)
- log_error("Could not login session (err %d).", rc);
- if (rc > 0) {
- iscsid_handle_error(rc);
- /* continue trying to login the rest of them */
- rc = 0;
+ for (i = 0; i < rec->session.initial_login_retry_max; i++) {
+ rc = session_login(rec);
+ if (!rc)
+ break;
+ /* we raced with another app or instance of iscsiadm */
+ if (rc == MGMT_IPC_ERR_EXISTS) {
+ rc = 0;
+ break;
+ }
+
+ if (rc)
+ log_error("Could not login session (err %d).", rc);
+ if (rc > 0) {
+ iscsid_handle_error(rc);
+ /* continue trying to login the rest of them */
+ rc = 0;
+ }
+
+ if (i + 1 != rec->session.initial_login_retry_max)
+ sleep(1);
}
return rc;
diff --git a/usr/util.c b/usr/util.c
index e0fdfb5..0c0cdfa 100644
--- a/usr/util.c
+++ b/usr/util.c
@@ -188,6 +188,7 @@ void idbm_node_setup_defaults(node_rec_t *rec)
rec->session.initial_cmdsn = 0;
rec->session.cmds_max = CMDS_MAX;
rec->session.queue_depth = QUEUE_DEPTH;
+ rec->session.initial_login_retry_max = DEF_INITIAL_LOGIN_RETRIES_MAX;
rec->session.reopen_max = 32;
rec->session.auth.authmethod = 0;
rec->session.auth.password_length = 0;