Whamcloud - gitweb
- merge with 1_5,some fixes.
[fs/lustre-release.git] / lustre / mdc / mdc_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
9  *   You may have signed or agreed to another license before downloading
10  *   this software.  If so, you are bound by the terms and conditions
11  *   of that agreement, and the following does not apply to you.  See the
12  *   LICENSE file included with this distribution for more information.
13  *
14  *   If you did not agree to a different license, then this copy of Lustre
15  *   is open source software; you can redistribute it and/or modify it
16  *   under the terms of version 2 of the GNU General Public License as
17  *   published by the Free Software Foundation.
18  *
19  *   In either case, Lustre is distributed in the hope that it will be
20  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   license text for more details.
23  */
24
25 #ifndef _MDC_INTERNAL_H
26 #define _MDC_INTERNAL_H
27
28 #include <lustre_mdc.h>
29
30 void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
31                        __u64 valid, struct lu_fid *fid, int ea_size, int flags);
32 void mdc_pack_rep_body(struct ptlrpc_request *);
33 void mdc_readdir_pack(struct ptlrpc_request *req, int pos, __u64 offset,
34                       __u32 size, struct lu_fid *fid);
35 void mdc_getattr_pack(struct ptlrpc_request *req, int offset, int valid,
36                       int flags, struct md_op_data *data);
37 void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
38                       struct md_op_data *op_data,
39                       struct iattr *iattr, void *ea, int ealen,
40                       void *ea2, int ea2len);
41 void mdc_create_pack(struct ptlrpc_request *req, int offset,
42                      struct md_op_data *op_data, const void *data, int datalen,
43                      __u32 mode, __u32 uid, __u32 gid, __u32 cap_effective,
44                      __u64 rdev);
45 void mdc_open_pack(struct ptlrpc_request *req, int offset,
46                    struct md_op_data *op_data, __u32 mode, __u64 rdev,
47                    __u32 flags, const void *data, int datalen);
48 void mdc_join_pack(struct ptlrpc_request *req, int offset, 
49                    struct md_op_data *op_data, __u64 head_size);
50 void mdc_unlink_pack(struct ptlrpc_request *req, int offset,
51                      struct md_op_data *op_data);
52 void mdc_link_pack(struct ptlrpc_request *req, int offset,
53                    struct md_op_data *op_data);
54 void mdc_rename_pack(struct ptlrpc_request *req, int offset,
55                      struct md_op_data *op_data,
56                      const char *old, int oldlen, const char *new, int newlen);
57 void mdc_close_pack(struct ptlrpc_request *req, int offset, struct md_op_data *op_data,
58                     int valid, struct obd_client_handle *och);
59 void mdc_exit_request(struct client_obd *cli);
60 void mdc_enter_request(struct client_obd *cli);
61
62 struct mdc_open_data {
63         struct obd_client_handle *mod_och;
64         struct ptlrpc_request    *mod_open_req;
65         struct ptlrpc_request    *mod_close_req;
66 };
67
68 struct mdc_rpc_lock {
69         struct semaphore rpcl_sem;
70         struct lookup_intent *rpcl_it;
71 };
72
73 static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck)
74 {
75         sema_init(&lck->rpcl_sem, 1);
76         lck->rpcl_it = NULL;
77 }
78
79 static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,
80                                     struct lookup_intent *it)
81 {
82         ENTRY;
83         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
84                 down(&lck->rpcl_sem);
85                 LASSERT(lck->rpcl_it == NULL);
86                 lck->rpcl_it = it;
87         }
88 }
89
90 static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
91                                     struct lookup_intent *it)
92 {
93         if (!it || (it->it_op != IT_GETATTR && it->it_op != IT_LOOKUP)) {
94                 LASSERT(it == lck->rpcl_it);
95                 lck->rpcl_it = NULL;
96                 up(&lck->rpcl_sem);
97         }
98         EXIT;
99 }
100
101 /* Quota stuff */
102 extern quota_interface_t *quota_interface;
103
104 /* mdc/mdc_locks.c */
105 int mdc_set_lock_data(struct obd_export *exp,
106                       __u64 *lockh, void *data);
107
108 int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid,
109                       ldlm_iterator_t it, void *data);
110 int mdc_intent_lock(struct obd_export *exp,
111                     struct md_op_data *,
112                     void *lmm, int lmmsize,
113                     struct lookup_intent *, int,
114                     struct ptlrpc_request **reqp,
115                     ldlm_blocking_callback cb_blocking, int extra_lock_flags);
116 int mdc_enqueue(struct obd_export *exp,
117                 int lock_type,
118                 struct lookup_intent *it,
119                 int lock_mode,
120                 struct md_op_data *op_data,
121                 struct lustre_handle *lockh,
122                 void *lmm,
123                 int lmmlen,
124                 ldlm_completion_callback cb_completion,
125                 ldlm_blocking_callback cb_blocking,
126                 void *cb_data, int extra_lock_flags);
127
128 /* mdc/mdc_request.c */
129 int mdc_init_ea_size(struct obd_export *exp, int easize, int def_easzie,
130                      int cookiesize);
131
132 int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid);
133 int mdc_getattr(struct obd_export *exp, struct lu_fid *fid,
134                 obd_valid valid, int ea_size,
135                 struct ptlrpc_request **request);
136 int mdc_getattr_name(struct obd_export *exp, struct lu_fid *fid,
137                      const char *filename, int namelen, obd_valid valid,
138                      int ea_size, struct ptlrpc_request **request);
139 int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
140                 struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len,
141                 struct ptlrpc_request **request);
142 int mdc_setxattr(struct obd_export *exp, struct lu_fid *fid,
143                  obd_valid valid, const char *xattr_name,
144                  const char *input, int input_size,
145                  int output_size, int flags,
146                  struct ptlrpc_request **request);
147 int mdc_getxattr(struct obd_export *exp, struct lu_fid *fid,
148                  obd_valid valid, const char *xattr_name,
149                  const char *input, int input_size,
150                  int output_size, int flags, struct ptlrpc_request **request);
151 int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags,
152              struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh,
153              struct ptlrpc_request **);
154
155 struct obd_client_handle;
156
157 int mdc_get_lustre_md(struct obd_export *md_exp, struct ptlrpc_request *req,
158                       int offset, struct obd_export *dt_exp, struct lustre_md *md);
159
160 int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md);
161
162 int mdc_set_open_replay_data(struct obd_export *exp,
163                              struct obd_client_handle *och,
164                              struct ptlrpc_request *open_req);
165
166 int mdc_clear_open_replay_data(struct obd_export *exp,
167                                struct obd_client_handle *och);
168
169 int mdc_close(struct obd_export *, struct md_op_data *,
170               struct obd_client_handle *, struct ptlrpc_request **);
171
172 int mdc_readpage(struct obd_export *exp, struct lu_fid *fid,
173                  __u64 offset,  struct page *, struct ptlrpc_request **);
174
175 int mdc_create(struct obd_export *exp, struct md_op_data *op_data,
176                const void *data, int datalen, int mode, __u32 uid,
177                __u32 gid, __u32 cap_effective, __u64 rdev,
178                struct ptlrpc_request **request);
179
180 int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data,
181                struct ptlrpc_request **request);
182
183 int mdc_link(struct obd_export *exp, struct md_op_data *op_data,
184              struct ptlrpc_request **);
185
186 int mdc_rename(struct obd_export *exp, struct md_op_data *op_data,
187                const char *old, int oldlen, const char *new, int newlen,
188                struct ptlrpc_request **request);
189
190 int mdc_sync(struct obd_export *exp, struct lu_fid *fid,
191              struct ptlrpc_request **);
192
193 int mdc_lock_match(struct obd_export *exp, int flags,
194                    struct lu_fid *fid, ldlm_type_t type,
195                    ldlm_policy_data_t *policy, ldlm_mode_t mode,
196                    struct lustre_handle *lockh);
197
198 int mdc_cancel_unused(struct obd_export *exp, struct lu_fid *fid,
199                       int flags, void *opaque);
200
201 int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data);
202
203 #endif