Whamcloud - gitweb
lu_object: add ->lct_exit() method to lu_context_key
authornikita <nikita>
Sat, 5 Aug 2006 09:02:36 +0000 (09:02 +0000)
committernikita <nikita>
Sat, 5 Aug 2006 09:02:36 +0000 (09:02 +0000)
lustre/include/lu_object.h
lustre/obdclass/lu_object.c

index 05f4183..530f5c1 100644 (file)
@@ -872,6 +872,13 @@ struct lu_context_key {
         void   (*lct_fini)(const struct lu_context *ctx,
                            struct lu_context_key *key, void *data);
         /*
+         * Optional method called on lu_context_exit() for all allocated
+         * keys. Can be used by debugging code checking that locks are
+         * released, etc.
+         */
+        void   (*lct_exit)(const struct lu_context *ctx,
+                           struct lu_context_key *key, void *data);
+        /*
          * Internal implementation detail: index within ->lc_value[] reserved
          * for this key.
          */
index 8640cd9..50223cb 100644 (file)
@@ -819,6 +819,21 @@ EXPORT_SYMBOL(lu_context_enter);
  */
 void lu_context_exit(struct lu_context *ctx)
 {
+        int i;
+
+        if (ctx->lc_value != NULL) {
+                for (i = 0; i < ARRAY_SIZE(lu_keys); ++i) {
+                        if (ctx->lc_value[i] != NULL) {
+                                struct lu_context_key *key;
+
+                                key = lu_keys[i];
+                                LASSERT(key != NULL);
+                                if (key->lct_exit != NULL)
+                                        key->lct_exit(ctx,
+                                                      key, ctx->lc_value[i]);
+                        }
+                }
+        }
 }
 EXPORT_SYMBOL(lu_context_exit);