diff options
author | Olaf Kirch <olaf.kirch@oracle.com> | 2007-12-13 12:43:25 -0600 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-11 18:28:27 -0600 |
commit | 6320377fd94316e58f75d0be6f6e7a644950a4ee (patch) | |
tree | 7c7b47e6bafae9f25cfd9e1416494b6406c2d0b9 /drivers/scsi/iscsi_tcp.c | |
parent | 38ad03de3fd350e683213ddf898a7049534628a8 (diff) | |
download | blackbird-op-linux-6320377fd94316e58f75d0be6f6e7a644950a4ee.tar.gz blackbird-op-linux-6320377fd94316e58f75d0be6f6e7a644950a4ee.zip |
[SCSI] libiscsi, iscsi_tcp: iscsi pool cleanup
iscsi_pool_init simplified
iscsi_pool_init currently has a lot of duplicate kfree() calls it does
when some allocation fails. This patch simplifies the code a little by
using iscsi_pool_free to tear down the pool in case of an error.
iscsi_pool_init also returns a copy of the item array to the caller.
Not all callers use this array, so we make it optional.
Instead of allocating a second array and return that, allocate just one
array, of twice the size.
Update users of iscsi_pool_{init,free}
This patch drops the (now useless) second argument to
iscsi_pool_free, and updates all callers.
It also removes the ctask->r2ts array, which was never
used anyway. Since the items argument to iscsi_pool_init
is now optional, we can pass NULL instead.
Signed-off-by: Olaf Kirch <olaf.kirch@oracle.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/iscsi_tcp.c')
-rw-r--r-- | drivers/scsi/iscsi_tcp.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 491845f18710..f79a457099e6 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -1998,8 +1998,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) */ /* R2T pool */ - if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4, - (void***)&tcp_ctask->r2ts, + if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4, NULL, sizeof(struct iscsi_r2t_info))) { goto r2t_alloc_fail; } @@ -2008,8 +2007,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) tcp_ctask->r2tqueue = kfifo_alloc( session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL); if (tcp_ctask->r2tqueue == ERR_PTR(-ENOMEM)) { - iscsi_pool_free(&tcp_ctask->r2tpool, - (void**)tcp_ctask->r2ts); + iscsi_pool_free(&tcp_ctask->r2tpool); goto r2t_alloc_fail; } } @@ -2022,8 +2020,7 @@ r2t_alloc_fail: struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; kfifo_free(tcp_ctask->r2tqueue); - iscsi_pool_free(&tcp_ctask->r2tpool, - (void**)tcp_ctask->r2ts); + iscsi_pool_free(&tcp_ctask->r2tpool); } return -ENOMEM; } @@ -2038,8 +2035,7 @@ iscsi_r2tpool_free(struct iscsi_session *session) struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; kfifo_free(tcp_ctask->r2tqueue); - iscsi_pool_free(&tcp_ctask->r2tpool, - (void**)tcp_ctask->r2ts); + iscsi_pool_free(&tcp_ctask->r2tpool); } } |