aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libiscsi.c
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/libiscsi.c
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/libiscsi.c')
-rw-r--r--drivers/scsi/libiscsi.c28
1 files changed, 27 insertions, 1 deletions
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;