*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* Client Lustre Object.
*
#include <obd_class.h>
#include <obd_support.h>
#include <lustre_fid.h>
-#include <libcfs/libcfs_hash.h> /* for cfs_hash stuff */
#include <cl_object.h>
#include <lu_object.h>
#include "cl_internal.h"
static struct kmem_cache *cl_env_kmem;
struct kmem_cache *cl_dio_aio_kmem;
+struct kmem_cache *cl_sub_dio_kmem;
struct kmem_cache *cl_page_kmem_array[16];
unsigned short cl_page_kmem_size_array[16];
EXPORT_SYMBOL(cl_object_attr_update);
/**
+ * Mark the inode as dirty when the inode has uncommitted (unstable) pages.
+ * Thus when the system is under momory pressure, it will trigger writeback
+ * on background to commit and unpin the pages.
+ */
+void cl_object_dirty_for_sync(const struct lu_env *env, struct cl_object *top)
+{
+ struct cl_object *obj;
+
+ ENTRY;
+
+ cl_object_for_each(obj, top) {
+ if (obj->co_ops->coo_dirty_for_sync != NULL)
+ obj->co_ops->coo_dirty_for_sync(env, obj);
+ }
+ EXIT;
+}
+EXPORT_SYMBOL(cl_object_dirty_for_sync);
+
+/**
* Notifies layers (bottom-to-top) that glimpse AST was received.
*
* Layers have to fill \a lvb fields with information that will be shipped
}
EXPORT_SYMBOL(cl_object_flush);
+int cl_object_inode_ops(const struct lu_env *env, struct cl_object *top,
+ enum coo_inode_opc opc, void *data)
+{
+ struct cl_object *obj;
+ int rc = 0;
+
+ ENTRY;
+
+ cl_object_for_each(obj, top) {
+ if (obj->co_ops->coo_inode_ops) {
+ rc = obj->co_ops->coo_inode_ops(env, obj, opc, data);
+ if (rc)
+ break;
+ }
+ }
+ RETURN(rc);
+}
+EXPORT_SYMBOL(cl_object_inode_ops);
+
/**
* Helper function removing all object locks, and marking object for
* deletion. All object pages must have been deleted at this point.
*/
int cl_site_stats_print(const struct cl_site *site, struct seq_file *m)
{
- static const char *pstate[] = {
+ static const char *const pstate[] = {
[CPS_CACHED] = "c",
[CPS_OWNED] = "o",
[CPS_PAGEOUT] = "w",
*
*/
-/**
- * The most efficient way is to store cl_env pointer in task specific
- * structures. On Linux, it isn't easy to use task_struct->journal_info
- * because Lustre code may call into other fs during memory reclaim, which
- * has certain assumptions about journal_info. There are not currently any
- * fields in task_struct that can be used for this purpose.
- * \note As long as we use task_struct to store cl_env, we assume that once
- * called into Lustre, we'll never call into the other part of the kernel
- * which will use those fields in task_struct without explicitly exiting
- * Lustre.
- *
- * Since there's no space in task_struct is available, hash will be used.
- * bz20044, bz22683.
- */
-
static unsigned cl_envs_cached_max = 32; /* XXX: prototype: arbitrary limit
* for now. */
static struct cl_env_cache {
OBD_SLAB_FREE_PTR(cle, cl_env_kmem);
}
+/* Get a cl_env, either from the per-CPU cache for the current CPU, or by
+ * allocating a new one.
+ */
static struct lu_env *cl_env_obtain(void *debug)
{
struct cl_env *cle;
}
/**
- * Returns lu_env: if there already is an environment associated with the
- * current thread, it is returned, otherwise, new environment is allocated.
+ * Returns an lu_env.
+ *
+ * No link to thread, this returns an env from the cache or
+ * allocates a new one.
*
- * Allocations are amortized through the global cache of environments.
+ * If you need to get the specific environment you created for this thread,
+ * you must either pass the pointer directly or store it in the file/inode
+ * private data and retrieve it from there using ll_cl_add/ll_cl_find.
*
* \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
* Release an environment.
*
* Decrement \a env reference counter. When counter drops to 0, nothing in
- * this thread is using environment and it is returned to the allocation
- * cache, or freed straight away, if cache is large enough.
+ * this thread is using environment and it is returned to the per-CPU cache or
+ * freed immediately if the cache is full.
*/
void cl_env_put(struct lu_env *env, __u16 *refcheck)
{
EXPORT_SYMBOL(cl_lvb2attr);
static struct cl_env cl_env_percpu[NR_CPUS];
+static DEFINE_MUTEX(cl_env_percpu_mutex);
static int cl_env_percpu_init(void)
{
{
int i;
+ mutex_lock(&cl_env_percpu_mutex);
for_each_possible_cpu(i)
lu_env_refill(&cl_env_percpu[i].ce_lu);
+ mutex_unlock(&cl_env_percpu_mutex);
}
void cl_env_percpu_put(struct lu_env *env)
.ckd_size = sizeof(struct cl_dio_aio)
},
{
+ .ckd_cache = &cl_sub_dio_kmem,
+ .ckd_name = "cl_sub_dio_kmem",
+ .ckd_size = sizeof(struct cl_sub_dio)
+ },
+ {
.ckd_cache = NULL
}
};