Skip to content
Snippets Groups Projects
Commit 9832985e authored by Nikita Danilov's avatar Nikita Danilov
Browse files

lu_kmem_descr and its companion interface allow to create and destroy a number

of kmem caches at once.
b=16450
parent cbfee37b
No related branches found
No related tags found
No related merge requests found
......@@ -1621,6 +1621,12 @@ Description: Add lu_ref support to struct lu_device.
Details : Add lu_ref support to lu_object and lu_device. lu_ref is used to
track leaked references.
Severity : normal
Bugzilla : 16450
Description: Introduce lu_kmem_descr.
Details : lu_kmem_descr and its companion interface allow to create
and destroy a number of kmem caches at once.
--------------------------------------------------------------------------------
2007-08-10 Cluster File Systems, Inc. <info@clusterfs.com>
......
......@@ -1301,4 +1301,15 @@ enum {
extern const char *lu_time_names[LU_TIME_NR];
struct lu_kmem_descr {
cfs_mem_cache_t **ckd_cache;
const char *ckd_name;
const size_t ckd_size;
};
int lu_kmem_init(struct lu_kmem_descr *caches);
void lu_kmem_fini(struct lu_kmem_descr *caches);
/** @} lu */
#endif /* __LUSTRE_LU_OBJECT_H */
......@@ -1529,3 +1529,43 @@ const char *lu_time_names[LU_TIME_NR] = {
[LU_TIME_FIND_INSERT] = "find_insert"
};
EXPORT_SYMBOL(lu_time_names);
/**
* Helper function to initialize a number of kmem slab caches at once.
*/
int lu_kmem_init(struct lu_kmem_descr *caches)
{
int result;
for (result = 0; caches->ckd_cache != NULL; ++caches) {
*caches->ckd_cache = cfs_mem_cache_create(caches->ckd_name,
caches->ckd_size,
0, 0);
if (*caches->ckd_cache == NULL) {
result = -ENOMEM;
break;
}
}
return result;
}
EXPORT_SYMBOL(lu_kmem_init);
/**
* Helper function to finalize a number of kmem slab cached at once. Dual to
* lu_kmem_init().
*/
void lu_kmem_fini(struct lu_kmem_descr *caches)
{
int rc;
for (; caches->ckd_cache != NULL; ++caches) {
if (*caches->ckd_cache != NULL) {
rc = cfs_mem_cache_destroy(*caches->ckd_cache);
LASSERTF(rc == 0, "couldn't destroy %s slab\n",
caches->ckd_name);
*caches->ckd_cache = NULL;
}
}
}
EXPORT_SYMBOL(lu_kmem_fini);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment