# include <sys/time.h>
#endif
-#ifdef PTL_USE_SLAB_CACHE
-static int ptl_slab_users;
-
-kmem_cache_t *ptl_md_slab;
-kmem_cache_t *ptl_msg_slab;
-kmem_cache_t *ptl_me_slab;
-kmem_cache_t *ptl_eq_slab;
-
-atomic_t md_in_use_count;
-atomic_t msg_in_use_count;
-atomic_t me_in_use_count;
-atomic_t eq_in_use_count;
-
-/* NB zeroing in ctor and on freeing ensures items that
- * kmem_cache_validate() OK, but haven't been initialised
- * as an MD/ME/EQ can't have valid handles
- */
-static void
-ptl_md_slab_ctor (void *obj, kmem_cache_t *slab, unsigned long flags)
-{
- memset (obj, 0, sizeof (lib_md_t));
-}
-
-static void
-ptl_me_slab_ctor (void *obj, kmem_cache_t *slab, unsigned long flags)
-{
- memset (obj, 0, sizeof (lib_me_t));
-}
-
-static void
-ptl_eq_slab_ctor (void *obj, kmem_cache_t *slab, unsigned long flags)
-{
- memset (obj, 0, sizeof (lib_eq_t));
-}
+#ifndef PTL_USE_LIB_FREELIST
int
kportal_descriptor_setup (nal_cb_t *nal)
{
- /* NB on failure caller must still call kportal_descriptor_cleanup */
- /* ****** */
-
- /* We'll have 1 set of slabs for ALL the nals :) */
-
- if (ptl_slab_users++)
- return 0;
-
- ptl_md_slab = kmem_cache_create("portals_MD",
- sizeof(lib_md_t), 0,
- SLAB_HWCACHE_ALIGN,
- ptl_md_slab_ctor, NULL);
- if (!ptl_md_slab) {
- CERROR("couldn't allocate ptl_md_t slab");
- RETURN (PTL_NOSPACE);
- }
-
- /* NB no ctor for msgs; they don't need handle verification */
- ptl_msg_slab = kmem_cache_create("portals_MSG",
- sizeof(lib_msg_t), 0,
- SLAB_HWCACHE_ALIGN,
- NULL, NULL);
- if (!ptl_msg_slab) {
- CERROR("couldn't allocate ptl_msg_t slab");
- RETURN (PTL_NOSPACE);
- }
-
- ptl_me_slab = kmem_cache_create("portals_ME",
- sizeof(lib_me_t), 0,
- SLAB_HWCACHE_ALIGN,
- ptl_me_slab_ctor, NULL);
- if (!ptl_me_slab) {
- CERROR("couldn't allocate ptl_me_t slab");
- RETURN (PTL_NOSPACE);
- }
-
- ptl_eq_slab = kmem_cache_create("portals_EQ",
- sizeof(lib_eq_t), 0,
- SLAB_HWCACHE_ALIGN,
- ptl_eq_slab_ctor, NULL);
- if (!ptl_eq_slab) {
- CERROR("couldn't allocate ptl_eq_t slab");
- RETURN (PTL_NOSPACE);
- }
-
- RETURN(PTL_OK);
+ return PTL_OK;
}
void
kportal_descriptor_cleanup (nal_cb_t *nal)
{
- if (--ptl_slab_users != 0)
- return;
-
- LASSERT (atomic_read (&md_in_use_count) == 0);
- LASSERT (atomic_read (&me_in_use_count) == 0);
- LASSERT (atomic_read (&eq_in_use_count) == 0);
- LASSERT (atomic_read (&msg_in_use_count) == 0);
-
- if (ptl_md_slab != NULL)
- kmem_cache_destroy(ptl_md_slab);
- if (ptl_msg_slab != NULL)
- kmem_cache_destroy(ptl_msg_slab);
- if (ptl_me_slab != NULL)
- kmem_cache_destroy(ptl_me_slab);
- if (ptl_eq_slab != NULL)
- kmem_cache_destroy(ptl_eq_slab);
}
#else
space = nal->cb_malloc (nal, n * size);
if (space == NULL)
- return (PTL_NOSPACE);
+ return (PTL_NO_SPACE);
INIT_LIST_HEAD (&fl->fl_list);
fl->fl_objs = space;
(struct list_head *)nal->cb_malloc (nal, ni->ni_lh_hash_size
* sizeof (struct list_head));
if (ni->ni_lh_hash_table == NULL)
- return (PTL_NOSPACE);
+ return (PTL_NO_SPACE);
for (i = 0; i < ni->ni_lh_hash_size; i++)
INIT_LIST_HEAD (&ni->ni_lh_hash_table[i]);
ni->tbl.tbl = nal->cb_malloc(nal, sizeof(struct list_head) * ptl_size);
if (ni->tbl.tbl == NULL) {
- rc = PTL_NOSPACE;
+ rc = PTL_NO_SPACE;
goto out;
}