diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2006-05-18 21:31:34 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-05-20 10:34:54 -0400 |
commit | d36ab6f3212053b260214bc915687765e2fd1178 (patch) | |
tree | b06957a99c8094ba45de16498b623d2eae5db543 /drivers/scsi/libiscsi.c | |
parent | 6e458cc943dd494ac68b570418f187883e555362 (diff) |
[SCSI] iscsi: only preallocate login buffer
We only use the mtask data buffer for login tasks so we do not
need to preallocate a buffer for every mtask. This saves
8 * 31 KB.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r-- | drivers/scsi/libiscsi.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 4750d4888100..580c0505603c 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -1258,15 +1258,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit, | |||
1258 | if (mgmt_task_size) | 1258 | if (mgmt_task_size) |
1259 | mtask->dd_data = &mtask[1]; | 1259 | mtask->dd_data = &mtask[1]; |
1260 | mtask->itt = ISCSI_MGMT_ITT_OFFSET + cmd_i; | 1260 | mtask->itt = ISCSI_MGMT_ITT_OFFSET + cmd_i; |
1261 | mtask->data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, | ||
1262 | GFP_KERNEL); | ||
1263 | if (!mtask->data) { | ||
1264 | int j; | ||
1265 | |||
1266 | for (j = 0; j < cmd_i; j++) | ||
1267 | kfree(session->mgmt_cmds[j]->data); | ||
1268 | goto immdata_alloc_fail; | ||
1269 | } | ||
1270 | } | 1261 | } |
1271 | 1262 | ||
1272 | if (scsi_add_host(shost, NULL)) | 1263 | if (scsi_add_host(shost, NULL)) |
@@ -1282,9 +1273,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit, | |||
1282 | cls_session_fail: | 1273 | cls_session_fail: |
1283 | scsi_remove_host(shost); | 1274 | scsi_remove_host(shost); |
1284 | add_host_fail: | 1275 | add_host_fail: |
1285 | for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) | ||
1286 | kfree(session->mgmt_cmds[cmd_i]->data); | ||
1287 | immdata_alloc_fail: | ||
1288 | iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); | 1276 | iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); |
1289 | mgmtpool_alloc_fail: | 1277 | mgmtpool_alloc_fail: |
1290 | iscsi_pool_free(&session->cmdpool, (void**)session->cmds); | 1278 | iscsi_pool_free(&session->cmdpool, (void**)session->cmds); |
@@ -1305,13 +1293,9 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) | |||
1305 | { | 1293 | { |
1306 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); | 1294 | struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); |
1307 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); | 1295 | struct iscsi_session *session = iscsi_hostdata(shost->hostdata); |
1308 | int cmd_i; | ||
1309 | 1296 | ||
1310 | scsi_remove_host(shost); | 1297 | scsi_remove_host(shost); |
1311 | 1298 | ||
1312 | for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++) | ||
1313 | kfree(session->mgmt_cmds[cmd_i]->data); | ||
1314 | |||
1315 | iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); | 1299 | iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); |
1316 | iscsi_pool_free(&session->cmdpool, (void**)session->cmds); | 1300 | iscsi_pool_free(&session->cmdpool, (void**)session->cmds); |
1317 | 1301 | ||
@@ -1331,6 +1315,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) | |||
1331 | struct iscsi_session *session = class_to_transport_session(cls_session); | 1315 | struct iscsi_session *session = class_to_transport_session(cls_session); |
1332 | struct iscsi_conn *conn; | 1316 | struct iscsi_conn *conn; |
1333 | struct iscsi_cls_conn *cls_conn; | 1317 | struct iscsi_cls_conn *cls_conn; |
1318 | char *data; | ||
1334 | 1319 | ||
1335 | cls_conn = iscsi_create_conn(cls_session, conn_idx); | 1320 | cls_conn = iscsi_create_conn(cls_session, conn_idx); |
1336 | if (!cls_conn) | 1321 | if (!cls_conn) |
@@ -1376,12 +1361,20 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) | |||
1376 | } | 1361 | } |
1377 | spin_unlock_bh(&session->lock); | 1362 | spin_unlock_bh(&session->lock); |
1378 | 1363 | ||
1364 | data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, GFP_KERNEL); | ||
1365 | if (!data) | ||
1366 | goto login_mtask_data_alloc_fail; | ||
1367 | conn->login_mtask->data = data; | ||
1368 | |||
1379 | init_timer(&conn->tmabort_timer); | 1369 | init_timer(&conn->tmabort_timer); |
1380 | mutex_init(&conn->xmitmutex); | 1370 | mutex_init(&conn->xmitmutex); |
1381 | init_waitqueue_head(&conn->ehwait); | 1371 | init_waitqueue_head(&conn->ehwait); |
1382 | 1372 | ||
1383 | return cls_conn; | 1373 | return cls_conn; |
1384 | 1374 | ||
1375 | login_mtask_data_alloc_fail: | ||
1376 | __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, | ||
1377 | sizeof(void*)); | ||
1385 | login_mtask_alloc_fail: | 1378 | login_mtask_alloc_fail: |
1386 | kfifo_free(conn->mgmtqueue); | 1379 | kfifo_free(conn->mgmtqueue); |
1387 | mgmtqueue_alloc_fail: | 1380 | mgmtqueue_alloc_fail: |
@@ -1451,6 +1444,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) | |||
1451 | } | 1444 | } |
1452 | 1445 | ||
1453 | spin_lock_bh(&session->lock); | 1446 | spin_lock_bh(&session->lock); |
1447 | kfree(conn->login_mtask->data); | ||
1454 | __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, | 1448 | __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, |
1455 | sizeof(void*)); | 1449 | sizeof(void*)); |
1456 | list_del(&conn->item); | 1450 | list_del(&conn->item); |