Whamcloud - gitweb
LU-2622 obdclass: Remove the global cl_env list
[fs/lustre-release.git] / lustre / obdclass / cl_object.c
index a13bf5c..1eb8e76 100644 (file)
@@ -58,9 +58,6 @@
 #include <lustre_fid.h>
 #include <libcfs/list.h>
 #include <libcfs/libcfs_hash.h> /* for cfs_hash stuff */
-/* lu_time_global_{init,fini}() */
-#include <lu_time.h>
-
 #include <cl_object.h>
 #include "cl_internal.h"
 
@@ -95,6 +92,7 @@ int cl_object_header_init(struct cl_object_header *h)
                 /* XXX hard coded GFP_* mask. */
                 INIT_RADIX_TREE(&h->coh_tree, GFP_ATOMIC);
                 CFS_INIT_LIST_HEAD(&h->coh_locks);
+               h->coh_page_bufsize = ALIGN(sizeof(struct cl_page), 8);
         }
         RETURN(result);
 }
@@ -535,12 +533,6 @@ EXPORT_SYMBOL(cl_site_stats_print);
  * bz20044, bz22683.
  */
 
-static CFS_LIST_HEAD(cl_envs);
-static unsigned cl_envs_cached_nr  = 0;
-static unsigned cl_envs_cached_max = 128; /* XXX: prototype: arbitrary limit
-                                           * for now. */
-static DEFINE_SPINLOCK(cl_envs_guard);
-
 struct cl_env {
         void             *ce_magic;
         struct lu_env     ce_lu;
@@ -795,40 +787,6 @@ static void cl_env_fini(struct cl_env *cle)
         OBD_SLAB_FREE_PTR(cle, cl_env_kmem);
 }
 
-static struct lu_env *cl_env_obtain(void *debug)
-{
-       struct cl_env *cle;
-       struct lu_env *env;
-
-       ENTRY;
-       spin_lock(&cl_envs_guard);
-       LASSERT(equi(cl_envs_cached_nr == 0, cfs_list_empty(&cl_envs)));
-       if (cl_envs_cached_nr > 0) {
-               int rc;
-
-               cle = container_of(cl_envs.next, struct cl_env, ce_linkage);
-               cfs_list_del_init(&cle->ce_linkage);
-               cl_envs_cached_nr--;
-               spin_unlock(&cl_envs_guard);
-
-                env = &cle->ce_lu;
-                rc = lu_env_refill(env);
-                if (rc == 0) {
-                        cl_env_init0(cle, debug);
-                        lu_context_enter(&env->le_ctx);
-                        lu_context_enter(&cle->ce_ses);
-                } else {
-                        cl_env_fini(cle);
-                        env = ERR_PTR(rc);
-                }
-        } else {
-               spin_unlock(&cl_envs_guard);
-               env = cl_env_new(lu_context_tags_default,
-                                lu_session_tags_default, debug);
-       }
-       RETURN(env);
-}
-
 static inline struct cl_env *cl_env_container(struct lu_env *env)
 {
         return container_of(env, struct cl_env, ce_lu);
@@ -860,8 +818,6 @@ EXPORT_SYMBOL(cl_env_peek);
  * Returns lu_env: if there already is an environment associated with the
  * current thread, it is returned, otherwise, new environment is allocated.
  *
- * Allocations are amortized through the global cache of environments.
- *
  * \param refcheck pointer to a counter used to detect environment leaks. In
  * the usual case cl_env_get() and cl_env_put() are called in the same lexical
  * scope and pointer to the same integer is passed as \a refcheck. This is
@@ -875,7 +831,10 @@ struct lu_env *cl_env_get(int *refcheck)
 
         env = cl_env_peek(refcheck);
         if (env == NULL) {
-                env = cl_env_obtain(__builtin_return_address(0));
+               env = cl_env_new(lu_context_tags_default,
+                                lu_session_tags_default,
+                                __builtin_return_address(0));
+
                 if (!IS_ERR(env)) {
                         struct cl_env *cle;
 
@@ -919,33 +878,6 @@ static void cl_env_exit(struct cl_env *cle)
 }
 
 /**
- * Finalizes and frees a given number of cached environments. This is done to
- * (1) free some memory (not currently hooked into VM), or (2) release
- * references to modules.
- */
-unsigned cl_env_cache_purge(unsigned nr)
-{
-       struct cl_env *cle;
-
-       ENTRY;
-       spin_lock(&cl_envs_guard);
-       for (; !cfs_list_empty(&cl_envs) && nr > 0; --nr) {
-               cle = container_of(cl_envs.next, struct cl_env, ce_linkage);
-               cfs_list_del_init(&cle->ce_linkage);
-               LASSERT(cl_envs_cached_nr > 0);
-               cl_envs_cached_nr--;
-               spin_unlock(&cl_envs_guard);
-
-               cl_env_fini(cle);
-               spin_lock(&cl_envs_guard);
-       }
-       LASSERT(equi(cl_envs_cached_nr == 0, cfs_list_empty(&cl_envs)));
-       spin_unlock(&cl_envs_guard);
-       RETURN(nr);
-}
-EXPORT_SYMBOL(cl_env_cache_purge);
-
-/**
  * Release an environment.
  *
  * Decrement \a env reference counter. When counter drops to 0, nothing in
@@ -967,21 +899,7 @@ void cl_env_put(struct lu_env *env, int *refcheck)
                 cl_env_detach(cle);
                 cle->ce_debug = NULL;
                 cl_env_exit(cle);
-                /*
-                 * Don't bother to take a lock here.
-                 *
-                 * Return environment to the cache only when it was allocated
-                 * with the standard tags.
-                 */
-                if (cl_envs_cached_nr < cl_envs_cached_max &&
-                    (env->le_ctx.lc_tags & ~LCT_HAS_EXIT) == LCT_CL_THREAD &&
-                    (env->le_ses->lc_tags & ~LCT_HAS_EXIT) == LCT_SESSION) {
-                       spin_lock(&cl_envs_guard);
-                       cfs_list_add(&cle->ce_linkage, &cl_envs);
-                       cl_envs_cached_nr++;
-                       spin_unlock(&cl_envs_guard);
-               } else
-                       cl_env_fini(cle);
+               cl_env_fini(cle);
        }
 }
 EXPORT_SYMBOL(cl_env_put);