1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #ifndef _MDS_INTERNAL_H
6 #define _MDS_INTERNAL_H
8 #include <linux/lustre_mds.h>
10 #define MDS_SERVICE_WATCHDOG_TIMEOUT 30000
12 #define MAX_ATIME_DIFF 60
14 struct mds_filter_data {
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))
22 #define MDS_NO_SPLIT_EXPECTED 0
23 #define MDS_EXPECT_SPLIT 1
24 #define MDS_NO_SPLITTABLE 2
26 /* 1048576 should be enough for one client pool */
27 #define MDS_FIDEXT_SIZE (1 << 20)
29 static inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
31 return &req->rq_export->exp_obd->u.mds;
33 static inline struct obd_device *req2obd(struct ptlrpc_request *req)
35 return req->rq_export->exp_obd;
39 /* Open counts for files. No longer atomic, must hold inode->i_sem */
40 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
41 # define mds_inode_oatomic(inode) ((inode)->i_cindex)
43 # define mds_inode_oatomic(inode) ((inode)->i_attr_flags)
46 static inline int mds_orphan_open_count(struct inode *inode)
48 LASSERT_MDS_ORPHAN_READ_LOCKED(inode);
49 return mds_inode_oatomic(inode);
52 static inline int mds_orphan_open_inc(struct inode *inode)
54 LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
55 return ++mds_inode_oatomic(inode);
58 static inline int mds_orphan_open_dec_test(struct inode *inode)
60 LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
61 return --mds_inode_oatomic(inode) == 0;
64 #define mds_inode_is_orphan(inode) ((inode)->i_flags & 0x4000000)
65 #define mds_inode_set_orphan(inode) \
67 (inode)->i_flags |= 0x4000000; \
68 CDEBUG(D_VFSTRACE, "setting orphan flag on inode %p\n", inode); \
70 #define mds_inode_unset_orphan(inode) \
72 (inode)->i_flags &= ~(0x4000000); \
73 CDEBUG(D_VFSTRACE, "removing orphan flag from inode %p\n", inode); \
77 /* inode flags managed by mds directly */
78 #define MDS_IF_ATTRS_OLD 0x8000000 /* inode needs attrs. refreshing */
80 #define mds_inode_has_old_attrs(inode) ((inode)->i_flags & MDS_IF_ATTRS_OLD)
81 #define mds_inode_set_attrs_old(inode) \
83 (inode)->i_flags |= MDS_IF_ATTRS_OLD; \
84 CDEBUG(D_VFSTRACE, "setting attr.old flag on inode %p\n", inode);\
86 #define mds_inode_unset_attrs_old(inode) \
88 (inode)->i_flags &= ~(MDS_IF_ATTRS_OLD); \
89 CDEBUG(D_VFSTRACE, "removing attrs.old flag from inode %p\n", inode);\
93 #endif /* __KERNEL__ */
96 int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
97 struct lustre_handle *p1_lockh, int p1_lock_mode,
98 ldlm_policy_data_t *p1_policy,
99 struct ldlm_res_id *p2_res_id,
100 struct lustre_handle *p2_lockh, int p2_lock_mode,
101 ldlm_policy_data_t *p2_policy);
103 int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
104 struct ptlrpc_request *req, int rc, __u32 op_data);
105 void mds_reconstruct_generic(struct ptlrpc_request *req);
106 void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd);
107 int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
108 struct lustre_id *id,
109 struct lustre_handle *parent_lockh,
110 struct dentry **dparentp, int parent_mode,
111 __u64 parent_lockpart, int *update_mode,
112 char *name, int namelen,
113 struct lustre_handle *child_lockh,
114 struct dentry **dchildp, int child_mode,
115 __u64 child_lockpart);
116 int mds_lock_new_child(struct obd_device *obd, struct inode *inode,
117 struct lustre_handle *child_lockh);
120 void groups_from_buffer(struct group_info *ginfo, __u32 *gids);
121 int mds_update_unpack(struct ptlrpc_request *, int offset,
122 struct mds_update_record *);
123 int mds_idmap_add(struct mds_idmap_table *tbl,
124 uid_t rmt_uid, uid_t lcl_uid,
125 gid_t rmt_gid, gid_t lcl_gid);
126 int mds_idmap_del(struct mds_idmap_table *tbl,
127 uid_t rmt_uid, uid_t lcl_uid,
128 gid_t rmt_gid, gid_t lcl_gid);
129 int mds_idmap_lookup_uid(struct mds_idmap_table *tbl, int reverse, uid_t uid);
130 int mds_idmap_lookup_gid(struct mds_idmap_table *tbl, int reverse, gid_t gid);
131 struct mds_idmap_table *mds_idmap_alloc(void);
132 void mds_idmap_free(struct mds_idmap_table *tbl);
133 void mds_body_do_reverse_map(struct mds_export_data *med,
134 struct mds_body *body);
135 int mds_init_ucred(struct lvfs_ucred *ucred, struct ptlrpc_request *req,
136 struct mds_req_sec_desc *rsd);
137 void mds_exit_ucred(struct lvfs_ucred *ucred);
139 int mds_set_gskey(struct obd_device *obd, void *handle,
140 struct inode *inode, void *key, int key_len, int valid);
141 int mds_set_crypto_type(struct obd_device *obd, void *val, __u32 vallen);
143 int mds_pack_gskey(struct obd_device *obd, struct lustre_msg *repmsg,
144 int *offset, struct mds_body *body, struct inode *inode);
145 /* mds/mds_unlink_open.c */
146 int mds_cleanup_orphans(struct obd_device *obd);
148 int mds_unlink_object(struct mds_obd *mds, struct inode *inode,
149 struct lov_mds_md *lmm, int lmm_size,
150 struct llog_cookie *logcookies,
151 int log_unlink, int async);
155 int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
156 struct lov_mds_md *lmm, int lmm_size,
157 struct llog_cookie *logcookies, int cookies_size,
158 struct llog_create_locks **res);
159 int mds_llog_init(struct obd_device *obd, struct obd_llogs *,
160 struct obd_device *tgt, int count, struct llog_catid *logid);
161 int mds_llog_finish(struct obd_device *obd, struct obd_llogs *, int count);
164 int mds_dt_connect(struct obd_device *obd, char * lov_name);
165 int mds_dt_disconnect(struct obd_device *obd, int flags);
166 int mds_dt_set_info(struct obd_export *exp, obd_count keylen,
167 void *key, obd_count vallen, void *val);
168 int mds_get_lovtgts(struct obd_device *, int tgt_count, struct obd_uuid *);
169 int mds_dt_write_objids(struct obd_device *obd);
170 int mds_dt_set_growth(struct mds_obd *mds, int count);
171 int mds_dt_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid);
172 int mds_post_mds_lovconf(struct obd_device *obd);
173 int mds_notify(struct obd_device *obd, struct obd_device *watched,
174 int active, void *data);
175 int mds_dt_update_config(struct obd_device *obd, int transno);
176 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
177 struct lov_mds_md *lmm, int lmm_size);
178 int mds_revalidate_lov_ea(struct obd_device *obd, struct inode *inode,
179 struct lustre_msg *msg, int offset);
180 void mds_dt_update_objids(struct obd_device *obd, obd_id *ids);
181 void mds_dt_save_objids(struct obd_device *obd, obd_id *ids);
184 int mds_create_object(struct obd_device *obd, struct ptlrpc_request *req,
185 int offset, struct mds_update_record *rec,
186 struct dentry *dchild, void **handle,
188 int mds_destroy_object(struct obd_device *obd,
189 struct inode *inode, int async);
190 int mds_query_write_access(struct inode *inode);
191 int mds_open(struct mds_update_record *rec, int offset,
192 struct ptlrpc_request *req, struct lustre_handle *);
193 int mds_pin(struct ptlrpc_request *req, int offset);
194 int mds_mfd_close(struct ptlrpc_request *req, int offset,
195 struct obd_device *obd, struct mds_file_data *mfd,
197 int mds_close(struct ptlrpc_request *req, int offset);
198 int mds_done_writing(struct ptlrpc_request *req, int offset);
199 struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle);
200 int mds_validate_size(struct obd_device *obd, struct inode *inode,
201 struct mds_body *body, struct iattr *iattr);
202 int accmode(int flags);
205 int mds_fidmap_init(struct obd_device *obd, int size);
206 int mds_fidmap_cleanup(struct obd_device *obd);
208 struct fidmap_entry *
209 mds_fidmap_find(struct obd_device *obd, __u64 fid);
212 mds_fidmap_lookup(struct obd_device *obd,
213 struct lustre_id *id);
215 void mds_fidmap_insert(struct obd_device *obd,
216 struct fidmap_entry *entry);
218 void mds_fidmap_remove(struct obd_device *obd,
219 struct fidmap_entry *entry);
221 int mds_fidmap_add(struct obd_device *obd,
222 struct lustre_id *id);
224 void mds_fidmap_del(struct obd_device *obd,
225 struct lustre_id *id);
227 int mds_client_add(struct obd_device *obd, struct mds_obd *mds,
228 struct mds_export_data *med, int cl_off);
229 int mds_client_free(struct obd_export *exp, int clear_client);
230 int mds_obd_create(struct obd_export *exp, struct obdo *oa,
231 void *acl, int acl_size,
232 struct lov_stripe_md **ea, struct obd_trans_info *oti);
233 int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
234 struct lov_stripe_md *ea, struct obd_trans_info *oti);
237 int mds_getattr_size(struct obd_device *obd, struct dentry *dentry,
238 struct ptlrpc_request *req, struct mds_body *body);
239 int mds_handle(struct ptlrpc_request *req);
240 extern struct lvfs_callback_ops mds_lvfs_ops;
241 int mds_dt_clean(struct obd_device *obd);
242 int mds_postrecov(struct obd_device *obd);
243 int mds_postrecov_common(struct obd_device *obd);
244 extern struct lvfs_callback_ops mds_lvfs_ops;
246 extern int mds_iocontrol(unsigned int cmd,
247 struct obd_export *exp,
251 extern int mds_lock_mode_for_dir(struct obd_device *,
252 struct dentry *, int);
254 int mds_fs_setup_rootid(struct obd_device *obd);
255 int mds_fs_setup_virtid(struct obd_device *obd);
257 __u64 mds_alloc_fid(struct obd_device *obd);
259 void mds_inode2id(struct obd_device *obd, struct lustre_id *id,
260 struct inode *inode, __u64 fid);
261 int mds_update_inode_ids(struct obd_device *, struct inode *,
262 void *, struct lustre_id *, struct lustre_id *);
263 int mds_read_inode_sid(struct obd_device *, struct inode *,
266 int mds_read_inode_pid(struct obd_device *, struct inode *,
269 void mds_commit_last_fid_cb(struct obd_device *, __u64 fid,
270 void *data, int error);
272 void mds_commit_last_transno_cb(struct obd_device *, __u64 transno,
273 void *data, int error);
275 void mds_set_last_fid(struct obd_device *obd, __u64 fid);
278 int mds_get_md(struct obd_device *, struct inode *, void *md,
279 int *size, int lock, int mea);
281 int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
282 struct mds_body *, struct inode *, int lock, int mea);
283 int mds_pack_link(struct dentry *dentry, struct ptlrpc_request *req,
284 struct mds_body *repbody, int reply_off);
285 int mds_pack_xattr(struct dentry *dentry, struct ptlrpc_request *req,
286 struct mds_body *repbody, int req_off, int reply_off);
287 int mds_pack_xattr_list(struct dentry *dentry, struct ptlrpc_request *req,
288 struct mds_body *repbody, int reply_off);
289 int mds_pack_acl(struct ptlrpc_request *req, int *reply_off,
290 struct mds_body *body, struct inode *inode);
292 int mds_pack_inode2id(struct obd_device *, struct lustre_id *,
293 struct inode *, int);
295 void mds_pack_inode2body(struct obd_device *, struct mds_body *,
296 struct inode *, int);
298 void mds_pack_dentry2id(struct obd_device *, struct lustre_id *,
299 struct dentry *, int);
301 void mds_pack_dentry2body(struct obd_device *, struct mds_body *b,
302 struct dentry *, int);
307 int mds_md_postsetup(struct obd_device *obd);
308 int mds_md_connect(struct obd_device *obd, char * lov_name);
309 int mds_md_disconnect(struct obd_device *obd, int flags);
310 int mds_try_to_split_dir(struct obd_device *, struct dentry *, struct mea **,
312 int mds_md_get_attr(struct obd_device *, struct inode *, struct mea **, int *);
313 int mds_choose_mdsnum(struct obd_device *, const char *, int, int,
314 struct ptlrpc_peer *, struct inode *, int);
315 int mds_md_postsetup(struct obd_device *);
316 int mds_splitting_expected(struct obd_device *, struct dentry *);
317 int mds_lock_slave_objs(struct obd_device *, struct dentry *,
318 struct lustre_handle **);
319 int mds_unlink_slave_objs(struct obd_device *, struct dentry *);
320 void mds_unlock_slave_objs(struct obd_device *, struct dentry *,
321 struct lustre_handle *);
322 int mds_lock_and_check_slave(int, struct ptlrpc_request *, struct lustre_handle *);
323 int mds_convert_mea_ea(struct obd_device *, struct inode *, struct lov_mds_md *, int);
324 int mds_is_dir_empty(struct obd_device *, struct dentry *);
325 int mds_md_reconnect(struct obd_device *obd);
328 struct upcall_cache *__mds_get_global_lsd_cache(void);
329 int mds_init_lsd_cache(void);
330 void mds_cleanup_lsd_cache(void);
331 struct lustre_sec_desc * mds_get_lsd(__u32 uid);
332 void mds_put_lsd(struct lustre_sec_desc *lsd);
333 void mds_flush_lsd(__u32 id);
335 /* mds_audit_path.c */
336 int mds_parse_id(struct ptlrpc_request *req);
339 int mds_set_audit(struct obd_device * obd, void * val);
340 int mds_pack_audit(struct obd_device *, struct inode *, struct mds_body *);
343 struct upcall_cache *__mds_get_global_rmtacl_upcall_cache(void);
344 int mds_init_rmtacl_upcall_cache(void);
345 void mds_cleanup_rmtacl_upcall_cache(void);
346 void mds_do_remote_acl_upcall(struct rmtacl_upcall_desc *desc);
349 extern struct timer_list mds_eck_timer;
351 int mds_read_capa_key(struct obd_device *obd, struct file *file);
352 void mds_capa_keys_cleanup(struct obd_device *obd);
353 void mds_capa_key_timer_callback(unsigned long data);
354 int mds_capa_key_start_thread(void);
355 void mds_capa_key_stop_thread(void);
356 int mds_pack_capa(struct obd_device *obd, struct mds_body *req_body,
357 struct lustre_capa *req_capa, struct lustre_msg *repmsg,
358 int *offset, struct mds_body *body);
360 #endif /* _MDS_INTERNAL_H */