1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
13 #include <linux/list.h>
14 #include <linux/smp_lock.h>
15 #include <linux/proc_fs.h>
17 #include <linux/lustre_lib.h>
18 #include <linux/lustre_idl.h>
19 #include <linux/lustre_mds.h>
20 #include <linux/lustre_export.h>
23 struct list_head typ_chain;
24 struct obd_ops *typ_ops;
36 struct lov_oinfo { /* per-child structure */
37 __u64 loi_id; /* object ID on the target OST */
38 __u64 loi_size; /* size of this object on the target OST */
39 struct lustre_handle *loi_handle; /* handle for object on OST */
40 int loi_ost_idx; /* OST stripe index in lmd_objects array */
43 struct lov_stripe_md {
45 __u32 lsm_mds_easize; /* packed size for MDS of ea - KILL ME*/
46 __u64 lsm_object_id; /* lov object id */
47 __u64 lsm_stripe_size; /* size of the stripe */
48 __u32 lsm_stripe_pattern; /* per-lov object stripe pattern */
49 int lsm_stripe_offset; /* offset of first stripe in lmd_objects */
50 int lsm_stripe_count; /* how many objects are being striped on */
51 int lsm_ost_count; /* how many OSTs are in this LOV - KILL ME */
52 struct lov_oinfo lsm_oinfo[0];
55 /* Individual type definitions */
58 struct super_block *e2_sb;
59 struct vfsmount *e2_vfsmnt;
67 #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
68 #define OBD_CTXT_DEBUG /* development-only debugging */
70 struct vfsmount *pwdmnt;
83 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
85 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
90 struct super_block *fo_sb;
91 struct vfsmount *fo_vfsmnt;
92 struct obd_run_ctxt fo_ctxt;
93 struct dentry *fo_dentry_O;
94 struct dentry *fo_dentry_O_mode[16];
97 struct file_operations *fo_fop;
98 struct inode_operations *fo_iop;
99 struct address_space_operations *fo_aops;
100 struct list_head fo_export_list;
103 struct mds_server_data;
106 struct obd_import cl_import;
107 struct semaphore cl_sem;
109 obd_uuid_t cl_target_uuid; /* XXX -> lustre_name */
110 int cl_max_mds_easize;
111 int cl_max_ost_easize;
115 struct ptlrpc_service *mds_service;
118 struct super_block *mds_sb;
119 struct super_operations *mds_sop;
120 struct vfsmount *mds_vfsmnt;
121 struct obd_run_ctxt mds_ctxt;
122 struct file_operations *mds_fop;
123 struct inode_operations *mds_iop;
124 struct address_space_operations *mds_aops;
125 struct mds_fs_operations *mds_fsops;
127 struct file *mds_rcvd_filp;
128 spinlock_t mds_last_lock;
129 __u64 mds_last_committed;
131 __u64 mds_mount_count;
132 struct ll_fid mds_rootfid;
133 struct mds_server_data *mds_server_data;
137 struct ptlrpc_service *ldlm_service;
138 struct ptlrpc_client *ldlm_client;
139 struct ptlrpc_connection *ldlm_server_conn;
157 spinlock_t recovd_lock;
158 struct list_head recovd_managed_items; /* items managed */
159 struct list_head recovd_troubled_items; /* items in recovery */
161 wait_queue_head_t recovd_recovery_waitq;
162 wait_queue_head_t recovd_ctl_waitq;
163 wait_queue_head_t recovd_waitq;
164 struct task_struct *recovd_thread;
169 struct obdtrace_opstats *stats;
174 unsigned int snap_index; /* which snapshot index are we accessing */
181 struct ptlrpc_service *ost_service;
182 struct lustre_handle ost_conn; /* the local connection to the OBD */
186 struct lov_tgt_desc {
188 struct lustre_handle conn;
189 int active; /* is this target available for requests, etc */
194 struct obd_device *mdcobd;
195 struct lov_desc desc;
197 struct lov_tgt_desc *tgts;
200 struct niobuf_local {
207 void *target_private;
208 struct dentry *dentry;
211 #define N_LOCAL_TEMP_PAGE 0x00000001
213 /* corresponds to one of the obd's */
215 struct obd_type *obd_type;
217 /* common and UUID name of this device */
223 struct proc_dir_entry *obd_proc_entry;
224 struct list_head obd_exports;
225 struct list_head obd_imports;
226 struct ldlm_namespace *obd_namespace;
227 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
228 /* a spinlock is OK for what we do now, may need a semaphore later */
229 spinlock_t obd_dev_lock;
231 struct ext2_obd ext2;
232 struct filter_obd filter;
234 struct client_obd cli;
236 // struct osc_obd osc;
237 struct ldlm_obd ldlm;
238 struct echo_obd echo;
239 struct recovd_obd recovd;
240 struct trace_obd trace;
243 struct snap_obd snap;
246 /* Fields used by LProcFS */
247 unsigned int cntr_mem_size;
254 int (*o_iocontrol)(long cmd, struct lustre_handle *, int len,
255 void *karg, void *uarg);
256 int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key,
257 obd_count *vallen, void **val);
258 int (*o_set_info)(struct lustre_handle *, obd_count keylen, void *key,
259 obd_count vallen, void *val);
260 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
261 int (*o_detach)(struct obd_device *dev);
262 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
263 int (*o_cleanup)(struct obd_device *dev);
264 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
265 obd_uuid_t cluuid, struct recovd_obd *recovd,
266 ptlrpc_recovery_cb_t recover);
267 int (*o_disconnect)(struct lustre_handle *conn);
270 int (*o_statfs)(struct lustre_handle *conn, struct obd_statfs *osfs);
271 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
273 int (*o_create)(struct lustre_handle *conn, struct obdo *oa,
274 struct lov_stripe_md **ea);
275 int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
276 struct lov_stripe_md *ea);
277 int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
278 struct lov_stripe_md *ea);
279 int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
280 struct lov_stripe_md *ea);
281 int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
282 struct lov_stripe_md *ea);
283 int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
284 struct lov_stripe_md *ea);
285 int (*o_brw)(int rw, struct lustre_handle *conn,
286 struct lov_stripe_md *ea, obd_count oa_bufs,
287 struct brw_page *pgarr, brw_callback_t callback,
288 struct io_cb_data *data);
289 int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
290 struct lov_stripe_md *ea, obd_size count,
292 int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
293 obd_size count, obd_off offset);
294 int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
295 struct obdo *src, obd_size count, obd_off offset);
296 int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
297 struct lustre_handle *srconn, struct obdo *src,
298 obd_size count, obd_off offset);
299 int (*o_iterate)(struct lustre_handle *conn,
300 int (*)(obd_id, obd_gr, void *),
301 obd_id *startid, obd_gr group, void *data);
302 int (*o_preprw)(int cmd, struct lustre_handle *conn,
303 int objcount, struct obd_ioobj *obj,
304 int niocount, struct niobuf_remote *remote,
305 struct niobuf_local *local, void **desc_private);
306 int (*o_commitrw)(int cmd, struct lustre_handle *conn,
307 int objcount, struct obd_ioobj *obj,
308 int niocount, struct niobuf_local *local,
310 int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
311 struct lustre_handle *parent_lock,
312 __u32 type, void *cookie, int cookielen, __u32 mode,
313 int *flags, void *cb, void *data, int datalen,
314 struct lustre_handle *lockh);
315 int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md,
316 __u32 mode, struct lustre_handle *);
317 int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
321 static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
324 return mds->mds_fsops->fs_start(inode, op);
327 static inline int mds_fs_commit(struct mds_obd *mds, struct inode *inode,
330 return mds->mds_fsops->fs_commit(inode, handle);
333 static inline int mds_fs_setattr(struct mds_obd *mds, struct dentry *dentry,
334 void *handle, struct iattr *iattr)
338 * NOTE: we probably don't need to take i_sem here when changing
339 * ATTR_SIZE because the MDS never needs to truncate a file.
340 * The ext2/ext3 code never truncates a directory, and files
341 * stored on the MDS are entirely sparse (no data blocks).
342 * If we do need to get it, we can do it here.
345 rc = mds->mds_fsops->fs_setattr(dentry, handle, iattr);
351 static inline int mds_fs_set_md(struct mds_obd *mds, struct inode *inode,
352 void *handle, struct lov_mds_md *md)
354 return mds->mds_fsops->fs_set_md(inode, handle, md);
357 static inline int mds_fs_get_md(struct mds_obd *mds, struct inode *inode,
358 struct lov_mds_md *md)
360 return mds->mds_fsops->fs_get_md(inode, md);
363 static inline ssize_t mds_fs_readpage(struct mds_obd *mds, struct file *file,
364 char *buf, size_t count, loff_t *offset)
366 return mds->mds_fsops->fs_readpage(file, buf, count, offset);
369 /* Set up callback to update mds->mds_last_committed with the current
370 * value of mds->mds_last_recieved when this transaction is on disk.
372 static inline int mds_fs_set_last_rcvd(struct mds_obd *mds, void *handle)
374 return mds->mds_fsops->fs_set_last_rcvd(mds, handle);
377 /* Enable data journaling on the given file */
378 static inline ssize_t mds_fs_journal_data(struct mds_obd *mds,
381 return mds->mds_fsops->fs_journal_data(file);
384 static inline int mds_fs_statfs(struct mds_obd *mds, struct statfs *sfs)
386 if (mds->mds_fsops->fs_statfs)
387 return mds->mds_fsops->fs_statfs(mds->mds_sb, sfs);
389 return vfs_statfs(mds->mds_sb, sfs);