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>
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 */
[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);
+