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 {
21 __u64 lsm_object_id; /* lov object id */
24 /* LOV-private members start here -- only for use in lov/. */
26 __u32 lsm_stripe_size; /* size of the stripe */
27 unsigned lsm_stripe_offset; /* offset of first stripe in lmd_objects */
28 unsigned lsm_stripe_count; /* how many objects are being striped on */
29 struct lov_oinfo lsm_oinfo[0];
32 #define IOC_OSC_TYPE 'h'
33 #define IOC_OSC_MIN_NR 20
34 #define IOC_OSC_REGISTER_LOV _IOWR(IOC_OSC_TYPE, 20, struct obd_device *)
35 #define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
36 #define IOC_OSC_MAX_NR 50
38 #define IOC_MDC_TYPE 'i'
39 #define IOC_MDC_MIN_NR 20
40 #define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
41 #define IOC_MDC_MAX_NR 50
44 # include <linux/fs.h>
45 # include <linux/list.h>
46 # include <linux/sched.h> /* for struct task_struct, for current.h */
47 # include <asm/current.h> /* for smp_lock.h */
48 # include <linux/smp_lock.h>
49 # include <linux/proc_fs.h>
51 # include <linux/lustre_lib.h>
52 # include <linux/lustre_idl.h>
53 # include <linux/lustre_mds.h>
54 # include <linux/lustre_export.h>
58 struct list_head typ_chain;
59 struct obd_ops *typ_ops;
60 struct proc_dir_entry *typ_procroot;
72 /* Individual type definitions */
74 struct ost_server_data;
77 const char *fo_fstype;
79 struct super_block *fo_sb;
80 struct vfsmount *fo_vfsmnt;
81 struct obd_run_ctxt fo_ctxt;
82 struct dentry *fo_dentry_O;
83 struct dentry *fo_dentry_O_mode[16];
84 struct dentry **fo_dentry_O_sub;
85 spinlock_t fo_objidlock; /* protect fo_lastobjid increment */
86 spinlock_t fo_translock; /* protect fsd_last_rcvd increment */
87 struct file *fo_rcvd_filp;
88 struct filter_server_data *fo_fsd;
89 unsigned long *fo_last_rcvd_slots;
91 struct file_operations *fo_fop;
92 struct inode_operations *fo_iop;
93 struct address_space_operations *fo_aops;
94 struct list_head fo_export_list;
95 spinlock_t fo_fddlock; /* protect setting dentry->d_fsdata */
99 struct mds_server_data;
102 struct obd_import *cl_import;
103 struct semaphore cl_sem;
105 /* max_mds_easize is purely a performance thing so we don't have to
106 * call obd_size_wiremd() all the time. */
107 int cl_max_mds_easize;
108 struct obd_device *cl_containing_lov;
113 struct ptlrpc_service *mds_service;
114 struct ptlrpc_service *mds_setattr_service;
115 struct ptlrpc_service *mds_readpage_service;
117 struct super_block *mds_sb;
118 struct vfsmount *mds_vfsmnt;
119 struct dentry *mds_fid_de;
120 struct obd_run_ctxt mds_ctxt;
121 struct file_operations *mds_fop;
122 struct inode_operations *mds_iop;
123 struct address_space_operations *mds_aops;
126 struct file *mds_rcvd_filp;
127 spinlock_t mds_transno_lock;
128 __u64 mds_last_transno;
129 __u64 mds_mount_count;
130 struct ll_fid mds_rootfid;
131 struct mds_server_data *mds_server_data;
133 int mds_has_lov_desc;
134 struct lov_desc mds_lov_desc;
135 unsigned long *mds_client_bitmap;
139 struct ptlrpc_service *ldlm_cb_service;
140 struct ptlrpc_service *ldlm_cancel_service;
141 struct ptlrpc_client *ldlm_client;
142 struct ptlrpc_connection *ldlm_server_conn;
160 * this struct does double-duty acting as either a client or
161 * server instance .. maybe not wise.
165 struct ptlrpc_service *ptlbd_service;
168 struct ptlrpc_client bd_client;
169 struct obd_import *bd_import;
170 struct obd_uuid bd_server_uuid;
171 struct lustre_handle bd_connect_handle;
172 int refcount; /* XXX sigh */
176 spinlock_t recovd_lock;
177 struct list_head recovd_managed_items; /* items managed */
178 struct list_head recovd_troubled_items; /* items in recovery */
180 wait_queue_head_t recovd_recovery_waitq;
181 wait_queue_head_t recovd_ctl_waitq;
182 wait_queue_head_t recovd_waitq;
183 struct task_struct *recovd_thread;
188 struct ptlrpc_service *ost_service;
191 struct echo_client_obd {
192 struct lustre_handle ec_conn; /* the local connection to osc/lov */
194 struct list_head ec_objects;
201 struct lustre_handle cobd_target; /* local connection to target obd */
202 struct lustre_handle cobd_cache; /* local connection to cache obd */
205 struct lov_tgt_desc {
206 struct obd_uuid uuid;
207 struct lustre_handle conn;
208 int active; /* is this target available for requests, etc */
213 struct obd_device *mdcobd;
214 struct lov_desc desc;
217 struct lov_tgt_desc *tgts;
220 struct niobuf_local {
226 struct dentry *dentry;
230 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
231 #define N_LOCAL_TEMP_PAGE 0x10000000
233 struct obd_trans_info {
235 /* Only used on the server side for tracking acks. */
236 struct oti_req_ack_lock {
237 struct lustre_handle lock;
242 /* corresponds to one of the obd's */
244 struct obd_type *obd_type;
246 /* common and UUID name of this device */
248 struct obd_uuid obd_uuid;
251 int obd_attached:1, obd_set_up:1, obd_recovering:1,
252 obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
253 obd_no_recov:1, obd_stopping:1;
254 atomic_t obd_refcount;
255 wait_queue_head_t obd_refcount_waitq;
256 struct proc_dir_entry *obd_proc_entry;
257 struct list_head obd_exports;
258 struct list_head obd_imports;
259 struct ldlm_namespace *obd_namespace;
260 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
261 /* a spinlock is OK for what we do now, may need a semaphore later */
262 spinlock_t obd_dev_lock;
263 __u64 obd_last_committed;
264 struct fsfilt_operations *obd_fsops;
266 /* XXX encapsulate all this recovery data into one struct */
267 svc_handler_t obd_recovery_handler;
268 int obd_recoverable_clients;
269 spinlock_t obd_processing_task_lock;
270 pid_t obd_processing_task;
271 __u64 obd_next_recovery_transno;
272 wait_queue_head_t obd_next_transno_waitq;
273 wait_queue_head_t obd_commit_waitq;
274 struct timer_list obd_recovery_timer;
275 struct list_head obd_recovery_queue;
276 struct list_head obd_delayed_reply_queue;
279 struct filter_obd filter;
281 struct client_obd cli;
283 struct echo_client_obd echo_client;;
284 struct ldlm_obd ldlm;
285 struct echo_obd echo;
286 struct recovd_obd recovd;
288 struct cache_obd cobd;
289 struct ptlbd_obd ptlbd;
291 /* Fields used by LProcFS */
292 unsigned int obd_cntr_base;
293 struct lprocfs_stats *obd_stats;
297 struct module *o_owner;
298 int (*o_iocontrol)(unsigned int cmd, struct lustre_handle *, int len,
299 void *karg, void *uarg);
300 int (*o_get_info)(struct lustre_handle *, __u32 keylen, void *key,
301 __u32 *vallen, void *val);
302 int (*o_set_info)(struct lustre_handle *, __u32 keylen, void *key,
303 __u32 vallen, void *val);
304 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
305 int (*o_detach)(struct obd_device *dev);
306 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
307 int (*o_cleanup)(struct obd_device *dev, int force, int failover);
308 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
309 struct obd_uuid *cluuid);
310 int (*o_disconnect)(struct lustre_handle *conn, int failover);
312 int (*o_statfs)(struct lustre_handle *conn, struct obd_statfs *osfs);
313 int (*o_syncfs)(struct obd_export *);
314 int (*o_packmd)(struct lustre_handle *, struct lov_mds_md **disk_tgt,
315 struct lov_stripe_md *mem_src);
316 int (*o_unpackmd)(struct lustre_handle *,
317 struct lov_stripe_md **mem_tgt,
318 struct lov_mds_md *disk_src, int disk_len);
319 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
321 int (*o_create)(struct lustre_handle *conn, struct obdo *oa,
322 struct lov_stripe_md **ea, struct obd_trans_info *oti);
323 int (*o_destroy)(struct lustre_handle *conn, struct obdo *oa,
324 struct lov_stripe_md *ea, struct obd_trans_info *oti);
325 int (*o_setattr)(struct lustre_handle *conn, struct obdo *oa,
326 struct lov_stripe_md *ea, struct obd_trans_info *oti);
327 int (*o_getattr)(struct lustre_handle *conn, struct obdo *oa,
328 struct lov_stripe_md *ea);
329 int (*o_getattr_async)(struct lustre_handle *conn, struct obdo *oa,
330 struct lov_stripe_md *ea,
331 struct ptlrpc_request_set *set);
332 int (*o_open)(struct lustre_handle *conn, struct obdo *oa,
333 struct lov_stripe_md *ea, struct obd_trans_info *oti,
334 struct obd_client_handle *och);
335 int (*o_close)(struct lustre_handle *conn, struct obdo *oa,
336 struct lov_stripe_md *ea, struct obd_trans_info *oti);
337 int (*o_brw)(int rw, struct lustre_handle *conn,
338 struct lov_stripe_md *ea, obd_count oa_bufs,
339 struct brw_page *pgarr, struct obd_trans_info *oti);
340 int (*o_brw_async)(int rw, struct lustre_handle *conn,
341 struct lov_stripe_md *ea, obd_count oa_bufs,
342 struct brw_page *pgarr, struct ptlrpc_request_set *,
343 struct obd_trans_info *oti);
344 int (*o_punch)(struct lustre_handle *conn, struct obdo *tgt,
345 struct lov_stripe_md *ea, obd_size count,
346 obd_off offset, struct obd_trans_info *oti);
347 int (*o_sync)(struct lustre_handle *conn, struct obdo *tgt,
348 obd_size count, obd_off offset);
349 int (*o_migrate)(struct lustre_handle *conn, struct obdo *dst,
350 struct obdo *src, obd_size count, obd_off offset);
351 int (*o_copy)(struct lustre_handle *dstconn, struct obdo *dst,
352 struct lustre_handle *srconn, struct obdo *src,
353 obd_size count, obd_off offset, struct obd_trans_info *);
354 int (*o_iterate)(struct lustre_handle *conn,
355 int (*)(obd_id, obd_gr, void *),
356 obd_id *startid, obd_gr group, void *data);
357 int (*o_preprw)(int cmd, struct obd_export *,
358 int objcount, struct obd_ioobj *obj,
359 int niocount, struct niobuf_remote *remote,
360 struct niobuf_local *local, void **desc_private,
361 struct obd_trans_info *oti);
362 int (*o_commitrw)(int cmd, struct obd_export *,
363 int objcount, struct obd_ioobj *obj,
364 int niocount, struct niobuf_local *local,
365 void *desc_private, struct obd_trans_info *oti);
366 int (*o_enqueue)(struct lustre_handle *conn, struct lov_stripe_md *md,
367 struct lustre_handle *parent_lock,
368 __u32 type, void *cookie, int cookielen, __u32 mode,
369 int *flags, void *cb, void *data,
370 struct lustre_handle *lockh);
371 int (*o_match)(struct lustre_handle *conn, struct lov_stripe_md *md,
372 __u32 type, void *cookie, int cookielen, __u32 mode,
373 int *flags, void *data, struct lustre_handle *lockh);
374 int (*o_cancel)(struct lustre_handle *, struct lov_stripe_md *md,
375 __u32 mode, struct lustre_handle *);
376 int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
377 int local_only, void *opaque);
378 int (*o_san_preprw)(int cmd, struct lustre_handle *conn,
379 int objcount, struct obd_ioobj *obj,
380 int niocount, struct niobuf_remote *remote);
381 void (*o_destroy_export)(struct obd_export *export);
384 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
388 CDEBUG(D_ERROR, "%s: transno "LPD64" commit error: %d\n",
389 obd->obd_name, transno, error);
392 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
393 obd->obd_name, transno);
394 if (transno > obd->obd_last_committed) {
395 obd->obd_last_committed = transno;
396 wake_up(&obd->obd_commit_waitq);
400 /* When adding a function pointer to struct obd_ops, please update
401 * function lprocfs_alloc_obd_counters() in obdclass/lprocfs_status.c