Add support for synchronous command timeout.

Default to 0 meaning no timeout.

Implement a test for iSCS to test what happens if we send a command
with CMDSN being higher than the target allows.
In this case we dont strictly know what will happen, just that what should
NOT happen is the target responding with success.
But we have to be prepared for any kind of failure, including a timeout,
scsi sense, or even iscsi reject or session failure.
This commit is contained in:
Ronnie Sahlberg
2013-04-29 20:42:33 -07:00
parent 5bce69f1f3
commit 4a8d967541
13 changed files with 324 additions and 169 deletions

View File

@@ -131,7 +131,8 @@ struct iscsi_context {
int reallocs;
int frees;
time_t last_reconnect;
time_t last_reconnect;
int scsi_timeout;
};
#define ISCSI_PDU_IMMEDIATE 0x40
@@ -224,6 +225,7 @@ struct iscsi_pdu {
struct iscsi_data indata;
struct iscsi_scsi_cbdata scsi_cbdata;
time_t scsi_timeout;
};
struct iscsi_pdu *iscsi_allocate_pdu(struct iscsi_context *iscsi,
@@ -326,6 +328,8 @@ iscsi_serial32_compare(uint32_t s1, uint32_t s2);
u_int32_t
iscsi_itt_post_increment(struct iscsi_context *iscsi);
void iscsi_timeout_scan(struct iscsi_context *iscsi);
#ifdef __cplusplus
}
#endif

View File

@@ -70,11 +70,18 @@ EXTERN int iscsi_service(struct iscsi_context *iscsi, int revents);
*/
EXTERN int iscsi_queue_length(struct iscsi_context *iscsi);
/*
* Set the timeout in seconds after which a synchronous SCSI command
* will timeout.
* Default is 0 == no timeout.
*/
EXTERN int iscsi_set_timeout(struct iscsi_context *iscsi, int timeout);
/*
* To set tcp keepalive for the session.
* Only options supported by given platform (if any) are set.
*/
int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval);
EXTERN int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval);
struct iscsi_url {
char portal[MAX_STRING_SIZE+1];
@@ -268,7 +275,8 @@ enum scsi_status {
SCSI_STATUS_RESERVATION_CONFLICT = 0x18,
SCSI_STATUS_REDIRECT = 0x101,
SCSI_STATUS_CANCELLED = 0x0f000000,
SCSI_STATUS_ERROR = 0x0f000001
SCSI_STATUS_ERROR = 0x0f000001,
SCSI_STATUS_TIMEOUT = 0x0f000002
};