When a transport (e.g. iscsi_tcp, ib_iser) is unloaded, a notification
must be sent to userspace. This will allow the userspace code to release
all transport related resources.

Signed-off-by: Erez Zilber <[EMAIL PROTECTED]>
---
 drivers/scsi/scsi_transport_iscsi.c |   31 +++++++++++++++++++++++++++++++
 include/scsi/iscsi_if.h             |   12 +++++++++---
 2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index cbd2b71..0e5fc83 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -871,6 +871,35 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum 
iscsi_err error)
 }
 EXPORT_SYMBOL_GPL(iscsi_conn_error);
 
+void iscsi_trans_error(struct iscsi_transport *tt)
+{
+       struct nlmsghdr *nlh;
+       struct sk_buff  *skb;
+       struct iscsi_uevent *ev;
+       int len = NLMSG_SPACE(sizeof(*ev));
+       struct iscsi_internal *priv;
+
+       priv = iscsi_if_transport_lookup(tt);
+       if (!priv)
+               return;
+
+       skb = alloc_skb(len, GFP_ATOMIC);
+       if (!skb) {
+               printk(KERN_ERR "iscsi: gracefully ignored transport error\n");
+               return;
+       }
+
+       nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0);
+       ev = NLMSG_DATA(nlh);
+       ev->transport_handle = iscsi_handle(tt);
+       ev->type = ISCSI_KEVENT_TRANS_ERROR;
+       strncpy(ev->r.trans_error.name, tt->name, ISCSI_TRANSPORT_NAME_MAXLEN);
+
+       iscsi_broadcast_skb(skb, GFP_ATOMIC);
+
+       printk(KERN_INFO "iscsi: detected transport error\n");
+}
+
 static int
 iscsi_if_send_reply(int pid, int seq, int type, int done, int multi,
                      void *payload, int size)
@@ -1719,6 +1748,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
 
        mutex_lock(&rx_queue_mutex);
 
+       iscsi_trans_error(tt);
+
        priv = iscsi_if_transport_lookup(tt);
        BUG_ON (!priv);
 
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 801a677..973d4eb 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -56,9 +56,10 @@ enum iscsi_uevent_e {
        ISCSI_KEVENT_RECV_PDU           = KEVENT_BASE + 1,
        ISCSI_KEVENT_CONN_ERROR         = KEVENT_BASE + 2,
        ISCSI_KEVENT_IF_ERROR           = KEVENT_BASE + 3,
-       ISCSI_KEVENT_DESTROY_SESSION    = KEVENT_BASE + 4,
-       ISCSI_KEVENT_UNBIND_SESSION     = KEVENT_BASE + 5,
-       ISCSI_KEVENT_CREATE_SESSION     = KEVENT_BASE + 6,
+       ISCSI_KEVENT_TRANS_ERROR        = KEVENT_BASE + 4,
+       ISCSI_KEVENT_DESTROY_SESSION    = KEVENT_BASE + 5,
+       ISCSI_KEVENT_UNBIND_SESSION     = KEVENT_BASE + 6,
+       ISCSI_KEVENT_CREATE_SESSION     = KEVENT_BASE + 7,
 };
 
 enum iscsi_tgt_dscvr {
@@ -67,6 +68,8 @@ enum iscsi_tgt_dscvr {
        ISCSI_TGT_DSCVR_SLP             = 3,
 };
 
+#define ISCSI_TRANSPORT_NAME_MAXLEN 16
+
 struct iscsi_uevent {
        uint32_t type; /* k/u events type */
        uint32_t iferror; /* carries interface or resource errors */
@@ -187,6 +190,9 @@ struct iscsi_uevent {
                struct msg_transport_connect_ret {
                        uint64_t        handle;
                } ep_connect_ret;
+               struct msg_trans_error {
+                       char            name[ISCSI_TRANSPORT_NAME_MAXLEN];
+               } trans_error;
        } r;
 } __attribute__ ((aligned (sizeof(uint64_t))));
 
-- 
1.5.4.4



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Reply via email to