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