Whamcloud - gitweb
LU-1347 build: remove the vim/emacs modelines
[fs/lustre-release.git] / lustre / include / lustre_mdc.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 /*
31  * Copyright (c) 2012 Whamcloud, Inc.
32  */
33 /*
34  * This file is part of Lustre, http://www.lustre.org/
35  * Lustre is a trademark of Sun Microsystems, Inc.
36  *
37  * lustre/include/lustre_mdc.h
38  *
39  * MDS data structures.
40  * See also lustre_idl.h for wire formats of requests.
41  */
42
43 #ifndef _LUSTRE_MDC_H
44 #define _LUSTRE_MDC_H
45
46 /** \defgroup mdc mdc
47  *
48  * @{
49  */
50
51 #ifdef __KERNEL__
52 # include <linux/fs.h>
53 # include <linux/dcache.h>
54 # ifdef CONFIG_FS_POSIX_ACL
55 #  include <linux/posix_acl_xattr.h>
56 # endif /* CONFIG_FS_POSIX_ACL */
57 # include <linux/lustre_intent.h>
58 #endif /* __KERNEL__ */
59 #include <lustre_handles.h>
60 #include <libcfs/libcfs.h>
61 #include <lustre/lustre_idl.h>
62 #include <lustre_lib.h>
63 #include <lustre_dlm.h>
64 #include <lustre_log.h>
65 #include <lustre_export.h>
66
67 struct ptlrpc_client;
68 struct obd_export;
69 struct ptlrpc_request;
70 struct obd_device;
71
72 struct mdc_rpc_lock {
73         cfs_mutex_t           rpcl_mutex;
74         struct lookup_intent *rpcl_it;
75 };
76
77 static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck)
78 {
79         cfs_mutex_init(&lck->rpcl_mutex);
80         lck->rpcl_it = NULL;
81 }
82
83 static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,
84                                     struct lookup_intent *it)
85 {
86         ENTRY;
87         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
88                 cfs_mutex_lock(&lck->rpcl_mutex);
89                 LASSERT(lck->rpcl_it == NULL);
90                 lck->rpcl_it = it;
91         }
92 }
93
94 static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
95                                     struct lookup_intent *it)
96 {
97         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
98                 LASSERT(it == lck->rpcl_it);
99                 lck->rpcl_it = NULL;
100                 cfs_mutex_unlock(&lck->rpcl_mutex);
101         }
102         EXIT;
103 }
104
105 static inline void mdc_update_max_ea_from_body(struct obd_export *exp,
106                                                struct mdt_body *body)
107 {
108         if (body->valid & OBD_MD_FLMODEASIZE) {
109                 if (exp->exp_obd->u.cli.cl_max_mds_easize < body->max_mdsize)
110                         exp->exp_obd->u.cli.cl_max_mds_easize =
111                                                 body->max_mdsize;
112                 if (exp->exp_obd->u.cli.cl_max_mds_cookiesize <
113                                                 body->max_cookiesize)
114                         exp->exp_obd->u.cli.cl_max_mds_cookiesize =
115                                                 body->max_cookiesize;
116         }
117 }
118
119
120 struct mdc_cache_waiter {
121         cfs_list_t              mcw_entry;
122         cfs_waitq_t             mcw_waitq;
123 };
124
125 /* mdc/mdc_locks.c */
126 int it_disposition(struct lookup_intent *it, int flag);
127 void it_clear_disposition(struct lookup_intent *it, int flag);
128 void it_set_disposition(struct lookup_intent *it, int flag);
129 int it_open_error(int phase, struct lookup_intent *it);
130 #ifdef HAVE_SPLIT_SUPPORT
131 int mdc_sendpage(struct obd_export *exp, const struct lu_fid *fid,
132                  const struct page *page, int offset);
133 #endif
134
135 /** @} mdc */
136
137 #endif