1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2003 Cluster File Systems, Inc. <info@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * MDS data structures.
22 * See also lustre_idl.h for wire formats of requests.
32 #include <linux/kp30.h>
33 #include <linux/lustre_idl.h>
35 struct ldlm_lock_desc;
37 struct ptlrpc_connection;
40 struct ptlrpc_request;
44 #define LUSTRE_MDS_NAME "mds"
45 #define LUSTRE_MDT_NAME "mdt"
46 #define LUSTRE_MDC_NAME "mdc"
49 struct semaphore rpcl_sem;
50 struct lookup_intent *rpcl_it;
52 extern struct mdc_rpc_lock mdc_rpc_lock;
54 static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck)
56 sema_init(&lck->rpcl_sem, 1);
60 static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck,
61 struct lookup_intent *it)
66 it->it_iattr = (void *)1;
70 static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
71 struct lookup_intent *it)
74 LASSERT(it == lck->rpcl_it);
78 if (it && it->it_iattr) {
80 LASSERT(it == lck->rpcl_it);
85 struct mdc_unlink_data {
86 struct inode *unl_dir;
93 struct mds_update_record {
98 struct ll_fid *ur_fid1;
99 struct ll_fid *ur_fid2;
104 struct iattr ur_iattr;
114 #define MDS_LR_CLIENT 8192
115 #define MDS_LR_SIZE 128
117 #define MDS_CLIENT_SLOTS 17
119 #define MDS_MOUNT_RECOV 2
120 #define MDS_RECOVERY_TIMEOUT (obd_timeout * 5 * HZ / 2) /* *waves hands* */
122 /* Data stored per server at the head of the last_rcvd file. In le32 order. */
123 struct mds_server_data {
124 __u8 msd_uuid[37]; /* server UUID */
125 __u8 uuid_padding[3]; /* unused */
126 __u64 msd_last_rcvd; /* last completed transaction ID */
127 __u64 msd_mount_count; /* MDS incarnation number */
128 __u8 padding[512 - 56];
131 /* Data stored per client in the last_rcvd file. In le32 order. */
132 struct mds_client_data {
133 __u8 mcd_uuid[37]; /* client UUID */
134 __u8 uuid_padding[3]; /* unused */
135 __u64 mcd_last_rcvd; /* last completed transaction ID */
136 __u64 mcd_mount_count; /* MDS incarnation number */
137 __u64 mcd_last_xid; /* client RPC xid for the last transaction */
138 __u8 padding[MDS_LR_SIZE - 64];
141 /* In-memory access to client data from MDS struct */
142 struct mds_export_data {
143 struct list_head med_open_head;
144 spinlock_t med_open_lock;
145 struct mds_client_data *med_mcd;
148 struct lustre_msg *med_last_reply;
152 /* file data for open files on MDS */
153 struct mds_file_data {
154 struct list_head mfd_list;
155 __u64 mfd_servercookie;
156 struct file *mfd_file;
159 /* mds/mds_reint.c */
160 int mds_reint_rec(struct mds_update_record *r, int offset,
161 struct ptlrpc_request *req, struct lustre_handle *);
164 int mds_open(struct mds_update_record *rec, int offset,
165 struct ptlrpc_request *req, struct lustre_handle *);
167 /* lib/mds_updates.c */
168 void mds_unpack_body(struct mds_body *b);
169 void mds_unpack_fid(struct ll_fid *fid);
170 void mds_pack_fid(struct ll_fid *fid);
171 void mds_pack_req_body(struct ptlrpc_request *);
172 void mds_pack_rep_body(struct ptlrpc_request *);
173 int mds_update_unpack(struct ptlrpc_request *, int offset,
174 struct mds_update_record *);
176 void mds_readdir_pack(struct ptlrpc_request *req, __u64 offset, obd_id ino,
177 int type, __u64 xid);
178 void mds_getattr_pack(struct ptlrpc_request *req, int valid, int offset, int fl,
179 struct inode *inode, const char *name, int namelen);
180 void mds_setattr_pack(struct ptlrpc_request *, struct inode *,
181 struct iattr *, void *ea, int ealen);
182 void mds_create_pack(struct ptlrpc_request *, int offset, struct inode *dir,
183 __u32 mode, __u64 rdev, __u32 uid, __u32 gid, __u64 time,
184 const char *name, int namelen, const void *data,
186 void mds_open_pack(struct ptlrpc_request *, int offset, struct inode *dir,
187 __u32 mode, __u64 rdev, __u32 uid, __u32 gid, __u64 time,
188 __u32 flags, const char *name, int namelen,
189 const void *data, int datalen);
190 void mds_unlink_pack(struct ptlrpc_request *, int offset, struct inode *inode,
191 struct inode *child, __u32 mode, const char *name,
193 void mds_link_pack(struct ptlrpc_request *, int offset, struct inode *ino,
194 struct inode *dir, const char *name, int namelen);
195 void mds_rename_pack(struct ptlrpc_request *, int offset, struct inode *srcdir,
196 struct inode *tgtdir, const char *name, int namelen,
197 const char *tgt, int tgtlen);
198 void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode);
199 void mds_pack_inode2body(struct mds_body *body, struct inode *inode);
202 struct dentry *mds_name2locked_dentry(struct obd_device *, struct dentry *dir,
203 struct vfsmount **mnt, char *name,
204 int namelen, int lock_mode,
205 struct lustre_handle *lockh,
207 struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
208 struct vfsmount **mnt, int lock_mode,
209 struct lustre_handle *lockh);
210 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
211 struct vfsmount **mnt);
212 int mds_reint(struct ptlrpc_request *req, int offset, struct lustre_handle *);
213 int mds_pack_md(struct obd_device *mds, struct lustre_msg *msg,
214 int offset, struct mds_body *body, struct inode *inode);
217 int mds_fs_setup(struct obd_device *obddev, struct vfsmount *mnt);
218 int mds_fs_cleanup(struct obd_device *obddev);
220 /* mdc/mdc_request.c */
221 int mdc_enqueue(struct lustre_handle *conn, int lock_type,
222 struct lookup_intent *it, int lock_mode, struct inode *dir,
223 struct dentry *de, struct lustre_handle *lockh, char *tgt,
224 int tgtlen, void *data, int datalen);
225 int mdc_cancel_unused(struct lustre_handle *conn, struct inode *, int flags);
226 int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
227 struct ptlrpc_request **request);
228 int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid);
229 int mdc_getattr(struct lustre_handle *conn,
230 obd_id ino, int type, unsigned long valid, unsigned int ea_size,
231 struct ptlrpc_request **request);
232 int mdc_getattr_name(struct lustre_handle *conn, struct inode *parent,
233 char *filename, int namelen, unsigned long valid,
234 unsigned int ea_size, struct ptlrpc_request **request);
235 int mdc_setattr(struct lustre_handle *conn,
236 struct inode *, struct iattr *iattr,
237 void *ea, int ealen, struct ptlrpc_request **);
238 int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
239 struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh,
240 struct ptlrpc_request **);
241 void mdc_set_open_replay_data(struct ll_file_data *fd);
242 int mdc_close(struct lustre_handle *conn, obd_id ino, int type,
243 struct lustre_handle *fh, struct ptlrpc_request **req);
244 int mdc_readpage(struct lustre_handle *conn, obd_id ino,
245 int type, __u64 offset, char *addr, struct ptlrpc_request **);
246 int mdc_create(struct lustre_handle *conn,
247 struct inode *dir, const char *name, int namelen,
248 const void *data, int datalen, int mode, __u32 uid, __u32 gid,
249 __u64 time, __u64 rdev, struct ptlrpc_request **);
250 int mdc_unlink(struct lustre_handle *, struct inode *dir, struct inode *child,
251 __u32 mode, const char *name, int namelen,
252 struct ptlrpc_request **);
253 int mdc_link(struct lustre_handle *conn,
254 struct inode *src, struct inode *dir, const char *name,
255 int namelen, struct ptlrpc_request **);
256 int mdc_rename(struct lustre_handle *conn,
257 struct inode *src, struct inode *tgt, const char *old,
258 int oldlen, const char *new, int newlen,
259 struct ptlrpc_request **);
260 int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl);
261 void mdc_lock_set_inode(struct lustre_handle *lock, struct inode *inode);
263 /* Store the generation of a newly-created inode in |req| for replay. */
264 void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
267 int mds_client_add(struct mds_obd *mds, struct mds_export_data *med,
269 int mds_client_free(struct obd_export *exp);
271 #endif /* __KERNEL__ */
273 /* ioctls for trying requests */
274 #define IOC_REQUEST_TYPE 'f'
275 #define IOC_REQUEST_MIN_NR 30
277 #define IOC_REQUEST_GETATTR _IOWR('f', 30, long)
278 #define IOC_REQUEST_READPAGE _IOWR('f', 31, long)
279 #define IOC_REQUEST_SETATTR _IOWR('f', 32, long)
280 #define IOC_REQUEST_CREATE _IOWR('f', 33, long)
281 #define IOC_REQUEST_OPEN _IOWR('f', 34, long)
282 #define IOC_REQUEST_CLOSE _IOWR('f', 35, long)
283 #define IOC_REQUEST_MAX_NR 35