Whamcloud - gitweb
Land b_smallfix onto HEAD (20040414_1359)
[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         struct file_operations *fo_fop;
179         struct inode_operations *fo_iop;
180         struct address_space_operations *fo_aops;
181
182         struct list_head     fo_export_list;
183         int                  fo_subdir_count;
184
185         obd_size             fo_tot_dirty;      /* protected by obd_osfs_lock */
186         obd_size             fo_tot_granted;    /* all values in bytes */
187         obd_size             fo_tot_pending;
188
189         obd_size             fo_readcache_max_filesize;
190
191         struct obd_import   *fo_mdc_imp;
192         struct obd_uuid      fo_mdc_uuid;
193         struct lustre_handle fo_mdc_conn;
194 #if 0
195         struct ptlrpc_client fo_mdc_client;
196 #endif
197         struct file        **fo_last_objid_files;
198         __u64               *fo_last_objids; /* last created objid for groups */
199
200         struct semaphore     fo_alloc_lock;
201
202         struct obd_histogram     fo_r_pages;
203         struct obd_histogram     fo_w_pages;
204         struct obd_histogram     fo_r_discont_pages;
205         struct obd_histogram     fo_w_discont_pages;
206         struct obd_histogram     fo_r_discont_blocks;
207         struct obd_histogram     fo_w_discont_blocks;
208 };
209
210 struct mds_server_data;
211
212 #define OSC_MAX_RIF_DEFAULT       4
213 #define OSC_MAX_RIF_MAX          32
214 #define OSC_MAX_DIRTY_DEFAULT     4
215 #define OSC_MAX_DIRTY_MB_MAX    256     /* totally arbitrary */
216
217 struct mdc_rpc_lock;
218 struct client_obd {
219         struct obd_import       *cl_import;
220         struct semaphore         cl_sem;
221         int                      cl_conn_count;
222         /* max_mds_easize is purely a performance thing so we don't have to
223          * call obd_size_wiremd() all the time. */
224         int                      cl_max_mds_easize;
225         int                      cl_max_mds_cookiesize;
226         kdev_t                   cl_sandev;
227
228         //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
229         void                    *cl_llcd_offset;
230
231         struct obd_device       *cl_mgmtcli_obd;
232
233         /* the grant values are protected by loi_list_lock below */
234         long                     cl_dirty;         /* all _dirty_ in bytes */
235         long                     cl_dirty_max;     /* allowed w/o rpc */
236         long                     cl_avail_grant;   /* bytes of credit for ost */
237         long                     cl_lost_grant;    /* lost credits (trunc) */
238         struct list_head         cl_cache_waiters; /* waiting for cache/grant */
239
240         /* keep track of objects that have lois that contain pages which
241          * have been queued for async brw.  this lock also protects the
242          * lists of osc_client_pages that hang off of the loi */
243         spinlock_t               cl_loi_list_lock;
244         struct list_head         cl_loi_ready_list;
245         struct list_head         cl_loi_write_list;
246         struct list_head         cl_loi_read_list;
247         int                      cl_brw_in_flight;
248         /* just a sum of the loi/lop pending numbers to be exported by /proc */
249         int                      cl_pending_w_pages;
250         int                      cl_pending_r_pages;
251         int                      cl_max_pages_per_rpc;
252         int                      cl_max_rpcs_in_flight;
253         struct obd_histogram     cl_read_rpc_hist;
254         struct obd_histogram     cl_write_rpc_hist;
255         struct obd_histogram     cl_read_page_hist;
256         struct obd_histogram     cl_write_page_hist;
257
258         struct mdc_rpc_lock     *cl_rpc_lock;
259         struct mdc_rpc_lock     *cl_setattr_lock;
260         struct osc_creator      cl_oscc;
261 };
262
263 /* Like a client, with some hangers-on.  Keep mc_client_obd first so that we
264  * can reuse the various client setup/connect functions. */
265 struct mgmtcli_obd {
266         struct client_obd        mc_client_obd; /* nested */
267         struct ptlrpc_thread    *mc_ping_thread;
268         struct obd_export       *mc_ping_exp; /* XXX single-target */
269         struct list_head         mc_registered;
270         void                    *mc_hammer;
271 };
272
273 #define mc_import mc_client_obd.cl_import
274
275 struct mds_obd {
276         struct ptlrpc_service           *mds_service;
277         struct ptlrpc_service           *mds_setattr_service;
278         struct ptlrpc_service           *mds_readpage_service;
279         struct super_block              *mds_sb;
280         struct vfsmount                 *mds_vfsmnt;
281         struct dentry                   *mds_fid_de;
282         int                              mds_max_mdsize;
283         int                              mds_max_cookiesize;
284         struct file                     *mds_rcvd_filp;
285         spinlock_t                       mds_transno_lock;
286         __u64                            mds_last_transno;
287         __u64                            mds_mount_count;
288         __u64                            mds_io_epoch;
289         struct semaphore                 mds_epoch_sem;
290         struct ll_fid                    mds_rootfid;
291         struct mds_server_data          *mds_server_data;
292         struct dentry                   *mds_pending_dir;
293         struct dentry                   *mds_logs_dir;
294         struct dentry                   *mds_objects_dir;
295         struct llog_handle              *mds_cfg_llh;
296 //        struct llog_handle              *mds_catalog;
297         struct obd_device               *mds_osc_obd; /* XXX lov_obd */
298         struct obd_uuid                  mds_lov_uuid;
299         char                            *mds_profile;
300         struct obd_export               *mds_osc_exp; /* XXX lov_exp */
301         int                              mds_has_lov_desc;
302         struct lov_desc                  mds_lov_desc;
303         obd_id                          *mds_lov_objids;
304         int                              mds_lov_objids_valid;
305         int                              mds_lov_nextid_set;
306         struct file                     *mds_lov_objid_filp;
307         unsigned long                   *mds_client_bitmap;
308         struct semaphore                 mds_orphan_recovery_sem;
309
310         atomic_t                         mds_open_count;
311 };
312
313 struct echo_obd {
314         struct obdo oa;
315         spinlock_t eo_lock;
316         __u64 eo_lastino;
317         atomic_t eo_getattr;
318         atomic_t eo_setattr;
319         atomic_t eo_create;
320         atomic_t eo_destroy;
321         atomic_t eo_prep;
322         atomic_t eo_read;
323         atomic_t eo_write;
324 };
325
326 /*
327  * this struct does double-duty acting as either a client or
328  * server instance .. maybe not wise.
329  */
330 struct ptlbd_obd {
331         /* server's */
332         struct ptlrpc_service *ptlbd_service;
333         struct file *filp;
334         /* client's */
335         struct ptlrpc_client    bd_client;
336         struct obd_import       *bd_import;
337         struct obd_uuid         bd_server_uuid;
338         struct obd_export       *bd_exp;
339         int refcount; /* XXX sigh */
340 };
341
342 struct recovd_obd {
343         spinlock_t            recovd_lock;
344         struct list_head      recovd_managed_items; /* items managed  */
345         struct list_head      recovd_troubled_items; /* items in recovery */
346
347         wait_queue_head_t     recovd_recovery_waitq;
348         wait_queue_head_t     recovd_ctl_waitq;
349         wait_queue_head_t     recovd_waitq;
350         struct task_struct   *recovd_thread;
351         __u32                 recovd_state;
352 };
353
354 struct ost_obd {
355         struct ptlrpc_service *ost_service;
356         struct ptlrpc_service *ost_create_service;
357 };
358
359 struct echo_client_obd {
360         struct obd_export   *ec_exp;   /* the local connection to osc/lov */
361         spinlock_t           ec_lock;
362         struct list_head     ec_objects;
363         int                  ec_nstripes;
364         __u64                ec_unique;
365 };
366
367 struct cache_obd {
368         struct obd_export *cobd_target_exp;/* local connection to target obd */
369         struct obd_export *cobd_cache_exp; /* local connection to cache obd */
370 };
371
372 struct lov_tgt_desc {
373         struct obd_uuid          uuid;
374         struct obd_export       *ltd_exp;
375         int                      active; /* is this target up for requests */
376 };
377
378 struct lov_obd {
379         spinlock_t lov_lock;
380         struct lov_desc desc;
381         int bufsize;
382         int refcount;
383         int lo_catalog_loaded:1;
384         struct lov_tgt_desc *tgts;
385 };
386
387 struct niobuf_local {
388         __u64 offset;
389         __u32 len;
390         __u32 flags;
391         struct page *page;
392         struct dentry *dentry;
393         int lnb_grant_used;
394         int rc;
395 };
396
397
398 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
399 #define N_LOCAL_TEMP_PAGE 0x10000000
400
401 struct obd_trans_info {
402         __u64                    oti_transno;
403         __u64                   *oti_objid;
404         /* Only used on the server side for tracking acks. */
405         struct oti_req_ack_lock {
406                 struct lustre_handle lock;
407                 __u32                mode;
408         }                        oti_ack_locks[4];
409         void                    *oti_handle;
410         struct llog_cookie       oti_onecookie;
411         struct llog_cookie      *oti_logcookies;
412         int                      oti_numcookies;
413 };
414
415 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
416 {
417         if (!oti)
418                 return;
419
420         if (num_cookies == 1)
421                 oti->oti_logcookies = &oti->oti_onecookie;
422         else
423                 OBD_ALLOC(oti->oti_logcookies,
424                           num_cookies * sizeof(oti->oti_onecookie));
425
426         oti->oti_numcookies = num_cookies;
427 }
428
429 static inline void oti_free_cookies(struct obd_trans_info *oti)
430 {
431         if (!oti || !oti->oti_logcookies)
432                 return;
433
434         if (oti->oti_logcookies == &oti->oti_onecookie)
435                 LASSERT(oti->oti_numcookies == 1);
436         else
437                 OBD_FREE(oti->oti_logcookies,
438                          oti->oti_numcookies * sizeof(oti->oti_onecookie));
439         oti->oti_logcookies = NULL;
440         oti->oti_numcookies = 0;
441 }
442
443 /* llog contexts */
444 enum llog_ctxt_id {
445         LLOG_CONFIG_ORIG_CTXT =  0,
446         LLOG_CONFIG_REPL_CTXT =  1,
447         LLOG_UNLINK_ORIG_CTXT =  2,
448         LLOG_UNLINK_REPL_CTXT =  3,
449         LLOG_SIZE_ORIG_CTXT   =  4,
450         LLOG_SIZE_REPL_CTXT   =  5,
451         LLOG_MD_ORIG_CTXT     =  6,
452         LLOG_MD_REPL_CTXT     =  7,
453         LLOG_RD1_ORIG_CTXT    =  8,
454         LLOG_RD1_REPL_CTXT    =  9,
455         LLOG_TEST_ORIG_CTXT   = 10,
456         LLOG_TEST_REPL_CTXT   = 11,
457         LLOG_MAX_CTXTS
458 };
459
460
461 /* corresponds to one of the obd's */
462 struct obd_device {
463         struct obd_type *obd_type;
464
465         /* common and UUID name of this device */
466         char *obd_name;
467         struct obd_uuid obd_uuid;
468
469         int obd_minor;
470         unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
471                 obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
472                 obd_no_recov:1, obd_stopping:1;
473         atomic_t obd_refcount;
474         wait_queue_head_t obd_refcount_waitq;
475         struct proc_dir_entry *obd_proc_entry;
476         struct list_head       obd_exports;
477         int                    obd_num_exports;
478         struct ldlm_namespace *obd_namespace;
479         struct ptlrpc_client   obd_ldlm_client; /* XXX OST/MDS only */
480         /* a spinlock is OK for what we do now, may need a semaphore later */
481         spinlock_t             obd_dev_lock;
482         __u64                  obd_last_committed;
483         struct fsfilt_operations *obd_fsops;
484         spinlock_t              obd_osfs_lock;
485         struct obd_statfs       obd_osfs;
486         unsigned long           obd_osfs_age;
487         struct obd_run_ctxt     obd_ctxt;
488         struct llog_ctxt        *obd_llog_ctxt[LLOG_MAX_CTXTS];
489         struct obd_device       *obd_observer;
490         struct obd_export       *obd_self_export;
491
492         /* XXX encapsulate all this recovery data into one struct */
493         svc_handler_t                    obd_recovery_handler;
494         int                              obd_max_recoverable_clients;
495         int                              obd_connected_clients;
496         int                              obd_recoverable_clients;
497         spinlock_t                       obd_processing_task_lock;
498         pid_t                            obd_processing_task;
499         __u64                            obd_next_recovery_transno;
500         int                              obd_replayed_requests;
501         int                              obd_requests_queued_for_recovery;
502         wait_queue_head_t                obd_next_transno_waitq;
503         struct list_head                 obd_uncommitted_replies;
504         spinlock_t                       obd_uncommitted_replies_lock;
505         struct timer_list                obd_recovery_timer;
506         struct list_head                 obd_recovery_queue;
507         struct list_head                 obd_delayed_reply_queue;
508
509         union {
510                 struct filter_obd filter;
511                 struct mds_obd mds;
512                 struct client_obd cli;
513                 struct ost_obd ost;
514                 struct echo_client_obd echo_client;
515                 struct echo_obd echo;
516                 struct recovd_obd recovd;
517                 struct lov_obd lov;
518                 struct cache_obd cobd;
519                 struct ptlbd_obd ptlbd;
520                 struct mgmtcli_obd mgmtcli;
521         } u;
522        /* Fields used by LProcFS */
523         unsigned int           obd_cntr_base;
524         struct lprocfs_stats  *obd_stats;
525         struct proc_dir_entry *obd_svc_procroot;
526         struct lprocfs_stats  *obd_svc_stats;
527 };
528
529 #define OBD_OPT_FORCE           0x0001
530 #define OBD_OPT_FAILOVER        0x0002
531
532 #define OBD_LLOG_FL_SENDNOW     0x0001
533
534 struct obd_ops {
535         struct module *o_owner;
536         int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
537                            void *karg, void *uarg);
538         int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
539                           __u32 *vallen, void *val);
540         int (*o_set_info)(struct obd_export *, __u32 keylen, void *key,
541                           __u32 vallen, void *val);
542         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
543         int (*o_detach)(struct obd_device *dev);
544         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
545         int (*o_precleanup)(struct obd_device *dev, int flags);
546         int (*o_cleanup)(struct obd_device *dev, int flags);
547         int (*o_postrecov)(struct obd_device *dev);
548         int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
549                          struct obd_uuid *cluuid);
550         int (*o_disconnect)(struct obd_export *exp, int flags);
551
552         int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
553                         unsigned long max_age);
554         int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
555                         struct lov_stripe_md *mem_src);
556         int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
557                           struct lov_mds_md *disk_src, int disk_len);
558         int (*o_preallocate)(struct lustre_handle *, obd_count *req,
559                              obd_id *ids);
560         int (*o_create)(struct obd_export *exp,  struct obdo *oa,
561                         struct lov_stripe_md **ea, struct obd_trans_info *oti);
562         int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
563                          struct lov_stripe_md *ea, struct obd_trans_info *oti);
564         int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
565                          struct lov_stripe_md *ea, struct obd_trans_info *oti);
566         int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
567                          struct lov_stripe_md *ea);
568         int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
569                                struct lov_stripe_md *ea,
570                                struct ptlrpc_request_set *set);
571         int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
572                      struct lov_stripe_md *ea, obd_count oa_bufs,
573                      struct brw_page *pgarr, struct obd_trans_info *oti);
574         int (*o_brw_async)(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 ptlrpc_request_set *,
577                            struct obd_trans_info *oti);
578         int (*o_prep_async_page)(struct obd_export *exp, 
579                                  struct lov_stripe_md *lsm,
580                                  struct lov_oinfo *loi, 
581                                  struct page *page, obd_off offset, 
582                                  struct obd_async_page_ops *ops, void *data,
583                                  void **res);
584         int (*o_queue_async_io)(struct obd_export *exp, 
585                                 struct lov_stripe_md *lsm, 
586                                 struct lov_oinfo *loi, void *cookie, 
587                                 int cmd, obd_off off, int count, 
588                                 obd_flag brw_flags, obd_flag async_flags);
589         int (*o_queue_group_io)(struct obd_export *exp, 
590                                 struct lov_stripe_md *lsm, 
591                                 struct lov_oinfo *loi, 
592                                 struct obd_io_group *oig, 
593                                 void *cookie, int cmd, obd_off off, int count, 
594                                 obd_flag brw_flags, obd_flag async_flags);
595         int (*o_trigger_group_io)(struct obd_export *exp, 
596                                   struct lov_stripe_md *lsm, 
597                                   struct lov_oinfo *loi, 
598                                   struct obd_io_group *oig);
599         int (*o_set_async_flags)(struct obd_export *exp,
600                                 struct lov_stripe_md *lsm,
601                                 struct lov_oinfo *loi, void *cookie,
602                                 obd_flag async_flags);
603         int (*o_teardown_async_page)(struct obd_export *exp,
604                                      struct lov_stripe_md *lsm,
605                                      struct lov_oinfo *loi, void *cookie);
606         int (*o_punch)(struct obd_export *exp, struct obdo *oa,
607                        struct lov_stripe_md *ea, obd_size start,
608                        obd_size end, struct obd_trans_info *oti);
609         int (*o_sync)(struct obd_export *exp, struct obdo *oa,
610                       struct lov_stripe_md *ea, obd_size start, obd_size end);
611         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
612                          struct lov_stripe_md *src, obd_size start,
613                          obd_size end, struct obd_trans_info *oti);
614         int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
615                       struct lustre_handle *srconn, struct lov_stripe_md *src,
616                       obd_size start, obd_size end, struct obd_trans_info *);
617         int (*o_iterate)(struct lustre_handle *conn,
618                          int (*)(obd_id, obd_gr, void *),
619                          obd_id *startid, obd_gr group, void *data);
620         int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
621                         int objcount, struct obd_ioobj *obj,
622                         int niocount, struct niobuf_remote *remote,
623                         struct niobuf_local *local, struct obd_trans_info *oti);
624         int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
625                           int objcount, struct obd_ioobj *obj,
626                           int niocount, struct niobuf_local *local,
627                           struct obd_trans_info *oti, int rc);
628         int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
629                          __u32 type, ldlm_policy_data_t *, __u32 mode,
630                          int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
631                          void *data, __u32 lvb_len, void *lvb_swabber,
632                          struct lustre_handle *lockh);
633         int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
634                        ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
635                        struct lustre_handle *lockh);
636         int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
637                                ldlm_iterator_t it, void *data);
638         int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
639                         __u32 mode, struct lustre_handle *);
640         int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
641                                int flags, void *opaque);
642         int (*o_san_preprw)(int cmd, struct obd_export *exp,
643                             struct obdo *oa, int objcount,
644                             struct obd_ioobj *obj, int niocount,
645                             struct niobuf_remote *remote);
646         int (*o_init_export)(struct obd_export *exp);
647         int (*o_destroy_export)(struct obd_export *exp);
648
649         /* llog related obd_methods */
650         int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
651                            int count, struct llog_catid *logid);
652         int (*o_llog_finish)(struct obd_device *obd, int count);
653
654         /* metadata-only methods */
655         int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
656                      struct obd_client_handle *, int flag);
657         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
658
659         int (*o_import_event)(struct obd_device *, struct obd_import *,
660                               enum obd_import_event);
661
662         int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
663                         int active);
664         /* 
665          * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
666          * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
667          * Also, add a wrapper function in include/linux/obd_class.h.
668          */
669 };
670
671
672 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
673                                          int error)
674 {
675         if (error) {
676                 CERROR("%s: transno "LPD64" commit error: %d\n",
677                        obd->obd_name, transno, error);
678                 return;
679         }
680         CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
681                obd->obd_name, transno);
682         if (transno > obd->obd_last_committed) {
683                 obd->obd_last_committed = transno;
684                 ptlrpc_commit_replies (obd);
685         }
686 }
687
688 #endif /* __OBD_H */