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