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 (obd_timeout * 1000)
12 #define MAX_ATIME_DIFF 60
14 struct mds_filter_data {
18 #define MDS_FILTERDATA(inode) ((struct mds_filter_data *)(inode)->i_filterdata)
20 static inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
22 return &req->rq_export->exp_obd->u.mds;
26 /* Open counts for files. No longer atomic, must hold inode->i_sem */
27 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
28 # define mds_inode_oatomic(inode) ((inode)->i_cindex)
30 # define mds_inode_oatomic(inode) ((inode)->i_attr_flags)
33 #ifdef HAVE_I_ALLOC_SEM
34 #define MDS_UP_READ_ORPHAN_SEM(i) UP_READ_I_ALLOC_SEM(i)
35 #define MDS_DOWN_READ_ORPHAN_SEM(i) DOWN_READ_I_ALLOC_SEM(i)
36 #define LASSERT_MDS_ORPHAN_READ_LOCKED(i) LASSERT_I_ALLOC_SEM_READ_LOCKED(i)
38 #define MDS_UP_WRITE_ORPHAN_SEM(i) UP_WRITE_I_ALLOC_SEM(i)
39 #define MDS_DOWN_WRITE_ORPHAN_SEM(i) DOWN_WRITE_I_ALLOC_SEM(i)
40 #define LASSERT_MDS_ORPHAN_WRITE_LOCKED(i) LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i)
41 #define MDS_PACK_MD_LOCK 1
43 #define MDS_UP_READ_ORPHAN_SEM(i) do { up(&(i)->i_sem); } while (0)
44 #define MDS_DOWN_READ_ORPHAN_SEM(i) do { down(&(i)->i_sem); } while (0)
45 #define LASSERT_MDS_ORPHAN_READ_LOCKED(i) LASSERT(down_trylock(&(i)->i_sem)!=0)
47 #define MDS_UP_WRITE_ORPHAN_SEM(i) do { up(&(i)->i_sem); } while (0)
48 #define MDS_DOWN_WRITE_ORPHAN_SEM(i) do { down(&(i)->i_sem); } while (0)
49 #define LASSERT_MDS_ORPHAN_WRITE_LOCKED(i) LASSERT(down_trylock(&(i)->i_sem)!=0)
50 #define MDS_PACK_MD_LOCK 0
53 static inline int mds_orphan_open_count(struct inode *inode)
55 LASSERT_MDS_ORPHAN_READ_LOCKED(inode);
56 return mds_inode_oatomic(inode);
59 static inline int mds_orphan_open_inc(struct inode *inode)
61 LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
62 return ++mds_inode_oatomic(inode);
65 static inline int mds_orphan_open_dec_test(struct inode *inode)
67 LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
68 return --mds_inode_oatomic(inode) == 0;
71 #define mds_inode_is_orphan(inode) ((inode)->i_flags & 0x4000000)
73 static inline void mds_inode_set_orphan(struct inode *inode)
75 inode->i_flags |= 0x4000000;
76 CDEBUG(D_VFSTRACE, "setting orphan flag on inode %p\n", inode);
79 static inline void mds_inode_unset_orphan(struct inode *inode)
81 inode->i_flags &= ~(0x4000000);
82 CDEBUG(D_VFSTRACE, "removing orphan flag from inode %p\n", inode);
85 #endif /* __KERNEL__ */
87 #define MDS_CHECK_RESENT(req, reconstruct) \
89 if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT) { \
90 struct mds_client_data *mcd = \
91 req->rq_export->exp_mds_data.med_mcd; \
92 if (mcd->mcd_last_xid == req->rq_xid) { \
94 RETURN(req->rq_repmsg->status); \
96 DEBUG_REQ(D_HA, req, "no reply for RESENT req (have "LPD64")",\
101 /* mds/mds_reint.c */
102 int res_gt(struct ldlm_res_id *res1, struct ldlm_res_id *res2);
103 int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
104 struct lustre_handle *p1_lockh, int p1_lock_mode,
105 struct ldlm_res_id *p2_res_id,
106 struct lustre_handle *p2_lockh, int p2_lock_mode);
107 void mds_commit_cb(struct obd_device *, __u64 last_rcvd, void *data, int error);
108 int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
109 struct ptlrpc_request *req, int rc, __u32 op_data);
110 void mds_reconstruct_generic(struct ptlrpc_request *req);
111 void mds_req_from_mcd(struct ptlrpc_request *req, struct mds_client_data *mcd);
112 int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
114 struct lustre_handle *parent_lockh,
115 struct dentry **dparentp, int parent_mode,
116 char *name, int namelen,
117 struct lustre_handle *child_lockh,
118 struct dentry **dchildp, int child_mode);
119 int mds_lock_new_child(struct obd_device *obd, struct inode *inode,
120 struct lustre_handle *child_lockh);
123 int mds_update_unpack(struct ptlrpc_request *, int offset,
124 struct mds_update_record *);
126 /* mds/mds_unlink_open.c */
127 int mds_cleanup_orphans(struct obd_device *obd);
131 int mds_log_op_unlink(struct obd_device *obd, struct inode *inode,
132 struct lov_mds_md *lmm, int lmm_size,
133 struct llog_cookie *logcookies, int cookies_size);
134 int mds_llog_init(struct obd_device *obd, struct obd_device *tgt, int count,
135 struct llog_catid *logid);
136 int mds_llog_finish(struct obd_device *obd, int count);
139 int mds_lov_connect(struct obd_device *obd, char * lov_name);
140 int mds_lov_disconnect(struct obd_device *obd);
141 void mds_lov_set_cleanup_flags(struct obd_device *);
142 int mds_lov_write_objids(struct obd_device *obd);
143 void mds_lov_update_objids(struct obd_device *obd, obd_id *ids);
144 int mds_lov_set_growth(struct mds_obd *mds, int count);
145 int mds_lov_set_nextid(struct obd_device *obd);
146 int mds_lov_clearorphans(struct mds_obd *mds, struct obd_uuid *ost_uuid);
147 int mds_post_mds_lovconf(struct obd_device *obd);
148 int mds_notify(struct obd_device *obd, struct obd_device *watched, int active);
149 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
150 struct lov_mds_md *lmm, int lmm_size);
151 void mds_objids_from_lmm(obd_id *ids, struct lov_mds_md *lmm,
152 struct lov_desc *desc);
155 int mds_query_write_access(struct inode *inode);
156 int mds_open(struct mds_update_record *rec, int offset,
157 struct ptlrpc_request *req, struct lustre_handle *);
158 int mds_pin(struct ptlrpc_request *req);
159 int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd,
160 struct mds_file_data *mfd, int unlink_orphan);
161 int mds_close(struct ptlrpc_request *req);
162 int mds_done_writing(struct ptlrpc_request *req);
166 int mds_client_add(struct obd_device *obd, struct mds_obd *mds,
167 struct mds_export_data *med, int cl_off);
168 int mds_client_free(struct obd_export *exp, int clear_client);
169 int mds_obd_create(struct obd_export *exp, struct obdo *oa,
170 struct lov_stripe_md **ea, struct obd_trans_info *oti);
171 int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
172 struct lov_stripe_md *ea, struct obd_trans_info *oti);
175 extern struct lvfs_callback_ops mds_lvfs_ops;
176 int mds_lov_clean(struct obd_device *obd);
177 extern int mds_iocontrol(unsigned int cmd, struct obd_export *exp,
178 int len, void *karg, void *uarg);
179 int mds_postrecov(struct obd_device *obd);
181 int mds_get_md(struct obd_device *, struct inode *, void *md, int *size,
183 int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
184 struct mds_body *, struct inode *, int lock);
185 void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode);
186 void mds_pack_inode2body(struct mds_body *body, struct inode *inode);
189 #endif /* _MDS_INTERNAL_H */