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