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