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 # define EXPORT_SYMTAB
46 #include <libcfs/libcfs.h>
47 #include <obd_class.h>
48 #include <obd_support.h>
49 #include <libcfs/list.h>
51 #include <cl_object.h>
52 #include "cl_internal.h"
54 static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
57 static cfs_mem_cache_t *cl_page_kmem = NULL;
59 static struct lu_kmem_descr cl_page_caches[] = {
61 .ckd_cache = &cl_page_kmem,
62 .ckd_name = "cl_page_kmem",
63 .ckd_size = sizeof (struct cl_page)
71 # define PASSERT(env, page, expr) \
73 if (unlikely(!(expr))) { \
74 CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
78 #else /* !LIBCFS_DEBUG */
79 # define PASSERT(env, page, exp) \
80 ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
81 #endif /* !LIBCFS_DEBUG */
83 #ifdef INVARIANT_CHECK
84 # define PINVRNT(env, page, expr) \
86 if (unlikely(!(expr))) { \
87 CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
91 #else /* !INVARIANT_CHECK */
92 # define PINVRNT(env, page, exp) \
93 ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
94 #endif /* !INVARIANT_CHECK */
97 * Internal version of cl_page_top, it should be called with page referenced,
98 * or coh_page_guard held.
100 static struct cl_page *cl_page_top_trusted(struct cl_page *page)
102 while (page->cp_parent != NULL)
103 page = page->cp_parent;
108 * Internal version of cl_page_get().
110 * This function can be used to obtain initial reference to previously
111 * unreferenced cached object. It can be called only if concurrent page
112 * reclamation is somehow prevented, e.g., by locking page radix-tree
113 * (cl_object_header::hdr->coh_page_guard), or by keeping a lock on a VM page,
114 * associated with \a page.
116 * Use with care! Not exported.
118 static void cl_page_get_trust(struct cl_page *page)
121 * Checkless version for trusted users.
123 if (cfs_atomic_inc_return(&page->cp_ref) == 1)
124 cfs_atomic_inc(&cl_object_site(page->cp_obj)->cs_pages.cs_busy);
128 * Returns a slice within a page, corresponding to the given layer in the
133 static const struct cl_page_slice *
134 cl_page_at_trusted(const struct cl_page *page,
135 const struct lu_device_type *dtype)
137 const struct cl_page_slice *slice;
139 #ifdef INVARIANT_CHECK
140 struct cl_object_header *ch = cl_object_header(page->cp_obj);
142 if (!cfs_atomic_read(&page->cp_ref))
143 LASSERT_SPIN_LOCKED(&ch->coh_page_guard);
147 page = cl_page_top_trusted((struct cl_page *)page);
149 cfs_list_for_each_entry(slice, &page->cp_layers, cpl_linkage) {
150 if (slice->cpl_obj->co_lu.lo_dev->ld_type == dtype)
153 page = page->cp_child;
154 } while (page != NULL);
159 * Returns a page with given index in the given object, or NULL if no page is
160 * found. Acquires a reference on \a page.
162 * Locking: called under cl_object_header::coh_page_guard spin-lock.
164 struct cl_page *cl_page_lookup(struct cl_object_header *hdr, pgoff_t index)
166 struct cl_page *page;
168 LASSERT_SPIN_LOCKED(&hdr->coh_page_guard);
170 page = radix_tree_lookup(&hdr->coh_tree, index);
172 cl_page_get_trust(page);
176 EXPORT_SYMBOL(cl_page_lookup);
179 * Returns a list of pages by a given [start, end] of \a obj.
181 * \param resched If not NULL, then we give up before hogging CPU for too
182 * long and set *resched = 1, in that case caller should implement a retry
185 * Gang tree lookup (radix_tree_gang_lookup()) optimization is absolutely
186 * crucial in the face of [offset, EOF] locks.
188 * Return at least one page in @queue unless there is no covered page.
190 int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj,
191 struct cl_io *io, pgoff_t start, pgoff_t end,
192 cl_page_gang_cb_t cb, void *cbdata)
194 struct cl_object_header *hdr;
195 struct cl_page *page;
196 struct cl_page **pvec;
197 const struct cl_page_slice *slice;
198 const struct lu_device_type *dtype;
203 int res = CLP_GANG_OKAY;
208 hdr = cl_object_header(obj);
209 pvec = cl_env_info(env)->clt_pvec;
210 dtype = cl_object_top(obj)->co_lu.lo_dev->ld_type;
211 cfs_spin_lock(&hdr->coh_page_guard);
212 while ((nr = radix_tree_gang_lookup(&hdr->coh_tree, (void **)pvec,
213 idx, CLT_PVEC_SIZE)) > 0) {
214 int end_of_region = 0;
215 idx = pvec[nr - 1]->cp_index + 1;
216 for (i = 0, j = 0; i < nr; ++i) {
220 LASSERT(page->cp_type == CPT_CACHEABLE);
221 if (page->cp_index > end) {
225 if (page->cp_state == CPS_FREEING)
228 slice = cl_page_at_trusted(page, dtype);
230 * Pages for lsm-less file has no underneath sub-page
231 * for osc, in case of ...
233 PASSERT(env, page, slice != NULL);
235 page = slice->cpl_page;
237 * Can safely call cl_page_get_trust() under
238 * radix-tree spin-lock.
240 * XXX not true, because @page is from object another
241 * than @hdr and protected by different tree lock.
243 cl_page_get_trust(page);
244 lu_ref_add_atomic(&page->cp_reference,
245 "gang_lookup", cfs_current());
250 * Here a delicate locking dance is performed. Current thread
251 * holds a reference to a page, but has to own it before it
252 * can be placed into queue. Owning implies waiting, so
253 * radix-tree lock is to be released. After a wait one has to
254 * check that pages weren't truncated (cl_page_own() returns
255 * error in the latter case).
257 cfs_spin_unlock(&hdr->coh_page_guard);
260 for (i = 0; i < j; ++i) {
262 if (res == CLP_GANG_OKAY)
263 res = (*cb)(env, io, page, cbdata);
264 lu_ref_del(&page->cp_reference,
265 "gang_lookup", cfs_current());
266 cl_page_put(env, page);
268 if (nr < CLT_PVEC_SIZE || end_of_region)
271 if (res == CLP_GANG_OKAY && cfs_need_resched())
272 res = CLP_GANG_RESCHED;
273 if (res != CLP_GANG_OKAY)
276 cfs_spin_lock(&hdr->coh_page_guard);
280 cfs_spin_unlock(&hdr->coh_page_guard);
283 EXPORT_SYMBOL(cl_page_gang_lookup);
285 static void cl_page_free(const struct lu_env *env, struct cl_page *page)
287 struct cl_object *obj = page->cp_obj;
288 struct cl_site *site = cl_object_site(obj);
290 PASSERT(env, page, cfs_list_empty(&page->cp_batch));
291 PASSERT(env, page, page->cp_owner == NULL);
292 PASSERT(env, page, page->cp_req == NULL);
293 PASSERT(env, page, page->cp_parent == NULL);
294 PASSERT(env, page, page->cp_state == CPS_FREEING);
298 while (!cfs_list_empty(&page->cp_layers)) {
299 struct cl_page_slice *slice;
301 slice = cfs_list_entry(page->cp_layers.next,
302 struct cl_page_slice, cpl_linkage);
303 cfs_list_del_init(page->cp_layers.next);
304 slice->cpl_ops->cpo_fini(env, slice);
306 cfs_atomic_dec(&site->cs_pages.cs_total);
308 #ifdef LUSTRE_PAGESTATE_TRACKING
309 cfs_atomic_dec(&site->cs_pages_state[page->cp_state]);
311 lu_object_ref_del_at(&obj->co_lu, page->cp_obj_ref, "cl_page", page);
312 cl_object_put(env, obj);
313 lu_ref_fini(&page->cp_reference);
314 OBD_SLAB_FREE_PTR(page, cl_page_kmem);
319 * Helper function updating page state. This is the only place in the code
320 * where cl_page::cp_state field is mutated.
322 static inline void cl_page_state_set_trust(struct cl_page *page,
323 enum cl_page_state state)
326 *(enum cl_page_state *)&page->cp_state = state;
329 static int cl_page_alloc(const struct lu_env *env, struct cl_object *o,
330 pgoff_t ind, struct page *vmpage,
331 enum cl_page_type type, struct cl_page **out)
333 struct cl_page *page;
334 struct cl_page *err = NULL;
335 struct lu_object_header *head;
336 struct cl_site *site = cl_object_site(o);
341 OBD_SLAB_ALLOC_PTR_GFP(page, cl_page_kmem, CFS_ALLOC_IO);
343 cfs_atomic_set(&page->cp_ref, 1);
346 page->cp_obj_ref = lu_object_ref_add(&o->co_lu,
348 page->cp_index = ind;
349 cl_page_state_set_trust(page, CPS_CACHED);
350 page->cp_type = type;
351 CFS_INIT_LIST_HEAD(&page->cp_layers);
352 CFS_INIT_LIST_HEAD(&page->cp_batch);
353 CFS_INIT_LIST_HEAD(&page->cp_flight);
354 cfs_mutex_init(&page->cp_mutex);
355 lu_ref_init(&page->cp_reference);
356 head = o->co_lu.lo_header;
357 cfs_list_for_each_entry(o, &head->loh_layers,
359 if (o->co_ops->coo_page_init != NULL) {
360 err = o->co_ops->coo_page_init(env, o,
363 cl_page_delete0(env, page, 0);
364 cl_page_free(env, page);
371 cfs_atomic_inc(&site->cs_pages.cs_busy);
372 cfs_atomic_inc(&site->cs_pages.cs_total);
374 #ifdef LUSTRE_PAGESTATE_TRACKING
375 cfs_atomic_inc(&site->cs_pages_state[CPS_CACHED]);
377 cfs_atomic_inc(&site->cs_pages.cs_created);
381 page = ERR_PTR(-ENOMEM);
387 * Returns a cl_page with index \a idx at the object \a o, and associated with
388 * the VM page \a vmpage.
390 * This is the main entry point into the cl_page caching interface. First, a
391 * cache (implemented as a per-object radix tree) is consulted. If page is
392 * found there, it is returned immediately. Otherwise new page is allocated
393 * and returned. In any case, additional reference to page is acquired.
395 * \see cl_object_find(), cl_lock_find()
397 static struct cl_page *cl_page_find0(const struct lu_env *env,
399 pgoff_t idx, struct page *vmpage,
400 enum cl_page_type type,
401 struct cl_page *parent)
403 struct cl_page *page = NULL;
404 struct cl_page *ghost = NULL;
405 struct cl_object_header *hdr;
406 struct cl_site *site = cl_object_site(o);
409 LASSERT(type == CPT_CACHEABLE || type == CPT_TRANSIENT);
414 hdr = cl_object_header(o);
415 cfs_atomic_inc(&site->cs_pages.cs_lookup);
417 CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n",
418 idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type);
420 if (type == CPT_CACHEABLE) {
422 * cl_vmpage_page() can be called here without any locks as
424 * - "vmpage" is locked (which prevents ->private from
425 * concurrent updates), and
427 * - "o" cannot be destroyed while current thread holds a
430 page = cl_vmpage_page(vmpage, o);
433 cl_page_vmpage(env, page) == vmpage &&
434 (void *)radix_tree_lookup(&hdr->coh_tree,
439 cfs_atomic_inc(&site->cs_pages.cs_hit);
443 /* allocate and initialize cl_page */
444 err = cl_page_alloc(env, o, idx, vmpage, type, &page);
448 if (type == CPT_TRANSIENT) {
450 LASSERT(page->cp_parent == NULL);
451 page->cp_parent = parent;
452 parent->cp_child = page;
458 * XXX optimization: use radix_tree_preload() here, and change tree
459 * gfp mask to GFP_KERNEL in cl_object_header_init().
461 cfs_spin_lock(&hdr->coh_page_guard);
462 err = radix_tree_insert(&hdr->coh_tree, idx, page);
466 * Noted by Jay: a lock on \a vmpage protects cl_page_find()
467 * from this race, but
469 * 0. it's better to have cl_page interface "locally
470 * consistent" so that its correctness can be reasoned
471 * about without appealing to the (obscure world of) VM
474 * 1. handling this race allows ->coh_tree to remain
475 * consistent even when VM locking is somehow busted,
476 * which is very useful during diagnosing and debugging.
479 CL_PAGE_DEBUG(D_ERROR, env, ghost,
480 "fail to insert into radix tree: %d\n", err);
483 LASSERT(page->cp_parent == NULL);
484 page->cp_parent = parent;
485 parent->cp_child = page;
489 cfs_spin_unlock(&hdr->coh_page_guard);
491 if (unlikely(ghost != NULL)) {
492 cfs_atomic_dec(&site->cs_pages.cs_busy);
493 cl_page_delete0(env, ghost, 0);
494 cl_page_free(env, ghost);
499 struct cl_page *cl_page_find(const struct lu_env *env, struct cl_object *o,
500 pgoff_t idx, struct page *vmpage,
501 enum cl_page_type type)
503 return cl_page_find0(env, o, idx, vmpage, type, NULL);
505 EXPORT_SYMBOL(cl_page_find);
508 struct cl_page *cl_page_find_sub(const struct lu_env *env, struct cl_object *o,
509 pgoff_t idx, struct page *vmpage,
510 struct cl_page *parent)
512 return cl_page_find0(env, o, idx, vmpage, parent->cp_type, parent);
514 EXPORT_SYMBOL(cl_page_find_sub);
516 static inline int cl_page_invariant(const struct cl_page *pg)
518 struct cl_object_header *header;
519 struct cl_page *parent;
520 struct cl_page *child;
524 * Page invariant is protected by a VM lock.
526 LINVRNT(cl_page_is_vmlocked(NULL, pg));
528 header = cl_object_header(pg->cp_obj);
529 parent = pg->cp_parent;
530 child = pg->cp_child;
531 owner = pg->cp_owner;
533 return cfs_atomic_read(&pg->cp_ref) > 0 &&
534 ergo(parent != NULL, parent->cp_child == pg) &&
535 ergo(child != NULL, child->cp_parent == pg) &&
536 ergo(child != NULL, pg->cp_obj != child->cp_obj) &&
537 ergo(parent != NULL, pg->cp_obj != parent->cp_obj) &&
538 ergo(owner != NULL && parent != NULL,
539 parent->cp_owner == pg->cp_owner->ci_parent) &&
540 ergo(owner != NULL && child != NULL,
541 child->cp_owner->ci_parent == owner) &&
543 * Either page is early in initialization (has neither child
544 * nor parent yet), or it is in the object radix tree.
546 ergo(pg->cp_state < CPS_FREEING && pg->cp_type == CPT_CACHEABLE,
547 (void *)radix_tree_lookup(&header->coh_tree,
548 pg->cp_index) == pg ||
549 (child == NULL && parent == NULL));
552 static void cl_page_state_set0(const struct lu_env *env,
553 struct cl_page *page, enum cl_page_state state)
555 enum cl_page_state old;
556 #ifdef LUSTRE_PAGESTATE_TRACKING
557 struct cl_site *site = cl_object_site(page->cp_obj);
561 * Matrix of allowed state transitions [old][new], for sanity
564 static const int allowed_transitions[CPS_NR][CPS_NR] = {
567 [CPS_OWNED] = 1, /* io finds existing cached page */
569 [CPS_PAGEOUT] = 1, /* write-out from the cache */
570 [CPS_FREEING] = 1, /* eviction on the memory pressure */
573 [CPS_CACHED] = 1, /* release to the cache */
575 [CPS_PAGEIN] = 1, /* start read immediately */
576 [CPS_PAGEOUT] = 1, /* start write immediately */
577 [CPS_FREEING] = 1, /* lock invalidation or truncate */
580 [CPS_CACHED] = 1, /* io completion */
587 [CPS_CACHED] = 1, /* io completion */
603 old = page->cp_state;
604 PASSERT(env, page, allowed_transitions[old][state]);
605 CL_PAGE_HEADER(D_TRACE, env, page, "%d -> %d\n", old, state);
606 for (; page != NULL; page = page->cp_child) {
607 PASSERT(env, page, page->cp_state == old);
609 equi(state == CPS_OWNED, page->cp_owner != NULL));
611 #ifdef LUSTRE_PAGESTATE_TRACKING
612 cfs_atomic_dec(&site->cs_pages_state[page->cp_state]);
613 cfs_atomic_inc(&site->cs_pages_state[state]);
615 cl_page_state_set_trust(page, state);
620 static void cl_page_state_set(const struct lu_env *env,
621 struct cl_page *page, enum cl_page_state state)
623 cl_page_state_set0(env, page, state);
627 * Acquires an additional reference to a page.
629 * This can be called only by caller already possessing a reference to \a
632 * \see cl_object_get(), cl_lock_get().
634 void cl_page_get(struct cl_page *page)
637 LASSERT(page->cp_state != CPS_FREEING);
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_object_header *hdr;
655 struct cl_site *site = cl_object_site(page->cp_obj);
657 PASSERT(env, page, cfs_atomic_read(&page->cp_ref) > !!page->cp_parent);
660 CL_PAGE_HEADER(D_TRACE, env, page, "%d\n",
661 cfs_atomic_read(&page->cp_ref));
663 hdr = cl_object_header(cl_object_top(page->cp_obj));
664 if (cfs_atomic_dec_and_lock(&page->cp_ref, &hdr->coh_page_guard)) {
665 cfs_atomic_dec(&site->cs_pages.cs_busy);
666 /* We're going to access the page w/o a reference, but it's
667 * ok because we have grabbed the lock coh_page_guard, which
668 * means nobody is able to free this page behind us.
670 if (page->cp_state == CPS_FREEING) {
671 /* We drop the page reference and check the page state
672 * inside the coh_page_guard. So that if it gets here,
673 * it is the REALLY last reference to this page.
675 cfs_spin_unlock(&hdr->coh_page_guard);
677 LASSERT(cfs_atomic_read(&page->cp_ref) == 0);
678 PASSERT(env, page, page->cp_owner == NULL);
679 PASSERT(env, page, cfs_list_empty(&page->cp_batch));
681 * Page is no longer reachable by other threads. Tear
684 cl_page_free(env, page);
689 cfs_spin_unlock(&hdr->coh_page_guard);
694 EXPORT_SYMBOL(cl_page_put);
697 * Returns a VM page associated with a given cl_page.
699 cfs_page_t *cl_page_vmpage(const struct lu_env *env, struct cl_page *page)
701 const struct cl_page_slice *slice;
704 * Find uppermost layer with ->cpo_vmpage() method, and return its
707 page = cl_page_top(page);
709 cfs_list_for_each_entry(slice, &page->cp_layers, cpl_linkage) {
710 if (slice->cpl_ops->cpo_vmpage != NULL)
711 RETURN(slice->cpl_ops->cpo_vmpage(env, slice));
713 page = page->cp_child;
714 } while (page != NULL);
715 LBUG(); /* ->cpo_vmpage() has to be defined somewhere in the stack */
717 EXPORT_SYMBOL(cl_page_vmpage);
720 * Returns a cl_page associated with a VM page, and given cl_object.
722 struct cl_page *cl_vmpage_page(cfs_page_t *vmpage, struct cl_object *obj)
724 struct cl_page *page;
725 struct cl_object_header *hdr;
728 KLASSERT(PageLocked(vmpage));
731 * NOTE: absence of races and liveness of data are guaranteed by page
732 * lock on a "vmpage". That works because object destruction has
733 * bottom-to-top pass.
737 * This loop assumes that ->private points to the top-most page. This
738 * can be rectified easily.
740 hdr = cl_object_header(cl_object_top(obj));
741 cfs_spin_lock(&hdr->coh_page_guard);
742 for (page = (void *)vmpage->private;
743 page != NULL; page = page->cp_child) {
744 if (cl_object_same(page->cp_obj, obj)) {
745 cl_page_get_trust(page);
749 cfs_spin_unlock(&hdr->coh_page_guard);
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 PASSERT(env, pg, pg->cp_owner == NULL);
1030 PINVRNT(env, pg, cl_object_same(pg->cp_obj, io->ci_obj));
1031 PINVRNT(env, pg, cl_page_invariant(pg));
1034 pg = cl_page_top(pg);
1037 cl_page_invoid(env, io, pg, CL_PAGE_OP(cpo_assume));
1039 pg->cp_task = current;
1040 cl_page_owner_set(pg);
1041 cl_page_state_set(env, pg, CPS_OWNED);
1044 EXPORT_SYMBOL(cl_page_assume);
1047 * Releases page ownership without unlocking the page.
1049 * Moves page into cl_page_state::CPS_CACHED without releasing a lock on the
1050 * underlying VM page (as VM is supposed to do this itself).
1052 * \pre cl_page_is_owned(pg, io)
1053 * \post !cl_page_is_owned(pg, io)
1055 * \see cl_page_assume()
1057 void cl_page_unassume(const struct lu_env *env,
1058 struct cl_io *io, struct cl_page *pg)
1060 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1061 PINVRNT(env, pg, cl_page_invariant(pg));
1064 pg = cl_page_top(pg);
1066 cl_page_owner_clear(pg);
1067 cl_page_state_set(env, pg, CPS_CACHED);
1068 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(cpo_unassume),
1069 (const struct lu_env *,
1070 const struct cl_page_slice *, struct cl_io *),
1074 EXPORT_SYMBOL(cl_page_unassume);
1077 * Releases page ownership.
1079 * Moves page into cl_page_state::CPS_CACHED.
1081 * \pre cl_page_is_owned(pg, io)
1082 * \post !cl_page_is_owned(pg, io)
1084 * \see cl_page_own()
1085 * \see cl_page_operations::cpo_disown()
1087 void cl_page_disown(const struct lu_env *env,
1088 struct cl_io *io, struct cl_page *pg)
1090 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1093 pg = cl_page_top(pg);
1095 cl_page_disown0(env, io, pg);
1098 EXPORT_SYMBOL(cl_page_disown);
1101 * Called when page is to be removed from the object, e.g., as a result of
1104 * Calls cl_page_operations::cpo_discard() top-to-bottom.
1106 * \pre cl_page_is_owned(pg, io)
1108 * \see cl_page_operations::cpo_discard()
1110 void cl_page_discard(const struct lu_env *env,
1111 struct cl_io *io, struct cl_page *pg)
1113 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1114 PINVRNT(env, pg, cl_page_invariant(pg));
1116 cl_page_invoid(env, io, pg, CL_PAGE_OP(cpo_discard));
1118 EXPORT_SYMBOL(cl_page_discard);
1121 * Version of cl_page_delete() that can be called for not fully constructed
1122 * pages, e.g,. in a error handling cl_page_find()->cl_page_delete0()
1123 * path. Doesn't check page invariant.
1125 static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
1128 struct cl_page *tmp = pg;
1131 PASSERT(env, pg, pg == cl_page_top(pg));
1132 PASSERT(env, pg, pg->cp_state != CPS_FREEING);
1135 * Severe all ways to obtain new pointers to @pg.
1137 cl_page_owner_clear(pg);
1140 * unexport the page firstly before freeing it so that
1141 * the page content is considered to be invalid.
1142 * We have to do this because a CPS_FREEING cl_page may
1143 * be NOT under the protection of a cl_lock.
1144 * Afterwards, if this page is found by other threads, then this
1145 * page will be forced to reread.
1147 cl_page_export(env, pg, 0);
1148 cl_page_state_set0(env, pg, CPS_FREEING);
1150 if (tmp->cp_type == CPT_CACHEABLE) {
1152 /* !radix means that @pg is not yet in the radix tree,
1156 for (; tmp != NULL; tmp = tmp->cp_child) {
1158 struct cl_object_header *hdr;
1160 hdr = cl_object_header(tmp->cp_obj);
1161 cfs_spin_lock(&hdr->coh_page_guard);
1162 value = radix_tree_delete(&hdr->coh_tree,
1164 PASSERT(env, tmp, value == tmp);
1165 PASSERT(env, tmp, hdr->coh_pages > 0);
1167 cfs_spin_unlock(&hdr->coh_page_guard);
1171 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_delete),
1172 (const struct lu_env *, const struct cl_page_slice *));
1177 * Called when a decision is made to throw page out of memory.
1179 * Notifies all layers about page destruction by calling
1180 * cl_page_operations::cpo_delete() method top-to-bottom.
1182 * Moves page into cl_page_state::CPS_FREEING state (this is the only place
1183 * where transition to this state happens).
1185 * Eliminates all venues through which new references to the page can be
1188 * - removes page from the radix trees,
1190 * - breaks linkage from VM page to cl_page.
1192 * Once page reaches cl_page_state::CPS_FREEING, all remaining references will
1193 * drain after some time, at which point page will be recycled.
1195 * \pre pg == cl_page_top(pg)
1196 * \pre VM page is locked
1197 * \post pg->cp_state == CPS_FREEING
1199 * \see cl_page_operations::cpo_delete()
1201 void cl_page_delete(const struct lu_env *env, struct cl_page *pg)
1203 PINVRNT(env, pg, cl_page_invariant(pg));
1205 cl_page_delete0(env, pg, 1);
1208 EXPORT_SYMBOL(cl_page_delete);
1211 * Unmaps page from user virtual memory.
1213 * Calls cl_page_operations::cpo_unmap() through all layers top-to-bottom. The
1214 * layer responsible for VM interaction has to unmap page from user space
1217 * \see cl_page_operations::cpo_unmap()
1219 int cl_page_unmap(const struct lu_env *env,
1220 struct cl_io *io, struct cl_page *pg)
1222 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1223 PINVRNT(env, pg, cl_page_invariant(pg));
1225 return cl_page_invoke(env, io, pg, CL_PAGE_OP(cpo_unmap));
1227 EXPORT_SYMBOL(cl_page_unmap);
1230 * Marks page up-to-date.
1232 * Call cl_page_operations::cpo_export() through all layers top-to-bottom. The
1233 * layer responsible for VM interaction has to mark/clear page as up-to-date
1234 * by the \a uptodate argument.
1236 * \see cl_page_operations::cpo_export()
1238 void cl_page_export(const struct lu_env *env, struct cl_page *pg, int uptodate)
1240 PINVRNT(env, pg, cl_page_invariant(pg));
1241 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_export),
1242 (const struct lu_env *,
1243 const struct cl_page_slice *, int), uptodate);
1245 EXPORT_SYMBOL(cl_page_export);
1248 * Returns true, iff \a pg is VM locked in a suitable sense by the calling
1251 int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg)
1254 const struct cl_page_slice *slice;
1257 pg = cl_page_top_trusted((struct cl_page *)pg);
1258 slice = container_of(pg->cp_layers.next,
1259 const struct cl_page_slice, cpl_linkage);
1260 PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked != NULL);
1262 * Call ->cpo_is_vmlocked() directly instead of going through
1263 * CL_PAGE_INVOKE(), because cl_page_is_vmlocked() is used by
1264 * cl_page_invariant().
1266 result = slice->cpl_ops->cpo_is_vmlocked(env, slice);
1267 PASSERT(env, pg, result == -EBUSY || result == -ENODATA);
1268 RETURN(result == -EBUSY);
1270 EXPORT_SYMBOL(cl_page_is_vmlocked);
1272 static enum cl_page_state cl_req_type_state(enum cl_req_type crt)
1275 RETURN(crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN);
1278 static void cl_page_io_start(const struct lu_env *env,
1279 struct cl_page *pg, enum cl_req_type crt)
1282 * Page is queued for IO, change its state.
1285 cl_page_owner_clear(pg);
1286 cl_page_state_set(env, pg, cl_req_type_state(crt));
1291 * Prepares page for immediate transfer. cl_page_operations::cpo_prep() is
1292 * called top-to-bottom. Every layer either agrees to submit this page (by
1293 * returning 0), or requests to omit this page (by returning -EALREADY). Layer
1294 * handling interactions with the VM also has to inform VM that page is under
1297 int cl_page_prep(const struct lu_env *env, struct cl_io *io,
1298 struct cl_page *pg, enum cl_req_type crt)
1302 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1303 PINVRNT(env, pg, cl_page_invariant(pg));
1304 PINVRNT(env, pg, crt < CRT_NR);
1307 * XXX this has to be called bottom-to-top, so that llite can set up
1308 * PG_writeback without risking other layers deciding to skip this
1311 result = cl_page_invoke(env, io, pg, CL_PAGE_OP(io[crt].cpo_prep));
1313 cl_page_io_start(env, pg, crt);
1315 KLASSERT(ergo(crt == CRT_WRITE && pg->cp_type == CPT_CACHEABLE,
1317 PageWriteback(cl_page_vmpage(env, pg)))));
1318 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1321 EXPORT_SYMBOL(cl_page_prep);
1324 * Notify layers about transfer completion.
1326 * Invoked by transfer sub-system (which is a part of osc) to notify layers
1327 * that a transfer, of which this page is a part of has completed.
1329 * Completion call-backs are executed in the bottom-up order, so that
1330 * uppermost layer (llite), responsible for the VFS/VM interaction runs last
1331 * and can release locks safely.
1333 * \pre pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT
1334 * \post pg->cp_state == CPS_CACHED
1336 * \see cl_page_operations::cpo_completion()
1338 void cl_page_completion(const struct lu_env *env,
1339 struct cl_page *pg, enum cl_req_type crt, int ioret)
1341 struct cl_sync_io *anchor = pg->cp_sync_io;
1343 PASSERT(env, pg, crt < CRT_NR);
1344 /* cl_page::cp_req already cleared by the caller (osc_completion()) */
1345 PASSERT(env, pg, pg->cp_req == NULL);
1346 PASSERT(env, pg, pg->cp_state == cl_req_type_state(crt));
1349 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, ioret);
1350 if (crt == CRT_READ && ioret == 0) {
1351 PASSERT(env, pg, !(pg->cp_flags & CPF_READ_COMPLETED));
1352 pg->cp_flags |= CPF_READ_COMPLETED;
1355 cl_page_state_set(env, pg, CPS_CACHED);
1356 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(io[crt].cpo_completion),
1357 (const struct lu_env *,
1358 const struct cl_page_slice *, int), ioret);
1360 LASSERT(cl_page_is_vmlocked(env, pg));
1361 LASSERT(pg->cp_sync_io == anchor);
1362 pg->cp_sync_io = NULL;
1363 cl_sync_io_note(anchor, ioret);
1366 /* Don't assert the page writeback bit here because the lustre file
1367 * may be as a backend of swap space. in this case, the page writeback
1368 * is set by VM, and obvious we shouldn't clear it at all. Fortunately
1369 * this type of pages are all TRANSIENT pages. */
1370 KLASSERT(ergo(pg->cp_type == CPT_CACHEABLE,
1371 !PageWriteback(cl_page_vmpage(env, pg))));
1374 EXPORT_SYMBOL(cl_page_completion);
1377 * Notify layers that transfer formation engine decided to yank this page from
1378 * the cache and to make it a part of a transfer.
1380 * \pre pg->cp_state == CPS_CACHED
1381 * \post pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT
1383 * \see cl_page_operations::cpo_make_ready()
1385 int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg,
1386 enum cl_req_type crt)
1390 PINVRNT(env, pg, crt < CRT_NR);
1393 result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(io[crt].cpo_make_ready),
1394 (const struct lu_env *,
1395 const struct cl_page_slice *));
1397 PASSERT(env, pg, pg->cp_state == CPS_CACHED);
1398 cl_page_io_start(env, pg, crt);
1400 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1403 EXPORT_SYMBOL(cl_page_make_ready);
1406 * Notify layers that high level io decided to place this page into a cache
1407 * for future transfer.
1409 * The layer implementing transfer engine (osc) has to register this page in
1412 * \pre cl_page_is_owned(pg, io)
1413 * \post ergo(result == 0,
1414 * pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT)
1416 * \see cl_page_operations::cpo_cache_add()
1418 int cl_page_cache_add(const struct lu_env *env, struct cl_io *io,
1419 struct cl_page *pg, enum cl_req_type crt)
1423 PINVRNT(env, pg, crt < CRT_NR);
1424 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1425 PINVRNT(env, pg, cl_page_invariant(pg));
1428 result = cl_page_invoke(env, io, pg, CL_PAGE_OP(io[crt].cpo_cache_add));
1430 cl_page_owner_clear(pg);
1431 cl_page_state_set(env, pg, CPS_CACHED);
1433 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1436 EXPORT_SYMBOL(cl_page_cache_add);
1439 * Checks whether page is protected by any extent lock is at least required
1442 * \return the same as in cl_page_operations::cpo_is_under_lock() method.
1443 * \see cl_page_operations::cpo_is_under_lock()
1445 int cl_page_is_under_lock(const struct lu_env *env, struct cl_io *io,
1446 struct cl_page *page)
1450 PINVRNT(env, page, cl_page_invariant(page));
1453 rc = CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_is_under_lock),
1454 (const struct lu_env *,
1455 const struct cl_page_slice *, struct cl_io *),
1457 PASSERT(env, page, rc != 0);
1460 EXPORT_SYMBOL(cl_page_is_under_lock);
1462 static int page_prune_cb(const struct lu_env *env, struct cl_io *io,
1463 struct cl_page *page, void *cbdata)
1465 cl_page_own(env, io, page);
1466 cl_page_unmap(env, io, page);
1467 cl_page_discard(env, io, page);
1468 cl_page_disown(env, io, page);
1469 return CLP_GANG_OKAY;
1473 * Purges all cached pages belonging to the object \a obj.
1475 int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj)
1477 struct cl_thread_info *info;
1478 struct cl_object *obj = cl_object_top(clobj);
1483 info = cl_env_info(env);
1487 * initialize the io. This is ugly since we never do IO in this
1488 * function, we just make cl_page_list functions happy. -jay
1491 result = cl_io_init(env, io, CIT_MISC, obj);
1493 cl_io_fini(env, io);
1494 RETURN(io->ci_result);
1498 result = cl_page_gang_lookup(env, obj, io, 0, CL_PAGE_EOF,
1499 page_prune_cb, NULL);
1500 if (result == CLP_GANG_RESCHED)
1502 } while (result != CLP_GANG_OKAY);
1504 cl_io_fini(env, io);
1507 EXPORT_SYMBOL(cl_pages_prune);
1510 * Tells transfer engine that only part of a page is to be transmitted.
1512 * \see cl_page_operations::cpo_clip()
1514 void cl_page_clip(const struct lu_env *env, struct cl_page *pg,
1517 PINVRNT(env, pg, cl_page_invariant(pg));
1519 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", from, to);
1520 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_clip),
1521 (const struct lu_env *,
1522 const struct cl_page_slice *,int, int),
1525 EXPORT_SYMBOL(cl_page_clip);
1528 * Prints human readable representation of \a pg to the \a f.
1530 void cl_page_header_print(const struct lu_env *env, void *cookie,
1531 lu_printer_t printer, const struct cl_page *pg)
1533 (*printer)(env, cookie,
1534 "page@%p[%d %p:%lu ^%p_%p %d %d %d %p %p %#x]\n",
1535 pg, cfs_atomic_read(&pg->cp_ref), pg->cp_obj,
1536 pg->cp_index, pg->cp_parent, pg->cp_child,
1537 pg->cp_state, pg->cp_error, pg->cp_type,
1538 pg->cp_owner, pg->cp_req, pg->cp_flags);
1540 EXPORT_SYMBOL(cl_page_header_print);
1543 * Prints human readable representation of \a pg to the \a f.
1545 void cl_page_print(const struct lu_env *env, void *cookie,
1546 lu_printer_t printer, const struct cl_page *pg)
1548 struct cl_page *scan;
1550 for (scan = cl_page_top((struct cl_page *)pg);
1551 scan != NULL; scan = scan->cp_child)
1552 cl_page_header_print(env, cookie, printer, scan);
1553 CL_PAGE_INVOKE(env, (struct cl_page *)pg, CL_PAGE_OP(cpo_print),
1554 (const struct lu_env *env,
1555 const struct cl_page_slice *slice,
1556 void *cookie, lu_printer_t p), cookie, printer);
1557 (*printer)(env, cookie, "end page@%p\n", pg);
1559 EXPORT_SYMBOL(cl_page_print);
1562 * Cancel a page which is still in a transfer.
1564 int cl_page_cancel(const struct lu_env *env, struct cl_page *page)
1566 return CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_cancel),
1567 (const struct lu_env *,
1568 const struct cl_page_slice *));
1570 EXPORT_SYMBOL(cl_page_cancel);
1573 * Converts a byte offset within object \a obj into a page index.
1575 loff_t cl_offset(const struct cl_object *obj, pgoff_t idx)
1580 return (loff_t)idx << CFS_PAGE_SHIFT;
1582 EXPORT_SYMBOL(cl_offset);
1585 * Converts a page index into a byte offset within object \a obj.
1587 pgoff_t cl_index(const struct cl_object *obj, loff_t offset)
1592 return offset >> CFS_PAGE_SHIFT;
1594 EXPORT_SYMBOL(cl_index);
1596 int cl_page_size(const struct cl_object *obj)
1598 return 1 << CFS_PAGE_SHIFT;
1600 EXPORT_SYMBOL(cl_page_size);
1603 * Adds page slice to the compound page.
1605 * This is called by cl_object_operations::coo_page_init() methods to add a
1606 * per-layer state to the page. New state is added at the end of
1607 * cl_page::cp_layers list, that is, it is at the bottom of the stack.
1609 * \see cl_lock_slice_add(), cl_req_slice_add(), cl_io_slice_add()
1611 void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice,
1612 struct cl_object *obj,
1613 const struct cl_page_operations *ops)
1616 cfs_list_add_tail(&slice->cpl_linkage, &page->cp_layers);
1617 slice->cpl_obj = obj;
1618 slice->cpl_ops = ops;
1619 slice->cpl_page = page;
1622 EXPORT_SYMBOL(cl_page_slice_add);
1624 int cl_page_init(void)
1626 return lu_kmem_init(cl_page_caches);
1629 void cl_page_fini(void)
1631 lu_kmem_fini(cl_page_caches);