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