4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Whamcloud, Inc.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 * Author: Nikita Danilov <nikita.danilov@sun.com>
41 #define DEBUG_SUBSYSTEM S_CLASS
43 #include <libcfs/libcfs.h>
44 #include <obd_class.h>
45 #include <obd_support.h>
46 #include <libcfs/list.h>
48 #include <cl_object.h>
49 #include "cl_internal.h"
51 static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
54 static cfs_mem_cache_t *cl_page_kmem = NULL;
56 static struct lu_kmem_descr cl_page_caches[] = {
58 .ckd_cache = &cl_page_kmem,
59 .ckd_name = "cl_page_kmem",
60 .ckd_size = sizeof (struct cl_page)
68 # define PASSERT(env, page, expr) \
70 if (unlikely(!(expr))) { \
71 CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
75 #else /* !LIBCFS_DEBUG */
76 # define PASSERT(env, page, exp) \
77 ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
78 #endif /* !LIBCFS_DEBUG */
80 #ifdef INVARIANT_CHECK
81 # define PINVRNT(env, page, expr) \
83 if (unlikely(!(expr))) { \
84 CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
88 #else /* !INVARIANT_CHECK */
89 # define PINVRNT(env, page, exp) \
90 ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
91 #endif /* !INVARIANT_CHECK */
94 * Internal version of cl_page_top, it should be called with page referenced,
97 static struct cl_page *cl_page_top_trusted(struct cl_page *page)
99 while (page->cp_parent != NULL)
100 page = page->cp_parent;
105 * Internal version of cl_page_get().
107 * This function can be used to obtain initial reference to previously
108 * unreferenced cached object. It can be called only if concurrent page
109 * reclamation is somehow prevented, e.g., by locking page radix-tree
110 * (cl_object_header::hdr->coh_page_guard), or by keeping a lock on a VM page,
111 * associated with \a page.
113 * Use with care! Not exported.
115 static void cl_page_get_trust(struct cl_page *page)
118 * Checkless version for trusted users.
120 if (cfs_atomic_inc_return(&page->cp_ref) == 1)
121 cfs_atomic_inc(&cl_object_site(page->cp_obj)->cs_pages.cs_busy);
125 * Returns a slice within a page, corresponding to the given layer in the
130 static const struct cl_page_slice *
131 cl_page_at_trusted(const struct cl_page *page,
132 const struct lu_device_type *dtype)
134 const struct cl_page_slice *slice;
136 #ifdef INVARIANT_CHECK
137 if (!cfs_atomic_read(&page->cp_ref))
138 LASSERT_SPIN_LOCKED(&page->cp_lock);
142 page = cl_page_top_trusted((struct cl_page *)page);
144 cfs_list_for_each_entry(slice, &page->cp_layers, cpl_linkage) {
145 if (slice->cpl_obj->co_lu.lo_dev->ld_type == dtype)
148 page = page->cp_child;
149 } while (page != NULL);
154 * Returns a page with given index in the given object, or NULL if no page is
155 * found. Acquires a reference on \a page.
157 * Locking: called under cl_object_header::coh_page_guard spin-lock.
159 struct cl_page *cl_page_lookup(struct cl_object_header *hdr, pgoff_t index)
161 struct cl_page *page;
163 LASSERT_SPIN_LOCKED(&hdr->coh_page_guard);
165 page = radix_tree_lookup(&hdr->coh_tree, index);
167 cl_page_get_trust(page);
171 EXPORT_SYMBOL(cl_page_lookup);
174 * Returns a list of pages by a given [start, end] of \a obj.
176 * \param resched If not NULL, then we give up before hogging CPU for too
177 * long and set *resched = 1, in that case caller should implement a retry
180 * Gang tree lookup (radix_tree_gang_lookup()) optimization is absolutely
181 * crucial in the face of [offset, EOF] locks.
183 * Return at least one page in @queue unless there is no covered page.
185 int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj,
186 struct cl_io *io, pgoff_t start, pgoff_t end,
187 cl_page_gang_cb_t cb, void *cbdata)
189 struct cl_object_header *hdr;
190 struct cl_page *page;
191 struct cl_page **pvec;
192 const struct cl_page_slice *slice;
193 const struct lu_device_type *dtype;
198 int res = CLP_GANG_OKAY;
203 hdr = cl_object_header(obj);
204 pvec = cl_env_info(env)->clt_pvec;
205 dtype = cl_object_top(obj)->co_lu.lo_dev->ld_type;
206 spin_lock(&hdr->coh_page_guard);
207 while ((nr = radix_tree_gang_lookup(&hdr->coh_tree, (void **)pvec,
208 idx, CLT_PVEC_SIZE)) > 0) {
209 int end_of_region = 0;
210 idx = pvec[nr - 1]->cp_index + 1;
211 for (i = 0, j = 0; i < nr; ++i) {
215 LASSERT(page->cp_type == CPT_CACHEABLE);
216 if (page->cp_index > end) {
220 if (page->cp_state == CPS_FREEING)
223 slice = cl_page_at_trusted(page, dtype);
225 * Pages for lsm-less file has no underneath sub-page
226 * for osc, in case of ...
228 PASSERT(env, page, slice != NULL);
230 page = slice->cpl_page;
232 * Can safely call cl_page_get_trust() under
233 * radix-tree spin-lock.
235 * XXX not true, because @page is from object another
236 * than @hdr and protected by different tree lock.
238 cl_page_get_trust(page);
239 lu_ref_add_atomic(&page->cp_reference,
240 "gang_lookup", cfs_current());
245 * Here a delicate locking dance is performed. Current thread
246 * holds a reference to a page, but has to own it before it
247 * can be placed into queue. Owning implies waiting, so
248 * radix-tree lock is to be released. After a wait one has to
249 * check that pages weren't truncated (cl_page_own() returns
250 * error in the latter case).
252 spin_unlock(&hdr->coh_page_guard);
255 for (i = 0; i < j; ++i) {
257 if (res == CLP_GANG_OKAY)
258 res = (*cb)(env, io, page, cbdata);
259 lu_ref_del(&page->cp_reference,
260 "gang_lookup", cfs_current());
261 cl_page_put(env, page);
263 if (nr < CLT_PVEC_SIZE || end_of_region)
266 if (res == CLP_GANG_OKAY && cfs_need_resched())
267 res = CLP_GANG_RESCHED;
268 if (res != CLP_GANG_OKAY)
271 spin_lock(&hdr->coh_page_guard);
275 spin_unlock(&hdr->coh_page_guard);
278 EXPORT_SYMBOL(cl_page_gang_lookup);
280 static void cl_page_free(const struct lu_env *env, struct cl_page *page)
282 struct cl_object *obj = page->cp_obj;
283 struct cl_site *site = cl_object_site(obj);
285 PASSERT(env, page, cfs_list_empty(&page->cp_batch));
286 PASSERT(env, page, page->cp_owner == NULL);
287 PASSERT(env, page, page->cp_req == NULL);
288 PASSERT(env, page, page->cp_parent == NULL);
289 PASSERT(env, page, page->cp_state == CPS_FREEING);
293 while (!cfs_list_empty(&page->cp_layers)) {
294 struct cl_page_slice *slice;
296 slice = cfs_list_entry(page->cp_layers.next,
297 struct cl_page_slice, cpl_linkage);
298 cfs_list_del_init(page->cp_layers.next);
299 slice->cpl_ops->cpo_fini(env, slice);
301 cfs_atomic_dec(&site->cs_pages.cs_total);
303 #ifdef LUSTRE_PAGESTATE_TRACKING
304 cfs_atomic_dec(&site->cs_pages_state[page->cp_state]);
306 lu_object_ref_del_at(&obj->co_lu, page->cp_obj_ref, "cl_page", page);
307 cl_object_put(env, obj);
308 lu_ref_fini(&page->cp_reference);
309 OBD_SLAB_FREE_PTR(page, cl_page_kmem);
314 * Helper function updating page state. This is the only place in the code
315 * where cl_page::cp_state field is mutated.
317 static inline void cl_page_state_set_trust(struct cl_page *page,
318 enum cl_page_state state)
321 *(enum cl_page_state *)&page->cp_state = state;
324 static int cl_page_alloc(const struct lu_env *env, struct cl_object *o,
325 pgoff_t ind, struct page *vmpage,
326 enum cl_page_type type, struct cl_page **out)
328 struct cl_page *page;
329 struct cl_page *err = NULL;
330 struct lu_object_header *head;
331 struct cl_site *site = cl_object_site(o);
336 OBD_SLAB_ALLOC_PTR_GFP(page, cl_page_kmem, CFS_ALLOC_IO);
338 cfs_atomic_set(&page->cp_ref, 1);
341 page->cp_obj_ref = lu_object_ref_add(&o->co_lu,
343 page->cp_index = ind;
344 cl_page_state_set_trust(page, CPS_CACHED);
345 spin_lock_init(&page->cp_lock);
346 page->cp_type = type;
347 CFS_INIT_LIST_HEAD(&page->cp_layers);
348 CFS_INIT_LIST_HEAD(&page->cp_batch);
349 CFS_INIT_LIST_HEAD(&page->cp_flight);
350 mutex_init(&page->cp_mutex);
351 lu_ref_init(&page->cp_reference);
352 head = o->co_lu.lo_header;
353 cfs_list_for_each_entry(o, &head->loh_layers,
355 if (o->co_ops->coo_page_init != NULL) {
356 err = o->co_ops->coo_page_init(env, o,
359 cl_page_delete0(env, page, 0);
360 cl_page_free(env, page);
367 cfs_atomic_inc(&site->cs_pages.cs_busy);
368 cfs_atomic_inc(&site->cs_pages.cs_total);
370 #ifdef LUSTRE_PAGESTATE_TRACKING
371 cfs_atomic_inc(&site->cs_pages_state[CPS_CACHED]);
373 cfs_atomic_inc(&site->cs_pages.cs_created);
377 page = ERR_PTR(-ENOMEM);
383 * Returns a cl_page with index \a idx at the object \a o, and associated with
384 * the VM page \a vmpage.
386 * This is the main entry point into the cl_page caching interface. First, a
387 * cache (implemented as a per-object radix tree) is consulted. If page is
388 * found there, it is returned immediately. Otherwise new page is allocated
389 * and returned. In any case, additional reference to page is acquired.
391 * \see cl_object_find(), cl_lock_find()
393 static struct cl_page *cl_page_find0(const struct lu_env *env,
395 pgoff_t idx, struct page *vmpage,
396 enum cl_page_type type,
397 struct cl_page *parent)
399 struct cl_page *page = NULL;
400 struct cl_page *ghost = NULL;
401 struct cl_object_header *hdr;
402 struct cl_site *site = cl_object_site(o);
405 LASSERT(type == CPT_CACHEABLE || type == CPT_TRANSIENT);
410 hdr = cl_object_header(o);
411 cfs_atomic_inc(&site->cs_pages.cs_lookup);
413 CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n",
414 idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type);
416 if (type == CPT_CACHEABLE) {
417 /* cl_page::cp_lock is used to protect the page state and
418 * refcount, but need an external lock to protect the
419 * child/parent relationship, so vmpage lock must be held for
421 KLASSERT(PageLocked(vmpage));
423 * cl_vmpage_page() can be called here without any locks as
425 * - "vmpage" is locked (which prevents ->private from
426 * concurrent updates), and
428 * - "o" cannot be destroyed while current thread holds a
431 page = cl_vmpage_page(vmpage, o);
434 cl_page_vmpage(env, page) == vmpage &&
435 (void *)radix_tree_lookup(&hdr->coh_tree,
440 cfs_atomic_inc(&site->cs_pages.cs_hit);
444 /* allocate and initialize cl_page */
445 err = cl_page_alloc(env, o, idx, vmpage, type, &page);
449 if (type == CPT_TRANSIENT) {
451 LASSERT(page->cp_parent == NULL);
452 page->cp_parent = parent;
453 parent->cp_child = page;
459 * XXX optimization: use radix_tree_preload() here, and change tree
460 * gfp mask to GFP_KERNEL in cl_object_header_init().
462 spin_lock(&hdr->coh_page_guard);
463 err = radix_tree_insert(&hdr->coh_tree, idx, page);
467 * Noted by Jay: a lock on \a vmpage protects cl_page_find()
468 * from this race, but
470 * 0. it's better to have cl_page interface "locally
471 * consistent" so that its correctness can be reasoned
472 * about without appealing to the (obscure world of) VM
475 * 1. handling this race allows ->coh_tree to remain
476 * consistent even when VM locking is somehow busted,
477 * which is very useful during diagnosing and debugging.
480 CL_PAGE_DEBUG(D_ERROR, env, ghost,
481 "fail to insert into radix tree: %d\n", err);
484 LASSERT(page->cp_parent == NULL);
485 page->cp_parent = parent;
486 parent->cp_child = page;
490 spin_unlock(&hdr->coh_page_guard);
492 if (unlikely(ghost != NULL)) {
493 cfs_atomic_dec(&site->cs_pages.cs_busy);
494 cl_page_delete0(env, ghost, 0);
495 cl_page_free(env, ghost);
500 struct cl_page *cl_page_find(const struct lu_env *env, struct cl_object *o,
501 pgoff_t idx, struct page *vmpage,
502 enum cl_page_type type)
504 return cl_page_find0(env, o, idx, vmpage, type, NULL);
506 EXPORT_SYMBOL(cl_page_find);
509 struct cl_page *cl_page_find_sub(const struct lu_env *env, struct cl_object *o,
510 pgoff_t idx, struct page *vmpage,
511 struct cl_page *parent)
513 return cl_page_find0(env, o, idx, vmpage, parent->cp_type, parent);
515 EXPORT_SYMBOL(cl_page_find_sub);
517 static inline int cl_page_invariant(const struct cl_page *pg)
519 struct cl_object_header *header;
520 struct cl_page *parent;
521 struct cl_page *child;
525 * Page invariant is protected by a VM lock.
527 LINVRNT(cl_page_is_vmlocked(NULL, pg));
529 header = cl_object_header(pg->cp_obj);
530 parent = pg->cp_parent;
531 child = pg->cp_child;
532 owner = pg->cp_owner;
534 return cfs_atomic_read(&pg->cp_ref) > 0 &&
535 ergo(parent != NULL, parent->cp_child == pg) &&
536 ergo(child != NULL, child->cp_parent == pg) &&
537 ergo(child != NULL, pg->cp_obj != child->cp_obj) &&
538 ergo(parent != NULL, pg->cp_obj != parent->cp_obj) &&
539 ergo(owner != NULL && parent != NULL,
540 parent->cp_owner == pg->cp_owner->ci_parent) &&
541 ergo(owner != NULL && child != NULL,
542 child->cp_owner->ci_parent == owner) &&
544 * Either page is early in initialization (has neither child
545 * nor parent yet), or it is in the object radix tree.
547 ergo(pg->cp_state < CPS_FREEING && pg->cp_type == CPT_CACHEABLE,
548 (void *)radix_tree_lookup(&header->coh_tree,
549 pg->cp_index) == pg ||
550 (child == NULL && parent == NULL));
553 static void cl_page_state_set0(const struct lu_env *env,
554 struct cl_page *page, enum cl_page_state state)
556 enum cl_page_state old;
557 #ifdef LUSTRE_PAGESTATE_TRACKING
558 struct cl_site *site = cl_object_site(page->cp_obj);
562 * Matrix of allowed state transitions [old][new], for sanity
565 static const int allowed_transitions[CPS_NR][CPS_NR] = {
568 [CPS_OWNED] = 1, /* io finds existing cached page */
570 [CPS_PAGEOUT] = 1, /* write-out from the cache */
571 [CPS_FREEING] = 1, /* eviction on the memory pressure */
574 [CPS_CACHED] = 1, /* release to the cache */
576 [CPS_PAGEIN] = 1, /* start read immediately */
577 [CPS_PAGEOUT] = 1, /* start write immediately */
578 [CPS_FREEING] = 1, /* lock invalidation or truncate */
581 [CPS_CACHED] = 1, /* io completion */
588 [CPS_CACHED] = 1, /* io completion */
604 old = page->cp_state;
605 PASSERT(env, page, allowed_transitions[old][state]);
606 CL_PAGE_HEADER(D_TRACE, env, page, "%d -> %d\n", old, state);
607 for (; page != NULL; page = page->cp_child) {
608 PASSERT(env, page, page->cp_state == old);
610 equi(state == CPS_OWNED, page->cp_owner != NULL));
612 #ifdef LUSTRE_PAGESTATE_TRACKING
613 cfs_atomic_dec(&site->cs_pages_state[page->cp_state]);
614 cfs_atomic_inc(&site->cs_pages_state[state]);
616 cl_page_state_set_trust(page, state);
621 static void cl_page_state_set(const struct lu_env *env,
622 struct cl_page *page, enum cl_page_state state)
624 cl_page_state_set0(env, page, state);
628 * Acquires an additional reference to a page.
630 * This can be called only by caller already possessing a reference to \a
633 * \see cl_object_get(), cl_lock_get().
635 void cl_page_get(struct cl_page *page)
638 cl_page_get_trust(page);
641 EXPORT_SYMBOL(cl_page_get);
644 * Releases a reference to a page.
646 * When last reference is released, page is returned to the cache, unless it
647 * is in cl_page_state::CPS_FREEING state, in which case it is immediately
650 * \see cl_object_put(), cl_lock_put().
652 void cl_page_put(const struct lu_env *env, struct cl_page *page)
654 struct cl_site *site = cl_object_site(page->cp_obj);
656 PASSERT(env, page, cfs_atomic_read(&page->cp_ref) > !!page->cp_parent);
659 CL_PAGE_HEADER(D_TRACE, env, page, "%d\n",
660 cfs_atomic_read(&page->cp_ref));
662 if (cfs_atomic_dec_and_lock(&page->cp_ref, &page->cp_lock)) {
663 cfs_atomic_dec(&site->cs_pages.cs_busy);
664 /* We're going to access the page w/o a reference, but it's
665 * ok because we have grabbed the lock cp_lock, which
666 * means nobody is able to free this page behind us.
668 if (page->cp_state == CPS_FREEING) {
669 /* We drop the page reference and check the page state
670 * inside the cp_lock. So that if it gets here,
671 * it is the REALLY last reference to this page.
673 spin_unlock(&page->cp_lock);
675 LASSERT(cfs_atomic_read(&page->cp_ref) == 0);
676 PASSERT(env, page, page->cp_owner == NULL);
677 PASSERT(env, page, cfs_list_empty(&page->cp_batch));
679 * Page is no longer reachable by other threads. Tear
682 cl_page_free(env, page);
687 spin_unlock(&page->cp_lock);
692 EXPORT_SYMBOL(cl_page_put);
695 * Returns a VM page associated with a given cl_page.
697 cfs_page_t *cl_page_vmpage(const struct lu_env *env, struct cl_page *page)
699 const struct cl_page_slice *slice;
702 * Find uppermost layer with ->cpo_vmpage() method, and return its
705 page = cl_page_top(page);
707 cfs_list_for_each_entry(slice, &page->cp_layers, cpl_linkage) {
708 if (slice->cpl_ops->cpo_vmpage != NULL)
709 RETURN(slice->cpl_ops->cpo_vmpage(env, slice));
711 page = page->cp_child;
712 } while (page != NULL);
713 LBUG(); /* ->cpo_vmpage() has to be defined somewhere in the stack */
715 EXPORT_SYMBOL(cl_page_vmpage);
718 * Returns a cl_page associated with a VM page, and given cl_object.
720 struct cl_page *cl_vmpage_page(cfs_page_t *vmpage, struct cl_object *obj)
723 struct cl_page *page;
726 KLASSERT(PageLocked(vmpage));
729 * NOTE: absence of races and liveness of data are guaranteed by page
730 * lock on a "vmpage". That works because object destruction has
731 * bottom-to-top pass.
735 * This loop assumes that ->private points to the top-most page. This
736 * can be rectified easily.
738 top = (struct cl_page *)vmpage->private;
742 spin_lock(&top->cp_lock);
743 for (page = top; page != NULL; page = page->cp_child) {
744 if (cl_object_same(page->cp_obj, obj)) {
745 cl_page_get_trust(page);
749 spin_unlock(&top->cp_lock);
750 LASSERT(ergo(page, page->cp_type == CPT_CACHEABLE));
753 EXPORT_SYMBOL(cl_vmpage_page);
756 * Returns the top-page for a given page.
758 * \see cl_object_top(), cl_io_top()
760 struct cl_page *cl_page_top(struct cl_page *page)
762 return cl_page_top_trusted(page);
764 EXPORT_SYMBOL(cl_page_top);
766 const struct cl_page_slice *cl_page_at(const struct cl_page *page,
767 const struct lu_device_type *dtype)
769 return cl_page_at_trusted(page, dtype);
771 EXPORT_SYMBOL(cl_page_at);
773 #define CL_PAGE_OP(opname) offsetof(struct cl_page_operations, opname)
775 #define CL_PAGE_INVOKE(_env, _page, _op, _proto, ...) \
777 const struct lu_env *__env = (_env); \
778 struct cl_page *__page = (_page); \
779 const struct cl_page_slice *__scan; \
781 ptrdiff_t __op = (_op); \
782 int (*__method)_proto; \
785 __page = cl_page_top(__page); \
787 cfs_list_for_each_entry(__scan, &__page->cp_layers, \
789 __method = *(void **)((char *)__scan->cpl_ops + \
791 if (__method != NULL) { \
792 __result = (*__method)(__env, __scan, \
798 __page = __page->cp_child; \
799 } while (__page != NULL && __result == 0); \
805 #define CL_PAGE_INVOID(_env, _page, _op, _proto, ...) \
807 const struct lu_env *__env = (_env); \
808 struct cl_page *__page = (_page); \
809 const struct cl_page_slice *__scan; \
810 ptrdiff_t __op = (_op); \
811 void (*__method)_proto; \
813 __page = cl_page_top(__page); \
815 cfs_list_for_each_entry(__scan, &__page->cp_layers, \
817 __method = *(void **)((char *)__scan->cpl_ops + \
819 if (__method != NULL) \
820 (*__method)(__env, __scan, \
823 __page = __page->cp_child; \
824 } while (__page != NULL); \
827 #define CL_PAGE_INVOID_REVERSE(_env, _page, _op, _proto, ...) \
829 const struct lu_env *__env = (_env); \
830 struct cl_page *__page = (_page); \
831 const struct cl_page_slice *__scan; \
832 ptrdiff_t __op = (_op); \
833 void (*__method)_proto; \
835 /* get to the bottom page. */ \
836 while (__page->cp_child != NULL) \
837 __page = __page->cp_child; \
839 cfs_list_for_each_entry_reverse(__scan, &__page->cp_layers, \
841 __method = *(void **)((char *)__scan->cpl_ops + \
843 if (__method != NULL) \
844 (*__method)(__env, __scan, \
847 __page = __page->cp_parent; \
848 } while (__page != NULL); \
851 static int cl_page_invoke(const struct lu_env *env,
852 struct cl_io *io, struct cl_page *page, ptrdiff_t op)
855 PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj));
857 RETURN(CL_PAGE_INVOKE(env, page, op,
858 (const struct lu_env *,
859 const struct cl_page_slice *, struct cl_io *),
863 static void cl_page_invoid(const struct lu_env *env,
864 struct cl_io *io, struct cl_page *page, ptrdiff_t op)
867 PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj));
869 CL_PAGE_INVOID(env, page, op,
870 (const struct lu_env *,
871 const struct cl_page_slice *, struct cl_io *), io);
875 static void cl_page_owner_clear(struct cl_page *page)
878 for (page = cl_page_top(page); page != NULL; page = page->cp_child) {
879 if (page->cp_owner != NULL) {
880 LASSERT(page->cp_owner->ci_owned_nr > 0);
881 page->cp_owner->ci_owned_nr--;
882 page->cp_owner = NULL;
883 page->cp_task = NULL;
889 static void cl_page_owner_set(struct cl_page *page)
892 for (page = cl_page_top(page); page != NULL; page = page->cp_child) {
893 LASSERT(page->cp_owner != NULL);
894 page->cp_owner->ci_owned_nr++;
899 void cl_page_disown0(const struct lu_env *env,
900 struct cl_io *io, struct cl_page *pg)
902 enum cl_page_state state;
905 state = pg->cp_state;
906 PINVRNT(env, pg, state == CPS_OWNED || state == CPS_FREEING);
907 PINVRNT(env, pg, cl_page_invariant(pg));
908 cl_page_owner_clear(pg);
910 if (state == CPS_OWNED)
911 cl_page_state_set(env, pg, CPS_CACHED);
913 * Completion call-backs are executed in the bottom-up order, so that
914 * uppermost layer (llite), responsible for VFS/VM interaction runs
915 * last and can release locks safely.
917 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(cpo_disown),
918 (const struct lu_env *,
919 const struct cl_page_slice *, struct cl_io *),
925 * returns true, iff page is owned by the given io.
927 int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io)
929 LINVRNT(cl_object_same(pg->cp_obj, io->ci_obj));
931 RETURN(pg->cp_state == CPS_OWNED && pg->cp_owner == io);
933 EXPORT_SYMBOL(cl_page_is_owned);
936 * Try to own a page by IO.
938 * Waits until page is in cl_page_state::CPS_CACHED state, and then switch it
939 * into cl_page_state::CPS_OWNED state.
941 * \pre !cl_page_is_owned(pg, io)
942 * \post result == 0 iff cl_page_is_owned(pg, io)
946 * \retval -ve failure, e.g., page was destroyed (and landed in
947 * cl_page_state::CPS_FREEING instead of cl_page_state::CPS_CACHED).
948 * or, page was owned by another thread, or in IO.
950 * \see cl_page_disown()
951 * \see cl_page_operations::cpo_own()
952 * \see cl_page_own_try()
955 static int cl_page_own0(const struct lu_env *env, struct cl_io *io,
956 struct cl_page *pg, int nonblock)
960 PINVRNT(env, pg, !cl_page_is_owned(pg, io));
963 pg = cl_page_top(pg);
966 if (pg->cp_state == CPS_FREEING) {
969 result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(cpo_own),
970 (const struct lu_env *,
971 const struct cl_page_slice *,
972 struct cl_io *, int),
975 PASSERT(env, pg, pg->cp_owner == NULL);
976 PASSERT(env, pg, pg->cp_req == NULL);
978 pg->cp_task = current;
979 cl_page_owner_set(pg);
980 if (pg->cp_state != CPS_FREEING) {
981 cl_page_state_set(env, pg, CPS_OWNED);
983 cl_page_disown0(env, io, pg);
988 PINVRNT(env, pg, ergo(result == 0, cl_page_invariant(pg)));
993 * Own a page, might be blocked.
995 * \see cl_page_own0()
997 int cl_page_own(const struct lu_env *env, struct cl_io *io, struct cl_page *pg)
999 return cl_page_own0(env, io, pg, 0);
1001 EXPORT_SYMBOL(cl_page_own);
1004 * Nonblock version of cl_page_own().
1006 * \see cl_page_own0()
1008 int cl_page_own_try(const struct lu_env *env, struct cl_io *io,
1011 return cl_page_own0(env, io, pg, 1);
1013 EXPORT_SYMBOL(cl_page_own_try);
1017 * Assume page ownership.
1019 * Called when page is already locked by the hosting VM.
1021 * \pre !cl_page_is_owned(pg, io)
1022 * \post cl_page_is_owned(pg, io)
1024 * \see cl_page_operations::cpo_assume()
1026 void cl_page_assume(const struct lu_env *env,
1027 struct cl_io *io, struct cl_page *pg)
1029 PINVRNT(env, pg, cl_object_same(pg->cp_obj, io->ci_obj));
1032 pg = cl_page_top(pg);
1035 cl_page_invoid(env, io, pg, CL_PAGE_OP(cpo_assume));
1036 PASSERT(env, pg, pg->cp_owner == NULL);
1038 pg->cp_task = current;
1039 cl_page_owner_set(pg);
1040 cl_page_state_set(env, pg, CPS_OWNED);
1043 EXPORT_SYMBOL(cl_page_assume);
1046 * Releases page ownership without unlocking the page.
1048 * Moves page into cl_page_state::CPS_CACHED without releasing a lock on the
1049 * underlying VM page (as VM is supposed to do this itself).
1051 * \pre cl_page_is_owned(pg, io)
1052 * \post !cl_page_is_owned(pg, io)
1054 * \see cl_page_assume()
1056 void cl_page_unassume(const struct lu_env *env,
1057 struct cl_io *io, struct cl_page *pg)
1059 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1060 PINVRNT(env, pg, cl_page_invariant(pg));
1063 pg = cl_page_top(pg);
1065 cl_page_owner_clear(pg);
1066 cl_page_state_set(env, pg, CPS_CACHED);
1067 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(cpo_unassume),
1068 (const struct lu_env *,
1069 const struct cl_page_slice *, struct cl_io *),
1073 EXPORT_SYMBOL(cl_page_unassume);
1076 * Releases page ownership.
1078 * Moves page into cl_page_state::CPS_CACHED.
1080 * \pre cl_page_is_owned(pg, io)
1081 * \post !cl_page_is_owned(pg, io)
1083 * \see cl_page_own()
1084 * \see cl_page_operations::cpo_disown()
1086 void cl_page_disown(const struct lu_env *env,
1087 struct cl_io *io, struct cl_page *pg)
1089 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1092 pg = cl_page_top(pg);
1094 cl_page_disown0(env, io, pg);
1097 EXPORT_SYMBOL(cl_page_disown);
1100 * Called when page is to be removed from the object, e.g., as a result of
1103 * Calls cl_page_operations::cpo_discard() top-to-bottom.
1105 * \pre cl_page_is_owned(pg, io)
1107 * \see cl_page_operations::cpo_discard()
1109 void cl_page_discard(const struct lu_env *env,
1110 struct cl_io *io, struct cl_page *pg)
1112 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1113 PINVRNT(env, pg, cl_page_invariant(pg));
1115 cl_page_invoid(env, io, pg, CL_PAGE_OP(cpo_discard));
1117 EXPORT_SYMBOL(cl_page_discard);
1120 * Version of cl_page_delete() that can be called for not fully constructed
1121 * pages, e.g,. in a error handling cl_page_find()->cl_page_delete0()
1122 * path. Doesn't check page invariant.
1124 static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
1127 struct cl_page *tmp = pg;
1130 PASSERT(env, pg, pg == cl_page_top(pg));
1131 PASSERT(env, pg, pg->cp_state != CPS_FREEING);
1134 * Severe all ways to obtain new pointers to @pg.
1136 cl_page_owner_clear(pg);
1139 * unexport the page firstly before freeing it so that
1140 * the page content is considered to be invalid.
1141 * We have to do this because a CPS_FREEING cl_page may
1142 * be NOT under the protection of a cl_lock.
1143 * Afterwards, if this page is found by other threads, then this
1144 * page will be forced to reread.
1146 cl_page_export(env, pg, 0);
1147 cl_page_state_set0(env, pg, CPS_FREEING);
1149 if (tmp->cp_type == CPT_CACHEABLE) {
1151 /* !radix means that @pg is not yet in the radix tree,
1155 for (; tmp != NULL; tmp = tmp->cp_child) {
1157 struct cl_object_header *hdr;
1159 hdr = cl_object_header(tmp->cp_obj);
1160 spin_lock(&hdr->coh_page_guard);
1161 value = radix_tree_delete(&hdr->coh_tree,
1163 PASSERT(env, tmp, value == tmp);
1164 PASSERT(env, tmp, hdr->coh_pages > 0);
1166 spin_unlock(&hdr->coh_page_guard);
1170 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_delete),
1171 (const struct lu_env *, const struct cl_page_slice *));
1176 * Called when a decision is made to throw page out of memory.
1178 * Notifies all layers about page destruction by calling
1179 * cl_page_operations::cpo_delete() method top-to-bottom.
1181 * Moves page into cl_page_state::CPS_FREEING state (this is the only place
1182 * where transition to this state happens).
1184 * Eliminates all venues through which new references to the page can be
1187 * - removes page from the radix trees,
1189 * - breaks linkage from VM page to cl_page.
1191 * Once page reaches cl_page_state::CPS_FREEING, all remaining references will
1192 * drain after some time, at which point page will be recycled.
1194 * \pre pg == cl_page_top(pg)
1195 * \pre VM page is locked
1196 * \post pg->cp_state == CPS_FREEING
1198 * \see cl_page_operations::cpo_delete()
1200 void cl_page_delete(const struct lu_env *env, struct cl_page *pg)
1202 PINVRNT(env, pg, cl_page_invariant(pg));
1204 cl_page_delete0(env, pg, 1);
1207 EXPORT_SYMBOL(cl_page_delete);
1210 * Unmaps page from user virtual memory.
1212 * Calls cl_page_operations::cpo_unmap() through all layers top-to-bottom. The
1213 * layer responsible for VM interaction has to unmap page from user space
1216 * \see cl_page_operations::cpo_unmap()
1218 int cl_page_unmap(const struct lu_env *env,
1219 struct cl_io *io, struct cl_page *pg)
1221 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1222 PINVRNT(env, pg, cl_page_invariant(pg));
1224 return cl_page_invoke(env, io, pg, CL_PAGE_OP(cpo_unmap));
1226 EXPORT_SYMBOL(cl_page_unmap);
1229 * Marks page up-to-date.
1231 * Call cl_page_operations::cpo_export() through all layers top-to-bottom. The
1232 * layer responsible for VM interaction has to mark/clear page as up-to-date
1233 * by the \a uptodate argument.
1235 * \see cl_page_operations::cpo_export()
1237 void cl_page_export(const struct lu_env *env, struct cl_page *pg, int uptodate)
1239 PINVRNT(env, pg, cl_page_invariant(pg));
1240 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_export),
1241 (const struct lu_env *,
1242 const struct cl_page_slice *, int), uptodate);
1244 EXPORT_SYMBOL(cl_page_export);
1247 * Returns true, iff \a pg is VM locked in a suitable sense by the calling
1250 int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg)
1253 const struct cl_page_slice *slice;
1256 pg = cl_page_top_trusted((struct cl_page *)pg);
1257 slice = container_of(pg->cp_layers.next,
1258 const struct cl_page_slice, cpl_linkage);
1259 PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked != NULL);
1261 * Call ->cpo_is_vmlocked() directly instead of going through
1262 * CL_PAGE_INVOKE(), because cl_page_is_vmlocked() is used by
1263 * cl_page_invariant().
1265 result = slice->cpl_ops->cpo_is_vmlocked(env, slice);
1266 PASSERT(env, pg, result == -EBUSY || result == -ENODATA);
1267 RETURN(result == -EBUSY);
1269 EXPORT_SYMBOL(cl_page_is_vmlocked);
1271 static enum cl_page_state cl_req_type_state(enum cl_req_type crt)
1274 RETURN(crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN);
1277 static void cl_page_io_start(const struct lu_env *env,
1278 struct cl_page *pg, enum cl_req_type crt)
1281 * Page is queued for IO, change its state.
1284 cl_page_owner_clear(pg);
1285 cl_page_state_set(env, pg, cl_req_type_state(crt));
1290 * Prepares page for immediate transfer. cl_page_operations::cpo_prep() is
1291 * called top-to-bottom. Every layer either agrees to submit this page (by
1292 * returning 0), or requests to omit this page (by returning -EALREADY). Layer
1293 * handling interactions with the VM also has to inform VM that page is under
1296 int cl_page_prep(const struct lu_env *env, struct cl_io *io,
1297 struct cl_page *pg, enum cl_req_type crt)
1301 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1302 PINVRNT(env, pg, cl_page_invariant(pg));
1303 PINVRNT(env, pg, crt < CRT_NR);
1306 * XXX this has to be called bottom-to-top, so that llite can set up
1307 * PG_writeback without risking other layers deciding to skip this
1310 result = cl_page_invoke(env, io, pg, CL_PAGE_OP(io[crt].cpo_prep));
1312 cl_page_io_start(env, pg, crt);
1314 KLASSERT(ergo(crt == CRT_WRITE && pg->cp_type == CPT_CACHEABLE,
1316 PageWriteback(cl_page_vmpage(env, pg)))));
1317 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1320 EXPORT_SYMBOL(cl_page_prep);
1323 * Notify layers about transfer completion.
1325 * Invoked by transfer sub-system (which is a part of osc) to notify layers
1326 * that a transfer, of which this page is a part of has completed.
1328 * Completion call-backs are executed in the bottom-up order, so that
1329 * uppermost layer (llite), responsible for the VFS/VM interaction runs last
1330 * and can release locks safely.
1332 * \pre pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT
1333 * \post pg->cp_state == CPS_CACHED
1335 * \see cl_page_operations::cpo_completion()
1337 void cl_page_completion(const struct lu_env *env,
1338 struct cl_page *pg, enum cl_req_type crt, int ioret)
1340 struct cl_sync_io *anchor = pg->cp_sync_io;
1342 PASSERT(env, pg, crt < CRT_NR);
1343 /* cl_page::cp_req already cleared by the caller (osc_completion()) */
1344 PASSERT(env, pg, pg->cp_req == NULL);
1345 PASSERT(env, pg, pg->cp_state == cl_req_type_state(crt));
1348 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, ioret);
1349 if (crt == CRT_READ && ioret == 0) {
1350 PASSERT(env, pg, !(pg->cp_flags & CPF_READ_COMPLETED));
1351 pg->cp_flags |= CPF_READ_COMPLETED;
1354 cl_page_state_set(env, pg, CPS_CACHED);
1355 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(io[crt].cpo_completion),
1356 (const struct lu_env *,
1357 const struct cl_page_slice *, int), ioret);
1359 LASSERT(cl_page_is_vmlocked(env, pg));
1360 LASSERT(pg->cp_sync_io == anchor);
1361 pg->cp_sync_io = NULL;
1362 cl_sync_io_note(anchor, ioret);
1366 EXPORT_SYMBOL(cl_page_completion);
1369 * Notify layers that transfer formation engine decided to yank this page from
1370 * the cache and to make it a part of a transfer.
1372 * \pre pg->cp_state == CPS_CACHED
1373 * \post pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT
1375 * \see cl_page_operations::cpo_make_ready()
1377 int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg,
1378 enum cl_req_type crt)
1382 PINVRNT(env, pg, crt < CRT_NR);
1385 result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(io[crt].cpo_make_ready),
1386 (const struct lu_env *,
1387 const struct cl_page_slice *));
1389 PASSERT(env, pg, pg->cp_state == CPS_CACHED);
1390 cl_page_io_start(env, pg, crt);
1392 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1395 EXPORT_SYMBOL(cl_page_make_ready);
1398 * Notify layers that high level io decided to place this page into a cache
1399 * for future transfer.
1401 * The layer implementing transfer engine (osc) has to register this page in
1404 * \pre cl_page_is_owned(pg, io)
1405 * \post cl_page_is_owned(pg, io)
1407 * \see cl_page_operations::cpo_cache_add()
1409 int cl_page_cache_add(const struct lu_env *env, struct cl_io *io,
1410 struct cl_page *pg, enum cl_req_type crt)
1412 const struct cl_page_slice *scan;
1415 PINVRNT(env, pg, crt < CRT_NR);
1416 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1417 PINVRNT(env, pg, cl_page_invariant(pg));
1421 cfs_list_for_each_entry(scan, &pg->cp_layers, cpl_linkage) {
1422 if (scan->cpl_ops->io[crt].cpo_cache_add == NULL)
1425 result = scan->cpl_ops->io[crt].cpo_cache_add(env, scan, io);
1429 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1432 EXPORT_SYMBOL(cl_page_cache_add);
1435 * Called if a pge is being written back by kernel's intention.
1437 * \pre cl_page_is_owned(pg, io)
1438 * \post ergo(result == 0, pg->cp_state == CPS_PAGEOUT)
1440 * \see cl_page_operations::cpo_flush()
1442 int cl_page_flush(const struct lu_env *env, struct cl_io *io,
1447 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1448 PINVRNT(env, pg, cl_page_invariant(pg));
1452 result = cl_page_invoke(env, io, pg, CL_PAGE_OP(cpo_flush));
1454 CL_PAGE_HEADER(D_TRACE, env, pg, "%d\n", result);
1457 EXPORT_SYMBOL(cl_page_flush);
1460 * Checks whether page is protected by any extent lock is at least required
1463 * \return the same as in cl_page_operations::cpo_is_under_lock() method.
1464 * \see cl_page_operations::cpo_is_under_lock()
1466 int cl_page_is_under_lock(const struct lu_env *env, struct cl_io *io,
1467 struct cl_page *page)
1471 PINVRNT(env, page, cl_page_invariant(page));
1474 rc = CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_is_under_lock),
1475 (const struct lu_env *,
1476 const struct cl_page_slice *, struct cl_io *),
1478 PASSERT(env, page, rc != 0);
1481 EXPORT_SYMBOL(cl_page_is_under_lock);
1483 static int page_prune_cb(const struct lu_env *env, struct cl_io *io,
1484 struct cl_page *page, void *cbdata)
1486 cl_page_own(env, io, page);
1487 cl_page_unmap(env, io, page);
1488 cl_page_discard(env, io, page);
1489 cl_page_disown(env, io, page);
1490 return CLP_GANG_OKAY;
1494 * Purges all cached pages belonging to the object \a obj.
1496 int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj)
1498 struct cl_thread_info *info;
1499 struct cl_object *obj = cl_object_top(clobj);
1504 info = cl_env_info(env);
1508 * initialize the io. This is ugly since we never do IO in this
1509 * function, we just make cl_page_list functions happy. -jay
1512 io->ci_ignore_layout = 1;
1513 result = cl_io_init(env, io, CIT_MISC, obj);
1515 cl_io_fini(env, io);
1516 RETURN(io->ci_result);
1520 result = cl_page_gang_lookup(env, obj, io, 0, CL_PAGE_EOF,
1521 page_prune_cb, NULL);
1522 if (result == CLP_GANG_RESCHED)
1524 } while (result != CLP_GANG_OKAY);
1526 cl_io_fini(env, io);
1529 EXPORT_SYMBOL(cl_pages_prune);
1532 * Tells transfer engine that only part of a page is to be transmitted.
1534 * \see cl_page_operations::cpo_clip()
1536 void cl_page_clip(const struct lu_env *env, struct cl_page *pg,
1539 PINVRNT(env, pg, cl_page_invariant(pg));
1541 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", from, to);
1542 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_clip),
1543 (const struct lu_env *,
1544 const struct cl_page_slice *,int, int),
1547 EXPORT_SYMBOL(cl_page_clip);
1550 * Prints human readable representation of \a pg to the \a f.
1552 void cl_page_header_print(const struct lu_env *env, void *cookie,
1553 lu_printer_t printer, const struct cl_page *pg)
1555 (*printer)(env, cookie,
1556 "page@%p[%d %p:%lu ^%p_%p %d %d %d %p %p %#x]\n",
1557 pg, cfs_atomic_read(&pg->cp_ref), pg->cp_obj,
1558 pg->cp_index, pg->cp_parent, pg->cp_child,
1559 pg->cp_state, pg->cp_error, pg->cp_type,
1560 pg->cp_owner, pg->cp_req, pg->cp_flags);
1562 EXPORT_SYMBOL(cl_page_header_print);
1565 * Prints human readable representation of \a pg to the \a f.
1567 void cl_page_print(const struct lu_env *env, void *cookie,
1568 lu_printer_t printer, const struct cl_page *pg)
1570 struct cl_page *scan;
1572 for (scan = cl_page_top((struct cl_page *)pg);
1573 scan != NULL; scan = scan->cp_child)
1574 cl_page_header_print(env, cookie, printer, scan);
1575 CL_PAGE_INVOKE(env, (struct cl_page *)pg, CL_PAGE_OP(cpo_print),
1576 (const struct lu_env *env,
1577 const struct cl_page_slice *slice,
1578 void *cookie, lu_printer_t p), cookie, printer);
1579 (*printer)(env, cookie, "end page@%p\n", pg);
1581 EXPORT_SYMBOL(cl_page_print);
1584 * Cancel a page which is still in a transfer.
1586 int cl_page_cancel(const struct lu_env *env, struct cl_page *page)
1588 return CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_cancel),
1589 (const struct lu_env *,
1590 const struct cl_page_slice *));
1592 EXPORT_SYMBOL(cl_page_cancel);
1595 * Converts a byte offset within object \a obj into a page index.
1597 loff_t cl_offset(const struct cl_object *obj, pgoff_t idx)
1602 return (loff_t)idx << CFS_PAGE_SHIFT;
1604 EXPORT_SYMBOL(cl_offset);
1607 * Converts a page index into a byte offset within object \a obj.
1609 pgoff_t cl_index(const struct cl_object *obj, loff_t offset)
1614 return offset >> CFS_PAGE_SHIFT;
1616 EXPORT_SYMBOL(cl_index);
1618 int cl_page_size(const struct cl_object *obj)
1620 return 1 << CFS_PAGE_SHIFT;
1622 EXPORT_SYMBOL(cl_page_size);
1625 * Adds page slice to the compound page.
1627 * This is called by cl_object_operations::coo_page_init() methods to add a
1628 * per-layer state to the page. New state is added at the end of
1629 * cl_page::cp_layers list, that is, it is at the bottom of the stack.
1631 * \see cl_lock_slice_add(), cl_req_slice_add(), cl_io_slice_add()
1633 void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice,
1634 struct cl_object *obj,
1635 const struct cl_page_operations *ops)
1638 cfs_list_add_tail(&slice->cpl_linkage, &page->cp_layers);
1639 slice->cpl_obj = obj;
1640 slice->cpl_ops = ops;
1641 slice->cpl_page = page;
1644 EXPORT_SYMBOL(cl_page_slice_add);
1646 int cl_page_init(void)
1648 return lu_kmem_init(cl_page_caches);
1651 void cl_page_fini(void)
1653 lu_kmem_fini(cl_page_caches);