1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
32 * Copyright (c) 2011, 2012, Whamcloud, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
40 * Author: Nikita Danilov <nikita.danilov@sun.com>
43 #define DEBUG_SUBSYSTEM S_CLASS
45 # define EXPORT_SYMTAB
48 #include <libcfs/libcfs.h>
49 #include <obd_class.h>
50 #include <obd_support.h>
51 #include <libcfs/list.h>
53 #include <cl_object.h>
54 #include "cl_internal.h"
56 static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
59 static cfs_mem_cache_t *cl_page_kmem = NULL;
61 static struct lu_kmem_descr cl_page_caches[] = {
63 .ckd_cache = &cl_page_kmem,
64 .ckd_name = "cl_page_kmem",
65 .ckd_size = sizeof (struct cl_page)
73 # define PASSERT(env, page, expr) \
75 if (unlikely(!(expr))) { \
76 CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
80 #else /* !LIBCFS_DEBUG */
81 # define PASSERT(env, page, exp) \
82 ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
83 #endif /* !LIBCFS_DEBUG */
85 #ifdef INVARIANT_CHECK
86 # define PINVRNT(env, page, expr) \
88 if (unlikely(!(expr))) { \
89 CL_PAGE_DEBUG(D_ERROR, (env), (page), #expr "\n"); \
93 #else /* !INVARIANT_CHECK */
94 # define PINVRNT(env, page, exp) \
95 ((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
96 #endif /* !INVARIANT_CHECK */
99 * Internal version of cl_page_top, it should be called with page referenced,
100 * or coh_page_guard held.
102 static struct cl_page *cl_page_top_trusted(struct cl_page *page)
104 while (page->cp_parent != NULL)
105 page = page->cp_parent;
110 * Internal version of cl_page_get().
112 * This function can be used to obtain initial reference to previously
113 * unreferenced cached object. It can be called only if concurrent page
114 * reclamation is somehow prevented, e.g., by locking page radix-tree
115 * (cl_object_header::hdr->coh_page_guard), or by keeping a lock on a VM page,
116 * associated with \a page.
118 * Use with care! Not exported.
120 static void cl_page_get_trust(struct cl_page *page)
123 * Checkless version for trusted users.
125 if (cfs_atomic_inc_return(&page->cp_ref) == 1)
126 cfs_atomic_inc(&cl_object_site(page->cp_obj)->cs_pages.cs_busy);
130 * Returns a slice within a page, corresponding to the given layer in the
135 static const struct cl_page_slice *
136 cl_page_at_trusted(const struct cl_page *page,
137 const struct lu_device_type *dtype)
139 const struct cl_page_slice *slice;
141 #ifdef INVARIANT_CHECK
142 struct cl_object_header *ch = cl_object_header(page->cp_obj);
144 if (!cfs_atomic_read(&page->cp_ref))
145 LASSERT_SPIN_LOCKED(&ch->coh_page_guard);
149 page = cl_page_top_trusted((struct cl_page *)page);
151 cfs_list_for_each_entry(slice, &page->cp_layers, cpl_linkage) {
152 if (slice->cpl_obj->co_lu.lo_dev->ld_type == dtype)
155 page = page->cp_child;
156 } while (page != NULL);
161 * Returns a page with given index in the given object, or NULL if no page is
162 * found. Acquires a reference on \a page.
164 * Locking: called under cl_object_header::coh_page_guard spin-lock.
166 struct cl_page *cl_page_lookup(struct cl_object_header *hdr, pgoff_t index)
168 struct cl_page *page;
170 LASSERT_SPIN_LOCKED(&hdr->coh_page_guard);
172 page = radix_tree_lookup(&hdr->coh_tree, index);
174 cl_page_get_trust(page);
178 EXPORT_SYMBOL(cl_page_lookup);
181 * Returns a list of pages by a given [start, end] of \a obj.
183 * \param resched If not NULL, then we give up before hogging CPU for too
184 * long and set *resched = 1, in that case caller should implement a retry
187 * Gang tree lookup (radix_tree_gang_lookup()) optimization is absolutely
188 * crucial in the face of [offset, EOF] locks.
190 * Return at least one page in @queue unless there is no covered page.
192 int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj,
193 struct cl_io *io, pgoff_t start, pgoff_t end,
194 cl_page_gang_cb_t cb, void *cbdata)
196 struct cl_object_header *hdr;
197 struct cl_page *page;
198 struct cl_page **pvec;
199 const struct cl_page_slice *slice;
200 const struct lu_device_type *dtype;
205 int res = CLP_GANG_OKAY;
210 hdr = cl_object_header(obj);
211 pvec = cl_env_info(env)->clt_pvec;
212 dtype = cl_object_top(obj)->co_lu.lo_dev->ld_type;
213 cfs_spin_lock(&hdr->coh_page_guard);
214 while ((nr = radix_tree_gang_lookup(&hdr->coh_tree, (void **)pvec,
215 idx, CLT_PVEC_SIZE)) > 0) {
216 int end_of_region = 0;
217 idx = pvec[nr - 1]->cp_index + 1;
218 for (i = 0, j = 0; i < nr; ++i) {
222 LASSERT(page->cp_type == CPT_CACHEABLE);
223 if (page->cp_index > end) {
227 if (page->cp_state == CPS_FREEING)
230 slice = cl_page_at_trusted(page, dtype);
232 * Pages for lsm-less file has no underneath sub-page
233 * for osc, in case of ...
235 PASSERT(env, page, slice != NULL);
237 page = slice->cpl_page;
239 * Can safely call cl_page_get_trust() under
240 * radix-tree spin-lock.
242 * XXX not true, because @page is from object another
243 * than @hdr and protected by different tree lock.
245 cl_page_get_trust(page);
246 lu_ref_add_atomic(&page->cp_reference,
247 "gang_lookup", cfs_current());
252 * Here a delicate locking dance is performed. Current thread
253 * holds a reference to a page, but has to own it before it
254 * can be placed into queue. Owning implies waiting, so
255 * radix-tree lock is to be released. After a wait one has to
256 * check that pages weren't truncated (cl_page_own() returns
257 * error in the latter case).
259 cfs_spin_unlock(&hdr->coh_page_guard);
262 for (i = 0; i < j; ++i) {
264 if (res == CLP_GANG_OKAY)
265 res = (*cb)(env, io, page, cbdata);
266 lu_ref_del(&page->cp_reference,
267 "gang_lookup", cfs_current());
268 cl_page_put(env, page);
270 if (nr < CLT_PVEC_SIZE || end_of_region)
273 if (res == CLP_GANG_OKAY && cfs_need_resched())
274 res = CLP_GANG_RESCHED;
275 if (res != CLP_GANG_OKAY)
278 cfs_spin_lock(&hdr->coh_page_guard);
282 cfs_spin_unlock(&hdr->coh_page_guard);
285 EXPORT_SYMBOL(cl_page_gang_lookup);
287 static void cl_page_free(const struct lu_env *env, struct cl_page *page)
289 struct cl_object *obj = page->cp_obj;
290 struct cl_site *site = cl_object_site(obj);
292 PASSERT(env, page, cfs_list_empty(&page->cp_batch));
293 PASSERT(env, page, page->cp_owner == NULL);
294 PASSERT(env, page, page->cp_req == NULL);
295 PASSERT(env, page, page->cp_parent == NULL);
296 PASSERT(env, page, page->cp_state == CPS_FREEING);
300 while (!cfs_list_empty(&page->cp_layers)) {
301 struct cl_page_slice *slice;
303 slice = cfs_list_entry(page->cp_layers.next,
304 struct cl_page_slice, cpl_linkage);
305 cfs_list_del_init(page->cp_layers.next);
306 slice->cpl_ops->cpo_fini(env, slice);
308 cfs_atomic_dec(&site->cs_pages.cs_total);
310 #ifdef LUSTRE_PAGESTATE_TRACKING
311 cfs_atomic_dec(&site->cs_pages_state[page->cp_state]);
313 lu_object_ref_del_at(&obj->co_lu, page->cp_obj_ref, "cl_page", page);
314 cl_object_put(env, obj);
315 lu_ref_fini(&page->cp_reference);
316 OBD_SLAB_FREE_PTR(page, cl_page_kmem);
321 * Helper function updating page state. This is the only place in the code
322 * where cl_page::cp_state field is mutated.
324 static inline void cl_page_state_set_trust(struct cl_page *page,
325 enum cl_page_state state)
328 *(enum cl_page_state *)&page->cp_state = state;
331 static int cl_page_alloc(const struct lu_env *env, struct cl_object *o,
332 pgoff_t ind, struct page *vmpage,
333 enum cl_page_type type, struct cl_page **out)
335 struct cl_page *page;
336 struct cl_page *err = NULL;
337 struct lu_object_header *head;
338 struct cl_site *site = cl_object_site(o);
343 OBD_SLAB_ALLOC_PTR_GFP(page, cl_page_kmem, CFS_ALLOC_IO);
345 cfs_atomic_set(&page->cp_ref, 1);
348 page->cp_obj_ref = lu_object_ref_add(&o->co_lu,
350 page->cp_index = ind;
351 cl_page_state_set_trust(page, CPS_CACHED);
352 page->cp_type = type;
353 CFS_INIT_LIST_HEAD(&page->cp_layers);
354 CFS_INIT_LIST_HEAD(&page->cp_batch);
355 CFS_INIT_LIST_HEAD(&page->cp_flight);
356 cfs_mutex_init(&page->cp_mutex);
357 lu_ref_init(&page->cp_reference);
358 head = o->co_lu.lo_header;
359 cfs_list_for_each_entry(o, &head->loh_layers,
361 if (o->co_ops->coo_page_init != NULL) {
362 err = o->co_ops->coo_page_init(env, o,
365 cl_page_delete0(env, page, 0);
366 cl_page_free(env, page);
373 cfs_atomic_inc(&site->cs_pages.cs_busy);
374 cfs_atomic_inc(&site->cs_pages.cs_total);
376 #ifdef LUSTRE_PAGESTATE_TRACKING
377 cfs_atomic_inc(&site->cs_pages_state[CPS_CACHED]);
379 cfs_atomic_inc(&site->cs_pages.cs_created);
383 page = ERR_PTR(-ENOMEM);
389 * Returns a cl_page with index \a idx at the object \a o, and associated with
390 * the VM page \a vmpage.
392 * This is the main entry point into the cl_page caching interface. First, a
393 * cache (implemented as a per-object radix tree) is consulted. If page is
394 * found there, it is returned immediately. Otherwise new page is allocated
395 * and returned. In any case, additional reference to page is acquired.
397 * \see cl_object_find(), cl_lock_find()
399 static struct cl_page *cl_page_find0(const struct lu_env *env,
401 pgoff_t idx, struct page *vmpage,
402 enum cl_page_type type,
403 struct cl_page *parent)
405 struct cl_page *page = NULL;
406 struct cl_page *ghost = NULL;
407 struct cl_object_header *hdr;
408 struct cl_site *site = cl_object_site(o);
411 LASSERT(type == CPT_CACHEABLE || type == CPT_TRANSIENT);
416 hdr = cl_object_header(o);
417 cfs_atomic_inc(&site->cs_pages.cs_lookup);
419 CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n",
420 idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type);
422 if (type == CPT_CACHEABLE) {
424 * cl_vmpage_page() can be called here without any locks as
426 * - "vmpage" is locked (which prevents ->private from
427 * concurrent updates), and
429 * - "o" cannot be destroyed while current thread holds a
432 page = cl_vmpage_page(vmpage, o);
435 cl_page_vmpage(env, page) == vmpage &&
436 (void *)radix_tree_lookup(&hdr->coh_tree,
441 cfs_atomic_inc(&site->cs_pages.cs_hit);
445 /* allocate and initialize cl_page */
446 err = cl_page_alloc(env, o, idx, vmpage, type, &page);
450 if (type == CPT_TRANSIENT) {
452 LASSERT(page->cp_parent == NULL);
453 page->cp_parent = parent;
454 parent->cp_child = page;
460 * XXX optimization: use radix_tree_preload() here, and change tree
461 * gfp mask to GFP_KERNEL in cl_object_header_init().
463 cfs_spin_lock(&hdr->coh_page_guard);
464 err = radix_tree_insert(&hdr->coh_tree, idx, page);
468 * Noted by Jay: a lock on \a vmpage protects cl_page_find()
469 * from this race, but
471 * 0. it's better to have cl_page interface "locally
472 * consistent" so that its correctness can be reasoned
473 * about without appealing to the (obscure world of) VM
476 * 1. handling this race allows ->coh_tree to remain
477 * consistent even when VM locking is somehow busted,
478 * which is very useful during diagnosing and debugging.
481 CL_PAGE_DEBUG(D_ERROR, env, ghost,
482 "fail to insert into radix tree: %d\n", err);
485 LASSERT(page->cp_parent == NULL);
486 page->cp_parent = parent;
487 parent->cp_child = page;
491 cfs_spin_unlock(&hdr->coh_page_guard);
493 if (unlikely(ghost != NULL)) {
494 cfs_atomic_dec(&site->cs_pages.cs_busy);
495 cl_page_delete0(env, ghost, 0);
496 cl_page_free(env, ghost);
501 struct cl_page *cl_page_find(const struct lu_env *env, struct cl_object *o,
502 pgoff_t idx, struct page *vmpage,
503 enum cl_page_type type)
505 return cl_page_find0(env, o, idx, vmpage, type, NULL);
507 EXPORT_SYMBOL(cl_page_find);
510 struct cl_page *cl_page_find_sub(const struct lu_env *env, struct cl_object *o,
511 pgoff_t idx, struct page *vmpage,
512 struct cl_page *parent)
514 return cl_page_find0(env, o, idx, vmpage, parent->cp_type, parent);
516 EXPORT_SYMBOL(cl_page_find_sub);
518 static inline int cl_page_invariant(const struct cl_page *pg)
520 struct cl_object_header *header;
521 struct cl_page *parent;
522 struct cl_page *child;
526 * Page invariant is protected by a VM lock.
528 LINVRNT(cl_page_is_vmlocked(NULL, pg));
530 header = cl_object_header(pg->cp_obj);
531 parent = pg->cp_parent;
532 child = pg->cp_child;
533 owner = pg->cp_owner;
535 return cfs_atomic_read(&pg->cp_ref) > 0 &&
536 ergo(parent != NULL, parent->cp_child == pg) &&
537 ergo(child != NULL, child->cp_parent == pg) &&
538 ergo(child != NULL, pg->cp_obj != child->cp_obj) &&
539 ergo(parent != NULL, pg->cp_obj != parent->cp_obj) &&
540 ergo(owner != NULL && parent != NULL,
541 parent->cp_owner == pg->cp_owner->ci_parent) &&
542 ergo(owner != NULL && child != NULL,
543 child->cp_owner->ci_parent == owner) &&
545 * Either page is early in initialization (has neither child
546 * nor parent yet), or it is in the object radix tree.
548 ergo(pg->cp_state < CPS_FREEING && pg->cp_type == CPT_CACHEABLE,
549 (void *)radix_tree_lookup(&header->coh_tree,
550 pg->cp_index) == pg ||
551 (child == NULL && parent == NULL));
554 static void cl_page_state_set0(const struct lu_env *env,
555 struct cl_page *page, enum cl_page_state state)
557 enum cl_page_state old;
558 #ifdef LUSTRE_PAGESTATE_TRACKING
559 struct cl_site *site = cl_object_site(page->cp_obj);
563 * Matrix of allowed state transitions [old][new], for sanity
566 static const int allowed_transitions[CPS_NR][CPS_NR] = {
569 [CPS_OWNED] = 1, /* io finds existing cached page */
571 [CPS_PAGEOUT] = 1, /* write-out from the cache */
572 [CPS_FREEING] = 1, /* eviction on the memory pressure */
575 [CPS_CACHED] = 1, /* release to the cache */
577 [CPS_PAGEIN] = 1, /* start read immediately */
578 [CPS_PAGEOUT] = 1, /* start write immediately */
579 [CPS_FREEING] = 1, /* lock invalidation or truncate */
582 [CPS_CACHED] = 1, /* io completion */
589 [CPS_CACHED] = 1, /* io completion */
605 old = page->cp_state;
606 PASSERT(env, page, allowed_transitions[old][state]);
607 CL_PAGE_HEADER(D_TRACE, env, page, "%d -> %d\n", old, state);
608 for (; page != NULL; page = page->cp_child) {
609 PASSERT(env, page, page->cp_state == old);
611 equi(state == CPS_OWNED, page->cp_owner != NULL));
613 #ifdef LUSTRE_PAGESTATE_TRACKING
614 cfs_atomic_dec(&site->cs_pages_state[page->cp_state]);
615 cfs_atomic_inc(&site->cs_pages_state[state]);
617 cl_page_state_set_trust(page, state);
622 static void cl_page_state_set(const struct lu_env *env,
623 struct cl_page *page, enum cl_page_state state)
625 cl_page_state_set0(env, page, state);
629 * Acquires an additional reference to a page.
631 * This can be called only by caller already possessing a reference to \a
634 * \see cl_object_get(), cl_lock_get().
636 void cl_page_get(struct cl_page *page)
639 LASSERT(page->cp_state != CPS_FREEING);
640 cl_page_get_trust(page);
643 EXPORT_SYMBOL(cl_page_get);
646 * Releases a reference to a page.
648 * When last reference is released, page is returned to the cache, unless it
649 * is in cl_page_state::CPS_FREEING state, in which case it is immediately
652 * \see cl_object_put(), cl_lock_put().
654 void cl_page_put(const struct lu_env *env, struct cl_page *page)
656 struct cl_object_header *hdr;
657 struct cl_site *site = cl_object_site(page->cp_obj);
659 PASSERT(env, page, cfs_atomic_read(&page->cp_ref) > !!page->cp_parent);
662 CL_PAGE_HEADER(D_TRACE, env, page, "%d\n",
663 cfs_atomic_read(&page->cp_ref));
665 hdr = cl_object_header(cl_object_top(page->cp_obj));
666 if (cfs_atomic_dec_and_lock(&page->cp_ref, &hdr->coh_page_guard)) {
667 cfs_atomic_dec(&site->cs_pages.cs_busy);
668 /* We're going to access the page w/o a reference, but it's
669 * ok because we have grabbed the lock coh_page_guard, which
670 * means nobody is able to free this page behind us.
672 if (page->cp_state == CPS_FREEING) {
673 /* We drop the page reference and check the page state
674 * inside the coh_page_guard. So that if it gets here,
675 * it is the REALLY last reference to this page.
677 cfs_spin_unlock(&hdr->coh_page_guard);
679 LASSERT(cfs_atomic_read(&page->cp_ref) == 0);
680 PASSERT(env, page, page->cp_owner == NULL);
681 PASSERT(env, page, cfs_list_empty(&page->cp_batch));
683 * Page is no longer reachable by other threads. Tear
686 cl_page_free(env, page);
691 cfs_spin_unlock(&hdr->coh_page_guard);
696 EXPORT_SYMBOL(cl_page_put);
699 * Returns a VM page associated with a given cl_page.
701 cfs_page_t *cl_page_vmpage(const struct lu_env *env, struct cl_page *page)
703 const struct cl_page_slice *slice;
706 * Find uppermost layer with ->cpo_vmpage() method, and return its
709 page = cl_page_top(page);
711 cfs_list_for_each_entry(slice, &page->cp_layers, cpl_linkage) {
712 if (slice->cpl_ops->cpo_vmpage != NULL)
713 RETURN(slice->cpl_ops->cpo_vmpage(env, slice));
715 page = page->cp_child;
716 } while (page != NULL);
717 LBUG(); /* ->cpo_vmpage() has to be defined somewhere in the stack */
719 EXPORT_SYMBOL(cl_page_vmpage);
722 * Returns a cl_page associated with a VM page, and given cl_object.
724 struct cl_page *cl_vmpage_page(cfs_page_t *vmpage, struct cl_object *obj)
726 struct cl_page *page;
727 struct cl_object_header *hdr;
730 KLASSERT(PageLocked(vmpage));
733 * NOTE: absence of races and liveness of data are guaranteed by page
734 * lock on a "vmpage". That works because object destruction has
735 * bottom-to-top pass.
739 * This loop assumes that ->private points to the top-most page. This
740 * can be rectified easily.
742 hdr = cl_object_header(cl_object_top(obj));
743 cfs_spin_lock(&hdr->coh_page_guard);
744 for (page = (void *)vmpage->private;
745 page != NULL; page = page->cp_child) {
746 if (cl_object_same(page->cp_obj, obj)) {
747 cl_page_get_trust(page);
751 cfs_spin_unlock(&hdr->coh_page_guard);
752 LASSERT(ergo(page, page->cp_type == CPT_CACHEABLE));
755 EXPORT_SYMBOL(cl_vmpage_page);
758 * Returns the top-page for a given page.
760 * \see cl_object_top(), cl_io_top()
762 struct cl_page *cl_page_top(struct cl_page *page)
764 return cl_page_top_trusted(page);
766 EXPORT_SYMBOL(cl_page_top);
768 const struct cl_page_slice *cl_page_at(const struct cl_page *page,
769 const struct lu_device_type *dtype)
771 return cl_page_at_trusted(page, dtype);
773 EXPORT_SYMBOL(cl_page_at);
775 #define CL_PAGE_OP(opname) offsetof(struct cl_page_operations, opname)
777 #define CL_PAGE_INVOKE(_env, _page, _op, _proto, ...) \
779 const struct lu_env *__env = (_env); \
780 struct cl_page *__page = (_page); \
781 const struct cl_page_slice *__scan; \
783 ptrdiff_t __op = (_op); \
784 int (*__method)_proto; \
787 __page = cl_page_top(__page); \
789 cfs_list_for_each_entry(__scan, &__page->cp_layers, \
791 __method = *(void **)((char *)__scan->cpl_ops + \
793 if (__method != NULL) { \
794 __result = (*__method)(__env, __scan, \
800 __page = __page->cp_child; \
801 } while (__page != NULL && __result == 0); \
807 #define CL_PAGE_INVOID(_env, _page, _op, _proto, ...) \
809 const struct lu_env *__env = (_env); \
810 struct cl_page *__page = (_page); \
811 const struct cl_page_slice *__scan; \
812 ptrdiff_t __op = (_op); \
813 void (*__method)_proto; \
815 __page = cl_page_top(__page); \
817 cfs_list_for_each_entry(__scan, &__page->cp_layers, \
819 __method = *(void **)((char *)__scan->cpl_ops + \
821 if (__method != NULL) \
822 (*__method)(__env, __scan, \
825 __page = __page->cp_child; \
826 } while (__page != NULL); \
829 #define CL_PAGE_INVOID_REVERSE(_env, _page, _op, _proto, ...) \
831 const struct lu_env *__env = (_env); \
832 struct cl_page *__page = (_page); \
833 const struct cl_page_slice *__scan; \
834 ptrdiff_t __op = (_op); \
835 void (*__method)_proto; \
837 /* get to the bottom page. */ \
838 while (__page->cp_child != NULL) \
839 __page = __page->cp_child; \
841 cfs_list_for_each_entry_reverse(__scan, &__page->cp_layers, \
843 __method = *(void **)((char *)__scan->cpl_ops + \
845 if (__method != NULL) \
846 (*__method)(__env, __scan, \
849 __page = __page->cp_parent; \
850 } while (__page != NULL); \
853 static int cl_page_invoke(const struct lu_env *env,
854 struct cl_io *io, struct cl_page *page, ptrdiff_t op)
857 PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj));
859 RETURN(CL_PAGE_INVOKE(env, page, op,
860 (const struct lu_env *,
861 const struct cl_page_slice *, struct cl_io *),
865 static void cl_page_invoid(const struct lu_env *env,
866 struct cl_io *io, struct cl_page *page, ptrdiff_t op)
869 PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj));
871 CL_PAGE_INVOID(env, page, op,
872 (const struct lu_env *,
873 const struct cl_page_slice *, struct cl_io *), io);
877 static void cl_page_owner_clear(struct cl_page *page)
880 for (page = cl_page_top(page); page != NULL; page = page->cp_child) {
881 if (page->cp_owner != NULL) {
882 LASSERT(page->cp_owner->ci_owned_nr > 0);
883 page->cp_owner->ci_owned_nr--;
884 page->cp_owner = NULL;
885 page->cp_task = NULL;
891 static void cl_page_owner_set(struct cl_page *page)
894 for (page = cl_page_top(page); page != NULL; page = page->cp_child) {
895 LASSERT(page->cp_owner != NULL);
896 page->cp_owner->ci_owned_nr++;
901 void cl_page_disown0(const struct lu_env *env,
902 struct cl_io *io, struct cl_page *pg)
904 enum cl_page_state state;
907 state = pg->cp_state;
908 PINVRNT(env, pg, state == CPS_OWNED || state == CPS_FREEING);
909 PINVRNT(env, pg, cl_page_invariant(pg));
910 cl_page_owner_clear(pg);
912 if (state == CPS_OWNED)
913 cl_page_state_set(env, pg, CPS_CACHED);
915 * Completion call-backs are executed in the bottom-up order, so that
916 * uppermost layer (llite), responsible for VFS/VM interaction runs
917 * last and can release locks safely.
919 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(cpo_disown),
920 (const struct lu_env *,
921 const struct cl_page_slice *, struct cl_io *),
927 * returns true, iff page is owned by the given io.
929 int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io)
931 LINVRNT(cl_object_same(pg->cp_obj, io->ci_obj));
933 RETURN(pg->cp_state == CPS_OWNED && pg->cp_owner == io);
935 EXPORT_SYMBOL(cl_page_is_owned);
938 * Try to own a page by IO.
940 * Waits until page is in cl_page_state::CPS_CACHED state, and then switch it
941 * into cl_page_state::CPS_OWNED state.
943 * \pre !cl_page_is_owned(pg, io)
944 * \post result == 0 iff cl_page_is_owned(pg, io)
948 * \retval -ve failure, e.g., page was destroyed (and landed in
949 * cl_page_state::CPS_FREEING instead of cl_page_state::CPS_CACHED).
950 * or, page was owned by another thread, or in IO.
952 * \see cl_page_disown()
953 * \see cl_page_operations::cpo_own()
954 * \see cl_page_own_try()
957 static int cl_page_own0(const struct lu_env *env, struct cl_io *io,
958 struct cl_page *pg, int nonblock)
962 PINVRNT(env, pg, !cl_page_is_owned(pg, io));
965 pg = cl_page_top(pg);
968 if (pg->cp_state == CPS_FREEING) {
971 result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(cpo_own),
972 (const struct lu_env *,
973 const struct cl_page_slice *,
974 struct cl_io *, int),
977 PASSERT(env, pg, pg->cp_owner == NULL);
978 PASSERT(env, pg, pg->cp_req == NULL);
980 pg->cp_task = current;
981 cl_page_owner_set(pg);
982 if (pg->cp_state != CPS_FREEING) {
983 cl_page_state_set(env, pg, CPS_OWNED);
985 cl_page_disown0(env, io, pg);
990 PINVRNT(env, pg, ergo(result == 0, cl_page_invariant(pg)));
995 * Own a page, might be blocked.
997 * \see cl_page_own0()
999 int cl_page_own(const struct lu_env *env, struct cl_io *io, struct cl_page *pg)
1001 return cl_page_own0(env, io, pg, 0);
1003 EXPORT_SYMBOL(cl_page_own);
1006 * Nonblock version of cl_page_own().
1008 * \see cl_page_own0()
1010 int cl_page_own_try(const struct lu_env *env, struct cl_io *io,
1013 return cl_page_own0(env, io, pg, 1);
1015 EXPORT_SYMBOL(cl_page_own_try);
1019 * Assume page ownership.
1021 * Called when page is already locked by the hosting VM.
1023 * \pre !cl_page_is_owned(pg, io)
1024 * \post cl_page_is_owned(pg, io)
1026 * \see cl_page_operations::cpo_assume()
1028 void cl_page_assume(const struct lu_env *env,
1029 struct cl_io *io, struct cl_page *pg)
1031 PASSERT(env, pg, pg->cp_owner == NULL);
1032 PINVRNT(env, pg, cl_object_same(pg->cp_obj, io->ci_obj));
1033 PINVRNT(env, pg, cl_page_invariant(pg));
1036 pg = cl_page_top(pg);
1039 cl_page_invoid(env, io, pg, CL_PAGE_OP(cpo_assume));
1041 pg->cp_task = current;
1042 cl_page_owner_set(pg);
1043 cl_page_state_set(env, pg, CPS_OWNED);
1046 EXPORT_SYMBOL(cl_page_assume);
1049 * Releases page ownership without unlocking the page.
1051 * Moves page into cl_page_state::CPS_CACHED without releasing a lock on the
1052 * underlying VM page (as VM is supposed to do this itself).
1054 * \pre cl_page_is_owned(pg, io)
1055 * \post !cl_page_is_owned(pg, io)
1057 * \see cl_page_assume()
1059 void cl_page_unassume(const struct lu_env *env,
1060 struct cl_io *io, struct cl_page *pg)
1062 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1063 PINVRNT(env, pg, cl_page_invariant(pg));
1066 pg = cl_page_top(pg);
1068 cl_page_owner_clear(pg);
1069 cl_page_state_set(env, pg, CPS_CACHED);
1070 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(cpo_unassume),
1071 (const struct lu_env *,
1072 const struct cl_page_slice *, struct cl_io *),
1076 EXPORT_SYMBOL(cl_page_unassume);
1079 * Releases page ownership.
1081 * Moves page into cl_page_state::CPS_CACHED.
1083 * \pre cl_page_is_owned(pg, io)
1084 * \post !cl_page_is_owned(pg, io)
1086 * \see cl_page_own()
1087 * \see cl_page_operations::cpo_disown()
1089 void cl_page_disown(const struct lu_env *env,
1090 struct cl_io *io, struct cl_page *pg)
1092 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1095 pg = cl_page_top(pg);
1097 cl_page_disown0(env, io, pg);
1100 EXPORT_SYMBOL(cl_page_disown);
1103 * Called when page is to be removed from the object, e.g., as a result of
1106 * Calls cl_page_operations::cpo_discard() top-to-bottom.
1108 * \pre cl_page_is_owned(pg, io)
1110 * \see cl_page_operations::cpo_discard()
1112 void cl_page_discard(const struct lu_env *env,
1113 struct cl_io *io, struct cl_page *pg)
1115 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1116 PINVRNT(env, pg, cl_page_invariant(pg));
1118 cl_page_invoid(env, io, pg, CL_PAGE_OP(cpo_discard));
1120 EXPORT_SYMBOL(cl_page_discard);
1123 * Version of cl_page_delete() that can be called for not fully constructed
1124 * pages, e.g,. in a error handling cl_page_find()->cl_page_delete0()
1125 * path. Doesn't check page invariant.
1127 static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
1130 struct cl_page *tmp = pg;
1133 PASSERT(env, pg, pg == cl_page_top(pg));
1134 PASSERT(env, pg, pg->cp_state != CPS_FREEING);
1137 * Severe all ways to obtain new pointers to @pg.
1139 cl_page_owner_clear(pg);
1142 * unexport the page firstly before freeing it so that
1143 * the page content is considered to be invalid.
1144 * We have to do this because a CPS_FREEING cl_page may
1145 * be NOT under the protection of a cl_lock.
1146 * Afterwards, if this page is found by other threads, then this
1147 * page will be forced to reread.
1149 cl_page_export(env, pg, 0);
1150 cl_page_state_set0(env, pg, CPS_FREEING);
1152 if (tmp->cp_type == CPT_CACHEABLE) {
1154 /* !radix means that @pg is not yet in the radix tree,
1158 for (; tmp != NULL; tmp = tmp->cp_child) {
1160 struct cl_object_header *hdr;
1162 hdr = cl_object_header(tmp->cp_obj);
1163 cfs_spin_lock(&hdr->coh_page_guard);
1164 value = radix_tree_delete(&hdr->coh_tree,
1166 PASSERT(env, tmp, value == tmp);
1167 PASSERT(env, tmp, hdr->coh_pages > 0);
1169 cfs_spin_unlock(&hdr->coh_page_guard);
1173 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_delete),
1174 (const struct lu_env *, const struct cl_page_slice *));
1179 * Called when a decision is made to throw page out of memory.
1181 * Notifies all layers about page destruction by calling
1182 * cl_page_operations::cpo_delete() method top-to-bottom.
1184 * Moves page into cl_page_state::CPS_FREEING state (this is the only place
1185 * where transition to this state happens).
1187 * Eliminates all venues through which new references to the page can be
1190 * - removes page from the radix trees,
1192 * - breaks linkage from VM page to cl_page.
1194 * Once page reaches cl_page_state::CPS_FREEING, all remaining references will
1195 * drain after some time, at which point page will be recycled.
1197 * \pre pg == cl_page_top(pg)
1198 * \pre VM page is locked
1199 * \post pg->cp_state == CPS_FREEING
1201 * \see cl_page_operations::cpo_delete()
1203 void cl_page_delete(const struct lu_env *env, struct cl_page *pg)
1205 PINVRNT(env, pg, cl_page_invariant(pg));
1207 cl_page_delete0(env, pg, 1);
1210 EXPORT_SYMBOL(cl_page_delete);
1213 * Unmaps page from user virtual memory.
1215 * Calls cl_page_operations::cpo_unmap() through all layers top-to-bottom. The
1216 * layer responsible for VM interaction has to unmap page from user space
1219 * \see cl_page_operations::cpo_unmap()
1221 int cl_page_unmap(const struct lu_env *env,
1222 struct cl_io *io, struct cl_page *pg)
1224 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1225 PINVRNT(env, pg, cl_page_invariant(pg));
1227 return cl_page_invoke(env, io, pg, CL_PAGE_OP(cpo_unmap));
1229 EXPORT_SYMBOL(cl_page_unmap);
1232 * Marks page up-to-date.
1234 * Call cl_page_operations::cpo_export() through all layers top-to-bottom. The
1235 * layer responsible for VM interaction has to mark/clear page as up-to-date
1236 * by the \a uptodate argument.
1238 * \see cl_page_operations::cpo_export()
1240 void cl_page_export(const struct lu_env *env, struct cl_page *pg, int uptodate)
1242 PINVRNT(env, pg, cl_page_invariant(pg));
1243 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_export),
1244 (const struct lu_env *,
1245 const struct cl_page_slice *, int), uptodate);
1247 EXPORT_SYMBOL(cl_page_export);
1250 * Returns true, iff \a pg is VM locked in a suitable sense by the calling
1253 int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg)
1256 const struct cl_page_slice *slice;
1259 pg = cl_page_top_trusted((struct cl_page *)pg);
1260 slice = container_of(pg->cp_layers.next,
1261 const struct cl_page_slice, cpl_linkage);
1262 PASSERT(env, pg, slice->cpl_ops->cpo_is_vmlocked != NULL);
1264 * Call ->cpo_is_vmlocked() directly instead of going through
1265 * CL_PAGE_INVOKE(), because cl_page_is_vmlocked() is used by
1266 * cl_page_invariant().
1268 result = slice->cpl_ops->cpo_is_vmlocked(env, slice);
1269 PASSERT(env, pg, result == -EBUSY || result == -ENODATA);
1270 RETURN(result == -EBUSY);
1272 EXPORT_SYMBOL(cl_page_is_vmlocked);
1274 static enum cl_page_state cl_req_type_state(enum cl_req_type crt)
1277 RETURN(crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN);
1280 static void cl_page_io_start(const struct lu_env *env,
1281 struct cl_page *pg, enum cl_req_type crt)
1284 * Page is queued for IO, change its state.
1287 cl_page_owner_clear(pg);
1288 cl_page_state_set(env, pg, cl_req_type_state(crt));
1293 * Prepares page for immediate transfer. cl_page_operations::cpo_prep() is
1294 * called top-to-bottom. Every layer either agrees to submit this page (by
1295 * returning 0), or requests to omit this page (by returning -EALREADY). Layer
1296 * handling interactions with the VM also has to inform VM that page is under
1299 int cl_page_prep(const struct lu_env *env, struct cl_io *io,
1300 struct cl_page *pg, enum cl_req_type crt)
1304 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1305 PINVRNT(env, pg, cl_page_invariant(pg));
1306 PINVRNT(env, pg, crt < CRT_NR);
1309 * XXX this has to be called bottom-to-top, so that llite can set up
1310 * PG_writeback without risking other layers deciding to skip this
1313 result = cl_page_invoke(env, io, pg, CL_PAGE_OP(io[crt].cpo_prep));
1315 cl_page_io_start(env, pg, crt);
1317 KLASSERT(ergo(crt == CRT_WRITE && pg->cp_type == CPT_CACHEABLE,
1319 PageWriteback(cl_page_vmpage(env, pg)))));
1320 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1323 EXPORT_SYMBOL(cl_page_prep);
1326 * Notify layers about transfer completion.
1328 * Invoked by transfer sub-system (which is a part of osc) to notify layers
1329 * that a transfer, of which this page is a part of has completed.
1331 * Completion call-backs are executed in the bottom-up order, so that
1332 * uppermost layer (llite), responsible for the VFS/VM interaction runs last
1333 * and can release locks safely.
1335 * \pre pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT
1336 * \post pg->cp_state == CPS_CACHED
1338 * \see cl_page_operations::cpo_completion()
1340 void cl_page_completion(const struct lu_env *env,
1341 struct cl_page *pg, enum cl_req_type crt, int ioret)
1343 struct cl_sync_io *anchor = pg->cp_sync_io;
1345 PASSERT(env, pg, crt < CRT_NR);
1346 /* cl_page::cp_req already cleared by the caller (osc_completion()) */
1347 PASSERT(env, pg, pg->cp_req == NULL);
1348 PASSERT(env, pg, pg->cp_state == cl_req_type_state(crt));
1351 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, ioret);
1352 if (crt == CRT_READ && ioret == 0) {
1353 PASSERT(env, pg, !(pg->cp_flags & CPF_READ_COMPLETED));
1354 pg->cp_flags |= CPF_READ_COMPLETED;
1357 cl_page_state_set(env, pg, CPS_CACHED);
1358 CL_PAGE_INVOID_REVERSE(env, pg, CL_PAGE_OP(io[crt].cpo_completion),
1359 (const struct lu_env *,
1360 const struct cl_page_slice *, int), ioret);
1362 LASSERT(cl_page_is_vmlocked(env, pg));
1363 LASSERT(pg->cp_sync_io == anchor);
1364 pg->cp_sync_io = NULL;
1365 cl_sync_io_note(anchor, ioret);
1368 /* Don't assert the page writeback bit here because the lustre file
1369 * may be as a backend of swap space. in this case, the page writeback
1370 * is set by VM, and obvious we shouldn't clear it at all. Fortunately
1371 * this type of pages are all TRANSIENT pages. */
1372 KLASSERT(ergo(pg->cp_type == CPT_CACHEABLE,
1373 !PageWriteback(cl_page_vmpage(env, pg))));
1376 EXPORT_SYMBOL(cl_page_completion);
1379 * Notify layers that transfer formation engine decided to yank this page from
1380 * the cache and to make it a part of a transfer.
1382 * \pre pg->cp_state == CPS_CACHED
1383 * \post pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT
1385 * \see cl_page_operations::cpo_make_ready()
1387 int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg,
1388 enum cl_req_type crt)
1392 PINVRNT(env, pg, crt < CRT_NR);
1395 result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(io[crt].cpo_make_ready),
1396 (const struct lu_env *,
1397 const struct cl_page_slice *));
1399 PASSERT(env, pg, pg->cp_state == CPS_CACHED);
1400 cl_page_io_start(env, pg, crt);
1402 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1405 EXPORT_SYMBOL(cl_page_make_ready);
1408 * Notify layers that high level io decided to place this page into a cache
1409 * for future transfer.
1411 * The layer implementing transfer engine (osc) has to register this page in
1414 * \pre cl_page_is_owned(pg, io)
1415 * \post ergo(result == 0,
1416 * pg->cp_state == CPS_PAGEIN || pg->cp_state == CPS_PAGEOUT)
1418 * \see cl_page_operations::cpo_cache_add()
1420 int cl_page_cache_add(const struct lu_env *env, struct cl_io *io,
1421 struct cl_page *pg, enum cl_req_type crt)
1425 PINVRNT(env, pg, crt < CRT_NR);
1426 PINVRNT(env, pg, cl_page_is_owned(pg, io));
1427 PINVRNT(env, pg, cl_page_invariant(pg));
1430 result = cl_page_invoke(env, io, pg, CL_PAGE_OP(io[crt].cpo_cache_add));
1432 cl_page_owner_clear(pg);
1433 cl_page_state_set(env, pg, CPS_CACHED);
1435 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result);
1438 EXPORT_SYMBOL(cl_page_cache_add);
1441 * Checks whether page is protected by any extent lock is at least required
1444 * \return the same as in cl_page_operations::cpo_is_under_lock() method.
1445 * \see cl_page_operations::cpo_is_under_lock()
1447 int cl_page_is_under_lock(const struct lu_env *env, struct cl_io *io,
1448 struct cl_page *page)
1452 PINVRNT(env, page, cl_page_invariant(page));
1455 rc = CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_is_under_lock),
1456 (const struct lu_env *,
1457 const struct cl_page_slice *, struct cl_io *),
1459 PASSERT(env, page, rc != 0);
1462 EXPORT_SYMBOL(cl_page_is_under_lock);
1464 static int page_prune_cb(const struct lu_env *env, struct cl_io *io,
1465 struct cl_page *page, void *cbdata)
1467 cl_page_own(env, io, page);
1468 cl_page_unmap(env, io, page);
1469 cl_page_discard(env, io, page);
1470 cl_page_disown(env, io, page);
1471 return CLP_GANG_OKAY;
1475 * Purges all cached pages belonging to the object \a obj.
1477 int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj)
1479 struct cl_thread_info *info;
1480 struct cl_object *obj = cl_object_top(clobj);
1485 info = cl_env_info(env);
1489 * initialize the io. This is ugly since we never do IO in this
1490 * function, we just make cl_page_list functions happy. -jay
1493 result = cl_io_init(env, io, CIT_MISC, obj);
1495 cl_io_fini(env, io);
1496 RETURN(io->ci_result);
1500 result = cl_page_gang_lookup(env, obj, io, 0, CL_PAGE_EOF,
1501 page_prune_cb, NULL);
1502 if (result == CLP_GANG_RESCHED)
1504 } while (result != CLP_GANG_OKAY);
1506 cl_io_fini(env, io);
1509 EXPORT_SYMBOL(cl_pages_prune);
1512 * Tells transfer engine that only part of a page is to be transmitted.
1514 * \see cl_page_operations::cpo_clip()
1516 void cl_page_clip(const struct lu_env *env, struct cl_page *pg,
1519 PINVRNT(env, pg, cl_page_invariant(pg));
1521 CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", from, to);
1522 CL_PAGE_INVOID(env, pg, CL_PAGE_OP(cpo_clip),
1523 (const struct lu_env *,
1524 const struct cl_page_slice *,int, int),
1527 EXPORT_SYMBOL(cl_page_clip);
1530 * Prints human readable representation of \a pg to the \a f.
1532 void cl_page_header_print(const struct lu_env *env, void *cookie,
1533 lu_printer_t printer, const struct cl_page *pg)
1535 (*printer)(env, cookie,
1536 "page@%p[%d %p:%lu ^%p_%p %d %d %d %p %p %#x]\n",
1537 pg, cfs_atomic_read(&pg->cp_ref), pg->cp_obj,
1538 pg->cp_index, pg->cp_parent, pg->cp_child,
1539 pg->cp_state, pg->cp_error, pg->cp_type,
1540 pg->cp_owner, pg->cp_req, pg->cp_flags);
1542 EXPORT_SYMBOL(cl_page_header_print);
1545 * Prints human readable representation of \a pg to the \a f.
1547 void cl_page_print(const struct lu_env *env, void *cookie,
1548 lu_printer_t printer, const struct cl_page *pg)
1550 struct cl_page *scan;
1552 for (scan = cl_page_top((struct cl_page *)pg);
1553 scan != NULL; scan = scan->cp_child)
1554 cl_page_header_print(env, cookie, printer, scan);
1555 CL_PAGE_INVOKE(env, (struct cl_page *)pg, CL_PAGE_OP(cpo_print),
1556 (const struct lu_env *env,
1557 const struct cl_page_slice *slice,
1558 void *cookie, lu_printer_t p), cookie, printer);
1559 (*printer)(env, cookie, "end page@%p\n", pg);
1561 EXPORT_SYMBOL(cl_page_print);
1564 * Cancel a page which is still in a transfer.
1566 int cl_page_cancel(const struct lu_env *env, struct cl_page *page)
1568 return CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_cancel),
1569 (const struct lu_env *,
1570 const struct cl_page_slice *));
1572 EXPORT_SYMBOL(cl_page_cancel);
1575 * Converts a byte offset within object \a obj into a page index.
1577 loff_t cl_offset(const struct cl_object *obj, pgoff_t idx)
1582 return (loff_t)idx << CFS_PAGE_SHIFT;
1584 EXPORT_SYMBOL(cl_offset);
1587 * Converts a page index into a byte offset within object \a obj.
1589 pgoff_t cl_index(const struct cl_object *obj, loff_t offset)
1594 return offset >> CFS_PAGE_SHIFT;
1596 EXPORT_SYMBOL(cl_index);
1598 int cl_page_size(const struct cl_object *obj)
1600 return 1 << CFS_PAGE_SHIFT;
1602 EXPORT_SYMBOL(cl_page_size);
1605 * Adds page slice to the compound page.
1607 * This is called by cl_object_operations::coo_page_init() methods to add a
1608 * per-layer state to the page. New state is added at the end of
1609 * cl_page::cp_layers list, that is, it is at the bottom of the stack.
1611 * \see cl_lock_slice_add(), cl_req_slice_add(), cl_io_slice_add()
1613 void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice,
1614 struct cl_object *obj,
1615 const struct cl_page_operations *ops)
1618 cfs_list_add_tail(&slice->cpl_linkage, &page->cp_layers);
1619 slice->cpl_obj = obj;
1620 slice->cpl_ops = ops;
1621 slice->cpl_page = page;
1624 EXPORT_SYMBOL(cl_page_slice_add);
1626 int cl_page_init(void)
1628 return lu_kmem_init(cl_page_caches);
1631 void cl_page_fini(void)
1633 lu_kmem_fini(cl_page_caches);