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 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 __u64 lsm_object_id; /* lov object id */
46 __u64 lsm_stripe_size; /* size of the stripe */
47 __u32 lsm_stripe_pattern; /* per-lov object stripe pattern */
48 int lsm_stripe_offset; /* offset of first stripe in lmd_objects */
49 int lsm_stripe_count; /* how many objects are being striped on */
50 struct lov_oinfo lsm_oinfo[0];
53 /* Individual type definitions */
56 struct super_block *e2_sb;
57 struct vfsmount *e2_vfsmnt;
66 #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
67 #define OBD_CTXT_DEBUG /* development-only debugging */
69 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];
94 spinlock_t fo_objidlock; /* protects fo_lastobjid increment */
96 struct file_operations *fo_fop;
97 struct inode_operations *fo_iop;
98 struct address_space_operations *fo_aops;
99 struct list_head fo_export_list;
100 spinlock_t fo_fddlock; /* protects setting dentry->d_fsdata */
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 /* max_mds_easize is purely a performance thing so we don't have to
111 * call obd_size_wiremd() all the time. */
112 int cl_max_mds_easize;
113 struct obd_device *cl_containing_lov;
116 #define IOC_OSC_TYPE 'h'
117 #define IOC_OSC_MIN_NR 20
118 #define IOC_OSC_REGISTER_LOV _IOWR('h', 20, struct obd_device *)
119 #define IOC_OSC_MAX_NR 50
122 struct ptlrpc_service *mds_service;
125 struct super_block *mds_sb;
126 struct super_operations *mds_sop;
127 struct vfsmount *mds_vfsmnt;
128 struct obd_run_ctxt mds_ctxt;
129 struct file_operations *mds_fop;
130 struct inode_operations *mds_iop;
131 struct address_space_operations *mds_aops;
132 struct mds_fs_operations *mds_fsops;
134 struct file *mds_rcvd_filp;
135 spinlock_t mds_last_lock;
136 __u64 mds_last_committed;
138 __u64 mds_mount_count;
139 struct ll_fid mds_rootfid;
140 struct mds_server_data *mds_server_data;
144 struct ptlrpc_service *ldlm_cb_service;
145 struct ptlrpc_service *ldlm_cancel_service;
146 struct ptlrpc_client *ldlm_client;
147 struct ptlrpc_connection *ldlm_server_conn;
165 spinlock_t recovd_lock;
166 struct list_head recovd_managed_items; /* items managed */
167 struct list_head recovd_troubled_items; /* items in recovery */
169 wait_queue_head_t recovd_recovery_waitq;
170 wait_queue_head_t recovd_ctl_waitq;
171 wait_queue_head_t recovd_waitq;
172 struct task_struct *recovd_thread;
177 struct obdtrace_opstats *stats;
182 unsigned int snap_index; /* which snapshot index are we accessing */
189 struct ptlrpc_service *ost_service;
190 struct lustre_handle ost_conn; /* the local connection to the OBD */
193 struct echo_client_obd {
194 struct lustre_handle conn; /* the local connection to osc/lov */
197 struct lov_tgt_desc {
199 struct lustre_handle conn;
200 int active; /* is this target available for requests, etc */
205 struct obd_device *mdcobd;
206 struct lov_desc desc;
209 struct lov_tgt_desc *tgts;
212 struct niobuf_local {
219 void *target_private;
220 struct dentry *dentry;
223 #define N_LOCAL_TEMP_PAGE 0x00000001
225 /* corresponds to one of the obd's */
227 struct obd_type *obd_type;
229 /* common and UUID name of this device */
235 struct proc_dir_entry *obd_proc_entry;
236 struct list_head obd_exports;
237 struct list_head obd_imports;
238 struct ldlm_namespace *obd_namespace;
239 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
240 /* a spinlock is OK for what we do now, may need a semaphore later */
241 spinlock_t obd_dev_lock;
243 struct ext2_obd ext2;
244 struct filter_obd filter;
246 struct client_obd cli;
248 struct echo_client_obd echo_client;;
249 // struct osc_obd osc;
250 struct ldlm_obd ldlm;
251 struct echo_obd echo;
252 struct recovd_obd recovd;
253 struct trace_obd trace;
256 struct snap_obd snap;
259 /* Fields used by LProcFS */
260 unsigned int cntr_mem_size;
265 int (*o_iocontrol)(long cmd, struct lustre_handle *, int len,
266 void *karg, void *uarg);
267 int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key,
268 obd_count *vallen, void **val);
269 int (*o_set_info)(struct lustre_handle *, obd_count keylen, void *key,
270 obd_count vallen, void *val);
271 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
272 int (*o_detach)(struct obd_device *dev);
273 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
274 int (*o_cleanup)(struct obd_device *dev);
275 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
276 obd_uuid_t cluuid, struct recovd_obd *recovd,
277 ptlrpc_recovery_cb_t recover);
278 int (*o_disconnect)(struct lustre_handle *conn);
281 int (*o_statfs)(struct lustre_handle *conn, struct obd_statfs *osfs);
282 int (*o_packmd)(struct lustre_handle *, struct lov_mds_md **wire_tgt,
283 struct lov_stripe_md *mem_src);
284 int (*o_unpackmd)(struct lustre_handle *,
285 struct lov_stripe_md **mem_tgt,
286 struct lov_mds_md *wire_src);
287 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
289 int (*o_create)(struct lustre_handle *conn, struct obdo *oa,
290 struct lov_stripe_md **ea);
291 int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
292 struct lov_stripe_md *ea);
293 int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
294 struct lov_stripe_md *ea);
295 int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
296 struct lov_stripe_md *ea);
297 int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
298 struct lov_stripe_md *ea);
299 int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
300 struct lov_stripe_md *ea);
301 int (*o_brw)(int rw, struct lustre_handle *conn,
302 struct lov_stripe_md *ea, obd_count oa_bufs,
303 struct brw_page *pgarr, struct obd_brw_set *);
304 int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
305 struct lov_stripe_md *ea, obd_size count,
307 int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
308 obd_size count, obd_off offset);
309 int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
310 struct obdo *src, obd_size count, obd_off offset);
311 int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
312 struct lustre_handle *srconn, struct obdo *src,
313 obd_size count, obd_off offset);
314 int (*o_iterate)(struct lustre_handle *conn,
315 int (*)(obd_id, obd_gr, void *),
316 obd_id *startid, obd_gr group, void *data);
317 int (*o_preprw)(int cmd, struct lustre_handle *conn,
318 int objcount, struct obd_ioobj *obj,
319 int niocount, struct niobuf_remote *remote,
320 struct niobuf_local *local, void **desc_private);
321 int (*o_commitrw)(int cmd, struct lustre_handle *conn,
322 int objcount, struct obd_ioobj *obj,
323 int niocount, struct niobuf_local *local,
325 int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
326 struct lustre_handle *parent_lock,
327 __u32 type, void *cookie, int cookielen, __u32 mode,
328 int *flags, void *cb, void *data, int datalen,
329 struct lustre_handle *lockh);
330 int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md,
331 __u32 mode, struct lustre_handle *);
332 int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
337 static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
340 return mds->mds_fsops->fs_start(inode, op);
343 static inline int mds_fs_commit(struct mds_obd *mds, struct inode *inode,
346 return mds->mds_fsops->fs_commit(inode, handle);
349 static inline int mds_fs_setattr(struct mds_obd *mds, struct dentry *dentry,
350 void *handle, struct iattr *iattr)
354 * NOTE: we probably don't need to take i_sem here when changing
355 * ATTR_SIZE because the MDS never needs to truncate a file.
356 * The ext2/ext3 code never truncates a directory, and files
357 * stored on the MDS are entirely sparse (no data blocks).
358 * If we do need to get it, we can do it here.
361 rc = mds->mds_fsops->fs_setattr(dentry, handle, iattr);
367 static inline int mds_fs_set_md(struct mds_obd *mds, struct inode *inode,
368 void *handle, struct lov_mds_md *md,
371 return mds->mds_fsops->fs_set_md(inode, handle, md, size);
374 static inline int mds_fs_get_md(struct mds_obd *mds, struct inode *inode,
375 struct lov_mds_md *md, int size)
377 return mds->mds_fsops->fs_get_md(inode, md, size);
380 static inline ssize_t mds_fs_readpage(struct mds_obd *mds, struct file *file,
381 char *buf, size_t count, loff_t *offset)
383 return mds->mds_fsops->fs_readpage(file, buf, count, offset);
386 /* Set up callback to update mds->mds_last_committed with the current
387 * value of mds->mds_last_recieved when this transaction is on disk.
389 static inline int mds_fs_set_last_rcvd(struct mds_obd *mds, void *handle)
391 return mds->mds_fsops->fs_set_last_rcvd(mds, handle);
394 /* Enable data journaling on the given file */
395 static inline ssize_t mds_fs_journal_data(struct mds_obd *mds,
398 return mds->mds_fsops->fs_journal_data(file);
401 static inline int mds_fs_statfs(struct mds_obd *mds, struct statfs *sfs)
403 if (mds->mds_fsops->fs_statfs)
404 return mds->mds_fsops->fs_statfs(mds->mds_sb, sfs);
406 return vfs_statfs(mds->mds_sb, sfs);