Whamcloud - gitweb
- register/degister keys in mod_init/exit to avoid issues while mds cleanup
authortappro <tappro>
Wed, 16 Aug 2006 22:30:24 +0000 (22:30 +0000)
committertappro <tappro>
Wed, 16 Aug 2006 22:30:24 +0000 (22:30 +0000)
- use one fld_thread_key structure
- remove unused code

lustre/fld/fld_handler.c
lustre/fld/fld_index.c
lustre/fld/fld_internal.h

index 1e0b03f..915ccaf 100644 (file)
 #include <obd_support.h>
 #include <lprocfs_status.h>
 
-#include <dt_object.h>
 #include <md_object.h>
-#include <lustre_req_layout.h>
-#include <lustre_fld.h>
+
 #include "fld_internal.h"
 
 #ifdef __KERNEL__
+static void *fld_key_init(const struct lu_context *ctx,
+                          struct lu_context_key *key)
+{
+        struct fld_thread_info *info;
+        ENTRY;
+
+        OBD_ALLOC_PTR(info);
+        if (info == NULL)
+                info = ERR_PTR(-ENOMEM);
+        RETURN(info);
+}
+
+static void fld_key_fini(const struct lu_context *ctx,
+                         struct lu_context_key *key, void *data)
+{
+        struct fld_thread_info *info = data;
+        ENTRY;
+        OBD_FREE_PTR(info);
+        EXIT;
+}
+
+struct lu_context_key fld_thread_key = {
+        .lct_tags = LCT_MD_THREAD|LCT_DT_THREAD,
+        .lct_init = fld_key_init,
+        .lct_fini = fld_key_fini
+};
+
 static int __init fld_mod_init(void)
 {
-        /* nothing to init seems */
+        lu_context_key_register(&fld_thread_key);
         return 0;
 }
 
 static void __exit fld_mod_exit(void)
 {
-        /* nothing to fini seems */
+        lu_context_key_degister(&fld_thread_key);
         return;
 }
 
@@ -117,11 +142,6 @@ static int fld_server_handle(struct lu_server_fld *fld,
 
 }
 
-struct fld_thread_info {
-        struct req_capsule fti_pill;
-        int                fti_rep_buf_size[3];
-};
-
 static int fld_req_handle0(const struct lu_context *ctx,
                            struct lu_server_fld *fld,
                            struct ptlrpc_request *req,
@@ -152,34 +172,6 @@ static int fld_req_handle0(const struct lu_context *ctx,
         RETURN(rc);
 }
 
-static void *fld_thread_init(const struct lu_context *ctx,
-                             struct lu_context_key *key)
-{
-        struct fld_thread_info *info;
-
-        /*
-         * check that no high order allocations are incurred.
-         */
-        CLASSERT(CFS_PAGE_SIZE >= sizeof *info);
-        OBD_ALLOC_PTR(info);
-        if (info == NULL)
-                info = ERR_PTR(-ENOMEM);
-        return info;
-}
-
-static void fld_thread_fini(const struct lu_context *ctx,
-                            struct lu_context_key *key, void *data)
-{
-        struct fld_thread_info *info = data;
-        OBD_FREE_PTR(info);
-}
-
-struct lu_context_key fld_thread_key = {
-        .lct_tags = LCT_MD_THREAD|LCT_DT_THREAD,
-        .lct_init = fld_thread_init,
-        .lct_fini = fld_thread_fini
-};
-
 static void fld_thread_info_init(struct ptlrpc_request *req,
                                  struct fld_thread_info *info)
 {
index 73c9332..e1a847f 100644 (file)
@@ -69,39 +69,7 @@ enum {
         FLD_TXN_INDEX_DELETE_CREDITS  = 20,
 };
 
-struct fld_thread_info {
-        __u64 fti_key;
-        __u64 fti_rec;
-};
-
-static void *fld_key_init(const struct lu_context *ctx,
-                          struct lu_context_key *key)
-{
-        struct fld_thread_info *info;
-        ENTRY;
-
-        OBD_ALLOC_PTR(info);
-        if (info == NULL)
-                info = ERR_PTR(-ENOMEM);
-        RETURN(info);
-}
-
-static void fld_key_fini(const struct lu_context *ctx,
-                         struct lu_context_key *key, void *data)
-{
-        struct fld_thread_info *info = data;
-        ENTRY;
-        OBD_FREE_PTR(info);
-        EXIT;
-}
-
-static int fld_key_registered = 0;
-
-static struct lu_context_key fld_thread_key = {
-        .lct_tags = LCT_MD_THREAD|LCT_DT_THREAD,
-        .lct_init = fld_key_init,
-        .lct_fini = fld_key_fini
-};
+extern struct lu_context_key fld_thread_key;
 
 static struct dt_key *fld_key(const struct lu_context *ctx,
                               const seqno_t seq)
@@ -204,13 +172,6 @@ int fld_index_init(struct lu_server_fld *fld,
         int rc;
         ENTRY;
 
-        if (fld_key_registered == 0) {
-                rc = lu_context_key_register(&fld_thread_key);
-                if (rc != 0)
-                        RETURN(rc);
-        }
-        fld_key_registered++;
-
         /*
          * lu_context_key has to be registered before threads are started,
          * check this.
@@ -244,9 +205,5 @@ void fld_index_fini(struct lu_server_fld *fld,
                         lu_object_put(ctx, &fld->fld_obj->do_lu);
                 fld->fld_obj = NULL;
         }
-        if (fld_key_registered > 0) {
-                if (--fld_key_registered == 0)
-                        lu_context_key_degister(&fld_thread_key);
-        }
         EXIT;
 }
index 9a1295a..d7ff46b 100644 (file)
@@ -35,6 +35,8 @@
 #include <libcfs/kp30.h>
 
 #include <linux/types.h>
+#include <lustre_req_layout.h>
+#include <lustre_fld.h>
 
 enum fld_op {
         FLD_CREATE = 0,
@@ -50,6 +52,12 @@ extern struct lu_fld_hash fld_hash[];
 
 #ifdef __KERNEL__
 #define FLD_SERVICE_WATCHDOG_TIMEOUT (obd_timeout * 1000)
+struct fld_thread_info {
+        struct req_capsule fti_pill;
+        int                fti_rep_buf_size[3];
+        __u64              fti_key;
+        __u64              fti_rec;
+};
 
 int fld_index_init(struct lu_server_fld *fld,
                    const struct lu_context *ctx,