Whamcloud - gitweb
LU-10171 headers: define pct(a,b) once
[fs/lustre-release.git] / lustre / include / cl_object.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2011, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  */
32 #ifndef _LUSTRE_CL_OBJECT_H
33 #define _LUSTRE_CL_OBJECT_H
34
35 /** \defgroup clio clio
36  *
37  * Client objects implement io operations and cache pages.
38  *
39  * Examples: lov and osc are implementations of cl interface.
40  *
41  * Big Theory Statement.
42  *
43  * Layered objects.
44  *
45  * Client implementation is based on the following data-types:
46  *
47  *   - cl_object
48  *
49  *   - cl_page
50  *
51  *   - cl_lock     represents an extent lock on an object.
52  *
53  *   - cl_io       represents high-level i/o activity such as whole read/write
54  *                 system call, or write-out of pages from under the lock being
55  *                 canceled. cl_io has sub-ios that can be stopped and resumed
56  *                 independently, thus achieving high degree of transfer
57  *                 parallelism. Single cl_io can be advanced forward by
58  *                 the multiple threads (although in the most usual case of
59  *                 read/write system call it is associated with the single user
60  *                 thread, that issued the system call).
61  *
62  * Terminology
63  *
64  *     - to avoid confusion high-level I/O operation like read or write system
65  *     call is referred to as "an io", whereas low-level I/O operation, like
66  *     RPC, is referred to as "a transfer"
67  *
68  *     - "generic code" means generic (not file system specific) code in the
69  *     hosting environment. "cl-code" means code (mostly in cl_*.c files) that
70  *     is not layer specific.
71  *
72  * Locking.
73  *
74  *  - i_mutex
75  *      - PG_locked
76  *          - cl_object_header::coh_page_guard
77  *          - lu_site::ls_guard
78  *
79  * See the top comment in cl_object.c for the description of overall locking and
80  * reference-counting design.
81  *
82  * See comments below for the description of i/o, page, and dlm-locking
83  * design.
84  *
85  * @{
86  */
87
88 /*
89  * super-class definitions.
90  */
91 #include <linux/aio.h>
92 #include <linux/fs.h>
93
94 #include <libcfs/libcfs.h>
95 #include <libcfs/libcfs_ptask.h>
96 #include <lu_object.h>
97 #include <linux/atomic.h>
98 #include <linux/mutex.h>
99 #include <linux/radix-tree.h>
100 #include <linux/spinlock.h>
101 #include <linux/wait.h>
102 #include <linux/pagevec.h>
103 #include <lustre_dlm.h>
104
105 struct obd_info;
106 struct inode;
107
108 struct cl_device;
109
110 struct cl_object;
111
112 struct cl_page;
113 struct cl_page_slice;
114 struct cl_lock;
115 struct cl_lock_slice;
116
117 struct cl_lock_operations;
118 struct cl_page_operations;
119
120 struct cl_io;
121 struct cl_io_slice;
122
123 struct cl_req_attr;
124
125 extern struct cfs_ptask_engine *cl_io_engine;
126
127 /**
128  * Device in the client stack.
129  *
130  * \see vvp_device, lov_device, lovsub_device, osc_device
131  */
132 struct cl_device {
133         /** Super-class. */
134         struct lu_device                   cd_lu_dev;
135 };
136
137 /** \addtogroup cl_object cl_object
138  * @{ */
139 /**
140  * "Data attributes" of cl_object. Data attributes can be updated
141  * independently for a sub-object, and top-object's attributes are calculated
142  * from sub-objects' ones.
143  */
144 struct cl_attr {
145         /** Object size, in bytes */
146         loff_t cat_size;
147         /**
148          * Known minimal size, in bytes.
149          *
150          * This is only valid when at least one DLM lock is held.
151          */
152         loff_t cat_kms;
153         /** Modification time. Measured in seconds since epoch. */
154         time64_t cat_mtime;
155         /** Access time. Measured in seconds since epoch. */
156         time64_t cat_atime;
157         /** Change time. Measured in seconds since epoch. */
158         time64_t cat_ctime;
159         /**
160          * Blocks allocated to this cl_object on the server file system.
161          *
162          * \todo XXX An interface for block size is needed.
163          */
164         __u64  cat_blocks;
165         /**
166          * User identifier for quota purposes.
167          */
168         uid_t  cat_uid;
169         /**
170          * Group identifier for quota purposes.
171          */
172         gid_t  cat_gid;
173
174         /* nlink of the directory */
175         __u64  cat_nlink;
176
177         /* Project identifier for quota purpose. */
178         __u32  cat_projid;
179 };
180
181 /**
182  * Fields in cl_attr that are being set.
183  */
184 enum cl_attr_valid {
185         CAT_SIZE   = 1 << 0,
186         CAT_KMS    = 1 << 1,
187         CAT_MTIME  = 1 << 3,
188         CAT_ATIME  = 1 << 4,
189         CAT_CTIME  = 1 << 5,
190         CAT_BLOCKS = 1 << 6,
191         CAT_UID    = 1 << 7,
192         CAT_GID    = 1 << 8,
193         CAT_PROJID = 1 << 9
194 };
195
196 /**
197  * Sub-class of lu_object with methods common for objects on the client
198  * stacks.
199  *
200  * cl_object: represents a regular file system object, both a file and a
201  *    stripe. cl_object is based on lu_object: it is identified by a fid,
202  *    layered, cached, hashed, and lrued. Important distinction with the server
203  *    side, where md_object and dt_object are used, is that cl_object "fans out"
204  *    at the lov/sns level: depending on the file layout, single file is
205  *    represented as a set of "sub-objects" (stripes). At the implementation
206  *    level, struct lov_object contains an array of cl_objects. Each sub-object
207  *    is a full-fledged cl_object, having its fid, living in the lru and hash
208  *    table.
209  *
210  *    This leads to the next important difference with the server side: on the
211  *    client, it's quite usual to have objects with the different sequence of
212  *    layers. For example, typical top-object is composed of the following
213  *    layers:
214  *
215  *        - vvp
216  *        - lov
217  *
218  *    whereas its sub-objects are composed of
219  *
220  *        - lovsub
221  *        - osc
222  *
223  *    layers. Here "lovsub" is a mostly dummy layer, whose purpose is to keep
224  *    track of the object-subobject relationship.
225  *
226  *    Sub-objects are not cached independently: when top-object is about to
227  *    be discarded from the memory, all its sub-objects are torn-down and
228  *    destroyed too.
229  *
230  * \see vvp_object, lov_object, lovsub_object, osc_object
231  */
232 struct cl_object {
233         /** super class */
234         struct lu_object                   co_lu;
235         /** per-object-layer operations */
236         const struct cl_object_operations *co_ops;
237         /** offset of page slice in cl_page buffer */
238         int                                co_slice_off;
239 };
240
241 /**
242  * Description of the client object configuration. This is used for the
243  * creation of a new client object that is identified by a more state than
244  * fid.
245  */
246 struct cl_object_conf {
247         /** Super-class. */
248         struct lu_object_conf     coc_lu;
249         union {
250                 /**
251                  * Object layout. This is consumed by lov.
252                  */
253                 struct lu_buf    coc_layout;
254                 /**
255                  * Description of particular stripe location in the
256                  * cluster. This is consumed by osc.
257                  */
258                 struct lov_oinfo *coc_oinfo;
259         } u;
260         /**
261          * VFS inode. This is consumed by vvp.
262          */
263         struct inode             *coc_inode;
264         /**
265          * Layout lock handle.
266          */
267         struct ldlm_lock         *coc_lock;
268         /**
269          * Operation to handle layout, OBJECT_CONF_XYZ.
270          */
271         int                       coc_opc;
272 };
273
274 enum {
275         /** configure layout, set up a new stripe, must be called while
276          * holding layout lock. */
277         OBJECT_CONF_SET = 0,
278         /** invalidate the current stripe configuration due to losing
279          * layout lock. */
280         OBJECT_CONF_INVALIDATE = 1,
281         /** wait for old layout to go away so that new layout can be
282          * set up. */
283         OBJECT_CONF_WAIT = 2
284 };
285
286 enum {
287         CL_LAYOUT_GEN_NONE      = (u32)-2,      /* layout lock was cancelled */
288         CL_LAYOUT_GEN_EMPTY     = (u32)-1,      /* for empty layout */
289 };
290
291 struct cl_layout {
292         /** the buffer to return the layout in lov_mds_md format. */
293         struct lu_buf   cl_buf;
294         /** size of layout in lov_mds_md format. */
295         size_t          cl_size;
296         /** size of DoM component if exists or zero otherwise */
297         u64             cl_dom_comp_size;
298         /** Layout generation. */
299         u32             cl_layout_gen;
300         /** whether layout is a composite one */
301         bool            cl_is_composite;
302 };
303
304 /**
305  * Operations implemented for each cl object layer.
306  *
307  * \see vvp_ops, lov_ops, lovsub_ops, osc_ops
308  */
309 struct cl_object_operations {
310         /**
311          * Initialize page slice for this layer. Called top-to-bottom through
312          * every object layer when a new cl_page is instantiated. Layer
313          * keeping private per-page data, or requiring its own page operations
314          * vector should allocate these data here, and attach then to the page
315          * by calling cl_page_slice_add(). \a vmpage is locked (in the VM
316          * sense). Optional.
317          *
318          * \retval NULL success.
319          *
320          * \retval ERR_PTR(errno) failure code.
321          *
322          * \retval valid-pointer pointer to already existing referenced page
323          *         to be used instead of newly created.
324          */
325         int  (*coo_page_init)(const struct lu_env *env, struct cl_object *obj,
326                                 struct cl_page *page, pgoff_t index);
327         /**
328          * Initialize lock slice for this layer. Called top-to-bottom through
329          * every object layer when a new cl_lock is instantiated. Layer
330          * keeping private per-lock data, or requiring its own lock operations
331          * vector should allocate these data here, and attach then to the lock
332          * by calling cl_lock_slice_add(). Mandatory.
333          */
334         int  (*coo_lock_init)(const struct lu_env *env,
335                               struct cl_object *obj, struct cl_lock *lock,
336                               const struct cl_io *io);
337         /**
338          * Initialize io state for a given layer.
339          *
340          * called top-to-bottom once per io existence to initialize io
341          * state. If layer wants to keep some state for this type of io, it
342          * has to embed struct cl_io_slice in lu_env::le_ses, and register
343          * slice with cl_io_slice_add(). It is guaranteed that all threads
344          * participating in this io share the same session.
345          */
346         int  (*coo_io_init)(const struct lu_env *env,
347                             struct cl_object *obj, struct cl_io *io);
348         /**
349          * Fill portion of \a attr that this layer controls. This method is
350          * called top-to-bottom through all object layers.
351          *
352          * \pre cl_object_header::coh_attr_guard of the top-object is locked.
353          *
354          * \return   0: to continue
355          * \return +ve: to stop iterating through layers (but 0 is returned
356          *              from enclosing cl_object_attr_get())
357          * \return -ve: to signal error
358          */
359         int (*coo_attr_get)(const struct lu_env *env, struct cl_object *obj,
360                             struct cl_attr *attr);
361         /**
362          * Update attributes.
363          *
364          * \a valid is a bitmask composed from enum #cl_attr_valid, and
365          * indicating what attributes are to be set.
366          *
367          * \pre cl_object_header::coh_attr_guard of the top-object is locked.
368          *
369          * \return the same convention as for
370          * cl_object_operations::coo_attr_get() is used.
371          */
372         int (*coo_attr_update)(const struct lu_env *env, struct cl_object *obj,
373                                const struct cl_attr *attr, unsigned valid);
374         /**
375          * Update object configuration. Called top-to-bottom to modify object
376          * configuration.
377          *
378          * XXX error conditions and handling.
379          */
380         int (*coo_conf_set)(const struct lu_env *env, struct cl_object *obj,
381                             const struct cl_object_conf *conf);
382         /**
383          * Glimpse ast. Executed when glimpse ast arrives for a lock on this
384          * object. Layers are supposed to fill parts of \a lvb that will be
385          * shipped to the glimpse originator as a glimpse result.
386          *
387          * \see vvp_object_glimpse(), lovsub_object_glimpse(),
388          * \see osc_object_glimpse()
389          */
390         int (*coo_glimpse)(const struct lu_env *env,
391                            const struct cl_object *obj, struct ost_lvb *lvb);
392         /**
393          * Object prune method. Called when the layout is going to change on
394          * this object, therefore each layer has to clean up their cache,
395          * mainly pages and locks.
396          */
397         int (*coo_prune)(const struct lu_env *env, struct cl_object *obj);
398         /**
399          * Object getstripe method.
400          */
401         int (*coo_getstripe)(const struct lu_env *env, struct cl_object *obj,
402                              struct lov_user_md __user *lum, size_t size);
403         /**
404          * Get FIEMAP mapping from the object.
405          */
406         int (*coo_fiemap)(const struct lu_env *env, struct cl_object *obj,
407                           struct ll_fiemap_info_key *fmkey,
408                           struct fiemap *fiemap, size_t *buflen);
409         /**
410          * Get layout and generation of the object.
411          */
412         int (*coo_layout_get)(const struct lu_env *env, struct cl_object *obj,
413                               struct cl_layout *layout);
414         /**
415          * Get maximum size of the object.
416          */
417         loff_t (*coo_maxbytes)(struct cl_object *obj);
418         /**
419          * Set request attributes.
420          */
421         void (*coo_req_attr_set)(const struct lu_env *env,
422                                  struct cl_object *obj,
423                                  struct cl_req_attr *attr);
424 };
425
426 /**
427  * Extended header for client object.
428  */
429 struct cl_object_header {
430         /** Standard lu_object_header. cl_object::co_lu::lo_header points
431          * here. */
432         struct lu_object_header coh_lu;
433
434         /**
435          * Parent object. It is assumed that an object has a well-defined
436          * parent, but not a well-defined child (there may be multiple
437          * sub-objects, for the same top-object). cl_object_header::coh_parent
438          * field allows certain code to be written generically, without
439          * limiting possible cl_object layouts unduly.
440          */
441         struct cl_object_header *coh_parent;
442         /**
443          * Protects consistency between cl_attr of parent object and
444          * attributes of sub-objects, that the former is calculated ("merged")
445          * from.
446          *
447          * \todo XXX this can be read/write lock if needed.
448          */
449         spinlock_t               coh_attr_guard;
450         /**
451          * Size of cl_page + page slices
452          */
453         unsigned short           coh_page_bufsize;
454         /**
455          * Number of objects above this one: 0 for a top-object, 1 for its
456          * sub-object, etc.
457          */
458         unsigned char            coh_nesting;
459 };
460
461 /**
462  * Helper macro: iterate over all layers of the object \a obj, assigning every
463  * layer top-to-bottom to \a slice.
464  */
465 #define cl_object_for_each(slice, obj)                          \
466         list_for_each_entry((slice),                            \
467                             &(obj)->co_lu.lo_header->loh_layers,\
468                             co_lu.lo_linkage)
469
470 /**
471  * Helper macro: iterate over all layers of the object \a obj, assigning every
472  * layer bottom-to-top to \a slice.
473  */
474 #define cl_object_for_each_reverse(slice, obj)                          \
475         list_for_each_entry_reverse((slice),                            \
476                                     &(obj)->co_lu.lo_header->loh_layers,\
477                                     co_lu.lo_linkage)
478
479 /** @} cl_object */
480
481 #define CL_PAGE_EOF ((pgoff_t)~0ull)
482
483 /** \addtogroup cl_page cl_page
484  * @{ */
485
486 /** \struct cl_page
487  * Layered client page.
488  *
489  * cl_page: represents a portion of a file, cached in the memory. All pages
490  *    of the given file are of the same size, and are kept in the radix tree
491  *    hanging off the cl_object. cl_page doesn't fan out, but as sub-objects
492  *    of the top-level file object are first class cl_objects, they have their
493  *    own radix trees of pages and hence page is implemented as a sequence of
494  *    struct cl_pages's, linked into double-linked list through
495  *    cl_page::cp_parent and cl_page::cp_child pointers, each residing in the
496  *    corresponding radix tree at the corresponding logical offset.
497  *
498  * cl_page is associated with VM page of the hosting environment (struct
499  *    page in Linux kernel, for example), struct page. It is assumed, that this
500  *    association is implemented by one of cl_page layers (top layer in the
501  *    current design) that
502  *
503  *        - intercepts per-VM-page call-backs made by the environment (e.g.,
504  *          memory pressure),
505  *
506  *        - translates state (page flag bits) and locking between lustre and
507  *          environment.
508  *
509  *    The association between cl_page and struct page is immutable and
510  *    established when cl_page is created.
511  *
512  * cl_page can be "owned" by a particular cl_io (see below), guaranteeing
513  *    this io an exclusive access to this page w.r.t. other io attempts and
514  *    various events changing page state (such as transfer completion, or
515  *    eviction of the page from the memory). Note, that in general cl_io
516  *    cannot be identified with a particular thread, and page ownership is not
517  *    exactly equal to the current thread holding a lock on the page. Layer
518  *    implementing association between cl_page and struct page has to implement
519  *    ownership on top of available synchronization mechanisms.
520  *
521  *    While lustre client maintains the notion of an page ownership by io,
522  *    hosting MM/VM usually has its own page concurrency control
523  *    mechanisms. For example, in Linux, page access is synchronized by the
524  *    per-page PG_locked bit-lock, and generic kernel code (generic_file_*())
525  *    takes care to acquire and release such locks as necessary around the
526  *    calls to the file system methods (->readpage(), ->prepare_write(),
527  *    ->commit_write(), etc.). This leads to the situation when there are two
528  *    different ways to own a page in the client:
529  *
530  *        - client code explicitly and voluntary owns the page (cl_page_own());
531  *
532  *        - VM locks a page and then calls the client, that has "to assume"
533  *          the ownership from the VM (cl_page_assume()).
534  *
535  *    Dual methods to release ownership are cl_page_disown() and
536  *    cl_page_unassume().
537  *
538  * cl_page is reference counted (cl_page::cp_ref). When reference counter
539  *    drops to 0, the page is returned to the cache, unless it is in
540  *    cl_page_state::CPS_FREEING state, in which case it is immediately
541  *    destroyed.
542  *
543  *    The general logic guaranteeing the absence of "existential races" for
544  *    pages is the following:
545  *
546  *        - there are fixed known ways for a thread to obtain a new reference
547  *          to a page:
548  *
549  *            - by doing a lookup in the cl_object radix tree, protected by the
550  *              spin-lock;
551  *
552  *            - by starting from VM-locked struct page and following some
553  *              hosting environment method (e.g., following ->private pointer in
554  *              the case of Linux kernel), see cl_vmpage_page();
555  *
556  *        - when the page enters cl_page_state::CPS_FREEING state, all these
557  *          ways are severed with the proper synchronization
558  *          (cl_page_delete());
559  *
560  *        - entry into cl_page_state::CPS_FREEING is serialized by the VM page
561  *          lock;
562  *
563  *        - no new references to the page in cl_page_state::CPS_FREEING state
564  *          are allowed (checked in cl_page_get()).
565  *
566  *    Together this guarantees that when last reference to a
567  *    cl_page_state::CPS_FREEING page is released, it is safe to destroy the
568  *    page, as neither references to it can be acquired at that point, nor
569  *    ones exist.
570  *
571  * cl_page is a state machine. States are enumerated in enum
572  *    cl_page_state. Possible state transitions are enumerated in
573  *    cl_page_state_set(). State transition process (i.e., actual changing of
574  *    cl_page::cp_state field) is protected by the lock on the underlying VM
575  *    page.
576  *
577  * Linux Kernel implementation.
578  *
579  *    Binding between cl_page and struct page (which is a typedef for
580  *    struct page) is implemented in the vvp layer. cl_page is attached to the
581  *    ->private pointer of the struct page, together with the setting of
582  *    PG_private bit in page->flags, and acquiring additional reference on the
583  *    struct page (much like struct buffer_head, or any similar file system
584  *    private data structures).
585  *
586  *    PG_locked lock is used to implement both ownership and transfer
587  *    synchronization, that is, page is VM-locked in CPS_{OWNED,PAGE{IN,OUT}}
588  *    states. No additional references are acquired for the duration of the
589  *    transfer.
590  *
591  * \warning *THIS IS NOT* the behavior expected by the Linux kernel, where
592  *          write-out is "protected" by the special PG_writeback bit.
593  */
594
595 /**
596  * States of cl_page. cl_page.c assumes particular order here.
597  *
598  * The page state machine is rather crude, as it doesn't recognize finer page
599  * states like "dirty" or "up to date". This is because such states are not
600  * always well defined for the whole stack (see, for example, the
601  * implementation of the read-ahead, that hides page up-to-dateness to track
602  * cache hits accurately). Such sub-states are maintained by the layers that
603  * are interested in them.
604  */
605 enum cl_page_state {
606         /**
607          * Page is in the cache, un-owned. Page leaves cached state in the
608          * following cases:
609          *
610          *     - [cl_page_state::CPS_OWNED] io comes across the page and
611          *     owns it;
612          *
613          *     - [cl_page_state::CPS_PAGEOUT] page is dirty, the
614          *     req-formation engine decides that it wants to include this page
615          *     into an RPC being constructed, and yanks it from the cache;
616          *
617          *     - [cl_page_state::CPS_FREEING] VM callback is executed to
618          *     evict the page form the memory;
619          *
620          * \invariant cl_page::cp_owner == NULL && cl_page::cp_req == NULL
621          */
622         CPS_CACHED,
623         /**
624          * Page is exclusively owned by some cl_io. Page may end up in this
625          * state as a result of
626          *
627          *     - io creating new page and immediately owning it;
628          *
629          *     - [cl_page_state::CPS_CACHED] io finding existing cached page
630          *     and owning it;
631          *
632          *     - [cl_page_state::CPS_OWNED] io finding existing owned page
633          *     and waiting for owner to release the page;
634          *
635          * Page leaves owned state in the following cases:
636          *
637          *     - [cl_page_state::CPS_CACHED] io decides to leave the page in
638          *     the cache, doing nothing;
639          *
640          *     - [cl_page_state::CPS_PAGEIN] io starts read transfer for
641          *     this page;
642          *
643          *     - [cl_page_state::CPS_PAGEOUT] io starts immediate write
644          *     transfer for this page;
645          *
646          *     - [cl_page_state::CPS_FREEING] io decides to destroy this
647          *     page (e.g., as part of truncate or extent lock cancellation).
648          *
649          * \invariant cl_page::cp_owner != NULL && cl_page::cp_req == NULL
650          */
651         CPS_OWNED,
652         /**
653          * Page is being written out, as a part of a transfer. This state is
654          * entered when req-formation logic decided that it wants this page to
655          * be sent through the wire _now_. Specifically, it means that once
656          * this state is achieved, transfer completion handler (with either
657          * success or failure indication) is guaranteed to be executed against
658          * this page independently of any locks and any scheduling decisions
659          * made by the hosting environment (that effectively means that the
660          * page is never put into cl_page_state::CPS_PAGEOUT state "in
661          * advance". This property is mentioned, because it is important when
662          * reasoning about possible dead-locks in the system). The page can
663          * enter this state as a result of
664          *
665          *     - [cl_page_state::CPS_OWNED] an io requesting an immediate
666          *     write-out of this page, or
667          *
668          *     - [cl_page_state::CPS_CACHED] req-forming engine deciding
669          *     that it has enough dirty pages cached to issue a "good"
670          *     transfer.
671          *
672          * The page leaves cl_page_state::CPS_PAGEOUT state when the transfer
673          * is completed---it is moved into cl_page_state::CPS_CACHED state.
674          *
675          * Underlying VM page is locked for the duration of transfer.
676          *
677          * \invariant: cl_page::cp_owner == NULL && cl_page::cp_req != NULL
678          */
679         CPS_PAGEOUT,
680         /**
681          * Page is being read in, as a part of a transfer. This is quite
682          * similar to the cl_page_state::CPS_PAGEOUT state, except that
683          * read-in is always "immediate"---there is no such thing a sudden
684          * construction of read request from cached, presumably not up to date,
685          * pages.
686          *
687          * Underlying VM page is locked for the duration of transfer.
688          *
689          * \invariant: cl_page::cp_owner == NULL && cl_page::cp_req != NULL
690          */
691         CPS_PAGEIN,
692         /**
693          * Page is being destroyed. This state is entered when client decides
694          * that page has to be deleted from its host object, as, e.g., a part
695          * of truncate.
696          *
697          * Once this state is reached, there is no way to escape it.
698          *
699          * \invariant: cl_page::cp_owner == NULL && cl_page::cp_req == NULL
700          */
701         CPS_FREEING,
702         CPS_NR
703 };
704
705 enum cl_page_type {
706         /** Host page, the page is from the host inode which the cl_page
707          * belongs to. */
708         CPT_CACHEABLE = 1,
709
710         /** Transient page, the transient cl_page is used to bind a cl_page
711          *  to vmpage which is not belonging to the same object of cl_page.
712          *  it is used in DirectIO and lockless IO. */
713         CPT_TRANSIENT,
714 };
715
716 /**
717  * Fields are protected by the lock on struct page, except for atomics and
718  * immutables.
719  *
720  * \invariant Data type invariants are in cl_page_invariant(). Basically:
721  * cl_page::cp_parent and cl_page::cp_child are a well-formed double-linked
722  * list, consistent with the parent/child pointers in the cl_page::cp_obj and
723  * cl_page::cp_owner (when set).
724  */
725 struct cl_page {
726         /** Reference counter. */
727         atomic_t                 cp_ref;
728         /** An object this page is a part of. Immutable after creation. */
729         struct cl_object        *cp_obj;
730         /** vmpage */
731         struct page             *cp_vmpage;
732         /** Linkage of pages within group. Pages must be owned */
733         struct list_head         cp_batch;
734         /** List of slices. Immutable after creation. */
735         struct list_head         cp_layers;
736         /**
737          * Page state. This field is const to avoid accidental update, it is
738          * modified only internally within cl_page.c. Protected by a VM lock.
739          */
740         const enum cl_page_state cp_state;
741         /**
742          * Page type. Only CPT_TRANSIENT is used so far. Immutable after
743          * creation.
744          */
745         enum cl_page_type        cp_type;
746
747         /**
748          * Owning IO in cl_page_state::CPS_OWNED state. Sub-page can be owned
749          * by sub-io. Protected by a VM lock.
750          */
751         struct cl_io            *cp_owner;
752         /** List of references to this page, for debugging. */
753         struct lu_ref            cp_reference;
754         /** Link to an object, for debugging. */
755         struct lu_ref_link       cp_obj_ref;
756         /** Link to a queue, for debugging. */
757         struct lu_ref_link       cp_queue_ref;
758         /** Assigned if doing a sync_io */
759         struct cl_sync_io       *cp_sync_io;
760 };
761
762 /**
763  * Per-layer part of cl_page.
764  *
765  * \see vvp_page, lov_page, osc_page
766  */
767 struct cl_page_slice {
768         struct cl_page                  *cpl_page;
769         pgoff_t                          cpl_index;
770         /**
771          * Object slice corresponding to this page slice. Immutable after
772          * creation.
773          */
774         struct cl_object                *cpl_obj;
775         const struct cl_page_operations *cpl_ops;
776         /** Linkage into cl_page::cp_layers. Immutable after creation. */
777         struct list_head                 cpl_linkage;
778 };
779
780 /**
781  * Lock mode. For the client extent locks.
782  *
783  * \ingroup cl_lock
784  */
785 enum cl_lock_mode {
786         CLM_READ,
787         CLM_WRITE,
788         CLM_GROUP,
789         CLM_MAX,
790 };
791
792 /**
793  * Requested transfer type.
794  */
795 enum cl_req_type {
796         CRT_READ,
797         CRT_WRITE,
798         CRT_NR
799 };
800
801 /**
802  * Per-layer page operations.
803  *
804  * Methods taking an \a io argument are for the activity happening in the
805  * context of given \a io. Page is assumed to be owned by that io, except for
806  * the obvious cases (like cl_page_operations::cpo_own()).
807  *
808  * \see vvp_page_ops, lov_page_ops, osc_page_ops
809  */
810 struct cl_page_operations {
811         /**
812          * cl_page<->struct page methods. Only one layer in the stack has to
813          * implement these. Current code assumes that this functionality is
814          * provided by the topmost layer, see cl_page_disown0() as an example.
815          */
816
817         /**
818          * Called when \a io acquires this page into the exclusive
819          * ownership. When this method returns, it is guaranteed that the is
820          * not owned by other io, and no transfer is going on against
821          * it. Optional.
822          *
823          * \see cl_page_own()
824          * \see vvp_page_own(), lov_page_own()
825          */
826         int  (*cpo_own)(const struct lu_env *env,
827                         const struct cl_page_slice *slice,
828                         struct cl_io *io, int nonblock);
829         /** Called when ownership it yielded. Optional.
830          *
831          * \see cl_page_disown()
832          * \see vvp_page_disown()
833          */
834         void (*cpo_disown)(const struct lu_env *env,
835                            const struct cl_page_slice *slice, struct cl_io *io);
836         /**
837          * Called for a page that is already "owned" by \a io from VM point of
838          * view. Optional.
839          *
840          * \see cl_page_assume()
841          * \see vvp_page_assume(), lov_page_assume()
842          */
843         void (*cpo_assume)(const struct lu_env *env,
844                            const struct cl_page_slice *slice, struct cl_io *io);
845         /** Dual to cl_page_operations::cpo_assume(). Optional. Called
846          * bottom-to-top when IO releases a page without actually unlocking
847          * it.
848          *
849          * \see cl_page_unassume()
850          * \see vvp_page_unassume()
851          */
852         void (*cpo_unassume)(const struct lu_env *env,
853                              const struct cl_page_slice *slice,
854                              struct cl_io *io);
855         /**
856          * Announces whether the page contains valid data or not by \a uptodate.
857          *
858          * \see cl_page_export()
859          * \see vvp_page_export()
860          */
861         void  (*cpo_export)(const struct lu_env *env,
862                             const struct cl_page_slice *slice, int uptodate);
863         /**
864          * Checks whether underlying VM page is locked (in the suitable
865          * sense). Used for assertions.
866          *
867          * \retval    -EBUSY: page is protected by a lock of a given mode;
868          * \retval  -ENODATA: page is not protected by a lock;
869          * \retval         0: this layer cannot decide. (Should never happen.)
870          */
871         int (*cpo_is_vmlocked)(const struct lu_env *env,
872                                const struct cl_page_slice *slice);
873
874         /**
875          * Update file attributes when all we have is this page.  Used for tiny
876          * writes to update attributes when we don't have a full cl_io.
877          */
878         void (*cpo_page_touch)(const struct lu_env *env,
879                                const struct cl_page_slice *slice, size_t to);
880         /**
881          * Page destruction.
882          */
883
884         /**
885          * Called when page is truncated from the object. Optional.
886          *
887          * \see cl_page_discard()
888          * \see vvp_page_discard(), osc_page_discard()
889          */
890         void (*cpo_discard)(const struct lu_env *env,
891                             const struct cl_page_slice *slice,
892                             struct cl_io *io);
893         /**
894          * Called when page is removed from the cache, and is about to being
895          * destroyed. Optional.
896          *
897          * \see cl_page_delete()
898          * \see vvp_page_delete(), osc_page_delete()
899          */
900         void (*cpo_delete)(const struct lu_env *env,
901                            const struct cl_page_slice *slice);
902         /** Destructor. Frees resources and slice itself. */
903         void (*cpo_fini)(const struct lu_env *env,
904                          struct cl_page_slice *slice,
905                          struct pagevec *pvec);
906         /**
907          * Optional debugging helper. Prints given page slice.
908          *
909          * \see cl_page_print()
910          */
911         int (*cpo_print)(const struct lu_env *env,
912                          const struct cl_page_slice *slice,
913                          void *cookie, lu_printer_t p);
914         /**
915          * \name transfer
916          *
917          * Transfer methods.
918          *
919          * @{
920          */
921         /**
922          * Request type dependent vector of operations.
923          *
924          * Transfer operations depend on transfer mode (cl_req_type). To avoid
925          * passing transfer mode to each and every of these methods, and to
926          * avoid branching on request type inside of the methods, separate
927          * methods for cl_req_type:CRT_READ and cl_req_type:CRT_WRITE are
928          * provided. That is, method invocation usually looks like
929          *
930          *         slice->cp_ops.io[req->crq_type].cpo_method(env, slice, ...);
931          */
932         struct {
933                 /**
934                  * Called when a page is submitted for a transfer as a part of
935                  * cl_page_list.
936                  *
937                  * \return    0         : page is eligible for submission;
938                  * \return    -EALREADY : skip this page;
939                  * \return    -ve       : error.
940                  *
941                  * \see cl_page_prep()
942                  */
943                 int  (*cpo_prep)(const struct lu_env *env,
944                                  const struct cl_page_slice *slice,
945                                  struct cl_io *io);
946                 /**
947                  * Completion handler. This is guaranteed to be eventually
948                  * fired after cl_page_operations::cpo_prep() or
949                  * cl_page_operations::cpo_make_ready() call.
950                  *
951                  * This method can be called in a non-blocking context. It is
952                  * guaranteed however, that the page involved and its object
953                  * are pinned in memory (and, hence, calling cl_page_put() is
954                  * safe).
955                  *
956                  * \see cl_page_completion()
957                  */
958                 void (*cpo_completion)(const struct lu_env *env,
959                                        const struct cl_page_slice *slice,
960                                        int ioret);
961                 /**
962                  * Called when cached page is about to be added to the
963                  * ptlrpc request as a part of req formation.
964                  *
965                  * \return    0       : proceed with this page;
966                  * \return    -EAGAIN : skip this page;
967                  * \return    -ve     : error.
968                  *
969                  * \see cl_page_make_ready()
970                  */
971                 int  (*cpo_make_ready)(const struct lu_env *env,
972                                        const struct cl_page_slice *slice);
973         } io[CRT_NR];
974         /**
975          * Tell transfer engine that only [to, from] part of a page should be
976          * transmitted.
977          *
978          * This is used for immediate transfers.
979          *
980          * \todo XXX this is not very good interface. It would be much better
981          * if all transfer parameters were supplied as arguments to
982          * cl_io_operations::cio_submit() call, but it is not clear how to do
983          * this for page queues.
984          *
985          * \see cl_page_clip()
986          */
987         void (*cpo_clip)(const struct lu_env *env,
988                          const struct cl_page_slice *slice,
989                          int from, int to);
990         /**
991          * \pre  the page was queued for transferring.
992          * \post page is removed from client's pending list, or -EBUSY
993          *       is returned if it has already been in transferring.
994          *
995          * This is one of seldom page operation which is:
996          * 0. called from top level;
997          * 1. don't have vmpage locked;
998          * 2. every layer should synchronize execution of its ->cpo_cancel()
999          *    with completion handlers. Osc uses client obd lock for this
1000          *    purpose. Based on there is no vvp_page_cancel and
1001          *    lov_page_cancel(), cpo_cancel is defacto protected by client lock.
1002          *
1003          * \see osc_page_cancel().
1004          */
1005         int (*cpo_cancel)(const struct lu_env *env,
1006                           const struct cl_page_slice *slice);
1007         /**
1008          * Write out a page by kernel. This is only called by ll_writepage
1009          * right now.
1010          *
1011          * \see cl_page_flush()
1012          */
1013         int (*cpo_flush)(const struct lu_env *env,
1014                          const struct cl_page_slice *slice,
1015                          struct cl_io *io);
1016         /** @} transfer */
1017 };
1018
1019 /**
1020  * Helper macro, dumping detailed information about \a page into a log.
1021  */
1022 #define CL_PAGE_DEBUG(mask, env, page, format, ...)                     \
1023 do {                                                                    \
1024         if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) {                   \
1025                 LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, NULL);        \
1026                 cl_page_print(env, &msgdata, lu_cdebug_printer, page);  \
1027                 CDEBUG(mask, format , ## __VA_ARGS__);                  \
1028         }                                                               \
1029 } while (0)
1030
1031 /**
1032  * Helper macro, dumping shorter information about \a page into a log.
1033  */
1034 #define CL_PAGE_HEADER(mask, env, page, format, ...)                          \
1035 do {                                                                          \
1036         if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) {                         \
1037                 LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, NULL);              \
1038                 cl_page_header_print(env, &msgdata, lu_cdebug_printer, page); \
1039                 CDEBUG(mask, format , ## __VA_ARGS__);                        \
1040         }                                                                     \
1041 } while (0)
1042
1043 static inline struct page *cl_page_vmpage(const struct cl_page *page)
1044 {
1045         LASSERT(page->cp_vmpage != NULL);
1046         return page->cp_vmpage;
1047 }
1048
1049 /**
1050  * Check if a cl_page is in use.
1051  *
1052  * Client cache holds a refcount, this refcount will be dropped when
1053  * the page is taken out of cache, see vvp_page_delete().
1054  */
1055 static inline bool __page_in_use(const struct cl_page *page, int refc)
1056 {
1057         return (atomic_read(&page->cp_ref) > refc + 1);
1058 }
1059
1060 /**
1061  * Caller itself holds a refcount of cl_page.
1062  */
1063 #define cl_page_in_use(pg)       __page_in_use(pg, 1)
1064 /**
1065  * Caller doesn't hold a refcount.
1066  */
1067 #define cl_page_in_use_noref(pg) __page_in_use(pg, 0)
1068
1069 /** @} cl_page */
1070
1071 /** \addtogroup cl_lock cl_lock
1072  * @{ */
1073 /** \struct cl_lock
1074  *
1075  * Extent locking on the client.
1076  *
1077  * LAYERING
1078  *
1079  * The locking model of the new client code is built around
1080  *
1081  *        struct cl_lock
1082  *
1083  * data-type representing an extent lock on a regular file. cl_lock is a
1084  * layered object (much like cl_object and cl_page), it consists of a header
1085  * (struct cl_lock) and a list of layers (struct cl_lock_slice), linked to
1086  * cl_lock::cll_layers list through cl_lock_slice::cls_linkage.
1087  *
1088  * Typical cl_lock consists of one layer:
1089  *
1090  *     - lov_lock (lov specific data).
1091  *
1092  * lov_lock contains an array of sub-locks. Each of these sub-locks is a
1093  * normal cl_lock: it has a header (struct cl_lock) and a list of layers:
1094  *
1095  *     - osc_lock
1096  *
1097  * Each sub-lock is associated with a cl_object (representing stripe
1098  * sub-object or the file to which top-level cl_lock is associated to), and is
1099  * linked into that cl_object::coh_locks. In this respect cl_lock is similar to
1100  * cl_object (that at lov layer also fans out into multiple sub-objects), and
1101  * is different from cl_page, that doesn't fan out (there is usually exactly
1102  * one osc_page for every vvp_page). We shall call vvp-lov portion of the lock
1103  * a "top-lock" and its lovsub-osc portion a "sub-lock".
1104  *
1105  * LIFE CYCLE
1106  *
1107  * cl_lock is a cacheless data container for the requirements of locks to
1108  * complete the IO. cl_lock is created before I/O starts and destroyed when the
1109  * I/O is complete.
1110  *
1111  * cl_lock depends on LDLM lock to fulfill lock semantics. LDLM lock is attached
1112  * to cl_lock at OSC layer. LDLM lock is still cacheable.
1113  *
1114  * INTERFACE AND USAGE
1115  *
1116  * Two major methods are supported for cl_lock: clo_enqueue and clo_cancel.  A
1117  * cl_lock is enqueued by cl_lock_request(), which will call clo_enqueue()
1118  * methods for each layer to enqueue the lock. At the LOV layer, if a cl_lock
1119  * consists of multiple sub cl_locks, each sub locks will be enqueued
1120  * correspondingly. At OSC layer, the lock enqueue request will tend to reuse
1121  * cached LDLM lock; otherwise a new LDLM lock will have to be requested from
1122  * OST side.
1123  *
1124  * cl_lock_cancel() must be called to release a cl_lock after use. clo_cancel()
1125  * method will be called for each layer to release the resource held by this
1126  * lock. At OSC layer, the reference count of LDLM lock, which is held at
1127  * clo_enqueue time, is released.
1128  *
1129  * LDLM lock can only be canceled if there is no cl_lock using it.
1130  *
1131  * Overall process of the locking during IO operation is as following:
1132  *
1133  *     - once parameters for IO are setup in cl_io, cl_io_operations::cio_lock()
1134  *       is called on each layer. Responsibility of this method is to add locks,
1135  *       needed by a given layer into cl_io.ci_lockset.
1136  *
1137  *     - once locks for all layers were collected, they are sorted to avoid
1138  *       dead-locks (cl_io_locks_sort()), and enqueued.
1139  *
1140  *     - when all locks are acquired, IO is performed;
1141  *
1142  *     - locks are released after IO is complete.
1143  *
1144  * Striping introduces major additional complexity into locking. The
1145  * fundamental problem is that it is generally unsafe to actively use (hold)
1146  * two locks on the different OST servers at the same time, as this introduces
1147  * inter-server dependency and can lead to cascading evictions.
1148  *
1149  * Basic solution is to sub-divide large read/write IOs into smaller pieces so
1150  * that no multi-stripe locks are taken (note that this design abandons POSIX
1151  * read/write semantics). Such pieces ideally can be executed concurrently. At
1152  * the same time, certain types of IO cannot be sub-divived, without
1153  * sacrificing correctness. This includes:
1154  *
1155  *  - O_APPEND write, where [0, EOF] lock has to be taken, to guarantee
1156  *  atomicity;
1157  *
1158  *  - ftruncate(fd, offset), where [offset, EOF] lock has to be taken.
1159  *
1160  * Also, in the case of read(fd, buf, count) or write(fd, buf, count), where
1161  * buf is a part of memory mapped Lustre file, a lock or locks protecting buf
1162  * has to be held together with the usual lock on [offset, offset + count].
1163  *
1164  * Interaction with DLM
1165  *
1166  * In the expected setup, cl_lock is ultimately backed up by a collection of
1167  * DLM locks (struct ldlm_lock). Association between cl_lock and DLM lock is
1168  * implemented in osc layer, that also matches DLM events (ASTs, cancellation,
1169  * etc.) into cl_lock_operation calls. See struct osc_lock for a more detailed
1170  * description of interaction with DLM.
1171  */
1172
1173 /**
1174  * Lock description.
1175  */
1176 struct cl_lock_descr {
1177         /** Object this lock is granted for. */
1178         struct cl_object *cld_obj;
1179         /** Index of the first page protected by this lock. */
1180         pgoff_t           cld_start;
1181         /** Index of the last page (inclusive) protected by this lock. */
1182         pgoff_t           cld_end;
1183         /** Group ID, for group lock */
1184         __u64             cld_gid;
1185         /** Lock mode. */
1186         enum cl_lock_mode cld_mode;
1187         /**
1188          * flags to enqueue lock. A combination of bit-flags from
1189          * enum cl_enq_flags.
1190          */
1191         __u32             cld_enq_flags;
1192 };
1193
1194 #define DDESCR "%s(%d):[%lu, %lu]:%x"
1195 #define PDESCR(descr)                                                   \
1196         cl_lock_mode_name((descr)->cld_mode), (descr)->cld_mode,        \
1197         (descr)->cld_start, (descr)->cld_end, (descr)->cld_enq_flags
1198
1199 const char *cl_lock_mode_name(const enum cl_lock_mode mode);
1200
1201 /**
1202  * Layered client lock.
1203  */
1204 struct cl_lock {
1205         /** List of slices. Immutable after creation. */
1206         struct list_head      cll_layers;
1207         /** lock attribute, extent, cl_object, etc. */
1208         struct cl_lock_descr  cll_descr;
1209 };
1210
1211 /**
1212  * Per-layer part of cl_lock
1213  *
1214  * \see lov_lock, osc_lock
1215  */
1216 struct cl_lock_slice {
1217         struct cl_lock                  *cls_lock;
1218         /** Object slice corresponding to this lock slice. Immutable after
1219          * creation. */
1220         struct cl_object                *cls_obj;
1221         const struct cl_lock_operations *cls_ops;
1222         /** Linkage into cl_lock::cll_layers. Immutable after creation. */
1223         struct list_head                 cls_linkage;
1224 };
1225
1226 /**
1227  *
1228  * \see lov_lock_ops, osc_lock_ops
1229  */
1230 struct cl_lock_operations {
1231         /** @{ */
1232         /**
1233          * Attempts to enqueue the lock. Called top-to-bottom.
1234          *
1235          * \retval 0    this layer has enqueued the lock successfully
1236          * \retval >0   this layer has enqueued the lock, but need to wait on
1237          *              @anchor for resources
1238          * \retval -ve  failure
1239          *
1240          * \see lov_lock_enqueue(), osc_lock_enqueue()
1241          */
1242         int  (*clo_enqueue)(const struct lu_env *env,
1243                             const struct cl_lock_slice *slice,
1244                             struct cl_io *io, struct cl_sync_io *anchor);
1245         /**
1246          * Cancel a lock, release its DLM lock ref, while does not cancel the
1247          * DLM lock
1248          */
1249         void (*clo_cancel)(const struct lu_env *env,
1250                            const struct cl_lock_slice *slice);
1251         /** @} */
1252         /**
1253          * Destructor. Frees resources and the slice.
1254          *
1255          * \see lov_lock_fini(), osc_lock_fini()
1256          */
1257         void (*clo_fini)(const struct lu_env *env, struct cl_lock_slice *slice);
1258         /**
1259          * Optional debugging helper. Prints given lock slice.
1260          */
1261         int (*clo_print)(const struct lu_env *env,
1262                          void *cookie, lu_printer_t p,
1263                          const struct cl_lock_slice *slice);
1264 };
1265
1266 #define CL_LOCK_DEBUG(mask, env, lock, format, ...)                     \
1267 do {                                                                    \
1268         if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) {                   \
1269                 LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, NULL);        \
1270                 cl_lock_print(env, &msgdata, lu_cdebug_printer, lock);  \
1271                 CDEBUG(mask, format , ## __VA_ARGS__);                  \
1272         }                                                               \
1273 } while (0)
1274
1275 #define CL_LOCK_ASSERT(expr, env, lock) do {                            \
1276         if (likely(expr))                                               \
1277                 break;                                                  \
1278                                                                         \
1279         CL_LOCK_DEBUG(D_ERROR, env, lock, "failed at %s.\n", #expr);    \
1280         LBUG();                                                         \
1281 } while (0)
1282
1283 /** @} cl_lock */
1284
1285 /** \addtogroup cl_page_list cl_page_list
1286  * Page list used to perform collective operations on a group of pages.
1287  *
1288  * Pages are added to the list one by one. cl_page_list acquires a reference
1289  * for every page in it. Page list is used to perform collective operations on
1290  * pages:
1291  *
1292  *     - submit pages for an immediate transfer,
1293  *
1294  *     - own pages on behalf of certain io (waiting for each page in turn),
1295  *
1296  *     - discard pages.
1297  *
1298  * When list is finalized, it releases references on all pages it still has.
1299  *
1300  * \todo XXX concurrency control.
1301  *
1302  * @{
1303  */
1304 struct cl_page_list {
1305         unsigned                 pl_nr;
1306         struct list_head         pl_pages;
1307         struct task_struct      *pl_owner;
1308 };
1309
1310 /**
1311  * A 2-queue of pages. A convenience data-type for common use case, 2-queue
1312  * contains an incoming page list and an outgoing page list.
1313  */
1314 struct cl_2queue {
1315         struct cl_page_list c2_qin;
1316         struct cl_page_list c2_qout;
1317 };
1318
1319 /** @} cl_page_list */
1320
1321 /** \addtogroup cl_io cl_io
1322  * @{ */
1323 /** \struct cl_io
1324  * I/O
1325  *
1326  * cl_io represents a high level I/O activity like
1327  * read(2)/write(2)/truncate(2) system call, or cancellation of an extent
1328  * lock.
1329  *
1330  * cl_io is a layered object, much like cl_{object,page,lock} but with one
1331  * important distinction. We want to minimize number of calls to the allocator
1332  * in the fast path, e.g., in the case of read(2) when everything is cached:
1333  * client already owns the lock over region being read, and data are cached
1334  * due to read-ahead. To avoid allocation of cl_io layers in such situations,
1335  * per-layer io state is stored in the session, associated with the io, see
1336  * struct {vvp,lov,osc}_io for example. Sessions allocation is amortized
1337  * by using free-lists, see cl_env_get().
1338  *
1339  * There is a small predefined number of possible io types, enumerated in enum
1340  * cl_io_type.
1341  *
1342  * cl_io is a state machine, that can be advanced concurrently by the multiple
1343  * threads. It is up to these threads to control the concurrency and,
1344  * specifically, to detect when io is done, and its state can be safely
1345  * released.
1346  *
1347  * For read/write io overall execution plan is as following:
1348  *
1349  *     (0) initialize io state through all layers;
1350  *
1351  *     (1) loop: prepare chunk of work to do
1352  *
1353  *     (2) call all layers to collect locks they need to process current chunk
1354  *
1355  *     (3) sort all locks to avoid dead-locks, and acquire them
1356  *
1357  *     (4) process the chunk: call per-page methods
1358  *         cl_io_operations::cio_prepare_write(),
1359  *         cl_io_operations::cio_commit_write() for write)
1360  *
1361  *     (5) release locks
1362  *
1363  *     (6) repeat loop.
1364  *
1365  * To implement the "parallel IO mode", lov layer creates sub-io's (lazily to
1366  * address allocation efficiency issues mentioned above), and returns with the
1367  * special error condition from per-page method when current sub-io has to
1368  * block. This causes io loop to be repeated, and lov switches to the next
1369  * sub-io in its cl_io_operations::cio_iter_init() implementation.
1370  */
1371
1372 /** IO types */
1373 enum cl_io_type {
1374         /** read system call */
1375         CIT_READ = 1,
1376         /** write system call */
1377         CIT_WRITE,
1378         /** truncate, utime system calls */
1379         CIT_SETATTR,
1380         /** get data version */
1381         CIT_DATA_VERSION,
1382         /**
1383          * page fault handling
1384          */
1385         CIT_FAULT,
1386         /**
1387          * fsync system call handling
1388          * To write out a range of file
1389          */
1390         CIT_FSYNC,
1391         /**
1392          * glimpse. An io context to acquire glimpse lock.
1393          */
1394         CIT_GLIMPSE,
1395         /**
1396          * Miscellaneous io. This is used for occasional io activity that
1397          * doesn't fit into other types. Currently this is used for:
1398          *
1399          *     - cancellation of an extent lock. This io exists as a context
1400          *     to write dirty pages from under the lock being canceled back
1401          *     to the server;
1402          *
1403          *     - VM induced page write-out. An io context for writing page out
1404          *     for memory cleansing;
1405          *
1406          *     - grouplock. An io context to acquire group lock.
1407          *
1408          * CIT_MISC io is used simply as a context in which locks and pages
1409          * are manipulated. Such io has no internal "process", that is,
1410          * cl_io_loop() is never called for it.
1411          */
1412         CIT_MISC,
1413         /**
1414          * ladvise handling
1415          * To give advice about access of a file
1416          */
1417         CIT_LADVISE,
1418         CIT_OP_NR
1419 };
1420
1421 /**
1422  * States of cl_io state machine
1423  */
1424 enum cl_io_state {
1425         /** Not initialized. */
1426         CIS_ZERO,
1427         /** Initialized. */
1428         CIS_INIT,
1429         /** IO iteration started. */
1430         CIS_IT_STARTED,
1431         /** Locks taken. */
1432         CIS_LOCKED,
1433         /** Actual IO is in progress. */
1434         CIS_IO_GOING,
1435         /** IO for the current iteration finished. */
1436         CIS_IO_FINISHED,
1437         /** Locks released. */
1438         CIS_UNLOCKED,
1439         /** Iteration completed. */
1440         CIS_IT_ENDED,
1441         /** cl_io finalized. */
1442         CIS_FINI
1443 };
1444
1445 /**
1446  * IO state private for a layer.
1447  *
1448  * This is usually embedded into layer session data, rather than allocated
1449  * dynamically.
1450  *
1451  * \see vvp_io, lov_io, osc_io
1452  */
1453 struct cl_io_slice {
1454         struct cl_io                    *cis_io;
1455         /** corresponding object slice. Immutable after creation. */
1456         struct cl_object                *cis_obj;
1457         /** io operations. Immutable after creation. */
1458         const struct cl_io_operations   *cis_iop;
1459         /**
1460          * linkage into a list of all slices for a given cl_io, hanging off
1461          * cl_io::ci_layers. Immutable after creation.
1462          */
1463         struct list_head                cis_linkage;
1464 };
1465
1466 typedef void (*cl_commit_cbt)(const struct lu_env *, struct cl_io *,
1467                               struct cl_page *);
1468
1469 struct cl_read_ahead {
1470         /* Maximum page index the readahead window will end.
1471          * This is determined DLM lock coverage, RPC and stripe boundary.
1472          * cra_end is included. */
1473         pgoff_t cra_end;
1474         /* optimal RPC size for this read, by pages */
1475         unsigned long cra_rpc_size;
1476         /* Release callback. If readahead holds resources underneath, this
1477          * function should be called to release it. */
1478         void    (*cra_release)(const struct lu_env *env, void *cbdata);
1479         /* Callback data for cra_release routine */
1480         void    *cra_cbdata;
1481 };
1482
1483 static inline void cl_read_ahead_release(const struct lu_env *env,
1484                                          struct cl_read_ahead *ra)
1485 {
1486         if (ra->cra_release != NULL)
1487                 ra->cra_release(env, ra->cra_cbdata);
1488         memset(ra, 0, sizeof(*ra));
1489 }
1490
1491
1492 /**
1493  * Per-layer io operations.
1494  * \see vvp_io_ops, lov_io_ops, lovsub_io_ops, osc_io_ops
1495  */
1496 struct cl_io_operations {
1497         /**
1498          * Vector of io state transition methods for every io type.
1499          *
1500          * \see cl_page_operations::io
1501          */
1502         struct {
1503                 /**
1504                  * Prepare io iteration at a given layer.
1505                  *
1506                  * Called top-to-bottom at the beginning of each iteration of
1507                  * "io loop" (if it makes sense for this type of io). Here
1508                  * layer selects what work it will do during this iteration.
1509                  *
1510                  * \see cl_io_operations::cio_iter_fini()
1511                  */
1512                 int (*cio_iter_init) (const struct lu_env *env,
1513                                       const struct cl_io_slice *slice);
1514                 /**
1515                  * Finalize io iteration.
1516                  *
1517                  * Called bottom-to-top at the end of each iteration of "io
1518                  * loop". Here layers can decide whether IO has to be
1519                  * continued.
1520                  *
1521                  * \see cl_io_operations::cio_iter_init()
1522                  */
1523                 void (*cio_iter_fini) (const struct lu_env *env,
1524                                        const struct cl_io_slice *slice);
1525                 /**
1526                  * Collect locks for the current iteration of io.
1527                  *
1528                  * Called top-to-bottom to collect all locks necessary for
1529                  * this iteration. This methods shouldn't actually enqueue
1530                  * anything, instead it should post a lock through
1531                  * cl_io_lock_add(). Once all locks are collected, they are
1532                  * sorted and enqueued in the proper order.
1533                  */
1534                 int  (*cio_lock) (const struct lu_env *env,
1535                                   const struct cl_io_slice *slice);
1536                 /**
1537                  * Finalize unlocking.
1538                  *
1539                  * Called bottom-to-top to finish layer specific unlocking
1540                  * functionality, after generic code released all locks
1541                  * acquired by cl_io_operations::cio_lock().
1542                  */
1543                 void  (*cio_unlock)(const struct lu_env *env,
1544                                     const struct cl_io_slice *slice);
1545                 /**
1546                  * Start io iteration.
1547                  *
1548                  * Once all locks are acquired, called top-to-bottom to
1549                  * commence actual IO. In the current implementation,
1550                  * top-level vvp_io_{read,write}_start() does all the work
1551                  * synchronously by calling generic_file_*(), so other layers
1552                  * are called when everything is done.
1553                  */
1554                 int  (*cio_start)(const struct lu_env *env,
1555                                   const struct cl_io_slice *slice);
1556                 /**
1557                  * Called top-to-bottom at the end of io loop. Here layer
1558                  * might wait for an unfinished asynchronous io.
1559                  */
1560                 void (*cio_end)  (const struct lu_env *env,
1561                                   const struct cl_io_slice *slice);
1562                 /**
1563                  * Called bottom-to-top to notify layers that read/write IO
1564                  * iteration finished, with \a nob bytes transferred.
1565                  */
1566                 void (*cio_advance)(const struct lu_env *env,
1567                                     const struct cl_io_slice *slice,
1568                                     size_t nob);
1569                 /**
1570                  * Called once per io, bottom-to-top to release io resources.
1571                  */
1572                 void (*cio_fini) (const struct lu_env *env,
1573                                   const struct cl_io_slice *slice);
1574         } op[CIT_OP_NR];
1575
1576         /**
1577          * Submit pages from \a queue->c2_qin for IO, and move
1578          * successfully submitted pages into \a queue->c2_qout. Return
1579          * non-zero if failed to submit even the single page. If
1580          * submission failed after some pages were moved into \a
1581          * queue->c2_qout, completion callback with non-zero ioret is
1582          * executed on them.
1583          */
1584         int  (*cio_submit)(const struct lu_env *env,
1585                         const struct cl_io_slice *slice,
1586                         enum cl_req_type crt,
1587                         struct cl_2queue *queue);
1588         /**
1589          * Queue async page for write.
1590          * The difference between cio_submit and cio_queue is that
1591          * cio_submit is for urgent request.
1592          */
1593         int  (*cio_commit_async)(const struct lu_env *env,
1594                         const struct cl_io_slice *slice,
1595                         struct cl_page_list *queue, int from, int to,
1596                         cl_commit_cbt cb);
1597         /**
1598          * Decide maximum read ahead extent
1599          *
1600          * \pre io->ci_type == CIT_READ
1601          */
1602         int (*cio_read_ahead)(const struct lu_env *env,
1603                               const struct cl_io_slice *slice,
1604                               pgoff_t start, struct cl_read_ahead *ra);
1605         /**
1606          * Optional debugging helper. Print given io slice.
1607          */
1608         int (*cio_print)(const struct lu_env *env, void *cookie,
1609                          lu_printer_t p, const struct cl_io_slice *slice);
1610 };
1611
1612 /**
1613  * Flags to lock enqueue procedure.
1614  * \ingroup cl_lock
1615  */
1616 enum cl_enq_flags {
1617         /**
1618          * instruct server to not block, if conflicting lock is found. Instead
1619          * -EWOULDBLOCK is returned immediately.
1620          */
1621         CEF_NONBLOCK     = 0x00000001,
1622         /**
1623          * Tell lower layers this is a glimpse request, translated to
1624          * LDLM_FL_HAS_INTENT at LDLM layer.
1625          *
1626          * Also, because glimpse locks never block other locks, we count this
1627          * as automatically compatible with other osc locks.
1628          * (see osc_lock_compatible)
1629          */
1630         CEF_GLIMPSE        = 0x00000002,
1631         /**
1632          * tell the server to instruct (though a flag in the blocking ast) an
1633          * owner of the conflicting lock, that it can drop dirty pages
1634          * protected by this lock, without sending them to the server.
1635          */
1636         CEF_DISCARD_DATA = 0x00000004,
1637         /**
1638          * tell the sub layers that it must be a `real' lock. This is used for
1639          * mmapped-buffer locks, glimpse locks, manually requested locks
1640          * (LU_LADVISE_LOCKAHEAD) that must never be converted into lockless
1641          * mode.
1642          *
1643          * \see vvp_mmap_locks(), cl_glimpse_lock, cl_request_lock().
1644          */
1645         CEF_MUST         = 0x00000008,
1646         /**
1647          * tell the sub layers that never request a `real' lock. This flag is
1648          * not used currently.
1649          *
1650          * cl_io::ci_lockreq and CEF_{MUST,NEVER} flags specify lockless
1651          * conversion policy: ci_lockreq describes generic information of lock
1652          * requirement for this IO, especially for locks which belong to the
1653          * object doing IO; however, lock itself may have precise requirements
1654          * that are described by the enqueue flags.
1655          */
1656         CEF_NEVER        = 0x00000010,
1657         /**
1658          * tell the dlm layer this is a speculative lock request
1659          * speculative lock requests are locks which are not requested as part
1660          * of an I/O operation.  Instead, they are requested because we expect
1661          * to use them in the future.  They are requested asynchronously at the
1662          * ptlrpc layer.
1663          *
1664          * Currently used for asynchronous glimpse locks and manually requested
1665          * locks (LU_LADVISE_LOCKAHEAD).
1666          */
1667         CEF_SPECULATIVE          = 0x00000020,
1668         /**
1669          * enqueue a lock to test DLM lock existence.
1670          */
1671         CEF_PEEK        = 0x00000040,
1672         /**
1673          * Lock match only. Used by group lock in I/O as group lock
1674          * is known to exist.
1675          */
1676         CEF_LOCK_MATCH  = 0x00000080,
1677         /**
1678          * tell the DLM layer to lock only the requested range
1679          */
1680         CEF_LOCK_NO_EXPAND    = 0x00000100,
1681         /**
1682          * mask of enq_flags.
1683          */
1684         CEF_MASK         = 0x000001ff,
1685 };
1686
1687 /**
1688  * Link between lock and io. Intermediate structure is needed, because the
1689  * same lock can be part of multiple io's simultaneously.
1690  */
1691 struct cl_io_lock_link {
1692         /** linkage into one of cl_lockset lists. */
1693         struct list_head        cill_linkage;
1694         struct cl_lock          cill_lock;
1695         /** optional destructor */
1696         void                    (*cill_fini)(const struct lu_env *env,
1697                                              struct cl_io_lock_link *link);
1698 };
1699 #define cill_descr      cill_lock.cll_descr
1700
1701 /**
1702  * Lock-set represents a collection of locks, that io needs at a
1703  * time. Generally speaking, client tries to avoid holding multiple locks when
1704  * possible, because
1705  *
1706  *      - holding extent locks over multiple ost's introduces the danger of
1707  *        "cascading timeouts";
1708  *
1709  *      - holding multiple locks over the same ost is still dead-lock prone,
1710  *        see comment in osc_lock_enqueue(),
1711  *
1712  * but there are certain situations where this is unavoidable:
1713  *
1714  *      - O_APPEND writes have to take [0, EOF] lock for correctness;
1715  *
1716  *      - truncate has to take [new-size, EOF] lock for correctness;
1717  *
1718  *      - SNS has to take locks across full stripe for correctness;
1719  *
1720  *      - in the case when user level buffer, supplied to {read,write}(file0),
1721  *        is a part of a memory mapped lustre file, client has to take a dlm
1722  *        locks on file0, and all files that back up the buffer (or a part of
1723  *        the buffer, that is being processed in the current chunk, in any
1724  *        case, there are situations where at least 2 locks are necessary).
1725  *
1726  * In such cases we at least try to take locks in the same consistent
1727  * order. To this end, all locks are first collected, then sorted, and then
1728  * enqueued.
1729  */
1730 struct cl_lockset {
1731         /** locks to be acquired. */
1732         struct list_head  cls_todo;
1733         /** locks acquired. */
1734         struct list_head  cls_done;
1735 };
1736
1737 /**
1738  * Lock requirements(demand) for IO. It should be cl_io_lock_req,
1739  * but 'req' is always to be thought as 'request' :-)
1740  */
1741 enum cl_io_lock_dmd {
1742         /** Always lock data (e.g., O_APPEND). */
1743         CILR_MANDATORY = 0,
1744         /** Layers are free to decide between local and global locking. */
1745         CILR_MAYBE,
1746         /** Never lock: there is no cache (e.g., liblustre). */
1747         CILR_NEVER
1748 };
1749
1750 enum cl_fsync_mode {
1751         /** start writeback, do not wait for them to finish */
1752         CL_FSYNC_NONE  = 0,
1753         /** start writeback and wait for them to finish */
1754         CL_FSYNC_LOCAL = 1,
1755         /** discard all of dirty pages in a specific file range */
1756         CL_FSYNC_DISCARD = 2,
1757         /** start writeback and make sure they have reached storage before
1758          * return. OST_SYNC RPC must be issued and finished */
1759         CL_FSYNC_ALL   = 3
1760 };
1761
1762 struct cl_io_range {
1763         loff_t cir_pos;
1764         size_t cir_count;
1765 };
1766
1767 struct cl_io_pt {
1768         struct cl_io_pt         *cip_next;
1769         struct cfs_ptask         cip_task;
1770         struct kiocb             cip_iocb;
1771         struct iov_iter          cip_iter;
1772         struct file             *cip_file;
1773         enum cl_io_type          cip_iot;
1774         unsigned int             cip_need_restart:1;
1775         loff_t                   cip_pos;
1776         size_t                   cip_count;
1777         ssize_t                  cip_result;
1778 };
1779
1780 /**
1781  * State for io.
1782  *
1783  * cl_io is shared by all threads participating in this IO (in current
1784  * implementation only one thread advances IO, but parallel IO design and
1785  * concurrent copy_*_user() require multiple threads acting on the same IO. It
1786  * is up to these threads to serialize their activities, including updates to
1787  * mutable cl_io fields.
1788  */
1789 struct cl_io {
1790         /** type of this IO. Immutable after creation. */
1791         enum cl_io_type                ci_type;
1792         /** current state of cl_io state machine. */
1793         enum cl_io_state               ci_state;
1794         /** main object this io is against. Immutable after creation. */
1795         struct cl_object              *ci_obj;
1796         /**
1797          * Upper layer io, of which this io is a part of. Immutable after
1798          * creation.
1799          */
1800         struct cl_io                  *ci_parent;
1801         /** List of slices. Immutable after creation. */
1802         struct list_head                ci_layers;
1803         /** list of locks (to be) acquired by this io. */
1804         struct cl_lockset              ci_lockset;
1805         /** lock requirements, this is just a help info for sublayers. */
1806         enum cl_io_lock_dmd            ci_lockreq;
1807         /** layout version when this IO occurs */
1808         __u32                           ci_layout_version;
1809         union {
1810                 struct cl_rw_io {
1811                         struct iov_iter          rw_iter;
1812                         struct kiocb             rw_iocb;
1813                         struct cl_io_range       rw_range;
1814                         struct file             *rw_file;
1815                         unsigned int             rw_nonblock:1,
1816                                                  rw_append:1,
1817                                                  rw_sync:1;
1818                         int (*rw_ptask)(struct cfs_ptask *ptask);
1819                 } ci_rw;
1820                 struct cl_setattr_io {
1821                         struct ost_lvb           sa_attr;
1822                         unsigned int             sa_attr_flags;
1823                         unsigned int             sa_avalid; /* ATTR_* */
1824                         unsigned int             sa_xvalid; /* OP_XVALID */
1825                         int                      sa_stripe_index;
1826                         struct ost_layout        sa_layout;
1827                         const struct lu_fid     *sa_parent_fid;
1828                 } ci_setattr;
1829                 struct cl_data_version_io {
1830                         u64 dv_data_version;
1831                         u32 dv_layout_version;
1832                         int dv_flags;
1833                 } ci_data_version;
1834                 struct cl_fault_io {
1835                         /** page index within file. */
1836                         pgoff_t         ft_index;
1837                         /** bytes valid byte on a faulted page. */
1838                         size_t          ft_nob;
1839                         /** writable page? for nopage() only */
1840                         int             ft_writable;
1841                         /** page of an executable? */
1842                         int             ft_executable;
1843                         /** page_mkwrite() */
1844                         int             ft_mkwrite;
1845                         /** resulting page */
1846                         struct cl_page *ft_page;
1847                 } ci_fault;
1848                 struct cl_fsync_io {
1849                         loff_t             fi_start;
1850                         loff_t             fi_end;
1851                         /** file system level fid */
1852                         struct lu_fid     *fi_fid;
1853                         enum cl_fsync_mode fi_mode;
1854                         /* how many pages were written/discarded */
1855                         unsigned int       fi_nr_written;
1856                 } ci_fsync;
1857                 struct cl_ladvise_io {
1858                         __u64                    li_start;
1859                         __u64                    li_end;
1860                         /** file system level fid */
1861                         struct lu_fid           *li_fid;
1862                         enum lu_ladvise_type     li_advice;
1863                         __u64                    li_flags;
1864                 } ci_ladvise;
1865         } u;
1866         struct cl_2queue     ci_queue;
1867         size_t               ci_nob;
1868         int                  ci_result;
1869         unsigned int         ci_continue:1,
1870         /**
1871          * This io has held grouplock, to inform sublayers that
1872          * don't do lockless i/o.
1873          */
1874                              ci_no_srvlock:1,
1875         /**
1876          * The whole IO need to be restarted because layout has been changed
1877          */
1878                              ci_need_restart:1,
1879         /**
1880          * to not refresh layout - the IO issuer knows that the layout won't
1881          * change(page operations, layout change causes all page to be
1882          * discarded), or it doesn't matter if it changes(sync).
1883          */
1884                              ci_ignore_layout:1,
1885         /**
1886          * Need MDS intervention to complete a write.
1887          * Write intent is required for the following cases:
1888          * 1. component being written is not initialized, or
1889          * 2. the mirrored files are NOT in WRITE_PENDING state.
1890          */
1891                              ci_need_write_intent:1,
1892         /**
1893          * Check if layout changed after the IO finishes. Mainly for HSM
1894          * requirement. If IO occurs to openning files, it doesn't need to
1895          * verify layout because HSM won't release openning files.
1896          * Right now, only two opertaions need to verify layout: glimpse
1897          * and setattr.
1898          */
1899                              ci_verify_layout:1,
1900         /**
1901          * file is released, restore has to to be triggered by vvp layer
1902          */
1903                              ci_restore_needed:1,
1904         /**
1905          * O_NOATIME
1906          */
1907                              ci_noatime:1,
1908         /** Set to 1 if parallel execution is allowed for current I/O? */
1909                              ci_pio:1,
1910         /* Tell sublayers not to expand LDLM locks requested for this IO */
1911                              ci_lock_no_expand:1,
1912         /**
1913          * Set if non-delay RPC should be used for this IO.
1914          *
1915          * If this file has multiple mirrors, and if the OSTs of the current
1916          * mirror is inaccessible, non-delay RPC would error out quickly so
1917          * that the upper layer can try to access the next mirror.
1918          */
1919                              ci_ndelay:1;
1920         /**
1921          * How many times the read has retried before this one.
1922          * Set by the top level and consumed by the LOV.
1923          */
1924         unsigned             ci_ndelay_tried;
1925         /**
1926          * Designated mirror index for this I/O.
1927          */
1928         unsigned             ci_designated_mirror;
1929         /**
1930          * Number of pages owned by this IO. For invariant checking.
1931          */
1932         unsigned             ci_owned_nr;
1933         /**
1934          * Range of write intent. Valid if ci_need_write_intent is set.
1935          */
1936         struct lu_extent        ci_write_intent;
1937 };
1938
1939 /** @} cl_io */
1940
1941 /**
1942  * Per-transfer attributes.
1943  */
1944 struct cl_req_attr {
1945         enum cl_req_type cra_type;
1946         u64              cra_flags;
1947         struct cl_page  *cra_page;
1948         /** Generic attributes for the server consumption. */
1949         struct obdo     *cra_oa;
1950         /** Jobid */
1951         char             cra_jobid[LUSTRE_JOBID_SIZE];
1952 };
1953
1954 enum cache_stats_item {
1955         /** how many cache lookups were performed */
1956         CS_lookup = 0,
1957         /** how many times cache lookup resulted in a hit */
1958         CS_hit,
1959         /** how many entities are in the cache right now */
1960         CS_total,
1961         /** how many entities in the cache are actively used (and cannot be
1962          * evicted) right now */
1963         CS_busy,
1964         /** how many entities were created at all */
1965         CS_create,
1966         CS_NR
1967 };
1968
1969 #define CS_NAMES { "lookup", "hit", "total", "busy", "create" }
1970
1971 /**
1972  * Stats for a generic cache (similar to inode, lu_object, etc. caches).
1973  */
1974 struct cache_stats {
1975         const char      *cs_name;
1976         atomic_t        cs_stats[CS_NR];
1977 };
1978
1979 /** These are not exported so far */
1980 void cache_stats_init (struct cache_stats *cs, const char *name);
1981
1982 /**
1983  * Client-side site. This represents particular client stack. "Global"
1984  * variables should (directly or indirectly) be added here to allow multiple
1985  * clients to co-exist in the single address space.
1986  */
1987 struct cl_site {
1988         struct lu_site          cs_lu;
1989         /**
1990          * Statistical counters. Atomics do not scale, something better like
1991          * per-cpu counters is needed.
1992          *
1993          * These are exported as /proc/fs/lustre/llite/.../site
1994          *
1995          * When interpreting keep in mind that both sub-locks (and sub-pages)
1996          * and top-locks (and top-pages) are accounted here.
1997          */
1998         struct cache_stats      cs_pages;
1999         atomic_t                cs_pages_state[CPS_NR];
2000 };
2001
2002 int  cl_site_init(struct cl_site *s, struct cl_device *top);
2003 void cl_site_fini(struct cl_site *s);
2004 void cl_stack_fini(const struct lu_env *env, struct cl_device *cl);
2005
2006 /**
2007  * Output client site statistical counters into a buffer. Suitable for
2008  * ll_rd_*()-style functions.
2009  */
2010 int cl_site_stats_print(const struct cl_site *site, struct seq_file *m);
2011
2012 /**
2013  * \name helpers
2014  *
2015  * Type conversion and accessory functions.
2016  */
2017 /** @{ */
2018
2019 static inline struct cl_site *lu2cl_site(const struct lu_site *site)
2020 {
2021         return container_of(site, struct cl_site, cs_lu);
2022 }
2023
2024 static inline struct cl_device *lu2cl_dev(const struct lu_device *d)
2025 {
2026         LASSERT(d == NULL || IS_ERR(d) || lu_device_is_cl(d));
2027         return container_of0(d, struct cl_device, cd_lu_dev);
2028 }
2029
2030 static inline struct lu_device *cl2lu_dev(struct cl_device *d)
2031 {
2032         return &d->cd_lu_dev;
2033 }
2034
2035 static inline struct cl_object *lu2cl(const struct lu_object *o)
2036 {
2037         LASSERT(o == NULL || IS_ERR(o) || lu_device_is_cl(o->lo_dev));
2038         return container_of0(o, struct cl_object, co_lu);
2039 }
2040
2041 static inline const struct cl_object_conf *
2042 lu2cl_conf(const struct lu_object_conf *conf)
2043 {
2044         return container_of0(conf, struct cl_object_conf, coc_lu);
2045 }
2046
2047 static inline struct cl_object *cl_object_next(const struct cl_object *obj)
2048 {
2049         return obj ? lu2cl(lu_object_next(&obj->co_lu)) : NULL;
2050 }
2051
2052 static inline struct cl_object_header *luh2coh(const struct lu_object_header *h)
2053 {
2054         return container_of0(h, struct cl_object_header, coh_lu);
2055 }
2056
2057 static inline struct cl_site *cl_object_site(const struct cl_object *obj)
2058 {
2059         return lu2cl_site(obj->co_lu.lo_dev->ld_site);
2060 }
2061
2062 static inline
2063 struct cl_object_header *cl_object_header(const struct cl_object *obj)
2064 {
2065         return luh2coh(obj->co_lu.lo_header);
2066 }
2067
2068 static inline int cl_device_init(struct cl_device *d, struct lu_device_type *t)
2069 {
2070         return lu_device_init(&d->cd_lu_dev, t);
2071 }
2072
2073 static inline void cl_device_fini(struct cl_device *d)
2074 {
2075         lu_device_fini(&d->cd_lu_dev);
2076 }
2077
2078 void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice,
2079                        struct cl_object *obj, pgoff_t index,
2080                        const struct cl_page_operations *ops);
2081 void cl_lock_slice_add(struct cl_lock *lock, struct cl_lock_slice *slice,
2082                        struct cl_object *obj,
2083                        const struct cl_lock_operations *ops);
2084 void cl_io_slice_add(struct cl_io *io, struct cl_io_slice *slice,
2085                      struct cl_object *obj, const struct cl_io_operations *ops);
2086 /** @} helpers */
2087
2088 /** \defgroup cl_object cl_object
2089  * @{ */
2090 struct cl_object *cl_object_top (struct cl_object *o);
2091 struct cl_object *cl_object_find(const struct lu_env *env, struct cl_device *cd,
2092                                  const struct lu_fid *fid,
2093                                  const struct cl_object_conf *c);
2094
2095 int  cl_object_header_init(struct cl_object_header *h);
2096 void cl_object_header_fini(struct cl_object_header *h);
2097 void cl_object_put        (const struct lu_env *env, struct cl_object *o);
2098 void cl_object_get        (struct cl_object *o);
2099 void cl_object_attr_lock  (struct cl_object *o);
2100 void cl_object_attr_unlock(struct cl_object *o);
2101 int  cl_object_attr_get(const struct lu_env *env, struct cl_object *obj,
2102                         struct cl_attr *attr);
2103 int  cl_object_attr_update(const struct lu_env *env, struct cl_object *obj,
2104                            const struct cl_attr *attr, unsigned valid);
2105 int  cl_object_glimpse    (const struct lu_env *env, struct cl_object *obj,
2106                            struct ost_lvb *lvb);
2107 int  cl_conf_set          (const struct lu_env *env, struct cl_object *obj,
2108                            const struct cl_object_conf *conf);
2109 int  cl_object_prune      (const struct lu_env *env, struct cl_object *obj);
2110 void cl_object_kill       (const struct lu_env *env, struct cl_object *obj);
2111 int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj,
2112                         struct lov_user_md __user *lum, size_t size);
2113 int cl_object_fiemap(const struct lu_env *env, struct cl_object *obj,
2114                      struct ll_fiemap_info_key *fmkey, struct fiemap *fiemap,
2115                      size_t *buflen);
2116 int cl_object_layout_get(const struct lu_env *env, struct cl_object *obj,
2117                          struct cl_layout *cl);
2118 loff_t cl_object_maxbytes(struct cl_object *obj);
2119
2120 /**
2121  * Returns true, iff \a o0 and \a o1 are slices of the same object.
2122  */
2123 static inline int cl_object_same(struct cl_object *o0, struct cl_object *o1)
2124 {
2125         return cl_object_header(o0) == cl_object_header(o1);
2126 }
2127
2128 static inline void cl_object_page_init(struct cl_object *clob, int size)
2129 {
2130         clob->co_slice_off = cl_object_header(clob)->coh_page_bufsize;
2131         cl_object_header(clob)->coh_page_bufsize += cfs_size_round(size);
2132         WARN_ON(cl_object_header(clob)->coh_page_bufsize > 512);
2133 }
2134
2135 static inline void *cl_object_page_slice(struct cl_object *clob,
2136                                          struct cl_page *page)
2137 {
2138         return (void *)((char *)page + clob->co_slice_off);
2139 }
2140
2141 /**
2142  * Return refcount of cl_object.
2143  */
2144 static inline int cl_object_refc(struct cl_object *clob)
2145 {
2146         struct lu_object_header *header = clob->co_lu.lo_header;
2147         return atomic_read(&header->loh_ref);
2148 }
2149
2150 /** @} cl_object */
2151
2152 /** \defgroup cl_page cl_page
2153  * @{ */
2154 enum {
2155         CLP_GANG_OKAY = 0,
2156         CLP_GANG_RESCHED,
2157         CLP_GANG_AGAIN,
2158         CLP_GANG_ABORT
2159 };
2160 /* callback of cl_page_gang_lookup() */
2161
2162 struct cl_page *cl_page_find        (const struct lu_env *env,
2163                                      struct cl_object *obj,
2164                                      pgoff_t idx, struct page *vmpage,
2165                                      enum cl_page_type type);
2166 struct cl_page *cl_page_alloc       (const struct lu_env *env,
2167                                      struct cl_object *o, pgoff_t ind,
2168                                      struct page *vmpage,
2169                                      enum cl_page_type type);
2170 void            cl_page_get         (struct cl_page *page);
2171 void            cl_page_put         (const struct lu_env *env,
2172                                      struct cl_page *page);
2173 void            cl_pagevec_put      (const struct lu_env *env,
2174                                      struct cl_page *page,
2175                                      struct pagevec *pvec);
2176 void            cl_page_print       (const struct lu_env *env, void *cookie,
2177                                      lu_printer_t printer,
2178                                      const struct cl_page *pg);
2179 void            cl_page_header_print(const struct lu_env *env, void *cookie,
2180                                      lu_printer_t printer,
2181                                      const struct cl_page *pg);
2182 struct cl_page *cl_vmpage_page      (struct page *vmpage, struct cl_object *obj);
2183 struct cl_page *cl_page_top         (struct cl_page *page);
2184
2185 const struct cl_page_slice *cl_page_at(const struct cl_page *page,
2186                                        const struct lu_device_type *dtype);
2187
2188 /**
2189  * \name ownership
2190  *
2191  * Functions dealing with the ownership of page by io.
2192  */
2193 /** @{ */
2194
2195 int  cl_page_own        (const struct lu_env *env,
2196                          struct cl_io *io, struct cl_page *page);
2197 int  cl_page_own_try    (const struct lu_env *env,
2198                          struct cl_io *io, struct cl_page *page);
2199 void cl_page_assume     (const struct lu_env *env,
2200                          struct cl_io *io, struct cl_page *page);
2201 void cl_page_unassume   (const struct lu_env *env,
2202                          struct cl_io *io, struct cl_page *pg);
2203 void cl_page_disown     (const struct lu_env *env,
2204                          struct cl_io *io, struct cl_page *page);
2205 int  cl_page_is_owned   (const struct cl_page *pg, const struct cl_io *io);
2206
2207 /** @} ownership */
2208
2209 /**
2210  * \name transfer
2211  *
2212  * Functions dealing with the preparation of a page for a transfer, and
2213  * tracking transfer state.
2214  */
2215 /** @{ */
2216 int  cl_page_prep       (const struct lu_env *env, struct cl_io *io,
2217                          struct cl_page *pg, enum cl_req_type crt);
2218 void cl_page_completion (const struct lu_env *env,
2219                          struct cl_page *pg, enum cl_req_type crt, int ioret);
2220 int  cl_page_make_ready (const struct lu_env *env, struct cl_page *pg,
2221                          enum cl_req_type crt);
2222 int  cl_page_cache_add  (const struct lu_env *env, struct cl_io *io,
2223                          struct cl_page *pg, enum cl_req_type crt);
2224 void cl_page_clip       (const struct lu_env *env, struct cl_page *pg,
2225                          int from, int to);
2226 int  cl_page_cancel     (const struct lu_env *env, struct cl_page *page);
2227 int  cl_page_flush      (const struct lu_env *env, struct cl_io *io,
2228                          struct cl_page *pg);
2229
2230 /** @} transfer */
2231
2232
2233 /**
2234  * \name helper routines
2235  * Functions to discard, delete and export a cl_page.
2236  */
2237 /** @{ */
2238 void    cl_page_discard(const struct lu_env *env, struct cl_io *io,
2239                         struct cl_page *pg);
2240 void    cl_page_delete(const struct lu_env *env, struct cl_page *pg);
2241 int     cl_page_is_vmlocked(const struct lu_env *env,
2242                             const struct cl_page *pg);
2243 void    cl_page_touch(const struct lu_env *env, const struct cl_page *pg,
2244                       size_t to);
2245 void    cl_page_export(const struct lu_env *env,
2246                        struct cl_page *pg, int uptodate);
2247 loff_t  cl_offset(const struct cl_object *obj, pgoff_t idx);
2248 pgoff_t cl_index(const struct cl_object *obj, loff_t offset);
2249 size_t  cl_page_size(const struct cl_object *obj);
2250
2251 void cl_lock_print(const struct lu_env *env, void *cookie,
2252                    lu_printer_t printer, const struct cl_lock *lock);
2253 void cl_lock_descr_print(const struct lu_env *env, void *cookie,
2254                          lu_printer_t printer,
2255                          const struct cl_lock_descr *descr);
2256 /* @} helper */
2257
2258 /**
2259  * Data structure managing a client's cached pages. A count of
2260  * "unstable" pages is maintained, and an LRU of clean pages is
2261  * maintained. "unstable" pages are pages pinned by the ptlrpc
2262  * layer for recovery purposes.
2263  */
2264 struct cl_client_cache {
2265         /**
2266          * # of client cache refcount
2267          * # of users (OSCs) + 2 (held by llite and lov)
2268          */
2269         atomic_t                ccc_users;
2270         /**
2271          * # of threads are doing shrinking
2272          */
2273         unsigned int            ccc_lru_shrinkers;
2274         /**
2275          * # of LRU entries available
2276          */
2277         atomic_long_t           ccc_lru_left;
2278         /**
2279          * List of entities(OSCs) for this LRU cache
2280          */
2281         struct list_head        ccc_lru;
2282         /**
2283          * Max # of LRU entries
2284          */
2285         unsigned long           ccc_lru_max;
2286         /**
2287          * Lock to protect ccc_lru list
2288          */
2289         spinlock_t              ccc_lru_lock;
2290         /**
2291          * Set if unstable check is enabled
2292          */
2293         unsigned int            ccc_unstable_check:1;
2294         /**
2295          * # of unstable pages for this mount point
2296          */
2297         atomic_long_t           ccc_unstable_nr;
2298         /**
2299          * Waitq for awaiting unstable pages to reach zero.
2300          * Used at umounting time and signaled on BRW commit
2301          */
2302         wait_queue_head_t       ccc_unstable_waitq;
2303 };
2304 /**
2305  * cl_cache functions
2306  */
2307 struct cl_client_cache *cl_cache_init(unsigned long lru_page_max);
2308 void cl_cache_incref(struct cl_client_cache *cache);
2309 void cl_cache_decref(struct cl_client_cache *cache);
2310
2311 /** @} cl_page */
2312
2313 /** \defgroup cl_lock cl_lock
2314  * @{ */
2315 int cl_lock_request(const struct lu_env *env, struct cl_io *io,
2316                     struct cl_lock *lock);
2317 int cl_lock_init(const struct lu_env *env, struct cl_lock *lock,
2318                  const struct cl_io *io);
2319 void cl_lock_fini(const struct lu_env *env, struct cl_lock *lock);
2320 const struct cl_lock_slice *cl_lock_at(const struct cl_lock *lock,
2321                                        const struct lu_device_type *dtype);
2322 void cl_lock_release(const struct lu_env *env, struct cl_lock *lock);
2323
2324 int cl_lock_enqueue(const struct lu_env *env, struct cl_io *io,
2325                     struct cl_lock *lock, struct cl_sync_io *anchor);
2326 void cl_lock_cancel(const struct lu_env *env, struct cl_lock *lock);
2327
2328 /** @} cl_lock */
2329
2330 /** \defgroup cl_io cl_io
2331  * @{ */
2332
2333 int   cl_io_init         (const struct lu_env *env, struct cl_io *io,
2334                           enum cl_io_type iot, struct cl_object *obj);
2335 int   cl_io_sub_init     (const struct lu_env *env, struct cl_io *io,
2336                           enum cl_io_type iot, struct cl_object *obj);
2337 int   cl_io_rw_init      (const struct lu_env *env, struct cl_io *io,
2338                           enum cl_io_type iot, loff_t pos, size_t count);
2339 int   cl_io_loop         (const struct lu_env *env, struct cl_io *io);
2340
2341 void  cl_io_fini         (const struct lu_env *env, struct cl_io *io);
2342 int   cl_io_iter_init    (const struct lu_env *env, struct cl_io *io);
2343 void  cl_io_iter_fini    (const struct lu_env *env, struct cl_io *io);
2344 int   cl_io_lock         (const struct lu_env *env, struct cl_io *io);
2345 void  cl_io_unlock       (const struct lu_env *env, struct cl_io *io);
2346 int   cl_io_start        (const struct lu_env *env, struct cl_io *io);
2347 void  cl_io_end          (const struct lu_env *env, struct cl_io *io);
2348 int   cl_io_lock_add     (const struct lu_env *env, struct cl_io *io,
2349                           struct cl_io_lock_link *link);
2350 int   cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io,
2351                            struct cl_lock_descr *descr);
2352 int   cl_io_submit_rw    (const struct lu_env *env, struct cl_io *io,
2353                           enum cl_req_type iot, struct cl_2queue *queue);
2354 int   cl_io_submit_sync  (const struct lu_env *env, struct cl_io *io,
2355                           enum cl_req_type iot, struct cl_2queue *queue,
2356                           long timeout);
2357 int   cl_io_commit_async (const struct lu_env *env, struct cl_io *io,
2358                           struct cl_page_list *queue, int from, int to,
2359                           cl_commit_cbt cb);
2360 int   cl_io_read_ahead   (const struct lu_env *env, struct cl_io *io,
2361                           pgoff_t start, struct cl_read_ahead *ra);
2362 void  cl_io_rw_advance   (const struct lu_env *env, struct cl_io *io,
2363                           size_t nob);
2364 int   cl_io_cancel       (const struct lu_env *env, struct cl_io *io,
2365                           struct cl_page_list *queue);
2366
2367 /**
2368  * True, iff \a io is an O_APPEND write(2).
2369  */
2370 static inline int cl_io_is_append(const struct cl_io *io)
2371 {
2372         return io->ci_type == CIT_WRITE && io->u.ci_rw.rw_append;
2373 }
2374
2375 static inline int cl_io_is_sync_write(const struct cl_io *io)
2376 {
2377         return io->ci_type == CIT_WRITE && io->u.ci_rw.rw_sync;
2378 }
2379
2380 static inline int cl_io_is_mkwrite(const struct cl_io *io)
2381 {
2382         return io->ci_type == CIT_FAULT && io->u.ci_fault.ft_mkwrite;
2383 }
2384
2385 /**
2386  * True, iff \a io is a truncate(2).
2387  */
2388 static inline int cl_io_is_trunc(const struct cl_io *io)
2389 {
2390         return io->ci_type == CIT_SETATTR &&
2391                 (io->u.ci_setattr.sa_avalid & ATTR_SIZE);
2392 }
2393
2394 struct cl_io *cl_io_top(struct cl_io *io);
2395
2396 void cl_io_print(const struct lu_env *env, void *cookie,
2397                  lu_printer_t printer, const struct cl_io *io);
2398
2399 #define CL_IO_SLICE_CLEAN(foo_io, base)                                 \
2400 do {                                                                    \
2401         typeof(foo_io) __foo_io = (foo_io);                             \
2402                                                                         \
2403         memset(&__foo_io->base, 0,                                      \
2404                sizeof(*__foo_io) - offsetof(typeof(*__foo_io), base));  \
2405 } while (0)
2406
2407 /** @} cl_io */
2408
2409 /** \defgroup cl_page_list cl_page_list
2410  * @{ */
2411
2412 /**
2413  * Last page in the page list.
2414  */
2415 static inline struct cl_page *cl_page_list_last(struct cl_page_list *plist)
2416 {
2417         LASSERT(plist->pl_nr > 0);
2418         return list_entry(plist->pl_pages.prev, struct cl_page, cp_batch);
2419 }
2420
2421 static inline struct cl_page *cl_page_list_first(struct cl_page_list *plist)
2422 {
2423         LASSERT(plist->pl_nr > 0);
2424         return list_entry(plist->pl_pages.next, struct cl_page, cp_batch);
2425 }
2426
2427 /**
2428  * Iterate over pages in a page list.
2429  */
2430 #define cl_page_list_for_each(page, list)                               \
2431         list_for_each_entry((page), &(list)->pl_pages, cp_batch)
2432
2433 /**
2434  * Iterate over pages in a page list, taking possible removals into account.
2435  */
2436 #define cl_page_list_for_each_safe(page, temp, list)                    \
2437         list_for_each_entry_safe((page), (temp), &(list)->pl_pages, cp_batch)
2438
2439 void cl_page_list_init   (struct cl_page_list *plist);
2440 void cl_page_list_add    (struct cl_page_list *plist, struct cl_page *page);
2441 void cl_page_list_move   (struct cl_page_list *dst, struct cl_page_list *src,
2442                           struct cl_page *page);
2443 void cl_page_list_move_head(struct cl_page_list *dst, struct cl_page_list *src,
2444                           struct cl_page *page);
2445 void cl_page_list_splice (struct cl_page_list *list,
2446                           struct cl_page_list *head);
2447 void cl_page_list_del    (const struct lu_env *env,
2448                           struct cl_page_list *plist, struct cl_page *page);
2449 void cl_page_list_disown (const struct lu_env *env,
2450                           struct cl_io *io, struct cl_page_list *plist);
2451 void cl_page_list_assume (const struct lu_env *env,
2452                           struct cl_io *io, struct cl_page_list *plist);
2453 void cl_page_list_discard(const struct lu_env *env,
2454                           struct cl_io *io, struct cl_page_list *plist);
2455 void cl_page_list_fini   (const struct lu_env *env, struct cl_page_list *plist);
2456
2457 void cl_2queue_init     (struct cl_2queue *queue);
2458 void cl_2queue_add      (struct cl_2queue *queue, struct cl_page *page);
2459 void cl_2queue_disown   (const struct lu_env *env,
2460                          struct cl_io *io, struct cl_2queue *queue);
2461 void cl_2queue_assume   (const struct lu_env *env,
2462                          struct cl_io *io, struct cl_2queue *queue);
2463 void cl_2queue_discard  (const struct lu_env *env,
2464                          struct cl_io *io, struct cl_2queue *queue);
2465 void cl_2queue_fini     (const struct lu_env *env, struct cl_2queue *queue);
2466 void cl_2queue_init_page(struct cl_2queue *queue, struct cl_page *page);
2467
2468 /** @} cl_page_list */
2469
2470 void cl_req_attr_set(const struct lu_env *env, struct cl_object *obj,
2471                      struct cl_req_attr *attr);
2472
2473 /** \defgroup cl_sync_io cl_sync_io
2474  * @{ */
2475
2476 /**
2477  * Anchor for synchronous transfer. This is allocated on a stack by thread
2478  * doing synchronous transfer, and a pointer to this structure is set up in
2479  * every page submitted for transfer. Transfer completion routine updates
2480  * anchor and wakes up waiting thread when transfer is complete.
2481  */
2482 struct cl_sync_io {
2483         /** number of pages yet to be transferred. */
2484         atomic_t                csi_sync_nr;
2485         /** error code. */
2486         int                     csi_sync_rc;
2487         /** barrier of destroy this structure */
2488         atomic_t                csi_barrier;
2489         /** completion to be signaled when transfer is complete. */
2490         wait_queue_head_t       csi_waitq;
2491         /** callback to invoke when this IO is finished */
2492         void                    (*csi_end_io)(const struct lu_env *,
2493                                               struct cl_sync_io *);
2494 };
2495
2496 void cl_sync_io_init(struct cl_sync_io *anchor, int nr,
2497                      void (*end)(const struct lu_env *, struct cl_sync_io *));
2498 int  cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor,
2499                      long timeout);
2500 void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
2501                      int ioret);
2502 void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor);
2503
2504 /** @} cl_sync_io */
2505
2506 /** \defgroup cl_env cl_env
2507  *
2508  * lu_env handling for a client.
2509  *
2510  * lu_env is an environment within which lustre code executes. Its major part
2511  * is lu_context---a fast memory allocation mechanism that is used to conserve
2512  * precious kernel stack space. Originally lu_env was designed for a server,
2513  * where
2514  *
2515  *     - there is a (mostly) fixed number of threads, and
2516  *
2517  *     - call chains have no non-lustre portions inserted between lustre code.
2518  *
2519  * On a client both these assumtpion fails, because every user thread can
2520  * potentially execute lustre code as part of a system call, and lustre calls
2521  * into VFS or MM that call back into lustre.
2522  *
2523  * To deal with that, cl_env wrapper functions implement the following
2524  * optimizations:
2525  *
2526  *     - allocation and destruction of environment is amortized by caching no
2527  *     longer used environments instead of destroying them;
2528  *
2529  * \see lu_env, lu_context, lu_context_key
2530  * @{ */
2531
2532 struct lu_env *cl_env_get(__u16 *refcheck);
2533 struct lu_env *cl_env_alloc(__u16 *refcheck, __u32 tags);
2534 void cl_env_put(struct lu_env *env, __u16 *refcheck);
2535 unsigned cl_env_cache_purge(unsigned nr);
2536 struct lu_env *cl_env_percpu_get(void);
2537 void cl_env_percpu_put(struct lu_env *env);
2538
2539 /** @} cl_env */
2540
2541 /*
2542  * Misc
2543  */
2544 void cl_attr2lvb(struct ost_lvb *lvb, const struct cl_attr *attr);
2545 void cl_lvb2attr(struct cl_attr *attr, const struct ost_lvb *lvb);
2546
2547 struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site,
2548                                 struct lu_device_type *ldt,
2549                                 struct lu_device *next);
2550 /** @} clio */
2551
2552 int cl_global_init(void);
2553 void cl_global_fini(void);
2554
2555 #endif /* _LINUX_CL_OBJECT_H */