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