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;
25 struct proc_dir_entry *typ_procroot;
37 struct lov_oinfo { /* per-child structure */
38 __u64 loi_id; /* object ID on the target OST */
39 __u64 loi_size; /* size of this object on the target OST */
40 struct lustre_handle *loi_handle; /* handle for object on OST */
41 int loi_ost_idx; /* OST stripe index in lmd_objects array */
44 struct lov_stripe_md {
46 __u32 lsm_mds_easize; /* packed size for MDS of ea - KILL ME*/
47 __u64 lsm_object_id; /* lov object id */
48 __u64 lsm_stripe_size; /* size of the stripe */
49 __u32 lsm_stripe_pattern; /* per-lov object stripe pattern */
50 int lsm_stripe_offset; /* offset of first stripe in lmd_objects */
51 int lsm_stripe_count; /* how many objects are being striped on */
52 int lsm_ost_count; /* how many OSTs are in this LOV - KILL ME */
53 struct lov_oinfo lsm_oinfo[0];
56 /* Individual type definitions */
59 struct super_block *e2_sb;
60 struct vfsmount *e2_vfsmnt;
68 #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
69 #define OBD_CTXT_DEBUG /* development-only debugging */
71 struct vfsmount *pwdmnt;
84 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
86 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
91 struct super_block *fo_sb;
92 struct vfsmount *fo_vfsmnt;
93 struct obd_run_ctxt fo_ctxt;
94 struct dentry *fo_dentry_O;
95 struct dentry *fo_dentry_O_mode[16];
96 spinlock_t fo_objidlock; /* protects fo_lastobjid increment */
98 struct file_operations *fo_fop;
99 struct inode_operations *fo_iop;
100 struct address_space_operations *fo_aops;
101 struct list_head fo_export_list;
102 spinlock_t fo_fddlock; /* protects setting dentry->d_fsdata */
105 struct mds_server_data;
108 struct obd_import cl_import;
109 struct semaphore cl_sem;
111 obd_uuid_t cl_target_uuid; /* XXX -> lustre_name */
112 int cl_max_mds_easize;
113 int cl_max_ost_easize;
114 struct obd_device *cl_containing_lov;
117 #define IOC_OSC_TYPE 'h'
118 #define IOC_OSC_MIN_NR 20
119 #define IOC_OSC_REGISTER_LOV _IOWR('h', 20, struct obd_device *)
120 #define IOC_OSC_MAX_NR 50
123 struct ptlrpc_service *mds_service;
126 struct super_block *mds_sb;
127 struct super_operations *mds_sop;
128 struct vfsmount *mds_vfsmnt;
129 struct obd_run_ctxt mds_ctxt;
130 struct file_operations *mds_fop;
131 struct inode_operations *mds_iop;
132 struct address_space_operations *mds_aops;
133 struct mds_fs_operations *mds_fsops;
135 struct file *mds_rcvd_filp;
136 spinlock_t mds_last_lock;
137 __u64 mds_last_committed;
139 __u64 mds_mount_count;
140 struct ll_fid mds_rootfid;
141 struct mds_server_data *mds_server_data;
145 struct ptlrpc_service *ldlm_cb_service;
146 struct ptlrpc_service *ldlm_cancel_service;
147 struct ptlrpc_client *ldlm_client;
148 struct ptlrpc_connection *ldlm_server_conn;
166 spinlock_t recovd_lock;
167 struct list_head recovd_managed_items; /* items managed */
168 struct list_head recovd_troubled_items; /* items in recovery */
170 wait_queue_head_t recovd_recovery_waitq;
171 wait_queue_head_t recovd_ctl_waitq;
172 wait_queue_head_t recovd_waitq;
173 struct task_struct *recovd_thread;
178 struct obdtrace_opstats *stats;
183 unsigned int snap_index; /* which snapshot index are we accessing */
190 struct ptlrpc_service *ost_service;
191 struct lustre_handle ost_conn; /* the local connection to the OBD */
195 struct lov_tgt_desc {
197 struct lustre_handle conn;
198 int active; /* is this target available for requests, etc */
203 struct obd_device *mdcobd;
204 struct lov_desc desc;
207 struct lov_tgt_desc *tgts;
210 struct niobuf_local {
217 void *target_private;
218 struct dentry *dentry;
221 #define N_LOCAL_TEMP_PAGE 0x00000001
223 /* corresponds to one of the obd's */
225 struct obd_type *obd_type;
227 /* common and UUID name of this device */
233 struct proc_dir_entry *obd_proc_entry;
234 struct list_head obd_exports;
235 struct list_head obd_imports;
236 struct ldlm_namespace *obd_namespace;
237 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
238 /* a spinlock is OK for what we do now, may need a semaphore later */
239 spinlock_t obd_dev_lock;
241 struct ext2_obd ext2;
242 struct filter_obd filter;
244 struct client_obd cli;
246 // struct osc_obd osc;
247 struct ldlm_obd ldlm;
248 struct echo_obd echo;
249 struct recovd_obd recovd;
250 struct trace_obd trace;
253 struct snap_obd snap;
256 /* Fields used by LProcFS */
257 unsigned int cntr_mem_size;
264 int (*o_iocontrol)(long cmd, struct lustre_handle *, int len,
265 void *karg, void *uarg);
266 int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key,
267 obd_count *vallen, void **val);
268 int (*o_set_info)(struct lustre_handle *, obd_count keylen, void *key,
269 obd_count vallen, void *val);
270 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
271 int (*o_detach)(struct obd_device *dev);
272 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
273 int (*o_cleanup)(struct obd_device *dev);
274 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
275 obd_uuid_t cluuid, struct recovd_obd *recovd,
276 ptlrpc_recovery_cb_t recover);
277 int (*o_disconnect)(struct lustre_handle *conn);
280 int (*o_statfs)(struct lustre_handle *conn, struct obd_statfs *osfs);
281 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
283 int (*o_create)(struct lustre_handle *conn, struct obdo *oa,
284 struct lov_stripe_md **ea);
285 int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
286 struct lov_stripe_md *ea);
287 int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
288 struct lov_stripe_md *ea);
289 int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
290 struct lov_stripe_md *ea);
291 int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
292 struct lov_stripe_md *ea);
293 int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
294 struct lov_stripe_md *ea);
295 int (*o_brw)(int rw, struct lustre_handle *conn,
296 struct lov_stripe_md *ea, obd_count oa_bufs,
297 struct brw_page *pgarr, brw_callback_t callback,
298 struct io_cb_data *data);
299 int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
300 struct lov_stripe_md *ea, obd_size count,
302 int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
303 obd_size count, obd_off offset);
304 int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
305 struct obdo *src, obd_size count, obd_off offset);
306 int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
307 struct lustre_handle *srconn, struct obdo *src,
308 obd_size count, obd_off offset);
309 int (*o_iterate)(struct lustre_handle *conn,
310 int (*)(obd_id, obd_gr, void *),
311 obd_id *startid, obd_gr group, void *data);
312 int (*o_preprw)(int cmd, struct lustre_handle *conn,
313 int objcount, struct obd_ioobj *obj,
314 int niocount, struct niobuf_remote *remote,
315 struct niobuf_local *local, void **desc_private);
316 int (*o_commitrw)(int cmd, struct lustre_handle *conn,
317 int objcount, struct obd_ioobj *obj,
318 int niocount, struct niobuf_local *local,
320 int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
321 struct lustre_handle *parent_lock,
322 __u32 type, void *cookie, int cookielen, __u32 mode,
323 int *flags, void *cb, void *data, int datalen,
324 struct lustre_handle *lockh);
325 int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md,
326 __u32 mode, struct lustre_handle *);
327 int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
332 static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
335 return mds->mds_fsops->fs_start(inode, op);
338 static inline int mds_fs_commit(struct mds_obd *mds, struct inode *inode,
341 return mds->mds_fsops->fs_commit(inode, handle);
344 static inline int mds_fs_setattr(struct mds_obd *mds, struct dentry *dentry,
345 void *handle, struct iattr *iattr)
349 * NOTE: we probably don't need to take i_sem here when changing
350 * ATTR_SIZE because the MDS never needs to truncate a file.
351 * The ext2/ext3 code never truncates a directory, and files
352 * stored on the MDS are entirely sparse (no data blocks).
353 * If we do need to get it, we can do it here.
356 rc = mds->mds_fsops->fs_setattr(dentry, handle, iattr);
362 static inline int mds_fs_set_md(struct mds_obd *mds, struct inode *inode,
363 void *handle, struct lov_mds_md *md)
365 return mds->mds_fsops->fs_set_md(inode, handle, md);
368 static inline int mds_fs_get_md(struct mds_obd *mds, struct inode *inode,
369 struct lov_mds_md *md)
371 return mds->mds_fsops->fs_get_md(inode, md);
374 static inline ssize_t mds_fs_readpage(struct mds_obd *mds, struct file *file,
375 char *buf, size_t count, loff_t *offset)
377 return mds->mds_fsops->fs_readpage(file, buf, count, offset);
380 /* Set up callback to update mds->mds_last_committed with the current
381 * value of mds->mds_last_recieved when this transaction is on disk.
383 static inline int mds_fs_set_last_rcvd(struct mds_obd *mds, void *handle)
385 return mds->mds_fsops->fs_set_last_rcvd(mds, handle);
388 /* Enable data journaling on the given file */
389 static inline ssize_t mds_fs_journal_data(struct mds_obd *mds,
392 return mds->mds_fsops->fs_journal_data(file);
395 static inline int mds_fs_statfs(struct mds_obd *mds, struct statfs *sfs)
397 if (mds->mds_fsops->fs_statfs)
398 return mds->mds_fsops->fs_statfs(mds->mds_sb, sfs);
400 return vfs_statfs(mds->mds_sb, sfs);