1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 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 */
41 struct lov_stripe_md {
43 __u32 lmd_easize; /* packed size for MDS of ea */
44 __u64 lmd_object_id; /* lov object id */
45 __u64 lmd_stripe_offset; /* offset of the stripe */
46 __u64 lmd_stripe_size; /* size of the stripe */
47 __u32 lmd_stripe_count; /* how many objects are being striped */
48 __u32 lmd_stripe_pattern; /* per-lov object stripe pattern */
49 struct lov_oinfo lmd_oinfo[0];
52 struct lov_stripe_md_one {
54 __u32 lmd_easize; /* packed size for MDS of ea */
55 __u64 lmd_object_id; /* lov object id */
56 __u64 lmd_stripe_offset; /* offset of the stripe */
57 __u64 lmd_stripe_size; /* size of the stripe */
58 __u32 lmd_stripe_count; /* how many objects are being striped */
59 __u32 lmd_stripe_pattern; /* per-lov object stripe pattern */
60 struct lov_oinfo lmd_oinfo[1];
63 /* Individual type definitions */
66 struct super_block *e2_sb;
67 struct vfsmount *e2_vfsmnt;
70 #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
71 #define OBD_CTXT_DEBUG /* development-only debugging */
73 struct vfsmount *pwdmnt;
82 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
84 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
89 struct super_block *fo_sb;
90 struct vfsmount *fo_vfsmnt;
91 struct obd_run_ctxt fo_ctxt;
92 struct dentry *fo_dentry_O;
93 struct dentry *fo_dentry_O_mode[16];
96 struct file_operations *fo_fop;
97 struct inode_operations *fo_iop;
98 struct address_space_operations *fo_aops;
101 struct mds_server_data;
104 struct obd_import cl_import;
105 struct semaphore cl_sem;
107 __u8 cl_target_uuid[37]; /* XXX -> lustre_name */
112 struct ptlrpc_service *mds_service;
115 struct super_block *mds_sb;
116 struct super_operations *mds_sop;
117 struct vfsmount *mds_vfsmnt;
118 struct obd_run_ctxt mds_ctxt;
119 struct file_operations *mds_fop;
120 struct inode_operations *mds_iop;
121 struct address_space_operations *mds_aops;
122 struct mds_fs_operations *mds_fsops;
124 struct file *mds_rcvd_filp;
125 spinlock_t mds_last_lock;
126 __u64 mds_last_committed;
128 __u64 mds_mount_count;
129 struct ll_fid mds_rootfid;
130 struct mds_server_data *mds_server_data;
134 struct ptlrpc_service *ldlm_service;
135 struct ptlrpc_client *ldlm_client;
136 struct ptlrpc_connection *ldlm_server_conn;
155 __u32 recovd_next_phase;
157 struct recovd_data *recovd_current_rd;
158 spinlock_t recovd_lock;
159 struct list_head recovd_managed_items; /* items managed */
160 struct list_head recovd_troubled_items; /* items in trouble */
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;
168 struct obdtrace_opstats *stats;
173 unsigned int snap_index; /* which snapshot index are we accessing */
180 struct ptlrpc_service *ost_service;
181 struct lustre_handle ost_conn; /* the local connection to the OBD */
185 struct lov_tgt_desc {
187 struct lustre_handle conn;
191 struct obd_device *mdcobd;
192 struct lov_desc desc;
194 struct lov_tgt_desc *tgts;
197 struct niobuf_local {
204 void *target_private;
205 struct dentry *dentry;
208 #define N_LOCAL_TEMP_PAGE 0x00000001
210 /* corresponds to one of the obd's */
212 struct obd_type *obd_type;
214 /* common and UUID name of this device */
220 struct proc_dir_entry *obd_proc_entry;
221 struct list_head obd_exports;
222 struct list_head obd_imports;
223 struct ldlm_namespace *obd_namespace;
224 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
225 /* a spinlock is OK for what we do now, may need a semaphore later */
226 spinlock_t obd_dev_lock;
228 struct ext2_obd ext2;
229 struct filter_obd filter;
231 struct client_obd cli;
233 // struct osc_obd osc;
234 struct ldlm_obd ldlm;
235 struct echo_obd echo;
236 struct recovd_obd recovd;
237 struct trace_obd trace;
240 struct snap_obd snap;
243 /* Fields used by LProcFS */
244 unsigned int cntr_mem_size;
251 int (*o_iocontrol)(long cmd, struct lustre_handle *, int len,
252 void *karg, void *uarg);
253 int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key,
254 obd_count *vallen, void **val);
255 int (*o_set_info)(struct lustre_handle *, obd_count keylen, void *key,
256 obd_count vallen, void *val);
257 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
258 int (*o_detach)(struct obd_device *dev);
259 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
260 int (*o_cleanup)(struct obd_device *dev);
261 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
263 int (*o_disconnect)(struct lustre_handle *conn);
266 int (*o_statfs)(struct lustre_handle *conn, struct obd_statfs *osfs);
267 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
269 int (*o_create)(struct lustre_handle *conn, struct obdo *oa,
270 struct lov_stripe_md **ea);
271 int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
272 struct lov_stripe_md *ea);
273 int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
274 struct lov_stripe_md *ea);
275 int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
276 struct lov_stripe_md *ea);
277 int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
278 struct lov_stripe_md *);
279 int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
280 struct lov_stripe_md *);
281 int (*o_brw)(int rw, struct lustre_handle *conn,
282 struct lov_stripe_md *md, obd_count oa_bufs,
283 struct brw_page *pgarr, brw_callback_t callback,
284 struct io_cb_data *data);
285 int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
286 struct lov_stripe_md *md, obd_size count,
288 int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
289 obd_size count, obd_off offset);
290 int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
291 struct obdo *src, obd_size count, obd_off offset);
292 int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
293 struct lustre_handle *srconn, struct obdo *src,
294 obd_size count, obd_off offset);
295 int (*o_iterate)(struct lustre_handle *conn,
296 int (*)(obd_id, obd_gr, void *),
297 obd_id *startid, obd_gr group, void *data);
298 int (*o_preprw)(int cmd, struct lustre_handle *conn,
299 int objcount, struct obd_ioobj *obj,
300 int niocount, struct niobuf_remote *remote,
301 struct niobuf_local *local, void **desc_private);
302 int (*o_commitrw)(int cmd, struct lustre_handle *conn,
303 int objcount, struct obd_ioobj *obj,
304 int niocount, struct niobuf_local *local,
306 int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
307 struct lustre_handle *parent_lock,
308 __u32 type, void *cookie, int cookielen, __u32 mode,
309 int *flags, void *cb, void *data, int datalen,
310 struct lustre_handle *lockh);
311 int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *);
314 #if BITS_PER_LONG > 32
324 static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
327 return mds->mds_fsops->fs_start(inode, op);
330 static inline int mds_fs_commit(struct mds_obd *mds, struct inode *inode,
333 return mds->mds_fsops->fs_commit(inode, handle);
336 static inline int mds_fs_setattr(struct mds_obd *mds, struct dentry *dentry,
337 void *handle, struct iattr *iattr)
341 * NOTE: we probably don't need to take i_sem here when changing
342 * ATTR_SIZE because the MDS never needs to truncate a file.
343 * The ext2/ext3 code never truncates a directory, and files
344 * stored on the MDS are entirely sparse (no data blocks).
345 * If we do need to get it, we can do it here.
348 rc = mds->mds_fsops->fs_setattr(dentry, handle, iattr);
354 static inline int mds_fs_set_md(struct mds_obd *mds, struct inode *inode,
355 void *handle, struct lov_mds_md *md)
357 return mds->mds_fsops->fs_set_md(inode, handle, md);
360 static inline int mds_fs_get_md(struct mds_obd *mds, struct inode *inode,
361 struct lov_mds_md *md)
363 return mds->mds_fsops->fs_get_md(inode, md);
366 static inline ssize_t mds_fs_readpage(struct mds_obd *mds, struct file *file,
367 char *buf, size_t count, loff_t *offset)
369 return mds->mds_fsops->fs_readpage(file, buf, count, offset);
372 /* Set up callback to update mds->mds_last_committed with the current
373 * value of mds->mds_last_recieved when this transaction is on disk.
375 static inline int mds_fs_set_last_rcvd(struct mds_obd *mds, void *handle)
377 return mds->mds_fsops->fs_set_last_rcvd(mds, handle);
380 /* Enable data journaling on the given file */
381 static inline ssize_t mds_fs_journal_data(struct mds_obd *mds,
384 return mds->mds_fsops->fs_journal_data(file);
387 static inline int mds_fs_statfs(struct mds_obd *mds, struct statfs *sfs)
389 if (mds->mds_fsops->fs_statfs)
390 return mds->mds_fsops->fs_statfs(mds->mds_sb, sfs);
392 return vfs_statfs(mds->mds_sb, sfs);