Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / cmm / cmm_device.c
index 717271a..3dee060 100644 (file)
@@ -383,30 +383,9 @@ static void cmm_device_free(const struct lu_env *env, struct lu_device *d)
 }
 
 /* context key constructor/destructor */
-static void *cmm_key_init(const struct lu_context *ctx,
-                          struct lu_context_key *key)
-{
-        struct cmm_thread_info *info;
-
-        CLASSERT(CFS_PAGE_SIZE >= sizeof *info);
-        OBD_ALLOC_PTR(info);
-        if (info == NULL)
-                info = ERR_PTR(-ENOMEM);
-        return info;
-}
-
-static void cmm_key_fini(const struct lu_context *ctx,
-                         struct lu_context_key *key, void *data)
-{
-        struct cmm_thread_info *info = data;
-        OBD_FREE_PTR(info);
-}
+LU_KEY_INIT_FINI(cmm, struct cmm_thread_info);
 
-static struct lu_context_key cmm_thread_key = {
-        .lct_tags = LCT_MD_THREAD,
-        .lct_init = cmm_key_init,
-        .lct_fini = cmm_key_fini
-};
+LU_CONTEXT_KEY_DEFINE(cmm, LCT_MD_THREAD);
 
 struct cmm_thread_info *cmm_env_info(const struct lu_env *env)
 {
@@ -417,16 +396,7 @@ struct cmm_thread_info *cmm_env_info(const struct lu_env *env)
         return info;
 }
 
-static int cmm_type_init(struct lu_device_type *t)
-{
-        LU_CONTEXT_KEY_INIT(&cmm_thread_key);
-        return lu_context_key_register(&cmm_thread_key);
-}
-
-static void cmm_type_fini(struct lu_device_type *t)
-{
-        lu_context_key_degister(&cmm_thread_key);
-}
+LU_TYPE_INIT_FINI(cmm, &cmm_thread_key);
 
 static int cmm_device_init(const struct lu_env *env, struct lu_device *d,
                            const char *name, struct lu_device *next)