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 MAX_ATIME_DIFF 60
12 struct mds_filter_data {
16 #define MDS_FILTERDATA(inode) ((struct mds_filter_data *)(inode)->i_filterdata)
17 #define DENTRY_VALID(dentry) \
18 ((dentry)->d_inode || ((dentry)->d_flags & DCACHE_CROSS_REF))
20 #define MDS_NO_SPLIT_EXPECTED 0
21 #define MDS_EXPECT_SPLIT 1
22 #define MDS_NO_SPLITTABLE 2
24 static inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
26 return &req->rq_export->exp_obd->u.mds;
28 static inline struct obd_device *req2obd(struct ptlrpc_request *req)
30 return req->rq_export->exp_obd;
39 MDS_GETATTR_COUNT = 5,
40 MDS_GETATTR_LOCK_COUNT = 6,
41 MDS_SETATTR_COUNT = 7,
44 MDS_LAST_OPC_COUNT = 10
47 struct lprocfs_stats * lprocfs_alloc_mds_counters(void);
48 void lprocfs_free_mds_counters(struct lprocfs_stats *ptr);
51 #define MDS_UPDATE_COUNTER(mds, opcode) do {} while (0)
54 #define MDS_UPDATE_COUNTER(mds, opcode) \
55 LASSERT( opcode < MDS_LAST_OPC_COUNT); \
56 LASSERT( mds->mds_counters != NULL); \
57 lprocfs_counter_incr(mds->mds_counters, opcode);
61 /* Open counts for files. No longer atomic, must hold inode->i_sem */
62 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
63 # define mds_inode_oatomic(inode) ((inode)->i_cindex)
65 # define mds_inode_oatomic(inode) ((inode)->i_attr_flags)
68 static inline int mds_orphan_open_count(struct inode *inode)
70 LASSERT_MDS_ORPHAN_READ_LOCKED(inode);
71 return mds_inode_oatomic(inode);
74 static inline int mds_orphan_open_inc(struct inode *inode)
76 LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
77 return ++mds_inode_oatomic(inode);
80 static inline int mds_orphan_open_dec_test(struct inode *inode)
82 LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
83 return --mds_inode_oatomic(inode) == 0;
86 #define mds_inode_is_orphan(inode) ((inode)->i_flags & 0x4000000)
87 #define mds_inode_set_orphan(inode) \
89 (inode)->i_flags |= 0x4000000; \
90 CDEBUG(D_VFSTRACE, "setting orphan flag on inode %p\n", inode); \
92 #define mds_inode_unset_orphan(inode) \
94 (inode)->i_flags &= ~(0x4000000); \
95 CDEBUG(D_VFSTRACE, "removing orphan flag from inode %p\n", inode); \
97 #endif /* __KERNEL__ */
100 int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
101 struct lustre_handle *p1_lockh, int p1_lock_mode,
102 ldlm_policy_data_t *p1_policy,
103 struct ldlm_res_id *p2_res_id,
104 struct lustre_handle *p2_lockh, int p2_lock_mode,
105 ldlm_policy_data_t *p2_policy);
107 int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
108 struct ptlrpc_request *req, int rc, __u32 op_data);
109 void mds_reconstruct_generic(struct ptlrpc_request *req);
110 void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd);
111 int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
112 struct lustre_id *id,
113 struct lustre_handle *parent_lockh,
114 struct dentry **dparentp, int parent_mode,
115 __u64 parent_lockpart, int *update_mode,
116 char *name, int namelen,
117 struct lustre_handle *child_lockh,
118 struct dentry **dchildp, int child_mode,
119 __u64 child_lockpart);
120 int mds_lock_new_child(struct obd_device *obd, struct inode *inode,
121 struct lustre_handle *child_lockh);
124 void groups_from_buffer(struct group_info *ginfo, __u32 *gids);
125 int mds_update_unpack(struct ptlrpc_request *, int offset,
126 struct mds_update_record *);
127 int mds_init_ucred(struct lvfs_ucred *ucred, struct mds_req_sec_desc *rsd);
128 void mds_exit_ucred(struct lvfs_ucred *ucred);
130 /* mds/mds_unlink_open.c */
131 int mds_cleanup_orphans(struct obd_device *obd);
135 int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
136 struct lov_mds_md *lmm, int lmm_size,
137 struct llog_cookie *logcookies, int cookies_size,
138 struct llog_create_locks **res);
139 int mds_llog_init(struct obd_device *obd, struct obd_llogs *,
140 struct obd_device *tgt, int count, struct llog_catid *logid);
141 int mds_llog_finish(struct obd_device *obd, struct obd_llogs *, int count);
144 int mds_lov_connect(struct obd_device *obd, char * lov_name);
145 int mds_lov_disconnect(struct obd_device *obd, int flags);
146 int mds_lov_set_info(struct obd_export *exp, obd_count keylen,
147 void *key, obd_count vallen, void *val);
148 int mds_get_lovtgts(struct obd_device *, int tgt_count, struct obd_uuid *);
149 int mds_lov_write_objids(struct obd_device *obd);
150 void mds_lov_update_objids(struct obd_device *obd, obd_id *ids);
151 int mds_lov_set_growth(struct mds_obd *mds, int count);
152 int mds_lov_set_nextid(struct obd_device *obd);
153 int mds_lov_clearorphans(struct mds_obd *mds, struct obd_uuid *ost_uuid);
154 int mds_post_mds_lovconf(struct obd_device *obd);
155 int mds_notify(struct obd_device *obd, struct obd_device *watched,
156 int active, void *data);
157 int mds_lov_update_config(struct obd_device *obd, int transno);
158 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
159 struct lov_mds_md *lmm, int lmm_size);
160 int mds_revalidate_lov_ea(struct obd_device *obd, struct inode *inode,
161 struct lustre_msg *msg, int offset);
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,
171 int mds_close(struct ptlrpc_request *req, int offset);
172 int mds_done_writing(struct ptlrpc_request *req, int offset);
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 struct lov_stripe_md **ea, struct obd_trans_info *oti);
181 int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
182 struct lov_stripe_md *ea, struct obd_trans_info *oti);
185 void mds_squash_root(struct mds_obd *mds, struct mds_req_sec_desc *rsd,
187 int mds_handle(struct ptlrpc_request *req);
188 extern struct lvfs_callback_ops mds_lvfs_ops;
189 int mds_lov_clean(struct obd_device *obd);
190 int mds_postrecov(struct obd_device *obd);
191 extern struct lvfs_callback_ops mds_lvfs_ops;
193 extern int mds_iocontrol(unsigned int cmd,
194 struct obd_export *exp,
198 extern int mds_lock_mode_for_dir(struct obd_device *,
199 struct dentry *, int);
201 int mds_fs_setup_rootid(struct obd_device *obd);
202 int mds_fs_setup_virtid(struct obd_device *obd);
204 int mds_alloc_inode_sid(struct obd_device *, struct inode *,
205 void *, struct lustre_id *);
207 int mds_update_inode_sid(struct obd_device *, struct inode *,
208 void *, struct lustre_id *);
210 int mds_read_inode_sid(struct obd_device *, struct inode *,
213 int mds_update_inode_mid(struct obd_device *, struct inode *,
214 void *, struct lustre_id *);
216 int mds_read_inode_mid(struct obd_device *, struct inode *,
219 void mds_commit_last_fid_cb(struct obd_device *, __u64 fid,
220 void *data, int error);
222 void mds_commit_last_transno_cb(struct obd_device *, __u64 transno,
223 void *data, int error);
225 void mds_set_last_fid(struct obd_device *obd, __u64 fid);
228 int mds_get_md(struct obd_device *, struct inode *, void *md,
229 int *size, int lock);
231 int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
232 struct mds_body *, struct inode *, int lock);
234 int mds_pack_inode2id(struct obd_device *, struct lustre_id *,
235 struct inode *, int);
237 void mds_pack_inode2body(struct obd_device *, struct mds_body *,
238 struct inode *, int);
240 void mds_pack_dentry2id(struct obd_device *, struct lustre_id *,
241 struct dentry *, int);
243 void mds_pack_dentry2body(struct obd_device *, struct mds_body *b,
244 struct dentry *, int);
248 int mds_lmv_postsetup(struct obd_device *obd);
249 int mds_lmv_connect(struct obd_device *obd, char * lov_name);
250 int mds_lmv_disconnect(struct obd_device *obd, int flags);
251 int mds_try_to_split_dir(struct obd_device *, struct dentry *, struct mea **,
253 int mds_get_lmv_attr(struct obd_device *, struct inode *, struct mea **, int *);
254 int mds_choose_mdsnum(struct obd_device *, const char *, int, int);
255 int mds_lmv_postsetup(struct obd_device *);
256 int mds_splitting_expected(struct obd_device *, struct dentry *);
257 int mds_lock_slave_objs(struct obd_device *, struct dentry *,
258 struct lustre_handle **);
259 int mds_unlink_slave_objs(struct obd_device *, struct dentry *);
260 void mds_unlock_slave_objs(struct obd_device *, struct dentry *,
261 struct lustre_handle *);
262 int mds_lock_and_check_slave(int, struct ptlrpc_request *, struct lustre_handle *);
263 int mds_convert_mea_ea(struct obd_device *, struct inode *, struct lov_mds_md *, int);
264 int mds_is_dir_empty(struct obd_device *, struct dentry *);
267 int mds_group_hash_init(void);
268 void mds_group_hash_cleanup(void);
269 void mds_group_hash_flush_idle(void);
270 int mds_allow_setgroups(void);
272 extern char mds_getgroups_upcall[PATH_MAX];
273 extern int mds_grp_hash_entry_expire;
274 extern int mds_grp_hash_acquire_expire;
276 struct mds_grp_hash *__mds_get_global_group_hash(void);
277 struct mds_grp_hash_entry * mds_get_group_entry(struct mds_obd *mds, uid_t uid);
278 void mds_put_group_entry(struct mds_obd *mds, struct mds_grp_hash_entry *entry);
279 int mds_handle_group_downcall(int err, uid_t uid, __u32 ngroups, gid_t *groups);
281 #endif /* _MDS_INTERNAL_H */