提交 d36ab6f3 编写于 作者: M Mike Christie 提交者: James Bottomley

[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: NMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: NJames Bottomley <James.Bottomley@SteelEye.com>
上级 6e458cc9
...@@ -1258,15 +1258,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit, ...@@ -1258,15 +1258,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
if (mgmt_task_size) if (mgmt_task_size)
mtask->dd_data = &mtask[1]; mtask->dd_data = &mtask[1];
mtask->itt = ISCSI_MGMT_ITT_OFFSET + cmd_i; mtask->itt = ISCSI_MGMT_ITT_OFFSET + cmd_i;
mtask->data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH,
GFP_KERNEL);
if (!mtask->data) {
int j;
for (j = 0; j < cmd_i; j++)
kfree(session->mgmt_cmds[j]->data);
goto immdata_alloc_fail;
}
} }
if (scsi_add_host(shost, NULL)) if (scsi_add_host(shost, NULL))
...@@ -1282,9 +1273,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit, ...@@ -1282,9 +1273,6 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
cls_session_fail: cls_session_fail:
scsi_remove_host(shost); scsi_remove_host(shost);
add_host_fail: add_host_fail:
for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++)
kfree(session->mgmt_cmds[cmd_i]->data);
immdata_alloc_fail:
iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);
mgmtpool_alloc_fail: mgmtpool_alloc_fail:
iscsi_pool_free(&session->cmdpool, (void**)session->cmds); iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
...@@ -1305,13 +1293,9 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session) ...@@ -1305,13 +1293,9 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
{ {
struct Scsi_Host *shost = iscsi_session_to_shost(cls_session); struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
struct iscsi_session *session = iscsi_hostdata(shost->hostdata); struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
int cmd_i;
scsi_remove_host(shost); scsi_remove_host(shost);
for (cmd_i = 0; cmd_i < session->mgmtpool_max; cmd_i++)
kfree(session->mgmt_cmds[cmd_i]->data);
iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);
iscsi_pool_free(&session->cmdpool, (void**)session->cmds); iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
...@@ -1331,6 +1315,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) ...@@ -1331,6 +1315,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
struct iscsi_session *session = class_to_transport_session(cls_session); struct iscsi_session *session = class_to_transport_session(cls_session);
struct iscsi_conn *conn; struct iscsi_conn *conn;
struct iscsi_cls_conn *cls_conn; struct iscsi_cls_conn *cls_conn;
char *data;
cls_conn = iscsi_create_conn(cls_session, conn_idx); cls_conn = iscsi_create_conn(cls_session, conn_idx);
if (!cls_conn) if (!cls_conn)
...@@ -1376,12 +1361,20 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx) ...@@ -1376,12 +1361,20 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
} }
spin_unlock_bh(&session->lock); spin_unlock_bh(&session->lock);
data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, GFP_KERNEL);
if (!data)
goto login_mtask_data_alloc_fail;
conn->login_mtask->data = data;
init_timer(&conn->tmabort_timer); init_timer(&conn->tmabort_timer);
mutex_init(&conn->xmitmutex); mutex_init(&conn->xmitmutex);
init_waitqueue_head(&conn->ehwait); init_waitqueue_head(&conn->ehwait);
return cls_conn; return cls_conn;
login_mtask_data_alloc_fail:
__kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
sizeof(void*));
login_mtask_alloc_fail: login_mtask_alloc_fail:
kfifo_free(conn->mgmtqueue); kfifo_free(conn->mgmtqueue);
mgmtqueue_alloc_fail: mgmtqueue_alloc_fail:
...@@ -1451,6 +1444,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) ...@@ -1451,6 +1444,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
} }
spin_lock_bh(&session->lock); spin_lock_bh(&session->lock);
kfree(conn->login_mtask->data);
__kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
sizeof(void*)); sizeof(void*));
list_del(&conn->item); list_del(&conn->item);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册