Whamcloud - gitweb
Revert Tom's commit. It breaks recovery.
[fs/lustre-release.git] / lustre / mds / mds_internal.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4
5 #ifndef _MDS_INTERNAL_H
6 #define _MDS_INTERNAL_H
7
8 #include <linux/lustre_mds.h>
9
10 #define MDS_SERVICE_WATCHDOG_TIMEOUT 30000
11
12 #define MAX_ATIME_DIFF 60
13
14 struct mds_filter_data {
15         __u64 io_epoch;
16 };
17
18 #define MDS_FILTERDATA(inode) ((struct mds_filter_data *)LUSTRE_FILTERDATA(inode))
19 #define DENTRY_VALID(dentry)    \
20         ((dentry)->d_inode || ((dentry)->d_flags & DCACHE_CROSS_REF))
21
22 #define MDS_NO_SPLIT_EXPECTED   0
23 #define MDS_EXPECT_SPLIT        1
24 #define MDS_NO_SPLITTABLE       2
25
26 static inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
27 {
28         return &req->rq_export->exp_obd->u.mds;
29 }
30 static inline struct obd_device *req2obd(struct ptlrpc_request *req)
31 {
32         return req->rq_export->exp_obd;
33 }
34
35 #ifdef __KERNEL__
36 /* Open counts for files.  No longer atomic, must hold inode->i_sem */
37 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
38 # define mds_inode_oatomic(inode)    ((inode)->i_cindex)
39 #else
40 # define mds_inode_oatomic(inode)    ((inode)->i_attr_flags)
41 #endif
42
43 static inline int mds_orphan_open_count(struct inode *inode)
44 {
45         LASSERT_MDS_ORPHAN_READ_LOCKED(inode);
46         return mds_inode_oatomic(inode);
47 }
48
49 static inline int mds_orphan_open_inc(struct inode *inode)
50 {
51         LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
52         return ++mds_inode_oatomic(inode);
53 }
54
55 static inline int mds_orphan_open_dec_test(struct inode *inode)
56 {
57         LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
58         return --mds_inode_oatomic(inode) == 0;
59 }
60
61 #define mds_inode_is_orphan(inode)  ((inode)->i_flags & 0x4000000)
62 #define mds_inode_set_orphan(inode)                                     \
63 do {                                                                    \
64         (inode)->i_flags |= 0x4000000;                                  \
65         CDEBUG(D_VFSTRACE, "setting orphan flag on inode %p\n", inode); \
66 } while (0)
67 #define mds_inode_unset_orphan(inode)                                      \
68 do {                                                                       \
69         (inode)->i_flags &= ~(0x4000000);                                  \
70         CDEBUG(D_VFSTRACE, "removing orphan flag from inode %p\n", inode); \
71 } while (0)
72 #endif /* __KERNEL__ */
73
74 /* mds/mds_reint.c */
75 int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
76                           struct lustre_handle *p1_lockh, int p1_lock_mode,
77                           ldlm_policy_data_t *p1_policy,
78                           struct ldlm_res_id *p2_res_id,
79                           struct lustre_handle *p2_lockh, int p2_lock_mode,
80                           ldlm_policy_data_t *p2_policy);
81
82 int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
83                        struct ptlrpc_request *req, int rc, __u32 op_data);
84 void mds_reconstruct_generic(struct ptlrpc_request *req);
85 void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd);
86 int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
87                                 struct lustre_id *id,
88                                 struct lustre_handle *parent_lockh,
89                                 struct dentry **dparentp, int parent_mode,
90                                 __u64 parent_lockpart, int *update_mode,
91                                 char *name, int namelen,
92                                 struct lustre_handle *child_lockh,
93                                 struct dentry **dchildp, int child_mode,
94                                 __u64 child_lockpart);
95 int mds_lock_new_child(struct obd_device *obd, struct inode *inode,
96                        struct lustre_handle *child_lockh);
97
98 /* mds/mds_lib.c */
99 void groups_from_buffer(struct group_info *ginfo, __u32 *gids);
100 int mds_update_unpack(struct ptlrpc_request *, int offset,
101                       struct mds_update_record *);
102 int mds_idmap_add(struct mds_idmap_table *tbl,
103                   uid_t rmt_uid, uid_t lcl_uid,
104                   gid_t rmt_gid, gid_t lcl_gid);
105 int mds_idmap_del(struct mds_idmap_table *tbl,
106                   uid_t rmt_uid, uid_t lcl_uid,
107                   gid_t rmt_gid, gid_t lcl_gid);
108 int mds_idmap_lookup_uid(struct mds_idmap_table *tbl, int reverse, uid_t uid);
109 int mds_idmap_lookup_gid(struct mds_idmap_table *tbl, int reverse, gid_t gid);
110 struct mds_idmap_table *mds_idmap_alloc(void);
111 void mds_idmap_free(struct mds_idmap_table *tbl);
112 void mds_body_do_reverse_map(struct mds_export_data *med,
113                              struct mds_body *body);
114 int mds_init_ucred(struct lvfs_ucred *ucred, struct ptlrpc_request *req,
115                    struct mds_req_sec_desc *rsd);
116 void mds_exit_ucred(struct lvfs_ucred *ucred);
117
118 /* mds/mds_unlink_open.c */
119 int mds_cleanup_orphans(struct obd_device *obd);
120
121 int mds_unlink_object(struct mds_obd *mds, struct inode *inode,
122                       struct lov_mds_md *lmm, int lmm_size,
123                       struct llog_cookie *logcookies,
124                       int log_unlink, int async);
125         
126
127 /* mds/mds_log.c */
128 int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
129                       struct lov_mds_md *lmm, int lmm_size,
130                       struct llog_cookie *logcookies, int cookies_size,
131                       struct llog_create_locks **res);
132 int mds_llog_init(struct obd_device *obd, struct obd_llogs *,
133                   struct obd_device *tgt, int count, struct llog_catid *logid);
134 int mds_llog_finish(struct obd_device *obd, struct obd_llogs *, int count);
135
136 /* mds/mds_lov.c */
137 int mds_dt_connect(struct obd_device *obd, char * lov_name);
138 int mds_dt_disconnect(struct obd_device *obd, int flags);
139 int mds_dt_set_info(struct obd_export *exp, obd_count keylen,
140                      void *key, obd_count vallen, void *val);
141 int mds_get_lovtgts(struct obd_device *, int tgt_count, struct obd_uuid *);
142 int mds_dt_write_objids(struct obd_device *obd);
143 int mds_dt_set_growth(struct mds_obd *mds, int count);
144 int mds_dt_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid);
145 int mds_post_mds_lovconf(struct obd_device *obd);
146 int mds_notify(struct obd_device *obd, struct obd_device *watched,
147                int active, void *data);
148 int mds_dt_update_config(struct obd_device *obd, int transno);
149 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
150                        struct lov_mds_md *lmm, int lmm_size);
151 int mds_revalidate_lov_ea(struct obd_device *obd, struct inode *inode,
152                           struct lustre_msg *msg, int offset);
153 void mds_dt_update_objids(struct obd_device *obd, obd_id *ids);
154 void mds_dt_save_objids(struct obd_device *obd, obd_id *ids);
155
156 /* mds/mds_open.c */
157 int
158 mds_create_object(struct obd_device *obd, struct ptlrpc_request *req,
159                   int offset, struct mds_update_record *rec,
160                   struct dentry *dchild, void **handle,
161                   obd_id *ids);
162 int mds_destroy_object(struct obd_device *obd,
163                        struct inode *inode, int async);
164 int mds_query_write_access(struct inode *inode);
165 int mds_open(struct mds_update_record *rec, int offset,
166              struct ptlrpc_request *req, struct lustre_handle *);
167 int mds_pin(struct ptlrpc_request *req, int offset);
168 int mds_mfd_close(struct ptlrpc_request *req, int offset,
169                   struct obd_device *obd, struct mds_file_data *mfd,
170                   int unlink_orphan);
171 int mds_close(struct ptlrpc_request *req, int offset);
172 int mds_done_writing(struct ptlrpc_request *req, int offset);
173
174
175 /* mds/mds_fs.c */
176 int mds_client_add(struct obd_device *obd, struct mds_obd *mds,
177                    struct mds_export_data *med, int cl_off);
178 int mds_client_free(struct obd_export *exp, int clear_client);
179 int mds_obd_create(struct obd_export *exp, struct obdo *oa,
180                    void *acl, int acl_size,
181                    struct lov_stripe_md **ea, struct obd_trans_info *oti);
182 int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
183                     struct lov_stripe_md *ea, struct obd_trans_info *oti);
184
185 /* mds/handler.c */
186 int mds_getattr_size(struct obd_device *obd, struct dentry *dentry,
187                      struct ptlrpc_request *req, struct mds_body *body);
188 int mds_handle(struct ptlrpc_request *req);
189 extern struct lvfs_callback_ops mds_lvfs_ops;
190 int mds_dt_clean(struct obd_device *obd);
191 int mds_postrecov(struct obd_device *obd);
192 int mds_postrecov_common(struct obd_device *obd);
193 extern struct lvfs_callback_ops mds_lvfs_ops;
194
195 extern int mds_iocontrol(unsigned int cmd,
196                          struct obd_export *exp,
197                          int len, void *karg,
198                          void *uarg);
199
200 extern int mds_lock_mode_for_dir(struct obd_device *,
201                                  struct dentry *, int);
202
203 int mds_fs_setup_rootid(struct obd_device *obd);
204 int mds_fs_setup_virtid(struct obd_device *obd);
205
206 __u64 mds_alloc_fid(struct obd_device *obd);
207
208 int mds_alloc_inode_sid(struct obd_device *, struct inode *,
209                         void *, struct lustre_id *);
210
211 int mds_update_inode_sid(struct obd_device *, struct inode *,
212                          void *, struct lustre_id *);
213
214 int mds_read_inode_sid(struct obd_device *, struct inode *,
215                        struct lustre_id *);
216
217 int mds_update_inode_mid(struct obd_device *, struct inode *,
218                          void *, struct lustre_id *);
219
220 int mds_read_inode_mid(struct obd_device *, struct inode *,
221                        struct lustre_id *);
222
223 void mds_commit_last_fid_cb(struct obd_device *, __u64 fid,
224                             void *data, int error);
225
226 void mds_commit_last_transno_cb(struct obd_device *, __u64 transno,
227                                 void *data, int error);
228
229 void mds_set_last_fid(struct obd_device *obd, __u64 fid);
230
231 #ifdef __KERNEL__
232 int mds_get_md(struct obd_device *, struct inode *, void *md,
233                int *size, int lock, int mea);
234
235 int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
236                 struct mds_body *, struct inode *, int lock, int mea);
237 int mds_pack_link(struct dentry *dentry, struct ptlrpc_request *req,
238                   struct mds_body *repbody, int reply_off);
239 int mds_pack_ea(struct dentry *dentry, struct ptlrpc_request *req,
240                 struct mds_body *repbody, int req_off, int reply_off);
241 int mds_pack_ealist(struct dentry *dentry, struct ptlrpc_request *req,
242                     struct mds_body *repbody, int reply_off);
243 int mds_pack_acl(struct ptlrpc_request *req, int reply_off,
244                  struct mds_body *body, struct inode *inode);
245 int mds_pack_inode2id(struct obd_device *, struct lustre_id *,
246                       struct inode *, int);
247
248 void mds_pack_inode2body(struct obd_device *, struct mds_body *,
249                          struct inode *, int);
250
251 void mds_pack_dentry2id(struct obd_device *, struct lustre_id *,
252                         struct dentry *, int);
253
254 void mds_pack_dentry2body(struct obd_device *, struct mds_body *b,
255                           struct dentry *, int);
256 #endif
257
258 /* mds/mds_lmv.c */
259 int mds_md_postsetup(struct obd_device *obd);
260 int mds_md_connect(struct obd_device *obd, char * lov_name);
261 int mds_md_disconnect(struct obd_device *obd, int flags);
262 int mds_try_to_split_dir(struct obd_device *, struct dentry *, struct mea **,
263                          int, int);
264 int mds_md_get_attr(struct obd_device *, struct inode *, struct mea **, int *);
265 int mds_choose_mdsnum(struct obd_device *, const char *, int, int, struct ptlrpc_peer *, struct inode *);
266 int mds_md_postsetup(struct obd_device *);
267 int mds_splitting_expected(struct obd_device *, struct dentry *);
268 int mds_lock_slave_objs(struct obd_device *, struct dentry *,
269                         struct lustre_handle **);
270 int mds_unlink_slave_objs(struct obd_device *, struct dentry *);
271 void mds_unlock_slave_objs(struct obd_device *, struct dentry *,
272                            struct lustre_handle *);
273 int mds_lock_and_check_slave(int, struct ptlrpc_request *, struct lustre_handle *);
274 int mds_convert_mea_ea(struct obd_device *, struct inode *, struct lov_mds_md *, int);
275 int mds_is_dir_empty(struct obd_device *, struct dentry *);
276 int mds_md_reconnect(struct obd_device *obd);
277
278 /* mds_lsd.c */
279 struct upcall_cache *__mds_get_global_lsd_cache(void);
280 int mds_init_lsd_cache(void);
281 void mds_cleanup_lsd_cache(void);
282 struct lustre_sec_desc * mds_get_lsd(__u32 uid);
283 void mds_put_lsd(struct lustre_sec_desc *lsd);
284 void mds_flush_lsd(__u32 id);
285
286 #endif /* _MDS_INTERNAL_H */