1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * This file is part of Lustre, http://www.lustre.org
7 * See also lustre_idl.h for wire formats of requests.
14 # include <linux/fs.h>
15 # include <linux/dcache.h>
17 #include <linux/lustre_handles.h>
18 #include <libcfs/kp30.h>
19 #include <linux/lustre_idl.h>
20 #include <linux/lustre_lib.h>
21 #include <linux/lustre_dlm.h>
22 #include <linux/lustre_log.h>
23 #include <linux/lustre_export.h>
25 struct ldlm_lock_desc;
27 struct ptlrpc_connection;
30 struct ptlrpc_request;
34 #define LUSTRE_MDS_NAME "mds"
35 #define LUSTRE_MDT_NAME "mdt"
36 #define LUSTRE_MDC_NAME "mdc"
39 struct mds_body *body;
40 struct lov_stripe_md *lsm;
58 struct mds_update_record {
60 struct ll_fid *ur_fid1;
61 struct ll_fid *ur_fid2;
69 struct llog_cookie *ur_logcookies;
70 struct iattr ur_iattr;
71 struct obd_ucred ur_uc;
78 #define ur_fsuid ur_uc.ouc_fsuid
79 #define ur_fsgid ur_uc.ouc_fsgid
80 #define ur_cap ur_uc.ouc_cap
81 #define ur_suppgid1 ur_uc.ouc_suppgid1
82 #define ur_suppgid2 ur_uc.ouc_suppgid2
83 #define ur_umask ur_uc.ouc_umask
85 #define MDS_LR_SERVER_SIZE 512
87 #define MDS_LR_CLIENT_START 8192
88 #define MDS_LR_CLIENT_SIZE 128
89 #if MDS_LR_CLIENT_START < MDS_LR_SERVER_SIZE
90 #error "Can't have MDS_LR_CLIENT_START < MDS_LR_SERVER_SIZE"
93 #define MDS_CLIENT_SLOTS 17
95 #define MDS_ROCOMPAT_LOVOBJID 0x00000001
96 #define MDS_ROCOMPAT_SUPP (MDS_ROCOMPAT_LOVOBJID)
98 #define MDS_INCOMPAT_SUPP (0)
100 /* Data stored per server at the head of the last_rcvd file. In le32 order.
101 * Try to keep this the same as fsd_server_data so we might one day merge. */
102 struct mds_server_data {
103 __u8 msd_uuid[40]; /* server UUID */
104 __u64 msd_last_transno; /* last completed transaction ID */
105 __u64 msd_mount_count; /* MDS incarnation number */
107 __u32 msd_feature_compat; /* compatible feature flags */
108 __u32 msd_feature_rocompat;/* read-only compatible feature flags */
109 __u32 msd_feature_incompat;/* incompatible feature flags */
110 __u32 msd_server_size; /* size of server data area */
111 __u32 msd_client_start; /* start of per-client data area */
112 __u16 msd_client_size; /* size of per-client data area */
113 __u16 msd_subdir_count; /* number of subdirectories for objects */
114 __u64 msd_catalog_oid; /* recovery catalog object id */
115 __u32 msd_catalog_ogen; /* recovery catalog inode generation */
116 __u8 msd_peeruuid[40]; /* UUID of LOV/OSC associated with MDS */
117 __u8 msd_padding[MDS_LR_SERVER_SIZE - 140];
120 /* Data stored per client in the last_rcvd file. In le32 order. */
121 struct mds_client_data {
122 __u8 mcd_uuid[40]; /* client UUID */
123 __u64 mcd_last_transno; /* last completed transaction ID */
124 __u64 mcd_last_xid; /* xid for the last transaction */
125 __u32 mcd_last_result; /* result from last RPC */
126 __u32 mcd_last_data; /* per-op data (disposition for open &c.) */
127 __u8 mcd_padding[MDS_LR_CLIENT_SIZE - 64];
130 /* file data for open files on MDS */
131 struct mds_file_data {
132 struct portals_handle mfd_handle; /* must be first */
133 atomic_t mfd_refcount;
134 struct list_head mfd_list;
137 struct dentry *mfd_dentry;
140 /* mds/mds_reint.c */
141 int mds_reint_rec(struct mds_update_record *r, int offset,
142 struct ptlrpc_request *req, struct lustre_handle *);
146 struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
147 struct vfsmount **mnt, int lock_mode,
148 struct lustre_handle *lockh,
149 char *name, int namelen);
150 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
151 struct vfsmount **mnt);
152 int mds_update_server_data(struct obd_device *, int force_sync);
155 int mds_fs_setup(struct obd_device *obddev, struct vfsmount *mnt);
156 int mds_fs_cleanup(struct obd_device *obddev, int failover);
161 /* mdc/mdc_locks.c */
162 int it_disposition(struct lookup_intent *it, int flag);
163 void it_set_disposition(struct lookup_intent *it, int flag);
164 int it_open_error(int phase, struct lookup_intent *it);
165 void mdc_set_lock_data(__u64 *lockh, void *data);
166 int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid,
167 ldlm_iterator_t it, void *data);
168 int mdc_intent_lock(struct obd_export *exp, struct ll_uctxt *,
169 struct ll_fid *parent,
170 const char *name, int len, void *lmm, int lmmsize,
171 struct ll_fid *child,
172 struct lookup_intent *, int,
173 struct ptlrpc_request **reqp,
174 ldlm_blocking_callback cb_blocking);
175 int mdc_enqueue(struct obd_export *exp,
177 struct lookup_intent *it,
179 struct mdc_op_data *data,
180 struct lustre_handle *lockh,
183 ldlm_completion_callback cb_completion,
184 ldlm_blocking_callback cb_blocking,
187 /* mdc/mdc_request.c */
188 int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp);
189 int mdc_req2lustre_md(struct ptlrpc_request *req, int offset,
190 struct obd_export *exp, struct lustre_md *md);
191 int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid);
192 int mdc_getattr(struct obd_export *exp, struct ll_fid *fid,
193 unsigned long valid, unsigned int ea_size,
194 struct ptlrpc_request **request);
195 int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
196 char *filename, int namelen, unsigned long valid,
197 unsigned int ea_size, struct ptlrpc_request **request);
198 int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data,
199 struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len,
200 struct ptlrpc_request **request);
201 int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags,
202 struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh,
203 struct ptlrpc_request **);
204 struct obd_client_handle;
205 void mdc_set_open_replay_data(struct obd_client_handle *och,
206 struct ptlrpc_request *open_req);
207 void mdc_clear_open_replay_data(struct obd_client_handle *och);
208 int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *,
209 struct ptlrpc_request **);
210 int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset,
211 struct page *, struct ptlrpc_request **);
212 int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
213 const void *data, int datalen, int mode, __u32 uid, __u32 gid,
214 __u64 rdev, struct ptlrpc_request **request);
215 int mdc_unlink(struct obd_export *exp, struct mdc_op_data *data,
216 struct ptlrpc_request **request);
217 int mdc_link(struct obd_export *exp, struct mdc_op_data *data,
218 struct ptlrpc_request **);
219 int mdc_rename(struct obd_export *exp, struct mdc_op_data *data,
220 const char *old, int oldlen, const char *new, int newlen,
221 struct ptlrpc_request **request);
222 int mdc_sync(struct obd_export *exp, struct ll_fid *fid,
223 struct ptlrpc_request **);
224 int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl);
226 /* Store the generation of a newly-created inode in |req| for replay. */
227 void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
229 int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data);
230 int mdc_done_writing(struct obd_export *exp, struct obdo *);
232 static inline void mdc_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen,
236 fid->generation = gen;
240 /* ioctls for trying requests */
241 #define IOC_REQUEST_TYPE 'f'
242 #define IOC_REQUEST_MIN_NR 30
244 #define IOC_REQUEST_GETATTR _IOWR('f', 30, long)
245 #define IOC_REQUEST_READPAGE _IOWR('f', 31, long)
246 #define IOC_REQUEST_SETATTR _IOWR('f', 32, long)
247 #define IOC_REQUEST_CREATE _IOWR('f', 33, long)
248 #define IOC_REQUEST_OPEN _IOWR('f', 34, long)
249 #define IOC_REQUEST_CLOSE _IOWR('f', 35, long)
250 #define IOC_REQUEST_MAX_NR 35