diff options
author | Olaf Kirch <olaf.kirch@oracle.com> | 2007-12-13 13:43:25 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-11 19:28:27 -0500 |
commit | 6320377fd94316e58f75d0be6f6e7a644950a4ee (patch) | |
tree | 7c7b47e6bafae9f25cfd9e1416494b6406c2d0b9 /drivers/scsi/iscsi_tcp.c | |
parent | 38ad03de3fd350e683213ddf898a7049534628a8 (diff) |
[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) | |||
1998 | */ | 1998 | */ |
1999 | 1999 | ||
2000 | /* R2T pool */ | 2000 | /* R2T pool */ |
2001 | if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4, | 2001 | if (iscsi_pool_init(&tcp_ctask->r2tpool, session->max_r2t * 4, NULL, |
2002 | (void***)&tcp_ctask->r2ts, | ||
2003 | sizeof(struct iscsi_r2t_info))) { | 2002 | sizeof(struct iscsi_r2t_info))) { |
2004 | goto r2t_alloc_fail; | 2003 | goto r2t_alloc_fail; |
2005 | } | 2004 | } |
@@ -2008,8 +2007,7 @@ iscsi_r2tpool_alloc(struct iscsi_session *session) | |||
2008 | tcp_ctask->r2tqueue = kfifo_alloc( | 2007 | tcp_ctask->r2tqueue = kfifo_alloc( |
2009 | session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL); | 2008 | session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL); |
2010 | if (tcp_ctask->r2tqueue == ERR_PTR(-ENOMEM)) { | 2009 | if (tcp_ctask->r2tqueue == ERR_PTR(-ENOMEM)) { |
2011 | iscsi_pool_free(&tcp_ctask->r2tpool, | 2010 | iscsi_pool_free(&tcp_ctask->r2tpool); |
2012 | (void**)tcp_ctask->r2ts); | ||
2013 | goto r2t_alloc_fail; | 2011 | goto r2t_alloc_fail; |
2014 | } | 2012 | } |
2015 | } | 2013 | } |
@@ -2022,8 +2020,7 @@ r2t_alloc_fail: | |||
2022 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; | 2020 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; |
2023 | 2021 | ||
2024 | kfifo_free(tcp_ctask->r2tqueue); | 2022 | kfifo_free(tcp_ctask->r2tqueue); |
2025 | iscsi_pool_free(&tcp_ctask->r2tpool, | 2023 | iscsi_pool_free(&tcp_ctask->r2tpool); |
2026 | (void**)tcp_ctask->r2ts); | ||
2027 | } | 2024 | } |
2028 | return -ENOMEM; | 2025 | return -ENOMEM; |
2029 | } | 2026 | } |
@@ -2038,8 +2035,7 @@ iscsi_r2tpool_free(struct iscsi_session *session) | |||
2038 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; | 2035 | struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data; |
2039 | 2036 | ||
2040 | kfifo_free(tcp_ctask->r2tqueue); | 2037 | kfifo_free(tcp_ctask->r2tqueue); |
2041 | iscsi_pool_free(&tcp_ctask->r2tpool, | 2038 | iscsi_pool_free(&tcp_ctask->r2tpool); |
2042 | (void**)tcp_ctask->r2ts); | ||
2043 | } | 2039 | } |
2044 | } | 2040 | } |
2045 | 2041 | ||