Whamcloud - gitweb
LU-5162 mdc: Add exception entry check for radix_tree
[fs/lustre-release.git] / lustre / include / lustre_lite.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.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef _LL_H
38 #define _LL_H
39
40 /** \defgroup lite lite
41  *
42  * @{
43  */
44
45 #if defined(__linux__)
46 #include <linux/lustre_lite.h>
47 #elif defined(__APPLE__)
48 #include <darwin/lustre_lite.h>
49 #elif defined(__WINNT__)
50 #include <winnt/lustre_lite.h>
51 #else
52 #error Unsupported operating system.
53 #endif
54
55 #include <obd_class.h>
56 #include <lustre_net.h>
57 #include <lustre_mds.h>
58 #include <lustre_ha.h>
59
60 /* 4UL * 1024 * 1024 */
61 #define LL_MAX_BLKSIZE_BITS     (22)
62 #define LL_MAX_BLKSIZE          (1UL<<LL_MAX_BLKSIZE_BITS)
63
64 #include <lustre/lustre_user.h>
65
66
67 struct lustre_rw_params {
68         int                lrp_lock_mode;
69         ldlm_policy_data_t lrp_policy;
70         obd_flag           lrp_brw_flags;
71         int                lrp_ast_flags;
72 };
73
74 /*
75  * XXX nikita: this function lives in the header because it is used by both
76  * llite kernel module and liblustre library, and there is no (?) better place
77  * to put it in.
78  */
79 static inline void lustre_build_lock_params(int cmd, unsigned long open_flags,
80                                             __u64 connect_flags,
81                                             loff_t pos, ssize_t len,
82                                             struct lustre_rw_params *params)
83 {
84         params->lrp_lock_mode = (cmd == OBD_BRW_READ) ? LCK_PR : LCK_PW;
85         params->lrp_brw_flags = 0;
86
87         params->lrp_policy.l_extent.start = pos;
88         params->lrp_policy.l_extent.end = pos + len - 1;
89         /*
90          * for now O_APPEND always takes local locks.
91          */
92         if (cmd == OBD_BRW_WRITE && (open_flags & O_APPEND)) {
93                 params->lrp_policy.l_extent.start = 0;
94                 params->lrp_policy.l_extent.end   = OBD_OBJECT_EOF;
95         } else if (LIBLUSTRE_CLIENT && (connect_flags & OBD_CONNECT_SRVLOCK)) {
96                 /*
97                  * liblustre: OST-side locking for all non-O_APPEND
98                  * reads/writes.
99                  */
100                 params->lrp_lock_mode = LCK_NL;
101                 params->lrp_brw_flags = OBD_BRW_SRVLOCK;
102         } else {
103                 /*
104                  * nothing special for the kernel. In the future llite may use
105                  * OST-side locks for small writes into highly contended
106                  * files.
107                  */
108         }
109         params->lrp_ast_flags = (open_flags & O_NONBLOCK) ?
110                 LDLM_FL_BLOCK_NOWAIT : 0;
111 }
112
113 /*
114  * This is embedded into liblustre and llite super-blocks to keep track of
115  * connect flags (capabilities) supported by all imports given mount is
116  * connected to.
117  */
118 struct lustre_client_ocd {
119         /*
120          * This is conjunction of connect_flags across all imports (LOVs) this
121          * mount is connected to. This field is updated by cl_ocd_update()
122          * under ->lco_lock.
123          */
124         __u64              lco_flags;
125         struct mutex       lco_lock;
126         struct obd_export *lco_md_exp;
127         struct obd_export *lco_dt_exp;
128 };
129
130 /*
131  * Chain of hash overflow pages.
132  */
133 struct ll_dir_chain {
134         /* XXX something. Later */
135 };
136
137 static inline void ll_dir_chain_init(struct ll_dir_chain *chain)
138 {
139 }
140
141 static inline void ll_dir_chain_fini(struct ll_dir_chain *chain)
142 {
143 }
144
145 /** @} lite */
146
147 #endif