iscsi update for 2.6.32
Subsystems (3)
The following patches are for 2.6.32. They were made againsts scsi-misc. There is not really anything interesting. The only new feature is Erez's logging changes, that allow you do turn logging on at run time.
There are some bug fixes which improve detection of when the target closes the connection on us, and a fix for the cmdsn management when using bnx2i.
PATCH 2/7 libiscsi: don't increment cmdsn if cmd is not sent
In reply to [email protected]From: Mike Christie <[email protected]>
We increment session->cmdsn at the top of iscsi_prep_scsi_cmd_pdu, but if the prep ecb or prep bidi or init_task calls fails then we leave the session->cmdsn incremented. This moves the cmdsn manipulation to the end of the function when we know it has succeeded.
It also adds a session->cmdsn--; in queuecommand for if a driver like bnx2i tries to send a a task from that context but it fails. We do not have to do this in the xmit thread context because that code will retry the same task if the initial call fails.
--- drivers/scsi/libiscsi.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +3 -2
@@ -301,8 +301,6 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task) hdr->flags =ISCSI_ATTR_SIMPLE ;int_to_scsilun (sc->device->lun, (struct scsi_lun *)hdr->lun);memcpy (task->lun, hdr->lun,sizeof (task->lun)); - hdr->cmdsn = task->cmdsn =cpu_to_be32 (session->cmdsn); - session->cmdsn++; hdr->exp_statsn =cpu_to_be32 (conn->exp_statsn); cmd_len = sc->cmd_len;if (cmd_len <ISCSI_CDB_SIZE )
@@ -388,6 +386,8 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)return -EIO ; task->state =ISCSI_TASK_RUNNING ; + hdr->cmdsn = task->cmdsn =cpu_to_be32 (session->cmdsn); + session->cmdsn++; conn->scsicmd_pdus_cnt++; ISCSI_DBG_SESSION(session, "iscsi prep [%s cid %d sc %p cdb 0x%x "
@@ -1497,6 +1497,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) } }if (session->tt->xmit_task (task)) { + session->cmdsn--; reason =FAILURE_SESSION_NOT_READY ; goto prepd_reject; }
Signature · 1 line
1.6.2.2
PATCH 1/7 iscsi_tcp: Evaluate socket state in data_ready()
In reply to [email protected]From: Hannes Reinecke <[email protected]>
The network core will call the state_change() callback prior to the data_ready() callback, which might cause us to lose a connection state change.
So we have to evaluate the socket state at the end of the data_ready() callback, too.
--- drivers/scsi/iscsi_tcp.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-)
drivers/scsi/iscsi_tcp.c +25 -3
@@ -99,6 +99,24 @@ static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,return total_consumed; } +/** +* iscsi_sw_sk_state_check - check socket state +* @sk: socket +* +* If the socket is in CLOSE or CLOSE_WAIT we should +* not close the connection if there is still some +* data pending. +*/ +static inline int iscsi_sw_sk_state_check (struct sock *sk) +{ +if ((sk->sk_state ==TCP_CLOSE_WAIT || + sk->sk_state ==TCP_CLOSE ) && + !atomic_read (&sk->sk_rmem_alloc)) +return -ECONNRESET ; + +return 0 ; +} +static void iscsi_sw_tcp_data_ready (struct sock *sk,int flag) {struct iscsi_conn *conn = sk->sk_user_data;
@@ -117,6 +135,12 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag) rd_desc.count =1 ;tcp_read_sock (sk, &rd_desc, iscsi_sw_tcp_recv); +if (iscsi_sw_sk_state_check (sk) <0 ) { +ISCSI_SW_TCP_DBG (conn,"iscsi_tcp_data_ready: " +"TCP_CLOSE|TCP_CLOSE_WAIT\n" ); +iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED ); + } +read_unlock (&sk->sk_callback_lock);/* If we had to (atomically) map a highmem page,
@@ -137,9 +161,7 @@ static void iscsi_sw_tcp_state_change(struct sock *sk) conn = (struct iscsi_conn *)sk->sk_user_data; session = conn->session; -if ((sk->sk_state ==TCP_CLOSE_WAIT || - sk->sk_state ==TCP_CLOSE ) && - !atomic_read (&sk->sk_rmem_alloc)) { +if (iscsi_sw_sk_state_check (sk) <0 ) {ISCSI_SW_TCP_DBG (conn,"iscsi_tcp_state_change: " "TCP_CLOSE|TCP_CLOSE_WAIT\n" );iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED );
Signature · 1 line
1.6.2.2
PATCH 3/7 libiscsi: handle immediate command rejections
In reply to [email protected]From: Mike Christie <[email protected]>
If we sent multiple pdus as immediate the target could be rejecting some and we have just been dropping the rejection notification. This adds code to handle nop-out rejections, so if a nop-out was sent as a ping and rejected we do not mark the connection bad. Instead we just clean up the timers since we have pdu making a rount trip we know the connection is good.
--- drivers/scsi/libiscsi.c | 106 ++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 87 insertions(+), 19 deletions(-)
drivers/scsi/libiscsi.c +87 -19
@@ -857,27 +857,102 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) } } +static int iscsi_nop_out_rsp (struct iscsi_task *task, +struct iscsi_nopin *nop,char *data,int datalen) +{ +struct iscsi_conn *conn = task->conn; +int rc =0 ; + +if (conn->ping_task != task) { +/* +* If this is not in response to one of our +* nops then it must be from userspace. +*/ +if (iscsi_recv_pdu (conn->cls_conn, (struct iscsi_hdr *)nop, + data, datalen)) + rc =ISCSI_ERR_CONN_FAILED ; + }else +mod_timer (&conn->transport_timer, jiffies + conn->recv_timeout); +iscsi_complete_task (task,ISCSI_TASK_COMPLETED ); +return rc; +} +static int iscsi_handle_reject (struct iscsi_conn *conn,struct iscsi_hdr *hdr,char *data,int datalen) {struct iscsi_reject *reject = (struct iscsi_reject *)hdr;struct iscsi_hdr rejected_pdu; +int opcode, rc =0 ; conn->exp_statsn =be32_to_cpu (reject->statsn) +1 ; -if (reject->reason ==ISCSI_REASON_DATA_DIGEST_ERROR ) { -if (ntoh24 (reject->dlength) > datalen) -return ISCSI_ERR_PROTO ; +if (ntoh24 (reject->dlength) > datalen || +ntoh24 (reject->dlength) <sizeof (struct iscsi_hdr )) { +iscsi_conn_printk (KERN_ERR , conn,"Cannot handle rejected " +"pdu. Invalid data length (pdu dlength " +"%u, datalen %d\n" ,ntoh24 (reject->dlength), + datalen); +return ISCSI_ERR_PROTO ; + } +memcpy (&rejected_pdu, data,sizeof (struct iscsi_hdr )); + opcode = rejected_pdu.opcode &ISCSI_OPCODE_MASK ; -if (ntoh24 (reject->dlength) >=sizeof (struct iscsi_hdr )) { -memcpy (&rejected_pdu, data,sizeof (struct iscsi_hdr )); -iscsi_conn_printk (KERN_ERR , conn, -"pdu (op 0x%x) rejected " -"due to DataDigest error.\n" , - rejected_pdu.opcode); +switch (reject->reason) { +case ISCSI_REASON_DATA_DIGEST_ERROR : +iscsi_conn_printk (KERN_ERR , conn, +"pdu (op 0x%x itt 0x%x) rejected " +"due to DataDigest error.\n" , + rejected_pdu.itt, opcode); +break ; +case ISCSI_REASON_IMM_CMD_REJECT : +iscsi_conn_printk (KERN_ERR , conn, +"pdu (op 0x%x itt 0x%x) rejected. Too many " +"immediate commands.\n" , + rejected_pdu.itt, opcode); +/* +* We only send one TMF at a time so if the target could not +* handle it, then it should get fixed (RFC mandates that +* a target can handle one immediate TMF per conn). +* +* For nops-outs, we could have sent more than one if +* the target is sending us lots of nop-ins +*/ +if (opcode !=ISCSI_OP_NOOP_OUT ) +return 0 ; + +if (rejected_pdu.itt ==cpu_to_be32 (ISCSI_RESERVED_TAG )) +/* +* nop-out in response to target's nop-out rejected. +* Just resend. +*/ +iscsi_send_nopout (conn, + (struct iscsi_nopin *)&rejected_pdu); +else { +struct iscsi_task *task; +/* +* Our nop as ping got dropped. We know the target +* and transport are ok so just clean up +*/ + task =iscsi_itt_to_task (conn, rejected_pdu.itt); +if (!task) { +iscsi_conn_printk (KERN_ERR , conn, +"Invalid pdu reject. Could " +"not lookup rejected task.\n" ); + rc =ISCSI_ERR_BAD_ITT ; + }else + rc =iscsi_nop_out_rsp (task, + (struct iscsi_nopin *)&rejected_pdu, +NULL ,0 ); } +break ; +default : +iscsi_conn_printk (KERN_ERR , conn, +"pdu (op 0x%x itt 0x%x) rejected. Reason " +"code 0x%x\n" , rejected_pdu.itt, + rejected_pdu.opcode, reject->reason); +break ; } -return 0 ; +return rc; }/**
@@ -1038,15 +1113,8 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, } conn->exp_statsn =be32_to_cpu (hdr->statsn) +1 ; -if (conn->ping_task != task) -/* -* If this is not in response to one of our -* nops then it must be from userspace. -*/ - goto recv_pdu; - -mod_timer (&conn->transport_timer, jiffies + conn->recv_timeout); -iscsi_complete_task (task,ISCSI_TASK_COMPLETED ); + rc =iscsi_nop_out_rsp (task, (struct iscsi_nopin *)hdr, + data, datalen);break ;default : rc =ISCSI_ERR_BAD_OPCODE ;
Signature · 1 line
1.6.2.2
PATCH 4/7 qla4xxx: Removed residual from overrun debug print
From: Mike Christie <[email protected]>
The residual variable is only valid for udnerrun so do not print it out for the overrun case.
--- drivers/scsi/qla4xxx/ql4_isr.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/qla4xxx/ql4_isr.c +4 -4
@@ -153,11 +153,11 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,case SCS_DATA_UNDERRUN :case SCS_DATA_OVERRUN :if ((sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_OVER ) || - (sts_entry->completionStatus ==SCS_DATA_OVERRUN )) { -DEBUG2 (printk ("scsi%ld:%d:%d:%d: %s: " "Data overrun, " -"residual = 0x%x\n" , ha->host_no, + (sts_entry->completionStatus ==SCS_DATA_OVERRUN )) { +DEBUG2 (printk ("scsi%ld:%d:%d:%d: %s: " "Data overrun\n" , + ha->host_no, cmd->device->channel, cmd->device->id, - cmd->device->lun, __func__, residual)); + cmd->device->lun, __func__)); cmd->result =DID_ERROR <<16 ;break ;
Signature · 1 line
1.6.2.2
PATCH 7/7 libiscsi, iscsi_tcp: check suspend bit before each call to xmit_task
In reply to [email protected]From: Mike Christie <[email protected]>
If we had multiple tasks on the cmd or requeue lists, and iscsi_tcp returns a error, the write_space function can still run and queue iscsi_data_xmit. If it was a legetimate problem and iscsi_conn_failure was run but we raced and iscsi_data_xmit was run first it could miss the suspend bit checks, and start trying to send data again and hit another timeout. A similar problem is present when using cxgb3i.
This has libiscsi check the suspend bit before calling the xmit task callout, so we at least do not try sending multiple tasks (one could be sent).
--- drivers/scsi/libiscsi.c | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-)
drivers/scsi/libiscsi.c +10 -9
@@ -1280,6 +1280,9 @@ static int iscsi_xmit_task(struct iscsi_conn *conn)struct iscsi_task *task = conn->task;int rc; +if (test_bit (ISCSI_SUSPEND_BIT , &conn->suspend_tx)) +return -ENODATA ; +__iscsi_get_task (task);spin_unlock_bh (&conn->session->lock); rc = conn->session->tt->xmit_task (task);
@@ -1329,7 +1332,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)int rc =0 ;spin_lock_bh (&conn->session->lock); -if (unlikely (conn->suspend_tx)) { +if (test_bit (ISCSI_SUSPEND_BIT , &conn->suspend_tx)) {ISCSI_DBG_SESSION (conn->session,"Tx suspended!\n" );spin_unlock_bh (&conn->session->lock);return -ENODATA ;
@@ -1338,7 +1341,7 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)if (conn->task) { rc =iscsi_xmit_task (conn);if (rc) - goto again; + goto done; }/*
@@ -1358,7 +1361,7 @@ check_mgmt: } rc =iscsi_xmit_task (conn);if (rc) - goto again; + goto done; }/* process pending command queue */
@@ -1379,14 +1382,14 @@ check_mgmt:list_add_tail (&conn->task->running, &conn->cmdqueue); conn->task =NULL ; - goto again; + goto done; }else fail_scsi_task (conn->task,DID_ABORT );continue ; } rc =iscsi_xmit_task (conn);if (rc) - goto again; + goto done;/* * we could continuously get new task requests so * we need to check the mgmt queue for nops that need to
@@ -1412,16 +1415,14 @@ check_mgmt: conn->task->state =ISCSI_TASK_RUNNING ; rc =iscsi_xmit_task (conn);if (rc) - goto again; + goto done;if (!list_empty (&conn->mgmtqueue)) goto check_mgmt; }spin_unlock_bh (&conn->session->lock);return -ENODATA ; -again: -if (unlikely (conn->suspend_tx)) - rc = -ENODATA ; +done:spin_unlock_bh (&conn->session->lock);return rc; }
Signature · 1 line
1.6.2.2
PATCH 5/7 iscsi class: Add logging to scsi_transport_iscsi.c
In reply to [email protected]From: Mike Christie <[email protected]>
Quoted 1 line
From Erez:
Logging for connections and sessions in the scsi_transport_iscsi module is now controlled by module parameters.
--- drivers/scsi/scsi_transport_iscsi.c | 73 ++++++++++++++++++++++++++++++++++- 1 files changed, 71 insertions(+), 2 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +71 -2
@@ -36,6 +36,38 @@#define ISCSI_TRANSPORT_VERSION "2.0-870" +static int dbg_session; +module_param_named (debug_session, dbg_session, int, +S_IRUGO |S_IWUSR ); +MODULE_PARM_DESC (debug_session, +"Turn on debugging for sessions in scsi_transport_iscsi " +"module. Set to 1 to turn on, and zero to turn off. Default " +"is off." ); + +static int dbg_conn; +module_param_named (debug_conn, dbg_conn, int, +S_IRUGO |S_IWUSR ); +MODULE_PARM_DESC (debug_conn, +"Turn on debugging for connections in scsi_transport_iscsi " +"module. Set to 1 to turn on, and zero to turn off. Default " +"is off." ); + +#define ISCSI_DBG_TRANS_SESSION(_session, dbg_fmt, arg...) \ + do { \ + if (dbg_session) \ + iscsi_cls_session_printk(KERN_INFO, _session, \ + "%s: " dbg_fmt, \ + __func__, ##arg); \ + } while (0); + +#define ISCSI_DBG_TRANS_CONN(_conn, dbg_fmt, arg...) \ + do { \ + if (dbg_conn) \ + iscsi_cls_conn_printk(KERN_INFO, _conn, \ + "%s: " dbg_fmt, \ + __func__, ##arg); \ + } while (0); +struct iscsi_internal {struct scsi_transport_template t;struct iscsi_transport *iscsi_transport;
@@ -377,6 +409,7 @@ static void iscsi_session_release(struct device *dev) shost =iscsi_session_to_shost (session);scsi_host_put (shost); +ISCSI_DBG_TRANS_SESSION (session,"Completing session release\n" );kfree (session); }
@@ -441,6 +474,9 @@ static int iscsi_user_scan_session(struct device *dev, void *data)return 0 ; session =iscsi_dev_to_session (dev); + +ISCSI_DBG_TRANS_SESSION (session,"Scanning session\n" ); + shost =iscsi_session_to_shost (session); ihost = shost->shost_data;
@@ -448,8 +484,7 @@ static int iscsi_user_scan_session(struct device *dev, void *data)spin_lock_irqsave (&session->lock, flags);if (session->state !=ISCSI_SESSION_LOGGED_IN ) {spin_unlock_irqrestore (&session->lock, flags); -mutex_unlock (&ihost->mutex); -return 0 ; + goto user_scan_exit; } id = session->target_id;spin_unlock_irqrestore (&session->lock, flags);
@@ -462,7 +497,10 @@ static int iscsi_user_scan_session(struct device *dev, void *data)scsi_scan_target (&session->dev,0 , id, scan_data->lun,1 ); } + +user_scan_exit:mutex_unlock (&ihost->mutex); +ISCSI_DBG_TRANS_SESSION (session,"Completed session scan\n" );return 0 ; }
@@ -522,7 +560,9 @@ static void session_recovery_timedout(struct work_struct *work)if (session->transport->session_recovery_timedout) session->transport->session_recovery_timedout (session); +ISCSI_DBG_TRANS_SESSION (session,"Unblocking SCSI target\n" );scsi_target_unblock (&session->dev); +ISCSI_DBG_TRANS_SESSION (session,"Completed unblocking SCSI target\n" ); }static void __iscsi_unblock_session (struct work_struct *work)
@@ -534,6 +574,7 @@ static void __iscsi_unblock_session(struct work_struct *work)struct iscsi_cls_host *ihost = shost->shost_data;unsigned long flags; +ISCSI_DBG_TRANS_SESSION (session,"Unblocking session\n" );/* * The recovery and unblock work get run from the same workqueue, * so try to cancel it if it was going to run after this unblock.
@@ -553,6 +594,7 @@ static void __iscsi_unblock_session(struct work_struct *work)if (scsi_queue_work (shost, &session->scan_work))atomic_inc (&ihost->nr_scans); } +ISCSI_DBG_TRANS_SESSION (session,"Completed unblocking session\n" ); }/**
@@ -579,10 +621,12 @@ static void __iscsi_block_session(struct work_struct *work) block_work);unsigned long flags; +ISCSI_DBG_TRANS_SESSION (session,"Blocking session\n" );spin_lock_irqsave (&session->lock, flags); session->state =ISCSI_SESSION_FAILED ;spin_unlock_irqrestore (&session->lock, flags);scsi_target_block (&session->dev); +ISCSI_DBG_TRANS_SESSION (session,"Completed SCSI target blocking\n" );queue_delayed_work (iscsi_eh_timer_workq, &session->recovery_work, session->recovery_tmo *HZ ); }
@@ -602,6 +646,8 @@ static void __iscsi_unbind_session(struct work_struct *work)struct iscsi_cls_host *ihost = shost->shost_data;unsigned long flags; +ISCSI_DBG_TRANS_SESSION (session,"Unbinding session\n" ); +/* Prevent new scans and make sure scanning is not in progress */ mutex_lock (&ihost->mutex);spin_lock_irqsave (&session->lock, flags);
@@ -616,6 +662,7 @@ static void __iscsi_unbind_session(struct work_struct *work)scsi_remove_target (&session->dev);iscsi_session_event (session,ISCSI_KEVENT_UNBIND_SESSION ); +ISCSI_DBG_TRANS_SESSION (session,"Completed target removal\n" ); } struct iscsi_cls_session *
@@ -647,6 +694,8 @@ iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,device_initialize (&session->dev);if (dd_size) session->dd_data = &session[1 ]; + +ISCSI_DBG_TRANS_SESSION (session,"Completed session allocation\n" );return session; }EXPORT_SYMBOL_GPL (iscsi_alloc_session);
@@ -712,6 +761,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)spin_unlock_irqrestore (&sesslock, flags);iscsi_session_event (session,ISCSI_KEVENT_CREATE_SESSION ); +ISCSI_DBG_TRANS_SESSION (session,"Completed session adding\n" );return 0 ; release_host:
@@ -752,6 +802,7 @@ static void iscsi_conn_release(struct device *dev)struct iscsi_cls_conn *conn =iscsi_dev_to_conn (dev);struct device *parent = conn->dev.parent; +ISCSI_DBG_TRANS_CONN (conn,"Releasing conn\n" );kfree (conn);put_device (parent); }
@@ -774,6 +825,8 @@ void iscsi_remove_session(struct iscsi_cls_session *session)unsigned long flags;int err; +ISCSI_DBG_TRANS_SESSION (session,"Removing session\n" ); +spin_lock_irqsave (&sesslock, flags);list_del (&session->sess_list);spin_unlock_irqrestore (&sesslock, flags);
@@ -807,12 +860,15 @@ void iscsi_remove_session(struct iscsi_cls_session *session) "for session. Error %d.\n", err);transport_unregister_device (&session->dev); + +ISCSI_DBG_TRANS_SESSION (session,"Completing session removal\n" );device_del (&session->dev); }EXPORT_SYMBOL_GPL (iscsi_remove_session);void iscsi_free_session (struct iscsi_cls_session *session) { +ISCSI_DBG_TRANS_SESSION (session,"Freeing session\n" );iscsi_session_event (session,ISCSI_KEVENT_DESTROY_SESSION );put_device (&session->dev); }
@@ -828,6 +884,7 @@ EXPORT_SYMBOL_GPL(iscsi_free_session);int iscsi_destroy_session (struct iscsi_cls_session *session) {iscsi_remove_session (session); +ISCSI_DBG_TRANS_SESSION (session,"Completing session destruction\n" );iscsi_free_session (session);return 0 ; }
@@ -885,6 +942,8 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)list_add (&conn->conn_list, &connlist); conn->active =1 ;spin_unlock_irqrestore (&connlock, flags); + +ISCSI_DBG_TRANS_CONN (conn,"Completed conn creation\n" );return conn; release_parent_ref:
@@ -912,6 +971,7 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)spin_unlock_irqrestore (&connlock, flags);transport_unregister_device (&conn->dev); +ISCSI_DBG_TRANS_CONN (conn,"Completing conn destruction\n" );device_unregister (&conn->dev);return 0 ; }
@@ -1200,6 +1260,9 @@ int iscsi_session_event(struct iscsi_cls_session *session,"Cannot notify userspace of session " "event %u. Check iscsi daemon\n" , event); + +ISCSI_DBG_TRANS_SESSION (session,"Completed handling event %d rc %d\n" , + event, rc);return rc; }EXPORT_SYMBOL_GPL (iscsi_session_event);
@@ -1221,6 +1284,8 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_endpoint *ep, shost =iscsi_session_to_shost (session); ev->r.c_session_ret.host_no = shost->host_no; ev->r.c_session_ret.sid = session->sid; +ISCSI_DBG_TRANS_SESSION (session, +"Completed creating transport session\n" );return 0 ; }
@@ -1246,6 +1311,8 @@ iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev) ev->r.c_conn_ret.sid = session->sid; ev->r.c_conn_ret.cid = conn->cid; + +ISCSI_DBG_TRANS_CONN (conn,"Completed creating transport conn\n" );return 0 ; }
@@ -1258,8 +1325,10 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *evif (!conn)return -EINVAL ; +ISCSI_DBG_TRANS_CONN (conn,"Destroying transport conn\n" );if (transport->destroy_conn) transport->destroy_conn (conn); +return 0 ; }
Signature · 1 line
1.6.2.2
PATCH 6/7 iscsi_tcp: add new conn error to indicate tcp conn closed
From: Mike Christie <[email protected]>
If a target closed the connection, we will detect it in the state_changed or data_ready callout. This adds a new conn error value to use for this problem, so it is not confused with when the initiator throws a conn error and drops the connection.
--- drivers/scsi/iscsi_tcp.c | 23 +++++++++-------------- include/scsi/iscsi_if.h | 1 + 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/scsi/iscsi_tcp.c +9 -14
@@ -109,11 +109,14 @@ static int iscsi_sw_tcp_recv(read_descriptor_t *rd_desc, struct sk_buff *skb,*/ static inline int iscsi_sw_sk_state_check (struct sock *sk) { -if ((sk->sk_state ==TCP_CLOSE_WAIT || - sk->sk_state ==TCP_CLOSE ) && - !atomic_read (&sk->sk_rmem_alloc)) -return -ECONNRESET ; +struct iscsi_conn *conn = (struct iscsi_conn *)sk->sk_user_data; +if ((sk->sk_state ==TCP_CLOSE_WAIT || sk->sk_state ==TCP_CLOSE ) && + !atomic_read (&sk->sk_rmem_alloc)) { +ISCSI_SW_TCP_DBG (conn,"TCP_CLOSE|TCP_CLOSE_WAIT\n" ); +iscsi_conn_failure (conn,ISCSI_ERR_TCP_CONN_CLOSE ); +return -ECONNRESET ; + }return 0 ; }
@@ -135,11 +138,7 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk, int flag) rd_desc.count =1 ;tcp_read_sock (sk, &rd_desc, iscsi_sw_tcp_recv); -if (iscsi_sw_sk_state_check (sk) <0 ) { -ISCSI_SW_TCP_DBG (conn,"iscsi_tcp_data_ready: " -"TCP_CLOSE|TCP_CLOSE_WAIT\n" ); -iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED ); - } +iscsi_sw_sk_state_check (sk);read_unlock (&sk->sk_callback_lock);
@@ -161,11 +160,7 @@ static void iscsi_sw_tcp_state_change(struct sock *sk) conn = (struct iscsi_conn *)sk->sk_user_data; session = conn->session; -if (iscsi_sw_sk_state_check (sk) <0 ) { -ISCSI_SW_TCP_DBG (conn,"iscsi_tcp_state_change: " -"TCP_CLOSE|TCP_CLOSE_WAIT\n" ); -iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED ); - } +iscsi_sw_sk_state_check (sk); tcp_conn = conn->dd_data; tcp_sw_conn = tcp_conn->dd_data;
include/scsi/iscsi_if.h +1 -0
@@ -262,6 +262,7 @@ enum iscsi_err {ISCSI_ERR_NO_SCSI_CMD =ISCSI_ERR_BASE +17 ,ISCSI_ERR_INVALID_HOST =ISCSI_ERR_BASE +18 ,ISCSI_ERR_XMIT_FAILED =ISCSI_ERR_BASE +19 , + ISCSI_ERR_TCP_CONN_CLOSE = ISCSI_ERR_BASE + 20, };/*
Signature · 1 line
1.6.2.2