aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2007-05-30 13:57:19 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-06-02 15:34:46 -0400
commit1548271ece9e9312fd5feb41fd58773b56a71d39 (patch)
tree89f990788a619a52c3ba4ecbf5f2a596c5711d04 /drivers/scsi
parent77a23c21aaa723f6b0ffc4a701be8c8e5a32346d (diff)
[SCSI] libiscsi: make can_queue configurable
This patch allows us to set can_queue and cmds_per_lun from userspace when we create the session/host. From there we can set it on a per target basis. The patch fully converts iscsi_tcp, but only hooks up ib_iser for cmd_per_lun since it currently has a lots of preallocations based on can_queue. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Cc: Roland Dreier <rdreier@cisco.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/iscsi_tcp.c5
-rw-r--r--drivers/scsi/libiscsi.c28
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c2
3 files changed, 32 insertions, 3 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 8edcfddc0baf..eca4d611dd49 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -2114,6 +2114,7 @@ iscsi_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *stats)
2114static struct iscsi_cls_session * 2114static struct iscsi_cls_session *
2115iscsi_tcp_session_create(struct iscsi_transport *iscsit, 2115iscsi_tcp_session_create(struct iscsi_transport *iscsit,
2116 struct scsi_transport_template *scsit, 2116 struct scsi_transport_template *scsit,
2117 uint16_t cmds_max, uint16_t qdepth,
2117 uint32_t initial_cmdsn, uint32_t *hostno) 2118 uint32_t initial_cmdsn, uint32_t *hostno)
2118{ 2119{
2119 struct iscsi_cls_session *cls_session; 2120 struct iscsi_cls_session *cls_session;
@@ -2121,7 +2122,7 @@ iscsi_tcp_session_create(struct iscsi_transport *iscsit,
2121 uint32_t hn; 2122 uint32_t hn;
2122 int cmd_i; 2123 int cmd_i;
2123 2124
2124 cls_session = iscsi_session_setup(iscsit, scsit, 2125 cls_session = iscsi_session_setup(iscsit, scsit, cmds_max, qdepth,
2125 sizeof(struct iscsi_tcp_cmd_task), 2126 sizeof(struct iscsi_tcp_cmd_task),
2126 sizeof(struct iscsi_tcp_mgmt_task), 2127 sizeof(struct iscsi_tcp_mgmt_task),
2127 initial_cmdsn, &hn); 2128 initial_cmdsn, &hn);
@@ -2164,7 +2165,7 @@ static struct scsi_host_template iscsi_sht = {
2164 .name = "iSCSI Initiator over TCP/IP", 2165 .name = "iSCSI Initiator over TCP/IP",
2165 .queuecommand = iscsi_queuecommand, 2166 .queuecommand = iscsi_queuecommand,
2166 .change_queue_depth = iscsi_change_queue_depth, 2167 .change_queue_depth = iscsi_change_queue_depth,
2167 .can_queue = ISCSI_XMIT_CMDS_MAX - 1, 2168 .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1,
2168 .sg_tablesize = ISCSI_SG_TABLESIZE, 2169 .sg_tablesize = ISCSI_SG_TABLESIZE,
2169 .max_sectors = 0xFFFF, 2170 .max_sectors = 0xFFFF,
2170 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, 2171 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 938f527cd81a..1632866f52cc 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1330,6 +1330,10 @@ EXPORT_SYMBOL_GPL(iscsi_pool_free);
1330 * iscsi_session_setup - create iscsi cls session and host and session 1330 * iscsi_session_setup - create iscsi cls session and host and session
1331 * @scsit: scsi transport template 1331 * @scsit: scsi transport template
1332 * @iscsit: iscsi transport template 1332 * @iscsit: iscsi transport template
1333 * @cmds_max: scsi host can queue
1334 * @qdepth: scsi host cmds per lun
1335 * @cmd_task_size: LLD ctask private data size
1336 * @mgmt_task_size: LLD mtask private data size
1333 * @initial_cmdsn: initial CmdSN 1337 * @initial_cmdsn: initial CmdSN
1334 * @hostno: host no allocated 1338 * @hostno: host no allocated
1335 * 1339 *
@@ -1339,6 +1343,7 @@ EXPORT_SYMBOL_GPL(iscsi_pool_free);
1339struct iscsi_cls_session * 1343struct iscsi_cls_session *
1340iscsi_session_setup(struct iscsi_transport *iscsit, 1344iscsi_session_setup(struct iscsi_transport *iscsit,
1341 struct scsi_transport_template *scsit, 1345 struct scsi_transport_template *scsit,
1346 uint16_t cmds_max, uint16_t qdepth,
1342 int cmd_task_size, int mgmt_task_size, 1347 int cmd_task_size, int mgmt_task_size,
1343 uint32_t initial_cmdsn, uint32_t *hostno) 1348 uint32_t initial_cmdsn, uint32_t *hostno)
1344{ 1349{
@@ -1347,11 +1352,32 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1347 struct iscsi_cls_session *cls_session; 1352 struct iscsi_cls_session *cls_session;
1348 int cmd_i; 1353 int cmd_i;
1349 1354
1355 if (qdepth > ISCSI_MAX_CMD_PER_LUN || qdepth < 1) {
1356 if (qdepth != 0)
1357 printk(KERN_ERR "iscsi: invalid queue depth of %d. "
1358 "Queue depth must be between 1 and %d.\n",
1359 qdepth, ISCSI_MAX_CMD_PER_LUN);
1360 qdepth = ISCSI_DEF_CMD_PER_LUN;
1361 }
1362
1363 if (cmds_max < 2 || (cmds_max & (cmds_max - 1)) ||
1364 cmds_max >= ISCSI_MGMT_ITT_OFFSET) {
1365 if (cmds_max != 0)
1366 printk(KERN_ERR "iscsi: invalid can_queue of %d. "
1367 "can_queue must be a power of 2 and between "
1368 "2 and %d - setting to %d.\n", cmds_max,
1369 ISCSI_MGMT_ITT_OFFSET, ISCSI_DEF_XMIT_CMDS_MAX);
1370 cmds_max = ISCSI_DEF_XMIT_CMDS_MAX;
1371 }
1372
1350 shost = scsi_host_alloc(iscsit->host_template, 1373 shost = scsi_host_alloc(iscsit->host_template,
1351 hostdata_privsize(sizeof(*session))); 1374 hostdata_privsize(sizeof(*session)));
1352 if (!shost) 1375 if (!shost)
1353 return NULL; 1376 return NULL;
1354 1377
1378 /* the iscsi layer takes one task for reserve */
1379 shost->can_queue = cmds_max - 1;
1380 shost->cmd_per_lun = qdepth;
1355 shost->max_id = 1; 1381 shost->max_id = 1;
1356 shost->max_channel = 0; 1382 shost->max_channel = 0;
1357 shost->max_lun = iscsit->max_lun; 1383 shost->max_lun = iscsit->max_lun;
@@ -1365,7 +1391,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1365 session->host = shost; 1391 session->host = shost;
1366 session->state = ISCSI_STATE_FREE; 1392 session->state = ISCSI_STATE_FREE;
1367 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX; 1393 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX;
1368 session->cmds_max = ISCSI_XMIT_CMDS_MAX; 1394 session->cmds_max = cmds_max;
1369 session->cmdsn = initial_cmdsn; 1395 session->cmdsn = initial_cmdsn;
1370 session->exp_cmdsn = initial_cmdsn + 1; 1396 session->exp_cmdsn = initial_cmdsn + 1;
1371 session->max_cmdsn = initial_cmdsn + 1; 1397 session->max_cmdsn = initial_cmdsn + 1;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 341d4fb5c6f8..859bd2100856 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -814,6 +814,8 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev)
814 uint32_t hostno; 814 uint32_t hostno;
815 815
816 session = transport->create_session(transport, &priv->t, 816 session = transport->create_session(transport, &priv->t,
817 ev->u.c_session.cmds_max,
818 ev->u.c_session.queue_depth,
817 ev->u.c_session.initial_cmdsn, 819 ev->u.c_session.initial_cmdsn,
818 &hostno); 820 &hostno);
819 if (!session) 821 if (!session)