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_NAME_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 int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
62 struct lustre_handle *p1_lockh, int p1_lock_mode,
63 ldlm_policy_data_t *p1_policy,
64 struct ldlm_res_id *p2_res_id,
65 struct lustre_handle *p2_lockh, int p2_lock_mode,
66 ldlm_policy_data_t *p2_policy);
67 void mds_commit_cb(struct obd_device *, __u64 last_rcvd, void *data, int error);
68 int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
69 struct ptlrpc_request *req, int rc, __u32 op_data);
70 void mds_reconstruct_generic(struct ptlrpc_request *req);
71 void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd);
72 int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
74 struct lustre_handle *parent_lockh,
75 struct dentry **dparentp, int parent_mode,
76 __u64 parent_lockpart, int *update_mode,
77 char *name, int namelen,
78 struct lustre_handle *child_lockh,
79 struct dentry **dchildp, int child_mode,
80 __u64 child_lockpart, void* clone_info);
81 int mds_lock_new_child(struct obd_device *obd, struct inode *inode,
82 struct lustre_handle *child_lockh);
85 void groups_from_buffer(struct group_info *ginfo, __u32 *gids);
86 int mds_update_unpack(struct ptlrpc_request *, int offset,
87 struct mds_update_record *);
88 int mds_init_ucred(struct lvfs_ucred *ucred, struct mds_req_sec_desc *rsd);
89 void mds_exit_ucred(struct lvfs_ucred *ucred);
91 /* mds/mds_unlink_open.c */
92 int mds_open_unlink_rename(struct mds_update_record *rec,
93 struct obd_device *obd, struct dentry *dparent,
94 struct dentry *dchild, void **handle);
95 int mds_cleanup_orphans(struct obd_device *obd);
99 int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
100 struct lov_mds_md *lmm, int lmm_size,
101 struct llog_cookie *logcookies, int cookies_size,
102 struct llog_create_locks **res);
103 int mds_llog_init(struct obd_device *obd, struct obd_llogs *,
104 struct obd_device *tgt, int count, struct llog_catid *logid);
105 int mds_llog_finish(struct obd_device *obd, struct obd_llogs *, int count);
108 int mds_lov_connect(struct obd_device *obd, char * lov_name);
109 int mds_lov_disconnect(struct obd_device *obd, int flags);
110 int mds_lov_set_info(struct obd_export *exp, obd_count keylen,
111 void *key, obd_count vallen, void *val);
112 int mds_get_lovtgts(struct obd_device *, int tgt_count, struct obd_uuid *);
113 int mds_lov_write_objids(struct obd_device *obd);
114 void mds_lov_update_objids(struct obd_device *obd, obd_id *ids);
115 int mds_lov_set_growth(struct mds_obd *mds, int count);
116 int mds_lov_set_nextid(struct obd_device *obd);
117 int mds_lov_clearorphans(struct mds_obd *mds, struct obd_uuid *ost_uuid);
118 int mds_post_mds_lovconf(struct obd_device *obd);
119 int mds_notify(struct obd_device *obd, struct obd_device *watched,
120 int active, void *data);
121 int mds_lov_update_config(struct obd_device *obd, int transno);
122 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
123 struct lov_mds_md *lmm, int lmm_size);
124 int mds_revalidate_lov_ea(struct obd_device *obd, struct inode *inode,
125 struct lustre_msg *msg, int offset);
128 int mds_query_write_access(struct inode *inode);
129 int mds_open(struct mds_update_record *rec, int offset,
130 struct ptlrpc_request *req, struct lustre_handle *);
131 int mds_pin(struct ptlrpc_request *req, int offset);
132 int mds_mfd_close(struct ptlrpc_request *req, int offset,
133 struct obd_device *obd, struct mds_file_data *mfd,
135 int mds_close(struct ptlrpc_request *req, int offset);
136 int mds_done_writing(struct ptlrpc_request *req, int offset);
140 int mds_client_add(struct obd_device *obd, struct mds_obd *mds,
141 struct mds_export_data *med, int cl_off);
142 int mds_client_free(struct obd_export *exp, int clear_client);
143 int mds_obd_create(struct obd_export *exp, struct obdo *oa,
144 struct lov_stripe_md **ea, struct obd_trans_info *oti);
145 int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
146 struct lov_stripe_md *ea, struct obd_trans_info *oti);
149 void mds_squash_root(struct mds_obd *mds, struct mds_req_sec_desc *rsd,
151 int mds_handle(struct ptlrpc_request *req);
152 extern struct lvfs_callback_ops mds_lvfs_ops;
153 int mds_lov_clean(struct obd_device *obd);
154 extern int mds_iocontrol(unsigned int cmd, struct obd_export *exp,
155 int len, void *karg, void *uarg);
156 extern int mds_lock_mode_for_dir(struct obd_device *, struct dentry *, int);
157 int mds_postrecov(struct obd_device *obd);
160 int mds_get_md(struct obd_device *, struct inode *, void *md, int *size,
162 int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
163 struct mds_body *, struct inode *, int lock);
164 void mds_pack_dentry2fid(struct ll_fid *, struct dentry *);
165 void mds_pack_dentry2body(struct mds_body *b, struct dentry *dentry);
166 void mds_pack_inode2fid(struct obd_device *, struct ll_fid *, struct inode *);
167 void mds_pack_inode2body(struct obd_device *, struct mds_body *, struct inode *);
171 int mds_lmv_postsetup(struct obd_device *obd);
172 int mds_lmv_connect(struct obd_device *obd, char * lov_name);
173 int mds_lmv_disconnect(struct obd_device *obd, int flags);
174 int mds_try_to_split_dir(struct obd_device *, struct dentry *, struct mea **,
176 int mds_get_lmv_attr(struct obd_device *, struct inode *, struct mea **, int *);
177 int mds_choose_mdsnum(struct obd_device *, const char *, int, int);
178 int mds_lmv_postsetup(struct obd_device *);
179 int mds_splitting_expected(struct obd_device *, struct dentry *);
180 int mds_lock_slave_objs(struct obd_device *, struct dentry *,
181 struct lustre_handle **);
182 int mds_unlink_slave_objs(struct obd_device *, struct dentry *);
183 void mds_unlock_slave_objs(struct obd_device *, struct dentry *,
184 struct lustre_handle *);
185 int mds_lock_and_check_slave(int, struct ptlrpc_request *, struct lustre_handle *);
186 int mds_convert_mea_ea(struct obd_device *, struct inode *, struct lov_mds_md *, int);
189 int mds_group_hash_init(void);
190 void mds_group_hash_cleanup(void);
191 void mds_group_hash_flush_idle(void);
192 int mds_allow_setgroups(void);
194 extern char mds_getgroups_upcall[PATH_MAX];
195 extern int mds_grp_hash_entry_expire;
196 extern int mds_grp_hash_acquire_expire;
198 struct mds_grp_hash *__mds_get_global_group_hash(void);
199 struct mds_grp_hash_entry * mds_get_group_entry(struct mds_obd *mds, uid_t uid);
200 void mds_put_group_entry(struct mds_obd *mds, struct mds_grp_hash_entry *entry);
201 int mds_handle_group_downcall(int err, uid_t uid, __u32 ngroups, gid_t *groups);
203 #endif /* _MDS_INTERNAL_H */