diff options
author | Lee Duncan <lduncan@suse.com> | 2021-12-08 13:53:53 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-08 13:53:53 -0800 |
commit | 38f5652d01e651c0bebfdc8f57d3c9a6e209ecb8 (patch) | |
tree | 6b2d3df16202e8220131420cada7782aca2f000c | |
parent | 92508ee649fd2379b909e8d83fe0baf8c42190ed (diff) | |
parent | 67eb8b217daa87ef3f14a1d631eb0345ba870684 (diff) | |
download | open-iscsi-38f5652d01e651c0bebfdc8f57d3c9a6e209ecb8.tar.gz |
Merge pull request #291 from mikechristie/iscsistart-fixes
iscsistart fix and timeout cleanup
-rw-r--r-- | include/iscsi_err.h | 2 | ||||
-rw-r--r-- | usr/iscsid_req.c | 9 | ||||
-rw-r--r-- | usr/iscsistart.c | 24 |
3 files changed, 11 insertions, 24 deletions
diff --git a/include/iscsi_err.h b/include/iscsi_err.h index 04a8723..c31b05a 100644 --- a/include/iscsi_err.h +++ b/include/iscsi_err.h @@ -70,6 +70,8 @@ enum iscsi_error_list { ISCSI_ERR_CHILD_TERMINATED = 31, /* session likely not connected */ ISCSI_ERR_SESSION_NOT_CONNECTED = 32, + /* iscsid request timed out */ + ISCSI_ERR_REQ_TIMEDOUT = 33, /* Always last. Indicates end of error code space */ ISCSI_MAX_ERR_VAL, diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c index 596086e..f0882b5 100644 --- a/usr/iscsid_req.c +++ b/usr/iscsid_req.c @@ -141,12 +141,7 @@ int iscsid_response(int fd, iscsiadm_cmd_e cmd, iscsiadm_rsp_t *rsp, size_t len = sizeof(*rsp); int iscsi_err = ISCSI_ERR_ISCSID_COMM_ERR; int err; - int poll_wait = 0; - if (timeout == -1) { - timeout = ISCSID_REQ_TIMEOUT; - poll_wait = 1; - } while (len) { struct pollfd pfd; @@ -154,9 +149,7 @@ int iscsid_response(int fd, iscsiadm_cmd_e cmd, iscsiadm_rsp_t *rsp, pfd.events = POLLIN; err = poll(&pfd, 1, timeout); if (!err) { - if (poll_wait) - continue; - return ISCSI_ERR_SESSION_NOT_CONNECTED; + return ISCSI_ERR_REQ_TIMEDOUT; } else if (err < 0) { if (errno == EINTR) continue; diff --git a/usr/iscsistart.c b/usr/iscsistart.c index 7eb573e..b23751b 100644 --- a/usr/iscsistart.c +++ b/usr/iscsistart.c @@ -241,26 +241,18 @@ static int login_session(struct node_rec *rec) /* * Need to handle race where iscsid proc is starting up while we are * trying to connect. Retry with exponential backoff, start from 50 ms. - * - * NOTE: another race condition can occur if the system is just coming - * up, where our login request will be sent, but the login response - * takes a while. In such a case, if we timeout and give up, the - * login response may still show up once we give up, in which case - * it seems to get iscsistart into a state where it cannot try to - * login again because it thinks there's already a session. So make - * sure our timeout is long enough, on each try, to give the response - * a chance to show up. The old value of 1 second was not enough, - * so we multiply that by 10, which seems reasonable for initial - * login. */ for (msec = 50; msec <= 15000; msec <<= 1) { - int tmo = ISCSID_REQ_TIMEOUT * 10; - - rc = iscsid_exec_req(&req, &rsp, 0, tmo); + /* + * Once our event loop is up then we want to wait for the login + * response. Either it logs in, we hit the login retries count, + * or this program crashes, so there no need for the response + * timeout. + */ + rc = iscsid_exec_req(&req, &rsp, 0, -1); if (rc == 0) { return rc; - } else if (rc == ISCSI_ERR_SESSION_NOT_CONNECTED || - rc == ISCSI_ERR_ISCSID_NOTCONN) { + } else if (rc == ISCSI_ERR_ISCSID_NOTCONN) { ts.tv_sec = msec / 1000; ts.tv_nsec = (msec % 1000) * 1000000L; |