aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_transport_iscsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi_transport_iscsi.c')
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c45
1 files changed, 10 insertions, 35 deletions
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 2adfab8c11c1..094795455293 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -246,30 +246,13 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
246 memset(ihost, 0, sizeof(*ihost)); 246 memset(ihost, 0, sizeof(*ihost));
247 atomic_set(&ihost->nr_scans, 0); 247 atomic_set(&ihost->nr_scans, 0);
248 mutex_init(&ihost->mutex); 248 mutex_init(&ihost->mutex);
249
250 snprintf(ihost->scan_workq_name, sizeof(ihost->scan_workq_name),
251 "iscsi_scan_%d", shost->host_no);
252 ihost->scan_workq = create_singlethread_workqueue(
253 ihost->scan_workq_name);
254 if (!ihost->scan_workq)
255 return -ENOMEM;
256 return 0;
257}
258
259static int iscsi_remove_host(struct transport_container *tc, struct device *dev,
260 struct device *cdev)
261{
262 struct Scsi_Host *shost = dev_to_shost(dev);
263 struct iscsi_cls_host *ihost = shost->shost_data;
264
265 destroy_workqueue(ihost->scan_workq);
266 return 0; 249 return 0;
267} 250}
268 251
269static DECLARE_TRANSPORT_CLASS(iscsi_host_class, 252static DECLARE_TRANSPORT_CLASS(iscsi_host_class,
270 "iscsi_host", 253 "iscsi_host",
271 iscsi_setup_host, 254 iscsi_setup_host,
272 iscsi_remove_host, 255 NULL,
273 NULL); 256 NULL);
274 257
275static DECLARE_TRANSPORT_CLASS(iscsi_session_class, 258static DECLARE_TRANSPORT_CLASS(iscsi_session_class,
@@ -568,7 +551,7 @@ static void __iscsi_unblock_session(struct work_struct *work)
568 * scanning from userspace). 551 * scanning from userspace).
569 */ 552 */
570 if (shost->hostt->scan_finished) { 553 if (shost->hostt->scan_finished) {
571 if (queue_work(ihost->scan_workq, &session->scan_work)) 554 if (scsi_queue_work(shost, &session->scan_work))
572 atomic_inc(&ihost->nr_scans); 555 atomic_inc(&ihost->nr_scans);
573 } 556 }
574} 557}
@@ -636,14 +619,6 @@ static void __iscsi_unbind_session(struct work_struct *work)
636 iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION); 619 iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION);
637} 620}
638 621
639static int iscsi_unbind_session(struct iscsi_cls_session *session)
640{
641 struct Scsi_Host *shost = iscsi_session_to_shost(session);
642 struct iscsi_cls_host *ihost = shost->shost_data;
643
644 return queue_work(ihost->scan_workq, &session->unbind_work);
645}
646
647struct iscsi_cls_session * 622struct iscsi_cls_session *
648iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport, 623iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
649 int dd_size) 624 int dd_size)
@@ -796,7 +771,6 @@ static int iscsi_iter_destroy_conn_fn(struct device *dev, void *data)
796void iscsi_remove_session(struct iscsi_cls_session *session) 771void iscsi_remove_session(struct iscsi_cls_session *session)
797{ 772{
798 struct Scsi_Host *shost = iscsi_session_to_shost(session); 773 struct Scsi_Host *shost = iscsi_session_to_shost(session);
799 struct iscsi_cls_host *ihost = shost->shost_data;
800 unsigned long flags; 774 unsigned long flags;
801 int err; 775 int err;
802 776
@@ -821,7 +795,7 @@ void iscsi_remove_session(struct iscsi_cls_session *session)
821 795
822 scsi_target_unblock(&session->dev); 796 scsi_target_unblock(&session->dev);
823 /* flush running scans then delete devices */ 797 /* flush running scans then delete devices */
824 flush_workqueue(ihost->scan_workq); 798 scsi_flush_work(shost);
825 __iscsi_unbind_session(&session->unbind_work); 799 __iscsi_unbind_session(&session->unbind_work);
826 800
827 /* hw iscsi may not have removed all connections from session */ 801 /* hw iscsi may not have removed all connections from session */
@@ -1215,14 +1189,15 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_endpoint *ep,
1215{ 1189{
1216 struct iscsi_transport *transport = priv->iscsi_transport; 1190 struct iscsi_transport *transport = priv->iscsi_transport;
1217 struct iscsi_cls_session *session; 1191 struct iscsi_cls_session *session;
1218 uint32_t host_no; 1192 struct Scsi_Host *shost;
1219 1193
1220 session = transport->create_session(ep, cmds_max, queue_depth, 1194 session = transport->create_session(ep, cmds_max, queue_depth,
1221 initial_cmdsn, &host_no); 1195 initial_cmdsn);
1222 if (!session) 1196 if (!session)
1223 return -ENOMEM; 1197 return -ENOMEM;
1224 1198
1225 ev->r.c_session_ret.host_no = host_no; 1199 shost = iscsi_session_to_shost(session);
1200 ev->r.c_session_ret.host_no = shost->host_no;
1226 ev->r.c_session_ret.sid = session->sid; 1201 ev->r.c_session_ret.sid = session->sid;
1227 return 0; 1202 return 0;
1228} 1203}
@@ -1439,7 +1414,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1439 case ISCSI_UEVENT_UNBIND_SESSION: 1414 case ISCSI_UEVENT_UNBIND_SESSION:
1440 session = iscsi_session_lookup(ev->u.d_session.sid); 1415 session = iscsi_session_lookup(ev->u.d_session.sid);
1441 if (session) 1416 if (session)
1442 iscsi_unbind_session(session); 1417 scsi_queue_work(iscsi_session_to_shost(session),
1418 &session->unbind_work);
1443 else 1419 else
1444 err = -EINVAL; 1420 err = -EINVAL;
1445 break; 1421 break;
@@ -1801,8 +1777,7 @@ iscsi_register_transport(struct iscsi_transport *tt)
1801 priv->daemon_pid = -1; 1777 priv->daemon_pid = -1;
1802 priv->iscsi_transport = tt; 1778 priv->iscsi_transport = tt;
1803 priv->t.user_scan = iscsi_user_scan; 1779 priv->t.user_scan = iscsi_user_scan;
1804 if (!(tt->caps & CAP_DATA_PATH_OFFLOAD)) 1780 priv->t.create_work_queue = 1;
1805 priv->t.create_work_queue = 1;
1806 1781
1807 priv->dev.class = &iscsi_transport_class; 1782 priv->dev.class = &iscsi_transport_class;
1808 dev_set_name(&priv->dev, "%s", tt->name); 1783 dev_set_name(&priv->dev, "%s", tt->name);