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 struct lov_oinfo { /* per-child structure */
14 __u64 loi_id; /* object ID on the target OST */
15 struct lustre_handle *loi_handle; /* open file handle for obj on OST */
16 int loi_ost_idx; /* OST stripe index in lmd_objects array */
19 struct lov_stripe_md {
20 __u64 lsm_object_id; /* lov object id */
22 __u32 lsm_stripe_size; /* size of the stripe */
23 unsigned lsm_stripe_offset; /* offset of first stripe in lmd_objects */
24 unsigned lsm_stripe_count; /* how many objects are being striped on */
25 struct lov_oinfo lsm_oinfo[0];
28 #define IOC_OSC_TYPE 'h'
29 #define IOC_OSC_MIN_NR 20
30 #define IOC_OSC_REGISTER_LOV _IOWR(IOC_OSC_TYPE, 20, struct obd_device *)
31 #define IOC_OSC_MAX_NR 50
33 #define IOC_MDC_TYPE 'i'
34 #define IOC_MDC_MIN_NR 20
35 #define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
36 #define IOC_MDC_MAX_NR 50
39 # include <linux/fs.h>
40 # include <linux/list.h>
41 # include <linux/sched.h> /* for struct task_struct, for current.h */
42 # include <asm/current.h> /* for smp_lock.h */
43 # include <linux/smp_lock.h>
44 # include <linux/proc_fs.h>
46 # include <linux/lustre_lib.h>
47 # include <linux/lustre_idl.h>
48 # include <linux/lustre_mds.h>
49 # include <linux/lustre_export.h>
53 struct list_head typ_chain;
54 struct obd_ops *typ_ops;
55 struct proc_dir_entry *typ_procroot;
67 /* Individual type definitions */
70 struct super_block *e2_sb;
71 struct vfsmount *e2_vfsmnt;
82 #define OBD_RUN_CTXT_MAGIC 0xC0FFEEAA
83 #define OBD_CTXT_DEBUG /* development-only debugging */
85 struct vfsmount *pwdmnt;
98 #define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC
100 #define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0)
103 struct ost_server_data;
105 #define FILTER_TRANSNO_SEM
108 #undef FILTER_TRANSNO_SEM
113 struct super_block *fo_sb;
114 struct vfsmount *fo_vfsmnt;
115 struct obd_run_ctxt fo_ctxt;
116 struct dentry *fo_dentry_O;
117 struct dentry *fo_dentry_O_mode[16];
118 struct dentry **fo_dentry_O_sub;
119 spinlock_t fo_objidlock; /* protects fo_lastobjid increment */
120 #ifdef FILTER_TRANSNO_SEM
121 struct semaphore fo_transno_sem;
123 spinlock_t fo_translock; /* protects fsd_last_rcvd increment */
125 struct file *fo_rcvd_filp;
126 struct filter_server_data *fo_fsd;
127 unsigned long *fo_last_rcvd_slots;
129 struct file_operations *fo_fop;
130 struct inode_operations *fo_iop;
131 struct address_space_operations *fo_aops;
132 struct list_head fo_export_list;
133 spinlock_t fo_fddlock; /* protects setting dentry->d_fsdata */
137 struct mds_server_data;
140 struct obd_import cl_import;
141 struct semaphore cl_sem;
143 struct obd_uuid cl_target_uuid; /* XXX -> lustre_name */
144 /* max_mds_easize is purely a performance thing so we don't have to
145 * call obd_size_wiremd() all the time. */
146 int cl_max_mds_easize;
147 struct obd_device *cl_containing_lov;
152 struct ptlrpc_service *mds_service;
153 struct ptlrpc_service *mds_setattr_service;
154 struct ptlrpc_service *mds_readpage_service;
156 struct super_block *mds_sb;
157 struct vfsmount *mds_vfsmnt;
158 struct obd_run_ctxt mds_ctxt;
159 struct file_operations *mds_fop;
160 struct inode_operations *mds_iop;
161 struct address_space_operations *mds_aops;
164 struct file *mds_rcvd_filp;
165 spinlock_t mds_transno_lock;
166 __u64 mds_last_transno;
167 __u64 mds_mount_count;
168 struct ll_fid mds_rootfid;
169 struct mds_server_data *mds_server_data;
171 int mds_has_lov_desc;
172 struct lov_desc mds_lov_desc;
176 struct ptlrpc_service *ldlm_cb_service;
177 struct ptlrpc_service *ldlm_cancel_service;
178 struct ptlrpc_client *ldlm_client;
179 struct ptlrpc_connection *ldlm_server_conn;
197 * this struct does double-duty acting as either a client or
198 * server instance .. maybe not wise.
202 struct ptlrpc_service *ptlbd_service;
205 struct ptlrpc_client bd_client;
206 struct obd_import bd_import;
207 int refcount; /* XXX sigh */
211 spinlock_t recovd_lock;
212 struct list_head recovd_managed_items; /* items managed */
213 struct list_head recovd_troubled_items; /* items in recovery */
215 wait_queue_head_t recovd_recovery_waitq;
216 wait_queue_head_t recovd_ctl_waitq;
217 wait_queue_head_t recovd_waitq;
218 struct task_struct *recovd_thread;
223 struct obdtrace_opstats *stats;
228 unsigned int snap_index; /* which snapshot index are we accessing */
235 struct ptlrpc_service *ost_service;
238 struct echo_client_obd {
239 struct lustre_handle ec_conn; /* the local connection to osc/lov */
241 struct list_head ec_objects;
248 struct lustre_handle cobd_target; /* local connection to target obd */
249 struct lustre_handle cobd_cache; /* local connection to cache obd */
252 struct lov_tgt_desc {
253 struct obd_uuid uuid;
254 struct lustre_handle conn;
255 int active; /* is this target available for requests, etc */
260 struct obd_device *mdcobd;
261 struct lov_desc desc;
264 struct lov_tgt_desc *tgts;
267 struct niobuf_local {
274 void *target_private;
275 struct dentry *dentry;
278 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
279 #define N_LOCAL_TEMP_PAGE 0x10000000
281 struct obd_trans_info {
285 /* corresponds to one of the obd's */
287 struct obd_type *obd_type;
289 /* common and UUID name of this device */
291 struct obd_uuid obd_uuid;
295 struct proc_dir_entry *obd_proc_entry;
296 struct list_head obd_exports;
297 struct list_head obd_imports;
298 struct ldlm_namespace *obd_namespace;
299 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
300 /* a spinlock is OK for what we do now, may need a semaphore later */
301 spinlock_t obd_dev_lock;
302 __u64 obd_last_committed;
303 struct fsfilt_operations *obd_fsops;
305 /* XXX encapsulate all this recovery data into one struct */
306 svc_handler_t obd_recovery_handler;
307 int obd_recoverable_clients;
308 spinlock_t obd_processing_task_lock;
309 pid_t obd_processing_task;
310 __u64 obd_next_recovery_transno;
311 wait_queue_head_t obd_next_transno_waitq;
312 struct timer_list obd_recovery_timer;
313 struct list_head obd_recovery_queue;
314 struct list_head obd_delayed_reply_queue;
317 struct ext2_obd ext2;
318 struct filter_obd filter;
320 struct client_obd cli;
322 struct echo_client_obd echo_client;;
323 struct ldlm_obd ldlm;
324 struct echo_obd echo;
325 struct recovd_obd recovd;
326 struct trace_obd trace;
328 struct cache_obd cobd;
329 struct ptlbd_obd ptlbd;
331 struct snap_obd snap;
334 /* Fields used by LProcFS */
335 unsigned int cntr_mem_size;
340 struct module *o_owner;
341 int (*o_iocontrol)(unsigned int cmd, struct lustre_handle *, int len,
342 void *karg, void *uarg);
343 int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key,
344 obd_count *vallen, void **val);
345 int (*o_set_info)(struct lustre_handle *, obd_count keylen, void *key,
346 obd_count vallen, void *val);
347 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
348 int (*o_detach)(struct obd_device *dev);
349 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
350 int (*o_cleanup)(struct obd_device *dev);
351 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
352 struct obd_uuid *cluuid, struct recovd_obd *recovd,
353 ptlrpc_recovery_cb_t recover);
354 int (*o_disconnect)(struct lustre_handle *conn);
357 int (*o_statfs)(struct lustre_handle *conn, struct obd_statfs *osfs);
358 int (*o_syncfs)(struct lustre_handle *conn);
359 int (*o_packmd)(struct lustre_handle *, struct lov_mds_md **wire_tgt,
360 struct lov_stripe_md *mem_src);
361 int (*o_unpackmd)(struct lustre_handle *,
362 struct lov_stripe_md **mem_tgt,
363 struct lov_mds_md *wire_src);
364 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
366 int (*o_create)(struct lustre_handle *conn, struct obdo *oa,
367 struct lov_stripe_md **ea, struct obd_trans_info *oti);
368 int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
369 struct lov_stripe_md *ea, struct obd_trans_info *oti);
370 int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
371 struct lov_stripe_md *ea, struct obd_trans_info *oti);
372 int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
373 struct lov_stripe_md *ea);
374 int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
375 struct lov_stripe_md *ea, struct obd_trans_info *oti);
376 int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
377 struct lov_stripe_md *ea, struct obd_trans_info *oti);
378 int (*o_brw)(int rw, struct lustre_handle *conn,
379 struct lov_stripe_md *ea, obd_count oa_bufs,
380 struct brw_page *pgarr, struct obd_brw_set *,
381 struct obd_trans_info *oti);
382 int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
383 struct lov_stripe_md *ea, obd_size count,
384 obd_off offset, struct obd_trans_info *oti);
385 int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
386 obd_size count, obd_off offset);
387 int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
388 struct obdo *src, obd_size count, obd_off offset);
389 int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
390 struct lustre_handle *srconn, struct obdo *src,
391 obd_size count, obd_off offset, struct obd_trans_info *);
392 int (*o_iterate)(struct lustre_handle *conn,
393 int (*)(obd_id, obd_gr, void *),
394 obd_id *startid, obd_gr group, void *data);
395 int (*o_preprw)(int cmd, struct lustre_handle *conn,
396 int objcount, struct obd_ioobj *obj,
397 int niocount, struct niobuf_remote *remote,
398 struct niobuf_local *local, void **desc_private,
399 struct obd_trans_info *oti);
400 int (*o_commitrw)(int cmd, struct lustre_handle *conn,
401 int objcount, struct obd_ioobj *obj,
402 int niocount, struct niobuf_local *local,
403 void *desc_private, struct obd_trans_info *oti);
404 int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
405 struct lustre_handle *parent_lock,
406 __u32 type, void *cookie, int cookielen, __u32 mode,
407 int *flags, void *cb, void *data, int datalen,
408 struct lustre_handle *lockh);
409 int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md,
410 __u32 mode, struct lustre_handle *);
411 int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
413 int (*o_san_preprw)(int cmd, struct lustre_handle *conn,
414 int objcount, struct obd_ioobj *obj,
415 int niocount, struct niobuf_remote *remote);