Skip to content

Commit 40753ca

Browse files
Mike ChristieJames Bottomley
authored andcommitted
[SCSI] iscsi class, iscsi_tcp/iser: add host arg to session creation
iscsi offload (bnx2i and qla4xx) allocate a scsi host per hba, so the session creation path needs a shost/host_no argument. Software iscsi/iser will follow the same behabior as before where it allcoates a host per session, but in the future iser will probably look more like bnx2i where the host's parent is the hardware (rnic for iser and for bnx2i it is the nic), because it does not use a socket layer like how iscsi_tcp does. Signed-off-by: Mike Christie <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent d54d48b commit 40753ca

File tree

6 files changed

+51
-13
lines changed

6 files changed

+51
-13
lines changed

drivers/infiniband/ulp/iser/iscsi_iser.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ static struct iscsi_transport iscsi_iser_transport;
368368
static struct iscsi_cls_session *
369369
iscsi_iser_session_create(struct iscsi_transport *iscsit,
370370
struct scsi_transport_template *scsit,
371+
struct Scsi_Host *shost,
371372
uint16_t cmds_max, uint16_t qdepth,
372373
uint32_t initial_cmdsn, uint32_t *hostno)
373374
{

drivers/scsi/iscsi_tcp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,9 @@ iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)
18711871
static struct iscsi_cls_session *
18721872
iscsi_tcp_session_create(struct iscsi_transport *iscsit,
18731873
struct scsi_transport_template *scsit,
1874-
uint16_t cmds_max, uint16_t qdepth,
1875-
uint32_t initial_cmdsn, uint32_t *hostno)
1874+
struct Scsi_Host *shost, uint16_t cmds_max,
1875+
uint16_t qdepth, uint32_t initial_cmdsn,
1876+
uint32_t *hostno)
18761877
{
18771878
struct iscsi_cls_session *cls_session;
18781879
struct iscsi_session *session;

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,21 +1017,38 @@ int iscsi_session_event(struct iscsi_cls_session *session,
10171017
EXPORT_SYMBOL_GPL(iscsi_session_event);
10181018

10191019
static int
1020-
iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev)
1020+
iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev,
1021+
uint32_t host_no, uint32_t initial_cmdsn,
1022+
uint16_t cmds_max, uint16_t queue_depth)
10211023
{
10221024
struct iscsi_transport *transport = priv->iscsi_transport;
10231025
struct iscsi_cls_session *session;
1024-
uint32_t hostno;
1026+
struct Scsi_Host *shost = NULL;
10251027

1026-
session = transport->create_session(transport, &priv->t,
1027-
ev->u.c_session.cmds_max,
1028-
ev->u.c_session.queue_depth,
1029-
ev->u.c_session.initial_cmdsn,
1030-
&hostno);
1028+
/*
1029+
* Software iscsi allocates a host per session, but
1030+
* offload drivers (and possibly iser one day) allocate a host per
1031+
* hba/nic/rnic. Offload will match a host here, but software will
1032+
* return a new hostno after the create_session callback has returned.
1033+
*/
1034+
if (host_no != UINT_MAX) {
1035+
shost = scsi_host_lookup(host_no);
1036+
if (IS_ERR(shost)) {
1037+
printk(KERN_ERR "Could not find host no %u to "
1038+
"create session\n", host_no);
1039+
return -ENODEV;
1040+
}
1041+
}
1042+
1043+
session = transport->create_session(transport, &priv->t, shost,
1044+
cmds_max, queue_depth,
1045+
initial_cmdsn, &host_no);
1046+
if (shost)
1047+
scsi_host_put(shost);
10311048
if (!session)
10321049
return -ENOMEM;
10331050

1034-
ev->r.c_session_ret.host_no = hostno;
1051+
ev->r.c_session_ret.host_no = host_no;
10351052
ev->r.c_session_ret.sid = session->sid;
10361053
return 0;
10371054
}
@@ -1190,6 +1207,7 @@ static int
11901207
iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
11911208
{
11921209
int err = 0;
1210+
uint32_t host_no = UINT_MAX;
11931211
struct iscsi_uevent *ev = NLMSG_DATA(nlh);
11941212
struct iscsi_transport *transport = NULL;
11951213
struct iscsi_internal *priv;
@@ -1208,7 +1226,17 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
12081226

12091227
switch (nlh->nlmsg_type) {
12101228
case ISCSI_UEVENT_CREATE_SESSION:
1211-
err = iscsi_if_create_session(priv, ev);
1229+
err = iscsi_if_create_session(priv, ev, host_no,
1230+
ev->u.c_session.initial_cmdsn,
1231+
ev->u.c_session.cmds_max,
1232+
ev->u.c_session.queue_depth);
1233+
break;
1234+
case ISCSI_UEVENT_CREATE_BOUND_SESSION:
1235+
err = iscsi_if_create_session(priv, ev,
1236+
ev->u.c_bound_session.host_no,
1237+
ev->u.c_bound_session.initial_cmdsn,
1238+
ev->u.c_bound_session.cmds_max,
1239+
ev->u.c_bound_session.queue_depth);
12121240
break;
12131241
case ISCSI_UEVENT_DESTROY_SESSION:
12141242
session = iscsi_session_lookup(ev->u.d_session.sid);

include/scsi/iscsi_if.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum iscsi_uevent_e {
5050
ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
5151
ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
5252
ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
53+
ISCSI_UEVENT_CREATE_BOUND_SESSION = UEVENT_BASE + 18,
5354

5455
/* up events */
5556
ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
@@ -78,6 +79,12 @@ struct iscsi_uevent {
7879
uint16_t cmds_max;
7980
uint16_t queue_depth;
8081
} c_session;
82+
struct msg_create_bound_session {
83+
uint32_t host_no;
84+
uint32_t initial_cmdsn;
85+
uint16_t cmds_max;
86+
uint16_t queue_depth;
87+
} c_bound_session;
8188
struct msg_destroy_session {
8289
uint32_t sid;
8390
} d_session;

include/scsi/libiscsi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define LIBISCSI_H
2525

2626
#include <linux/types.h>
27+
#include <linux/wait.h>
2728
#include <linux/mutex.h>
2829
#include <linux/timer.h>
2930
#include <linux/workqueue.h>

include/scsi/scsi_transport_iscsi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ struct iscsi_transport {
9292
unsigned int max_conn;
9393
unsigned int max_cmd_len;
9494
struct iscsi_cls_session *(*create_session) (struct iscsi_transport *it,
95-
struct scsi_transport_template *t, uint16_t, uint16_t,
96-
uint32_t sn, uint32_t *hn);
95+
struct scsi_transport_template *t, struct Scsi_Host *shost,
96+
uint16_t cmds_max, uint16_t qdepth, uint32_t sn, uint32_t *hn);
9797
void (*destroy_session) (struct iscsi_cls_session *session);
9898
struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,
9999
uint32_t cid);

0 commit comments

Comments
 (0)