Whamcloud - gitweb
b=22683 fix unbalanced cl_env hash.
[fs/lustre-release.git] / lustre / obdclass / cl_object.c
index 9616efa..1d6572d 100644 (file)
@@ -536,7 +536,10 @@ struct cl_env {
         cfs_hlist_node_t  ce_node;
         /**
          * Owner for the current cl_env, the key for cfs_hash.
         cfs_hlist_node_t  ce_node;
         /**
          * Owner for the current cl_env, the key for cfs_hash.
-         * Now current thread pointer is stored.
+         * Now current thread pid is stored. Note using thread pointer would
+         * lead to unbalanced hash because of its specific allocation locality
+         * and could be varied for different platforms and OSes, even different
+         * OS versions.
          */
         void             *ce_owner;
         /*
          */
         void             *ce_owner;
         /*
@@ -607,7 +610,7 @@ static cfs_hash_ops_t cl_env_hops = {
 static inline struct cl_env *cl_env_fetch(void)
 {
         struct cl_env *cle;
 static inline struct cl_env *cl_env_fetch(void)
 {
         struct cl_env *cle;
-        cle = cfs_hash_lookup(cl_env_hash, cfs_current());
+        cle = cfs_hash_lookup(cl_env_hash, (void *) (long) cfs_current()->pid);
         LASSERT(ergo(cle, cle->ce_magic == &cl_env_init0));
         return cle;
 }
         LASSERT(ergo(cle, cle->ce_magic == &cl_env_init0));
         return cle;
 }
@@ -617,9 +620,9 @@ static inline void cl_env_attach(struct cl_env *cle)
         if (cle) {
                 int rc;
                 LASSERT(cle->ce_owner == NULL);
         if (cle) {
                 int rc;
                 LASSERT(cle->ce_owner == NULL);
-                cle->ce_owner = cfs_current();
+                cle->ce_owner = (void *) (long) cfs_current()->pid;
                 rc = cfs_hash_add_unique(cl_env_hash, cle->ce_owner,
                 rc = cfs_hash_add_unique(cl_env_hash, cle->ce_owner,
-                                            &cle->ce_node);
+                                         &cle->ce_node);
                 LASSERT(rc == 0);
         }
 }
                 LASSERT(rc == 0);
         }
 }
@@ -630,9 +633,9 @@ static inline struct cl_env *cl_env_detach(struct cl_env *cle)
                 cle = cl_env_fetch();
         if (cle && cle->ce_owner) {
                 void *cookie;
                 cle = cl_env_fetch();
         if (cle && cle->ce_owner) {
                 void *cookie;
-                LASSERT(cle->ce_owner == cfs_current());
+                LASSERT(cle->ce_owner == (void *) (long) cfs_current()->pid);
                 cookie = cfs_hash_del(cl_env_hash, cle->ce_owner,
                 cookie = cfs_hash_del(cl_env_hash, cle->ce_owner,
-                                         &cle->ce_node);
+                                      &cle->ce_node);
                 cle->ce_owner = NULL;
                 LASSERT(cookie == cle);
         }
                 cle->ce_owner = NULL;
                 LASSERT(cookie == cle);
         }