Whamcloud - gitweb
Land b1_2 onto HEAD (20040317_2319)
[fs/lustre-release.git] / lustre / include / linux / obd.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5  *
6  * This code is issued under the GNU General Public License.
7  * See the file COPYING in this distribution
8  */
9
10 #ifndef __OBD_H
11 #define __OBD_H
12
13 #define IOC_OSC_TYPE         'h'
14 #define IOC_OSC_MIN_NR       20
15 #define IOC_OSC_SET_ACTIVE   _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
16 #define IOC_OSC_MAX_NR       50
17
18 #define IOC_MDC_TYPE         'i'
19 #define IOC_MDC_MIN_NR       20
20 #define IOC_MDC_LOOKUP       _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
21 #define IOC_MDC_MAX_NR       50
22
23 #ifdef __KERNEL__
24 # include <linux/fs.h>
25 # include <linux/list.h>
26 # include <linux/sched.h> /* for struct task_struct, for current.h */
27 # include <asm/current.h> /* for smp_lock.h */
28 # include <linux/smp_lock.h>
29 # include <linux/proc_fs.h>
30 # include <linux/mount.h>
31 #endif
32
33 #include <linux/lustre_lib.h>
34 #include <linux/lustre_idl.h>
35 #include <linux/lustre_export.h>
36
37 /* this is really local to the OSC */
38 struct loi_oap_pages {
39         struct list_head        lop_pending;
40         int                     lop_num_pending;
41         struct list_head        lop_urgent;
42         struct list_head        lop_pending_group;
43 };
44
45 struct lov_oinfo {                 /* per-stripe data structure */
46         __u64 loi_id;              /* object ID on the target OST */
47         __u64 loi_gr;              /* object group on the target OST */
48         int loi_ost_idx;           /* OST stripe index in lov_tgt_desc->tgts */
49         int loi_ost_gen;           /* generation of this loi_ost_idx */
50
51         /* used by the osc to keep track of what objects to build into rpcs */
52         struct loi_oap_pages loi_read_lop;
53         struct loi_oap_pages loi_write_lop;
54         /* _cli_ is poorly named, it should be _ready_ */
55         struct list_head loi_cli_item;
56         struct list_head loi_write_item;
57         struct list_head loi_read_item;
58
59         int loi_kms_valid:1;
60         __u64 loi_kms; /* known minimum size */
61         __u64 loi_rss; /* recently seen size */
62         __u64 loi_mtime; /* recently seen mtime */
63 };
64
65 static inline void loi_init(struct lov_oinfo *loi)
66 {
67         INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
68         INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
69         INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
70         INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
71         INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
72         INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
73         INIT_LIST_HEAD(&loi->loi_cli_item);
74         INIT_LIST_HEAD(&loi->loi_write_item);
75         INIT_LIST_HEAD(&loi->loi_read_item);
76 }
77
78 struct lov_stripe_md {
79         /* Public members. */
80         __u64 lsm_object_id;        /* lov object id */
81         __u64 lsm_object_gr;        /* lov object id */
82         __u64 lsm_maxbytes;         /* maximum possible file size */
83         unsigned long lsm_xfersize; /* optimal transfer size */
84
85         /* LOV-private members start here -- only for use in lov/. */
86         __u32 lsm_magic;
87         __u32 lsm_stripe_size;      /* size of the stripe */
88         __u32 lsm_pattern;          /* striping pattern (RAID0, RAID1) */
89         unsigned lsm_stripe_count;  /* number of objects being striped over */
90         struct lov_oinfo lsm_oinfo[0];
91 };
92
93 struct obd_type {
94         struct list_head typ_chain;
95         struct obd_ops *typ_ops;
96         struct proc_dir_entry *typ_procroot;
97         char *typ_name;
98         int  typ_refcnt;
99 };
100
101 struct brw_page {
102         obd_off  off;
103         struct page *pg;
104         int count;
105         obd_flag flag;
106 };
107
108 enum async_flags {
109         ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
110                               page is added to an rpc */
111         ASYNC_URGENT = 0x2,
112         ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
113                                      to give the caller a chance to update
114                                      or cancel the size of the io */
115         ASYNC_GROUP_SYNC = 0x8,  /* ap_completion will not be called, instead
116                                     the page is accounted for in the
117                                     obd_io_group given to 
118                                     obd_queue_group_io */
119 };
120
121 struct obd_async_page_ops {
122         int  (*ap_make_ready)(void *data, int cmd);
123         int  (*ap_refresh_count)(void *data, int cmd);
124         void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
125         void (*ap_completion)(void *data, int cmd, int rc);
126 };
127
128 /* the `oig' is passed down from a caller of obd rw methods.  the callee
129  * records enough state such that the caller can sleep on the oig and
130  * be woken when all the callees have finished their work */
131 struct obd_io_group {
132         spinlock_t      oig_lock;
133         atomic_t        oig_refcount;
134         int             oig_pending;
135         int             oig_rc;
136         struct list_head oig_occ_list;
137         wait_queue_head_t oig_waitq;
138 };
139
140 /* the oig callback context lets the callee of obd rw methods register
141  * for callbacks from the caller. */
142 struct oig_callback_context {
143         struct list_head occ_oig_item;
144         /* called when the caller has received a signal while sleeping.
145          * callees of this method are encouraged to abort their state 
146          * in the oig.  This may be called multiple times. */
147         void (*occ_interrupted)(struct oig_callback_context *occ);
148 };
149
150 /* if we find more consumers this could be generalized */
151 #define OBD_HIST_MAX 32
152 struct obd_histogram {
153         spinlock_t      oh_lock;
154         unsigned long   oh_buckets[OBD_HIST_MAX];
155 };
156
157 /* Individual type definitions */
158
159 struct ost_server_data;
160
161 struct filter_obd {
162         const char          *fo_fstype;
163         struct super_block  *fo_sb;
164         struct vfsmount     *fo_vfsmnt;
165         struct dentry       *fo_dentry_O;
166         struct dentry      **fo_dentry_O_groups;
167         struct dentry      **fo_dentry_O_sub;
168         spinlock_t           fo_objidlock; /* protect fo_lastobjid increment */
169         spinlock_t           fo_translock; /* protect fsd_last_rcvd increment */
170         struct file         *fo_rcvd_filp;
171         struct filter_server_data *fo_fsd;
172         unsigned long       *fo_last_rcvd_slots;
173         __u64                fo_mount_count;
174
175         struct file_operations *fo_fop;
176         struct inode_operations *fo_iop;
177         struct address_space_operations *fo_aops;
178
179         struct list_head     fo_export_list;
180         int                  fo_subdir_count;
181
182         obd_size             fo_tot_dirty;      /* protected by obd_osfs_lock */
183         obd_size             fo_tot_granted;    /* all values in bytes */
184         obd_size             fo_tot_pending;
185
186         obd_size             fo_readcache_max_filesize;
187
188         struct obd_import   *fo_mdc_imp;
189         struct obd_uuid      fo_mdc_uuid;
190         struct lustre_handle fo_mdc_conn;
191 #if 0
192         struct ptlrpc_client fo_mdc_client;
193 #endif
194         struct file        **fo_last_objid_files;
195         __u64               *fo_last_objids; /* last created objid for groups */
196
197         struct semaphore     fo_alloc_lock;
198
199         struct obd_histogram     fo_r_pages;
200         struct obd_histogram     fo_w_pages;
201         struct obd_histogram     fo_r_discont_pages;
202         struct obd_histogram     fo_w_discont_pages;
203         struct obd_histogram     fo_r_discont_blocks;
204         struct obd_histogram     fo_w_discont_blocks;
205 };
206
207 struct mds_server_data;
208
209 #define OSC_MAX_RIF_DEFAULT       4
210 #define OSC_MAX_RIF_MAX          32
211 #define OSC_MAX_DIRTY_DEFAULT     4
212 #define OSC_MAX_DIRTY_MB_MAX    256     /* totally arbitrary */
213
214 struct mdc_rpc_lock;
215 struct client_obd {
216         struct obd_import       *cl_import;
217         struct semaphore         cl_sem;
218         int                      cl_conn_count;
219         /* max_mds_easize is purely a performance thing so we don't have to
220          * call obd_size_wiremd() all the time. */
221         int                      cl_max_mds_easize;
222         int                      cl_max_mds_cookiesize;
223         kdev_t                   cl_sandev;
224
225         //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
226         void                    *cl_llcd_offset;
227
228         struct obd_device       *cl_mgmtcli_obd;
229
230         /* the grant values are protected by loi_list_lock below */
231         long                     cl_dirty;         /* all _dirty_ in bytes */
232         long                     cl_dirty_max;     /* allowed w/o rpc */
233         long                     cl_avail_grant;   /* bytes of credit for ost */
234         long                     cl_lost_grant;    /* lost credits (trunc) */
235         struct list_head         cl_cache_waiters; /* waiting for cache/grant */
236
237         /* keep track of objects that have lois that contain pages which
238          * have been queued for async brw.  this lock also protects the
239          * lists of osc_client_pages that hang off of the loi */
240         spinlock_t               cl_loi_list_lock;
241         struct list_head         cl_loi_ready_list;
242         struct list_head         cl_loi_write_list;
243         struct list_head         cl_loi_read_list;
244         int                      cl_brw_in_flight;
245         /* just a sum of the loi/lop pending numbers to be exported by /proc */
246         int                      cl_pending_w_pages;
247         int                      cl_pending_r_pages;
248         int                      cl_max_pages_per_rpc;
249         int                      cl_max_rpcs_in_flight;
250         struct obd_histogram     cl_read_rpc_hist;
251         struct obd_histogram     cl_write_rpc_hist;
252         struct obd_histogram     cl_read_page_hist;
253         struct obd_histogram     cl_write_page_hist;
254
255         struct mdc_rpc_lock     *cl_rpc_lock;
256         struct mdc_rpc_lock     *cl_setattr_lock;
257         struct osc_creator      cl_oscc;
258 };
259
260 /* Like a client, with some hangers-on.  Keep mc_client_obd first so that we
261  * can reuse the various client setup/connect functions. */
262 struct mgmtcli_obd {
263         struct client_obd        mc_client_obd; /* nested */
264         struct ptlrpc_thread    *mc_ping_thread;
265         struct obd_export       *mc_ping_exp; /* XXX single-target */
266         struct list_head         mc_registered;
267         void                    *mc_hammer;
268 };
269
270 #define mc_import mc_client_obd.cl_import
271
272 struct mds_obd {
273         struct ptlrpc_service           *mds_service;
274         struct ptlrpc_service           *mds_setattr_service;
275         struct ptlrpc_service           *mds_readpage_service;
276         struct super_block              *mds_sb;
277         struct vfsmount                 *mds_vfsmnt;
278         struct dentry                   *mds_fid_de;
279         int                              mds_max_mdsize;
280         int                              mds_max_cookiesize;
281         struct file                     *mds_rcvd_filp;
282         spinlock_t                       mds_transno_lock;
283         __u64                            mds_last_transno;
284         __u64                            mds_mount_count;
285         __u64                            mds_io_epoch;
286         struct semaphore                 mds_epoch_sem;
287         struct ll_fid                    mds_rootfid;
288         struct mds_server_data          *mds_server_data;
289         struct dentry                   *mds_pending_dir;
290         struct dentry                   *mds_logs_dir;
291         struct dentry                   *mds_objects_dir;
292         struct llog_handle              *mds_cfg_llh;
293 //        struct llog_handle              *mds_catalog;
294         struct obd_device               *mds_osc_obd; /* XXX lov_obd */
295         struct obd_uuid                  mds_lov_uuid;
296         char                            *mds_profile;
297         struct obd_export               *mds_osc_exp; /* XXX lov_exp */
298         int                              mds_has_lov_desc;
299         struct lov_desc                  mds_lov_desc;
300         obd_id                          *mds_lov_objids;
301         int                              mds_lov_objids_valid;
302         int                              mds_lov_nextid_set;
303         struct file                     *mds_lov_objid_filp;
304         unsigned long                   *mds_client_bitmap;
305         struct semaphore                 mds_orphan_recovery_sem;
306
307         atomic_t                         mds_open_count;
308 };
309
310 struct echo_obd {
311         struct obdo oa;
312         spinlock_t eo_lock;
313         __u64 eo_lastino;
314         atomic_t eo_getattr;
315         atomic_t eo_setattr;
316         atomic_t eo_create;
317         atomic_t eo_destroy;
318         atomic_t eo_prep;
319         atomic_t eo_read;
320         atomic_t eo_write;
321 };
322
323 /*
324  * this struct does double-duty acting as either a client or
325  * server instance .. maybe not wise.
326  */
327 struct ptlbd_obd {
328         /* server's */
329         struct ptlrpc_service *ptlbd_service;
330         struct file *filp;
331         /* client's */
332         struct ptlrpc_client    bd_client;
333         struct obd_import       *bd_import;
334         struct obd_uuid         bd_server_uuid;
335         struct obd_export       *bd_exp;
336         int refcount; /* XXX sigh */
337 };
338
339 struct recovd_obd {
340         spinlock_t            recovd_lock;
341         struct list_head      recovd_managed_items; /* items managed  */
342         struct list_head      recovd_troubled_items; /* items in recovery */
343
344         wait_queue_head_t     recovd_recovery_waitq;
345         wait_queue_head_t     recovd_ctl_waitq;
346         wait_queue_head_t     recovd_waitq;
347         struct task_struct   *recovd_thread;
348         __u32                 recovd_state;
349 };
350
351 struct ost_obd {
352         struct ptlrpc_service *ost_service;
353         struct ptlrpc_service *ost_create_service;
354 };
355
356 struct echo_client_obd {
357         struct obd_export   *ec_exp;   /* the local connection to osc/lov */
358         spinlock_t           ec_lock;
359         struct list_head     ec_objects;
360         int                  ec_nstripes;
361         __u64                ec_unique;
362 };
363
364 struct cache_obd {
365         struct obd_export *cobd_target_exp;/* local connection to target obd */
366         struct obd_export *cobd_cache_exp; /* local connection to cache obd */
367 };
368
369 struct lov_tgt_desc {
370         struct obd_uuid          uuid;
371         struct obd_export       *ltd_exp;
372         int                      active; /* is this target up for requests */
373 };
374
375 struct lov_obd {
376         spinlock_t lov_lock;
377         struct lov_desc desc;
378         int bufsize;
379         int refcount;
380         int lo_catalog_loaded:1;
381         struct lov_tgt_desc *tgts;
382 };
383
384 struct niobuf_local {
385         __u64 offset;
386         __u32 len;
387         __u32 flags;
388         struct page *page;
389         struct dentry *dentry;
390         int lnb_grant_used;
391         int rc;
392 };
393
394
395 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
396 #define N_LOCAL_TEMP_PAGE 0x10000000
397
398 struct obd_trans_info {
399         __u64                    oti_transno;
400         __u64                   *oti_objid;
401         /* Only used on the server side for tracking acks. */
402         struct oti_req_ack_lock {
403                 struct lustre_handle lock;
404                 __u32                mode;
405         }                        oti_ack_locks[4];
406         void                    *oti_handle;
407         struct llog_cookie       oti_onecookie;
408         struct llog_cookie      *oti_logcookies;
409         int                      oti_numcookies;
410 };
411
412 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
413 {
414         if (!oti)
415                 return;
416
417         if (num_cookies == 1)
418                 oti->oti_logcookies = &oti->oti_onecookie;
419         else
420                 OBD_ALLOC(oti->oti_logcookies,
421                           num_cookies * sizeof(oti->oti_onecookie));
422
423         oti->oti_numcookies = num_cookies;
424 }
425
426 static inline void oti_free_cookies(struct obd_trans_info *oti)
427 {
428         if (!oti || !oti->oti_logcookies)
429                 return;
430
431         if (oti->oti_logcookies == &oti->oti_onecookie)
432                 LASSERT(oti->oti_numcookies == 1);
433         else
434                 OBD_FREE(oti->oti_logcookies,
435                          oti->oti_numcookies * sizeof(oti->oti_onecookie));
436         oti->oti_logcookies = NULL;
437         oti->oti_numcookies = 0;
438 }
439
440 /* llog contexts */
441 enum llog_ctxt_id {
442         LLOG_CONFIG_ORIG_CTXT =  0,
443         LLOG_CONFIG_REPL_CTXT =  1,
444         LLOG_UNLINK_ORIG_CTXT =  2,
445         LLOG_UNLINK_REPL_CTXT =  3,
446         LLOG_SIZE_ORIG_CTXT   =  4,
447         LLOG_SIZE_REPL_CTXT   =  5,
448         LLOG_MD_ORIG_CTXT     =  6,
449         LLOG_MD_REPL_CTXT     =  7,
450         LLOG_RD1_ORIG_CTXT    =  8,
451         LLOG_RD1_REPL_CTXT    =  9,
452         LLOG_TEST_ORIG_CTXT   = 10,
453         LLOG_TEST_REPL_CTXT   = 11,
454         LLOG_MAX_CTXTS
455 };
456
457
458 /* corresponds to one of the obd's */
459 struct obd_device {
460         struct obd_type *obd_type;
461
462         /* common and UUID name of this device */
463         char *obd_name;
464         struct obd_uuid obd_uuid;
465
466         int obd_minor;
467         int obd_attached:1, obd_set_up:1, obd_recovering:1,
468             obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
469             obd_no_recov:1, obd_stopping:1;
470         atomic_t obd_refcount;
471         wait_queue_head_t obd_refcount_waitq;
472         struct proc_dir_entry *obd_proc_entry;
473         struct list_head       obd_exports;
474         int                    obd_num_exports;
475         struct ldlm_namespace *obd_namespace;
476         struct ptlrpc_client   obd_ldlm_client; /* XXX OST/MDS only */
477         /* a spinlock is OK for what we do now, may need a semaphore later */
478         spinlock_t             obd_dev_lock;
479         __u64                  obd_last_committed;
480         struct fsfilt_operations *obd_fsops;
481         spinlock_t              obd_osfs_lock;
482         struct obd_statfs       obd_osfs;
483         unsigned long           obd_osfs_age;
484         struct obd_run_ctxt     obd_ctxt;
485         struct llog_ctxt        *obd_llog_ctxt[LLOG_MAX_CTXTS];
486         struct obd_device       *obd_observer;
487         struct obd_export       *obd_self_export;
488
489         /* XXX encapsulate all this recovery data into one struct */
490         svc_handler_t                    obd_recovery_handler;
491         int                              obd_max_recoverable_clients;
492         int                              obd_connected_clients;
493         int                              obd_recoverable_clients;
494         spinlock_t                       obd_processing_task_lock;
495         pid_t                            obd_processing_task;
496         __u64                            obd_next_recovery_transno;
497         int                              obd_replayed_requests;
498         int                              obd_requests_queued_for_recovery;
499         wait_queue_head_t                obd_next_transno_waitq;
500         struct list_head                 obd_uncommitted_replies;
501         spinlock_t                       obd_uncommitted_replies_lock;
502         struct timer_list                obd_recovery_timer;
503         struct list_head                 obd_recovery_queue;
504         struct list_head                 obd_delayed_reply_queue;
505
506         union {
507                 struct filter_obd filter;
508                 struct mds_obd mds;
509                 struct client_obd cli;
510                 struct ost_obd ost;
511                 struct echo_client_obd echo_client;
512                 struct echo_obd echo;
513                 struct recovd_obd recovd;
514                 struct lov_obd lov;
515                 struct cache_obd cobd;
516                 struct ptlbd_obd ptlbd;
517                 struct mgmtcli_obd mgmtcli;
518         } u;
519        /* Fields used by LProcFS */
520         unsigned int           obd_cntr_base;
521         struct lprocfs_stats  *obd_stats;
522         struct proc_dir_entry *obd_svc_procroot;
523         struct lprocfs_stats  *obd_svc_stats;
524 };
525
526 #define OBD_OPT_FORCE           0x0001
527 #define OBD_OPT_FAILOVER        0x0002
528
529 #define OBD_LLOG_FL_SENDNOW     0x0001
530
531 struct obd_ops {
532         struct module *o_owner;
533         int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
534                            void *karg, void *uarg);
535         int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
536                           __u32 *vallen, void *val);
537         int (*o_set_info)(struct obd_export *, __u32 keylen, void *key,
538                           __u32 vallen, void *val);
539         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
540         int (*o_detach)(struct obd_device *dev);
541         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
542         int (*o_precleanup)(struct obd_device *dev, int flags);
543         int (*o_cleanup)(struct obd_device *dev, int flags);
544         int (*o_postrecov)(struct obd_device *dev);
545         int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
546                          struct obd_uuid *cluuid);
547         int (*o_disconnect)(struct obd_export *exp, int flags);
548
549         int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
550                         unsigned long max_age);
551         int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
552                         struct lov_stripe_md *mem_src);
553         int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
554                           struct lov_mds_md *disk_src, int disk_len);
555         int (*o_preallocate)(struct lustre_handle *, obd_count *req,
556                              obd_id *ids);
557         int (*o_create)(struct obd_export *exp,  struct obdo *oa,
558                         struct lov_stripe_md **ea, struct obd_trans_info *oti);
559         int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
560                          struct lov_stripe_md *ea, struct obd_trans_info *oti);
561         int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
562                          struct lov_stripe_md *ea, struct obd_trans_info *oti);
563         int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
564                          struct lov_stripe_md *ea);
565         int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
566                                struct lov_stripe_md *ea,
567                                struct ptlrpc_request_set *set);
568         int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
569                      struct lov_stripe_md *ea, obd_count oa_bufs,
570                      struct brw_page *pgarr, struct obd_trans_info *oti);
571         int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
572                            struct lov_stripe_md *ea, obd_count oa_bufs,
573                            struct brw_page *pgarr, struct ptlrpc_request_set *,
574                            struct obd_trans_info *oti);
575         int (*o_prep_async_page)(struct obd_export *exp, 
576                                  struct lov_stripe_md *lsm,
577                                  struct lov_oinfo *loi, 
578                                  struct page *page, obd_off offset, 
579                                  struct obd_async_page_ops *ops, void *data,
580                                  void **res);
581         int (*o_queue_async_io)(struct obd_export *exp, 
582                                 struct lov_stripe_md *lsm, 
583                                 struct lov_oinfo *loi, void *cookie, 
584                                 int cmd, obd_off off, int count, 
585                                 obd_flag brw_flags, obd_flag async_flags);
586         int (*o_queue_group_io)(struct obd_export *exp, 
587                                 struct lov_stripe_md *lsm, 
588                                 struct lov_oinfo *loi, 
589                                 struct obd_io_group *oig, 
590                                 void *cookie, int cmd, obd_off off, int count, 
591                                 obd_flag brw_flags, obd_flag async_flags);
592         int (*o_trigger_group_io)(struct obd_export *exp, 
593                                   struct lov_stripe_md *lsm, 
594                                   struct lov_oinfo *loi, 
595                                   struct obd_io_group *oig);
596         int (*o_set_async_flags)(struct obd_export *exp,
597                                 struct lov_stripe_md *lsm,
598                                 struct lov_oinfo *loi, void *cookie,
599                                 obd_flag async_flags);
600         int (*o_teardown_async_page)(struct obd_export *exp,
601                                      struct lov_stripe_md *lsm,
602                                      struct lov_oinfo *loi, void *cookie);
603         int (*o_punch)(struct obd_export *exp, struct obdo *oa,
604                        struct lov_stripe_md *ea, obd_size start,
605                        obd_size end, struct obd_trans_info *oti);
606         int (*o_sync)(struct obd_export *exp, struct obdo *oa,
607                       struct lov_stripe_md *ea, obd_size start, obd_size end);
608         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
609                          struct lov_stripe_md *src, obd_size start,
610                          obd_size end, struct obd_trans_info *oti);
611         int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
612                       struct lustre_handle *srconn, struct lov_stripe_md *src,
613                       obd_size start, obd_size end, struct obd_trans_info *);
614         int (*o_iterate)(struct lustre_handle *conn,
615                          int (*)(obd_id, obd_gr, void *),
616                          obd_id *startid, obd_gr group, void *data);
617         int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
618                         int objcount, struct obd_ioobj *obj,
619                         int niocount, struct niobuf_remote *remote,
620                         struct niobuf_local *local, struct obd_trans_info *oti);
621         int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
622                           int objcount, struct obd_ioobj *obj,
623                           int niocount, struct niobuf_local *local,
624                           struct obd_trans_info *oti, int rc);
625         int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
626                          __u32 type, ldlm_policy_data_t *, __u32 mode,
627                          int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
628                          void *data, __u32 lvb_len, void *lvb_swabber,
629                          struct lustre_handle *lockh);
630         int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
631                        ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
632                        struct lustre_handle *lockh);
633         int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
634                                ldlm_iterator_t it, void *data);
635         int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
636                         __u32 mode, struct lustre_handle *);
637         int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
638                                int flags, void *opaque);
639         int (*o_san_preprw)(int cmd, struct obd_export *exp,
640                             struct obdo *oa, int objcount,
641                             struct obd_ioobj *obj, int niocount,
642                             struct niobuf_remote *remote);
643         int (*o_init_export)(struct obd_export *exp);
644         int (*o_destroy_export)(struct obd_export *exp);
645
646         /* llog related obd_methods */
647         int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
648                            int count, struct llog_catid *logid);
649         int (*o_llog_finish)(struct obd_device *obd, int count);
650
651         /* metadata-only methods */
652         int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
653                      struct obd_client_handle *, int flag);
654         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
655
656         int (*o_import_event)(struct obd_device *, struct obd_import *,
657                               enum obd_import_event);
658
659         int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
660                         int active);
661         /* 
662          * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
663          * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
664          * Also, add a wrapper function in include/linux/obd_class.h.
665          */
666 };
667
668
669 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
670                                          int error)
671 {
672         if (error) {
673                 CERROR("%s: transno "LPD64" commit error: %d\n",
674                        obd->obd_name, transno, error);
675                 return;
676         }
677         CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
678                obd->obd_name, transno);
679         if (transno > obd->obd_last_committed) {
680                 obd->obd_last_committed = transno;
681                 ptlrpc_commit_replies (obd);
682         }
683 }
684
685 #endif /* __OBD_H */