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