From: ftillier Date: Fri, 7 Apr 2006 04:36:53 +0000 (+0000) Subject: [IBAL] Cleanup user-mode __get_mad_element for better legibility. X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=e1984f9c4356964d581ec546fdcf383c840dd75c;p=~shefty%2Frdma-win.git [IBAL] Cleanup user-mode __get_mad_element for better legibility. git-svn-id: svn://openib.tc.cornell.edu/gen1@292 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/core/al/user/al_mad_pool.c b/trunk/core/al/user/al_mad_pool.c index 231f4274..0ec4e156 100644 --- a/trunk/core/al/user/al_mad_pool.c +++ b/trunk/core/al/user/al_mad_pool.c @@ -191,16 +191,20 @@ ib_create_mad_pool( /* Save the pool parameters. Set grow_size to min for initialization. */ h_pool->max = max; - h_pool->grow_size = min; - - /* Grow the pool to the minimum size. */ - status = __grow_mad_pool( h_pool, NULL ); - if( status != IB_SUCCESS ) + if( min ) { - h_pool->obj.pfn_destroy( &h_pool->obj, NULL ); - CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, - ("grow_mad_pool failed with status %s.\n", ib_get_err_str(status)) ); - return status; + h_pool->grow_size = min; + + /* Grow the pool to the minimum size. */ + status = __grow_mad_pool( h_pool, NULL ); + if( status != IB_SUCCESS ) + { + h_pool->obj.pfn_destroy( &h_pool->obj, NULL ); + CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, + ("grow_mad_pool failed with status %s.\n", + ib_get_err_str(status)) ); + return status; + } } /* Save the grow_size for subsequent allocations. */ @@ -771,9 +775,8 @@ __get_mad_element( { al_pool_key_t* p_pool_key; ib_pool_handle_t h_pool; - cl_list_item_t* p_mad_item; - al_mad_element_t* p_mad_element; - mad_item_t* p_mad; + cl_list_item_t* p_item; + mad_item_t* p_mad_item; ib_api_status_t status; CL_ENTER( AL_DBG_MAD_POOL, g_al_dbg_lvl ); @@ -786,14 +789,13 @@ __get_mad_element( /* Obtain a MAD item from the stack. */ cl_spinlock_acquire( &h_pool->obj.lock ); - p_mad_item = cl_qlist_remove_head( &h_pool->mad_stack ); - p_mad_element = PARENT_STRUCT( p_mad_item, al_mad_element_t, list_item ); - p_mad = PARENT_STRUCT( p_mad_element, mad_item_t, al_mad_element ); - if( p_mad_item == cl_qlist_end( &h_pool->mad_stack ) ) + p_item = cl_qlist_remove_head( &h_pool->mad_stack ); + p_mad_item = PARENT_STRUCT( p_item, mad_item_t, al_mad_element.list_item ); + if( p_item == cl_qlist_end( &h_pool->mad_stack ) ) { /* The stack was empty. Grow the pool and obtain a new item. */ cl_spinlock_release( &h_pool->obj.lock ); - status = __grow_mad_pool( h_pool, &p_mad ); + status = __grow_mad_pool( h_pool, &p_mad_item ); if( status != IB_SUCCESS ) { CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, @@ -807,16 +809,13 @@ __get_mad_element( cl_spinlock_release( &h_pool->obj.lock ); } - if( p_mad == NULL ) - return IB_INSUFFICIENT_RESOURCES; - /* Get the local data segment information for this pool key. */ - status = __init_mad_element( p_pool_key, p_mad ); + status = __init_mad_element( p_pool_key, p_mad_item ); if( status != IB_SUCCESS ) { cl_spinlock_acquire( &h_pool->obj.lock ); cl_qlist_insert_head( &h_pool->mad_stack, - &p_mad_element->list_item ); + &p_mad_item->al_mad_element.list_item ); cl_spinlock_release( &h_pool->obj.lock ); CL_TRACE_EXIT( AL_DBG_ERROR, g_al_dbg_lvl, @@ -826,11 +825,11 @@ __get_mad_element( } /* Hold a reference on the array while a MAD element is removed. */ - ref_al_obj( &p_mad->p_mad_array->obj ); + ref_al_obj( &p_mad_item->p_mad_array->obj ); - p_mad->al_mad_element.pool_key = (ib_pool_key_t)pool_key; + p_mad_item->al_mad_element.pool_key = (ib_pool_key_t)pool_key; /* Return the MAD element. */ - *pp_mad_element = &p_mad->al_mad_element; + *pp_mad_element = &p_mad_item->al_mad_element; CL_EXIT( AL_DBG_MAD_POOL, g_al_dbg_lvl ); return IB_SUCCESS; @@ -1004,11 +1003,7 @@ __grow_mad_pool( /* Determine if the pool is allowed to grow. */ if( h_pool->grow_size == 0 ) - { - /* Cannot grow the pool. Clear the p_mad_item if one was provided. */ - if( pp_mad_item != NULL) *pp_mad_item = NULL; - return IB_SUCCESS; - } + return IB_INSUFFICIENT_RESOURCES; /* Lock the pool. */ cl_spinlock_acquire( &h_pool->obj.lock );