Whamcloud - gitweb
cf80b7a93f3d2888dcccdd056ec8df04eaf677be
[fs/lustre-release.git] / lustre / include / 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 #if defined(__linux__)
9 #include <linux/obd.h>
10 #elif defined(__APPLE__)
11 #include <darwin/obd.h>
12 #elif defined(__WINNT__)
13 #include <winnt/obd.h>
14 #else
15 #error Unsupported operating system.
16 #endif
17
18 #define IOC_OSC_TYPE         'h'
19 #define IOC_OSC_MIN_NR       20
20 #define IOC_OSC_SET_ACTIVE   _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
21 #define IOC_OSC_MAX_NR       50
22
23 #define IOC_MDC_TYPE         'i'
24 #define IOC_MDC_MIN_NR       20
25 /* Moved to lustre_user.h
26 #define IOC_MDC_LOOKUP       _IOWR(IOC_MDC_TYPE, 20, struct obd_ioctl_data *)
27 #define IOC_MDC_GETSTRIPE    _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *) */
28 #define IOC_MDC_MAX_NR       50
29
30 #include <lustre_lib.h>
31 #include <lustre/lustre_idl.h>
32 #include <lustre_export.h>
33 #include <lustre_quota.h>
34 #include <class_hash.h>
35
36 #include <libcfs/bitmap.h>
37
38
39 #define MAX_OBD_DEVICES 8192
40
41 /* this is really local to the OSC */
42 struct loi_oap_pages {
43         struct list_head        lop_pending;
44         struct list_head        lop_urgent;
45         struct list_head        lop_pending_group;
46         int                     lop_num_pending;
47 };
48
49 struct osc_async_rc {
50         int     ar_rc;
51         int     ar_force_sync;
52         __u64   ar_min_xid;
53 };
54
55 struct lov_oinfo {                 /* per-stripe data structure */
56         __u64 loi_id;              /* object ID on the target OST */
57         __u64 loi_gr;              /* object group on the target OST */
58         int loi_ost_idx;           /* OST stripe index in lov_tgt_desc->tgts */
59         int loi_ost_gen;           /* generation of this loi_ost_idx */
60
61         /* used by the osc to keep track of what objects to build into rpcs */
62         struct loi_oap_pages loi_read_lop;
63         struct loi_oap_pages loi_write_lop;
64         /* _cli_ is poorly named, it should be _ready_ */
65         struct list_head loi_cli_item;
66         struct list_head loi_write_item;
67         struct list_head loi_read_item;
68
69         unsigned long loi_kms_valid:1;
70         __u64 loi_kms;             /* known minimum size */
71         struct ost_lvb loi_lvb;
72         struct osc_async_rc     loi_ar;
73 };
74
75 static inline void loi_init(struct lov_oinfo *loi)
76 {
77         CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
78         CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
79         CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
80         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
81         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
82         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
83         CFS_INIT_LIST_HEAD(&loi->loi_cli_item);
84         CFS_INIT_LIST_HEAD(&loi->loi_write_item);
85         CFS_INIT_LIST_HEAD(&loi->loi_read_item);
86 }
87
88 /*extent array item for describing the joined file extent info*/
89 struct lov_extent {
90         __u64 le_start;            /* extent start */
91         __u64 le_len;              /* extent length */
92         int   le_loi_idx;          /* extent #1 loi's index in lsm loi array */
93         int   le_stripe_count;     /* extent stripe count*/
94 };
95
96 /*Lov array info for describing joined file array EA info*/
97 struct lov_array_info {
98         struct llog_logid    lai_array_id;    /* MDS med llog object id */
99         unsigned             lai_ext_count; /* number of extent count */
100         struct lov_extent    *lai_ext_array; /* extent desc array */
101 };
102
103 struct lov_stripe_md {
104         spinlock_t       lsm_lock;
105         void            *lsm_lock_owner; /* debugging */
106
107         struct {
108                 /* Public members. */
109                 __u64 lw_object_id;        /* lov object id */
110                 __u64 lw_object_gr;        /* lov object group */
111                 __u64 lw_maxbytes;         /* maximum possible file size */
112
113                 /* LOV-private members start here -- only for use in lov/. */
114                 __u32 lw_magic;
115                 __u32 lw_stripe_size;      /* size of the stripe */
116                 __u32 lw_pattern;          /* striping pattern (RAID0, RAID1) */
117                 unsigned lw_stripe_count;  /* number of objects being striped over */
118         } lsm_wire;
119
120         struct lov_array_info *lsm_array; /*Only for joined file array info*/
121         struct lov_oinfo *lsm_oinfo[0];
122 };
123
124 #define lsm_object_id    lsm_wire.lw_object_id
125 #define lsm_object_gr    lsm_wire.lw_object_gr
126 #define lsm_maxbytes     lsm_wire.lw_maxbytes
127 #define lsm_magic        lsm_wire.lw_magic
128 #define lsm_stripe_size  lsm_wire.lw_stripe_size
129 #define lsm_pattern      lsm_wire.lw_pattern
130 #define lsm_stripe_count lsm_wire.lw_stripe_count
131
132 struct obd_info;
133
134 typedef int (*obd_enqueue_update_f)(struct obd_info *oinfo, int rc);
135
136 /* obd info for a particular level (lov, osc). */
137 struct obd_info {
138         /* Lock policy. It keeps an extent which is specific for a particular
139          * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy,
140          * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */
141         ldlm_policy_data_t      oi_policy;
142         /* Flags used while lock handling. The flags obtained on the enqueue
143          * request are set here, therefore they are request specific. */
144         int                     oi_flags;
145         /* Lock handle specific for every OSC lock. */
146         struct lustre_handle   *oi_lockh;
147         /* lsm data specific for every OSC. */
148         struct lov_stripe_md   *oi_md;
149         /* obdo data specific for every OSC, if needed at all. */
150         struct obdo            *oi_oa;
151         /* statfs data specific for every OSC, if needed at all. */
152         struct obd_statfs      *oi_osfs;
153         /* An update callback which is called to update some data on upper
154          * level. E.g. it is used for update lsm->lsm_oinfo at every recieved
155          * request in osc level for enqueue requests. It is also possible to
156          * update some caller data from LOV layer if needed. */
157         obd_enqueue_update_f     oi_cb_up;
158 };
159
160 /* compare all relevant fields. */
161 static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
162                                     struct lov_stripe_md *m2)
163 {
164         /*
165          * ->lsm_wire contains padding, but it should be zeroed out during
166          * allocation.
167          */
168         return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof m1->lsm_wire);
169 }
170
171 void lov_stripe_lock(struct lov_stripe_md *md);
172 void lov_stripe_unlock(struct lov_stripe_md *md);
173
174 struct obd_type {
175         struct list_head typ_chain;
176         struct obd_ops *typ_ops;
177         cfs_proc_dir_entry_t *typ_procroot;
178         char *typ_name;
179         int  typ_refcnt;
180         spinlock_t obd_type_lock;
181 };
182
183 struct brw_page {
184         obd_off  off;
185         cfs_page_t *pg;
186         int count;
187         obd_flag flag;
188 };
189
190 enum async_flags {
191         ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
192                               page is added to an rpc */
193         ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
194         ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
195                                      to give the caller a chance to update
196                                      or cancel the size of the io */
197         ASYNC_GROUP_SYNC = 0x8,  /* ap_completion will not be called, instead
198                                     the page is accounted for in the
199                                     obd_io_group given to
200                                     obd_queue_group_io */
201 };
202
203 struct obd_async_page_ops {
204         int  (*ap_make_ready)(void *data, int cmd);
205         int  (*ap_refresh_count)(void *data, int cmd);
206         void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
207         void (*ap_update_obdo)(void *data, int cmd, struct obdo *oa,
208                                obd_valid valid);
209         int  (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
210 };
211
212 /* the `oig' is passed down from a caller of obd rw methods.  the callee
213  * records enough state such that the caller can sleep on the oig and
214  * be woken when all the callees have finished their work */
215 struct obd_io_group {
216         spinlock_t      oig_lock;
217         atomic_t        oig_refcount;
218         int             oig_pending;
219         int             oig_rc;
220         struct list_head oig_occ_list;
221         cfs_waitq_t     oig_waitq;
222 };
223
224 /* the oig callback context lets the callee of obd rw methods register
225  * for callbacks from the caller. */
226 struct oig_callback_context {
227         struct list_head occ_oig_item;
228         /* called when the caller has received a signal while sleeping.
229          * callees of this method are encouraged to abort their state
230          * in the oig.  This may be called multiple times. */
231         void (*occ_interrupted)(struct oig_callback_context *occ);
232         unsigned long interrupted:1;
233 };
234
235 /* Individual type definitions */
236
237 struct ost_server_data;
238
239 /* hold common fields for "target" device */
240 struct obd_device_target {
241         struct super_block       *obt_sb;
242         atomic_t                  obt_quotachecking;
243         struct lustre_quota_ctxt  obt_qctxt;
244 };
245
246 typedef void (*obd_pin_extent_cb)(void *data);
247 typedef int (*obd_page_removal_cb_t)(void *data, int discard);
248 typedef int (*obd_lock_cancel_cb)(struct ldlm_lock *,struct ldlm_lock_desc *,
249                                    void *, int);
250
251 #define FILTER_GROUP_LLOG 1
252 #define FILTER_GROUP_ECHO 2
253
254 struct filter_ext {
255         __u64                fe_start;
256         __u64                fe_end;
257 };
258
259 struct filter_obd {
260         /* NB this field MUST be first */
261         struct obd_device_target fo_obt;
262         const char          *fo_fstype;
263         struct vfsmount     *fo_vfsmnt;
264         cfs_dentry_t        *fo_dentry_O;
265         cfs_dentry_t       **fo_dentry_O_groups;
266         cfs_dentry_t       **fo_dentry_O_sub;
267         spinlock_t           fo_objidlock;      /* protect fo_lastobjid */
268         spinlock_t           fo_translock;      /* protect fsd_last_transno */
269         struct file         *fo_rcvd_filp;
270         struct file         *fo_health_check_filp;
271         struct lr_server_data *fo_fsd;
272         unsigned long       *fo_last_rcvd_slots;
273         __u64                fo_mount_count;
274
275         int                  fo_destroy_in_progress;
276         struct semaphore     fo_create_lock;
277
278         struct list_head     fo_export_list;
279         int                  fo_subdir_count;
280
281         obd_size             fo_tot_dirty;      /* protected by obd_osfs_lock */
282         obd_size             fo_tot_granted;    /* all values in bytes */
283         obd_size             fo_tot_pending;
284
285         obd_size             fo_readcache_max_filesize;
286
287         struct obd_import   *fo_mdc_imp;
288         struct obd_uuid      fo_mdc_uuid;
289         struct lustre_handle fo_mdc_conn;
290         struct file        **fo_last_objid_files;
291         __u64               *fo_last_objids; /* last created objid for groups,
292                                               * protected by fo_objidlock */
293
294         struct semaphore     fo_alloc_lock;
295
296         atomic_t             fo_r_in_flight;
297         atomic_t             fo_w_in_flight;
298
299         /*
300          * per-filter pool of kiobuf's allocated by filter_common_setup() and
301          * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
302          * which ->fo_iobuf_count were allocated.
303          *
304          * This pool contains kiobuf used by
305          * filter_{prep,commit}rw_{read,write}() and is shared by all OST
306          * threads.
307          *
308          * Locking: none, each OST thread uses only one element, determined by
309          * its "ordinal number", ->t_id.
310          */
311         struct filter_iobuf    **fo_iobuf_pool;
312         int                      fo_iobuf_count;
313
314         struct brw_stats         fo_filter_stats;
315         struct lustre_quota_ctxt fo_quota_ctxt;
316         spinlock_t               fo_quotacheck_lock;
317         atomic_t                 fo_quotachecking;
318
319         int                      fo_fmd_max_num; /* per exp filter_mod_data */
320         int                      fo_fmd_max_age; /* jiffies to fmd expiry */
321         void                     *fo_lcm;
322 };
323
324 #define OSC_MAX_RIF_DEFAULT       8
325 #define OSC_MAX_RIF_MAX         256
326 #define OSC_MAX_DIRTY_DEFAULT  (OSC_MAX_RIF_DEFAULT * 4)
327 #define OSC_MAX_DIRTY_MB_MAX   2048     /* arbitrary, but < MAX_LONG bytes */
328 #define OSC_DEFAULT_RESENDS      10
329
330 #define MDC_MAX_RIF_DEFAULT       8
331 #define MDC_MAX_RIF_MAX         512
332
333 struct mdc_rpc_lock;
334 struct obd_import;
335 struct lustre_cache;
336 struct client_obd {
337         struct semaphore         cl_sem;
338         struct obd_uuid          cl_target_uuid;
339         struct obd_import       *cl_import; /* ptlrpc connection state */
340         int                      cl_conn_count;
341         /* max_mds_easize is purely a performance thing so we don't have to
342          * call obd_size_diskmd() all the time. */
343         int                      cl_default_mds_easize;
344         int                      cl_max_mds_easize;
345         int                      cl_max_mds_cookiesize;
346
347         //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
348         void                    *cl_llcd_offset;
349
350         /* the grant values are protected by loi_list_lock below */
351         long                     cl_dirty;         /* all _dirty_ in bytes */
352         long                     cl_dirty_max;     /* allowed w/o rpc */
353         long                     cl_avail_grant;   /* bytes of credit for ost */
354         long                     cl_lost_grant;    /* lost credits (trunc) */
355         struct list_head         cl_cache_waiters; /* waiting for cache/grant */
356
357         /* keep track of objects that have lois that contain pages which
358          * have been queued for async brw.  this lock also protects the
359          * lists of osc_client_pages that hang off of the loi */
360         /*
361          * ->cl_loi_list_lock protects consistency of
362          * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
363          * ->ap_completion() call-backs are executed under this lock. As we
364          * cannot guarantee that these call-backs never block on all platforms
365          * (as a matter of fact they do block on Mac OS X), type of
366          * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
367          * and blocking mutex on Mac OS X. (Alternative is to make this lock
368          * blocking everywhere, but we don't want to slow down fast-path of
369          * our main platform.)
370          *
371          * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
372          * with client_obd_list_{un,}lock() and
373          * client_obd_list_lock_{init,done}() functions.
374          */
375         client_obd_lock_t        cl_loi_list_lock;
376         struct list_head         cl_loi_ready_list;
377         struct list_head         cl_loi_write_list;
378         struct list_head         cl_loi_read_list;
379         int                      cl_r_in_flight;
380         int                      cl_w_in_flight;
381         /* just a sum of the loi/lop pending numbers to be exported by /proc */
382         int                      cl_pending_w_pages;
383         int                      cl_pending_r_pages;
384         int                      cl_max_pages_per_rpc;
385         int                      cl_max_rpcs_in_flight;
386         struct obd_histogram     cl_read_rpc_hist;
387         struct obd_histogram     cl_write_rpc_hist;
388         struct obd_histogram     cl_read_page_hist;
389         struct obd_histogram     cl_write_page_hist;
390         struct obd_histogram     cl_read_offset_hist;
391         struct obd_histogram     cl_write_offset_hist;
392
393         /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */
394         atomic_t                 cl_destroy_in_flight;
395         cfs_waitq_t              cl_destroy_waitq;
396
397         struct mdc_rpc_lock     *cl_rpc_lock;
398         struct mdc_rpc_lock     *cl_setattr_lock;
399         struct mdc_rpc_lock     *cl_close_lock;
400         struct osc_creator       cl_oscc;
401
402         /* mgc datastruct */
403         struct semaphore         cl_mgc_sem;
404         struct vfsmount         *cl_mgc_vfsmnt;
405         struct dentry           *cl_mgc_configs_dir;
406         atomic_t                 cl_mgc_refcount;
407         struct obd_export       *cl_mgc_mgsexp;
408
409         /* Flags section */
410         unsigned long            cl_checksum:1; /* debug checksums */
411
412         /* also protected by the poorly named _loi_list_lock lock above */
413         struct osc_async_rc      cl_ar;
414
415         /* used by quotacheck */
416         int                      cl_qchk_stat; /* quotacheck stat of the peer */
417         atomic_t                 cl_resends; /* resend count */
418         /* Cache of triples */
419         struct lustre_cache     *cl_cache;
420         obd_lock_cancel_cb       cl_ext_lock_cancel_cb;
421 };
422 #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
423
424 #define CL_NOT_QUOTACHECKED 1   /* client->cl_qchk_stat init value */
425
426 struct mgs_obd {
427         struct ptlrpc_service           *mgs_service;
428         struct vfsmount                 *mgs_vfsmnt;
429         struct super_block              *mgs_sb;
430         struct dentry                   *mgs_configs_dir;
431         struct dentry                   *mgs_fid_de;
432         struct list_head                 mgs_fs_db_list;
433         struct semaphore                 mgs_sem;
434         cfs_proc_dir_entry_t            *mgs_proc_live;
435 };
436
437 struct mds_obd {
438         /* NB this field MUST be first */
439         struct obd_device_target         mds_obt;
440         struct ptlrpc_service           *mds_service;
441         struct ptlrpc_service           *mds_setattr_service;
442         struct ptlrpc_service           *mds_readpage_service;
443         struct vfsmount                 *mds_vfsmnt;
444         cfs_dentry_t                    *mds_fid_de;
445         int                              mds_max_mdsize;
446         int                              mds_max_cookiesize;
447         struct file                     *mds_rcvd_filp;
448         spinlock_t                       mds_transno_lock;
449         __u64                            mds_last_transno;
450         __u64                            mds_mount_count;
451         __u64                            mds_io_epoch;
452         unsigned long                    mds_atime_diff;
453         struct semaphore                 mds_epoch_sem;
454         struct ll_fid                    mds_rootfid;
455         struct lr_server_data           *mds_server_data;
456         cfs_dentry_t                    *mds_pending_dir;
457         cfs_dentry_t                    *mds_logs_dir;
458         cfs_dentry_t                    *mds_objects_dir;
459         struct llog_handle              *mds_cfg_llh;
460 //        struct llog_handle              *mds_catalog;
461         struct obd_device               *mds_osc_obd; /* XXX lov_obd */
462         struct obd_uuid                  mds_lov_uuid;
463         char                            *mds_profile;
464         struct obd_export               *mds_osc_exp; /* XXX lov_exp */
465         struct lov_desc                  mds_lov_desc;
466         
467         /* mark pages dirty for write. */
468         bitmap_t                         *mds_lov_page_dirty;
469         /* array for store pages with obd_id */
470         void                            **mds_lov_page_array;
471         /* file for store objid */
472         struct file                     *mds_lov_objid_filp;
473         __u32                            mds_lov_objid_count;
474         __u32                            mds_lov_objid_lastpage;
475         __u32                            mds_lov_objid_lastidx;
476
477         struct file                     *mds_health_check_filp;
478         unsigned long                   *mds_client_bitmap;
479         struct upcall_cache             *mds_group_hash;
480
481         struct lustre_quota_info         mds_quota_info;
482         struct semaphore                 mds_qonoff_sem;
483         struct semaphore                 mds_health_sem;
484         unsigned long                    mds_fl_user_xattr:1,
485                                          mds_fl_acl:1,
486                                          mds_fl_cfglog:1,
487                                          mds_fl_synced:1,
488                                          mds_evict_ost_nids:1;
489
490         uid_t                            mds_squash_uid;
491         gid_t                            mds_squash_gid;
492         lnet_nid_t                       mds_nosquash_nid;
493 };
494
495 /* lov objid */
496 #define mds_max_ost_index  (0xFFFF)
497 #define MDS_LOV_ALLOC_SIZE (CFS_PAGE_SIZE)
498
499 #define OBJID_PER_PAGE() (MDS_LOV_ALLOC_SIZE / sizeof(obd_id))
500
501 #define MDS_LOV_OBJID_PAGES_COUNT (mds_max_ost_index/OBJID_PER_PAGE())
502
503 extern int mds_lov_init_objids(struct obd_device *obd);
504 extern void mds_lov_destroy_objids(struct obd_device *obd);
505
506 struct obd_id_info {
507         __u32   idx;
508         obd_id  *data;
509 };
510
511 /* */
512
513 struct echo_obd {
514         struct obdo          eo_oa;
515         spinlock_t           eo_lock;
516         __u64                eo_lastino;
517         struct lustre_handle eo_nl_lock;
518         atomic_t             eo_prep;
519 };
520
521 struct ost_obd {
522         struct ptlrpc_service *ost_service;
523         struct ptlrpc_service *ost_create_service;
524         struct ptlrpc_service *ost_io_service;
525         struct semaphore       ost_health_sem;
526 };
527
528 struct echo_client_obd {
529         struct obd_export   *ec_exp;   /* the local connection to osc/lov */
530         spinlock_t           ec_lock;
531         struct list_head     ec_objects;
532         int                  ec_nstripes;
533         __u64                ec_unique;
534 };
535
536 struct lov_qos_oss {
537         struct obd_uuid     lqo_uuid;       /* ptlrpc's c_remote_uuid */
538         struct list_head    lqo_oss_list;   /* link to lov_qos */
539         __u32               lqo_ost_count;  /* number of osts on this oss */
540         __u64               lqo_bavail;     /* total bytes avail on OSS */
541         __u64               lqo_penalty;    /* current penalty */
542         __u64               lqo_penalty_per_obj; /* penalty decrease every obj*/
543 };
544
545 struct ltd_qos {
546         struct lov_qos_oss *ltq_oss;         /* oss info */
547         __u64               ltq_penalty;     /* current penalty */
548         __u64               ltq_penalty_per_obj; /* penalty decrease every obj*/
549         __u64               ltq_weight;      /* net weighting */
550         unsigned int        ltq_usable:1;    /* usable for striping */
551 };
552
553 struct lov_qos {
554         struct list_head    lq_oss_list;    /* list of OSSs that targets use */
555         struct rw_semaphore lq_rw_sem;
556         __u32               lq_active_oss_count;
557         __u32              *lq_rr_array;    /* round-robin optimized list */
558         unsigned int        lq_rr_size;     /* rr array size */
559         unsigned int        lq_prio_free;   /* priority for free space */
560         unsigned long       lq_dirty:1,     /* recalc qos data */
561                             lq_dirty_rr:1,  /* recalc round-robin list */
562                             lq_same_space:1,/* the ost's all have approx.
563                                                the same space avail */
564                             lq_reset:1;     /* zero current penalties */
565 };
566
567 struct lov_tgt_desc {
568         struct obd_uuid     ltd_uuid;
569         struct obd_export  *ltd_exp;
570         struct ltd_qos      ltd_qos;     /* qos info per target */
571         __u32               ltd_gen;
572         __u32               ltd_index;   /* index in lov_obd->tgts */
573         unsigned long       ltd_active:1,/* is this target up for requests */
574                             ltd_activate:1,/* should this target be activated */
575                             ltd_reap:1;  /* should this target be deleted */
576 };
577
578 struct lov_obd {
579         struct lov_desc         desc;
580         struct lov_tgt_desc   **lov_tgts;
581         struct semaphore        lov_lock;
582         struct obd_connect_data lov_ocd;
583         struct lov_qos          lov_qos;               /* qos info per lov */
584         atomic_t                lov_refcount;
585         __u32                   lov_tgt_count;         /* how many OBD's */
586         __u32                   lov_active_tgt_count;  /* how many active */
587         __u32                   lov_death_row;/* tgts scheduled to be deleted */
588         __u32                   lov_tgt_size;   /* size of tgts array */
589         __u32                   lov_start_idx;  /* start index of new inode */
590         __u32                   lov_offset_idx; /* aliasing for start_idx  */
591         int                     lov_start_count;/* reseed counter */
592         int                     lov_connects;
593         obd_page_removal_cb_t   lov_page_removal_cb;
594         obd_pin_extent_cb       lov_page_pin_cb;
595         obd_lock_cancel_cb      lov_lock_cancel_cb;
596 };
597
598 struct niobuf_local {
599         __u64 offset;
600         __u32 len;
601         __u32 flags;
602         cfs_page_t    *page;
603         cfs_dentry_t  *dentry;
604         int lnb_grant_used;
605         int rc;
606 };
607
608 /* obd device type names */
609  /* FIXME all the references to LUSTRE_MDS_NAME should be swapped with LUSTRE_MDT_NAME */
610 #define LUSTRE_MDS_NAME         "mds"
611 #define LUSTRE_MDT_NAME         "mdt"
612 #define LUSTRE_MDC_NAME         "mdc"
613 #define LUSTRE_OSS_NAME         "ost" /*FIXME change name to oss*/
614 #define LUSTRE_OST_NAME         "obdfilter" /* FIXME change name to ost*/
615 #define LUSTRE_OSC_NAME         "osc"
616 #define LUSTRE_LOV_NAME         "lov"
617 #define LUSTRE_MGS_NAME         "mgs"
618 #define LUSTRE_MGC_NAME         "mgc"
619
620 #define LUSTRE_CACHEOBD_NAME    "cobd"
621 #define LUSTRE_ECHO_NAME        "obdecho"
622 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
623
624 /* Constant obd names (post-rename) */
625 #define LUSTRE_MDS_OBDNAME "MDS"
626 #define LUSTRE_OSS_OBDNAME "OSS"
627 #define LUSTRE_MGS_OBDNAME "MGS"
628 #define LUSTRE_MGC_OBDNAME "MGC"
629
630 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
631 #define N_LOCAL_TEMP_PAGE 0x10000000
632
633 struct obd_trans_info {
634         __u64                    oti_transno;
635         __u64                    oti_xid;
636         /* Only used on the server side for tracking acks. */
637         struct oti_req_ack_lock {
638                 struct lustre_handle lock;
639                 __u32                mode;
640         }                        oti_ack_locks[4];
641         void                    *oti_handle;
642         struct llog_cookie       oti_onecookie;
643         struct llog_cookie      *oti_logcookies;
644         int                      oti_numcookies;
645
646         /* initial thread handling transaction */
647         int                      oti_thread_id;
648         __u32                    oti_conn_cnt;
649 };
650
651 static inline void oti_init(struct obd_trans_info *oti,
652                             struct ptlrpc_request *req)
653 {
654         if (oti == NULL)
655                 return;
656         memset(oti, 0, sizeof *oti);
657
658         if (req == NULL)
659                 return;
660
661         oti->oti_xid = req->rq_xid;
662
663         if ((req->rq_reqmsg != NULL) && (req->rq_repmsg != NULL))
664                 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
665         oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
666         oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
667 }
668
669 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
670 {
671         if (!oti)
672                 return;
673
674         if (num_cookies == 1)
675                 oti->oti_logcookies = &oti->oti_onecookie;
676         else
677                 OBD_ALLOC(oti->oti_logcookies,
678                           num_cookies * sizeof(oti->oti_onecookie));
679
680         oti->oti_numcookies = num_cookies;
681 }
682
683 static inline void oti_free_cookies(struct obd_trans_info *oti)
684 {
685         if (!oti || !oti->oti_logcookies)
686                 return;
687
688         if (oti->oti_logcookies == &oti->oti_onecookie)
689                 LASSERT(oti->oti_numcookies == 1);
690         else
691                 OBD_FREE(oti->oti_logcookies,
692                          oti->oti_numcookies * sizeof(oti->oti_onecookie));
693         oti->oti_logcookies = NULL;
694         oti->oti_numcookies = 0;
695 }
696
697 /* llog contexts */
698 enum llog_ctxt_id {
699         LLOG_CONFIG_ORIG_CTXT  =  0,
700         LLOG_CONFIG_REPL_CTXT  =  1,
701         LLOG_MDS_OST_ORIG_CTXT =  2,
702         LLOG_MDS_OST_REPL_CTXT =  3,
703         LLOG_SIZE_ORIG_CTXT    =  4,
704         LLOG_SIZE_REPL_CTXT    =  5,
705         LLOG_MD_ORIG_CTXT      =  6,
706         LLOG_MD_REPL_CTXT      =  7,
707         LLOG_RD1_ORIG_CTXT     =  8,
708         LLOG_RD1_REPL_CTXT     =  9,
709         LLOG_TEST_ORIG_CTXT    = 10,
710         LLOG_TEST_REPL_CTXT    = 11,
711         LLOG_LOVEA_ORIG_CTXT   = 12,
712         LLOG_LOVEA_REPL_CTXT   = 13,
713         LLOG_MAX_CTXTS
714 };
715
716 /*
717  * Events signalled through obd_notify() upcall-chain.
718  */
719 enum obd_notify_event {
720         /* Device activated */
721         OBD_NOTIFY_ACTIVE,
722         /* Device deactivated */
723         OBD_NOTIFY_INACTIVE,
724         /* Connect data for import were changed */
725         OBD_NOTIFY_OCD,
726         /* Sync request */
727         OBD_NOTIFY_SYNC_NONBLOCK,
728         OBD_NOTIFY_SYNC,
729         /* Configuration event */
730         OBD_NOTIFY_CONFIG
731 };
732
733 #define CONFIG_LOG  0x1  /* finished processing config log */
734 #define CONFIG_SYNC 0x2  /* mdt synced 1 ost */
735
736 /*
737  * Data structure used to pass obd_notify()-event to non-obd listeners (llite
738  * and liblustre being main examples).
739  */
740 struct obd_notify_upcall {
741         int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
742                           enum obd_notify_event ev, void *owner);
743         /* Opaque datum supplied by upper layer listener */
744         void *onu_owner;
745 };
746
747 /* corresponds to one of the obd's */
748 #define MAX_OBD_NAME 128
749 #define OBD_DEVICE_MAGIC        0XAB5CD6EF
750 struct obd_device {
751         struct obd_type        *obd_type;
752         __u32                   obd_magic;
753
754         /* common and UUID name of this device */
755         char                    obd_name[MAX_OBD_NAME];
756         struct obd_uuid         obd_uuid;
757
758         int                     obd_minor;
759         unsigned long obd_attached:1,      /* finished attach */
760                       obd_set_up:1,        /* finished setup */
761                       obd_recovering:1,    /* there are recoverable clients */
762                       obd_abort_recovery:1,/* somebody ioctl'ed us to abort */ 
763                       obd_replayable:1,    /* recovery is enabled; inform clients */
764                       obd_no_transno:1,    /* no committed-transno notification */
765                       obd_no_recov:1,      /* fail instead of retry messages */
766                       obd_stopping:1,      /* started cleanup */
767                       obd_starting:1,      /* started setup */
768                       obd_force:1,         /* cleanup with > 0 obd refcount */
769                       obd_fail:1,          /* cleanup with failover */
770                       obd_async_recov:1,   /* allow asyncronous orphan cleanup */
771                       obd_no_conn:1,       /* deny new connections */
772                       obd_inactive:1;      /* device active/inactive
773                                            * (for /proc/status only!!) */
774         /* uuid-export hash body */
775         struct lustre_class_hash_body *obd_uuid_hash_body;
776         /* nid-export hash body */
777         struct lustre_class_hash_body *obd_nid_hash_body;
778         /* nid stats body */
779         struct lustre_class_hash_body *obd_nid_stats_hash_body;
780         struct list_head        obd_nid_stats;
781         atomic_t                obd_refcount;
782         cfs_waitq_t             obd_refcount_waitq;
783         cfs_waitq_t             obd_llog_waitq;
784         struct list_head        obd_exports;
785         int                     obd_num_exports;
786         spinlock_t              nid_lock;
787         struct ldlm_namespace  *obd_namespace;
788         struct ptlrpc_client    obd_ldlm_client; /* XXX OST/MDS only */
789         /* a spinlock is OK for what we do now, may need a semaphore later */
790         spinlock_t              obd_dev_lock;
791         struct semaphore        obd_dev_sem;
792         __u64                   obd_last_committed;
793         struct fsfilt_operations *obd_fsops;
794         spinlock_t              obd_osfs_lock;
795         struct obd_statfs       obd_osfs;       /* locked by obd_osfs_lock */
796         __u64                   obd_osfs_age;   
797         struct lvfs_run_ctxt    obd_lvfs_ctxt;
798         struct llog_ctxt        *obd_llog_ctxt[LLOG_MAX_CTXTS];
799         struct obd_device       *obd_observer;
800         struct obd_notify_upcall obd_upcall;
801         struct obd_export       *obd_self_export;
802         /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
803         struct list_head        obd_exports_timed;
804         time_t                  obd_eviction_timer; /* for ping evictor */
805
806         /* XXX encapsulate all this recovery data into one struct */
807         svc_handler_t                    obd_recovery_handler;
808         int                              obd_max_recoverable_clients;
809         int                              obd_connected_clients;
810         int                              obd_recoverable_clients;
811         spinlock_t                       obd_processing_task_lock; /* BH lock (timer) */
812         pid_t                            obd_processing_task;
813         __u64                            obd_next_recovery_transno;
814         int                              obd_replayed_requests;
815         int                              obd_requests_queued_for_recovery;
816         cfs_waitq_t                      obd_next_transno_waitq;
817         struct list_head                 obd_uncommitted_replies;
818         spinlock_t                       obd_uncommitted_replies_lock;
819         cfs_timer_t                      obd_recovery_timer;
820         struct list_head                 obd_recovery_queue;
821         struct list_head                 obd_delayed_reply_queue;
822         time_t                           obd_recovery_start; /* seconds */
823         time_t                           obd_recovery_end; /* seconds, for lprocfs_status */
824 #ifdef CRAY_XT3
825         time_t                           obd_recovery_max_time; /* seconds, bz13079 */
826 #endif
827         int                              obd_recovery_timeout;
828
829         union {
830                 struct obd_device_target obt;
831                 struct filter_obd filter;
832                 struct mds_obd mds;
833                 struct client_obd cli;
834                 struct ost_obd ost;
835                 struct echo_client_obd echo_client;
836                 struct echo_obd echo;
837                 struct lov_obd lov;
838                 struct mgs_obd mgs;
839         } u;
840         /* Fields used by LProcFS */
841         cfs_proc_dir_entry_t  *obd_proc_entry;
842         cfs_proc_dir_entry_t  *obd_proc_exports_entry;
843         cfs_proc_dir_entry_t  *obd_svc_procroot;
844         struct lprocfs_stats  *obd_stats;
845         struct lprocfs_stats  *obd_svc_stats;
846         unsigned int           obd_cntr_base;
847         atomic_t               obd_evict_inprogress;
848         cfs_waitq_t            obd_evict_inprogress_waitq;
849 };
850
851 #define OBD_OPT_FORCE           0x0001
852 #define OBD_OPT_FAILOVER        0x0002
853
854 #define OBD_LLOG_FL_SENDNOW     0x0001
855
856 enum obd_cleanup_stage {
857 /* Special case hack for MDS LOVs */
858         OBD_CLEANUP_EARLY,
859 /* Precleanup stage 1, we must make sure all exports (other than the
860    self-export) get destroyed. */
861         OBD_CLEANUP_EXPORTS,
862 /* Precleanup stage 2,  do other type-specific cleanup requiring the
863    self-export. */
864         OBD_CLEANUP_SELF_EXP,
865 /* FIXME we should eliminate the "precleanup" function and make them stages
866    of the "cleanup" function. */
867         OBD_CLEANUP_OBD,
868 };
869
870 /* get/set_info keys */
871 #define KEY_MDS_CONN "mds_conn"
872 #define KEY_NEXT_ID  "next_id"
873 #define KEY_LOVDESC  "lovdesc"
874 #define KEY_INIT_RECOV "initial_recov"
875 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"
876 #define KEY_LOV_IDX             "lov_idx"
877 #define KEY_LAST_ID             "last_id"
878
879 struct obd_ops {
880         struct module *o_owner;
881         int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
882                            void *karg, void *uarg);
883         int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
884                           __u32 *vallen, void *val);
885         int (*o_set_info_async)(struct obd_export *, __u32 keylen, void *key,
886                                 __u32 vallen, void *val,
887                                 struct ptlrpc_request_set *set);
888         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
889         int (*o_detach)(struct obd_device *dev);
890         int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
891         int (*o_precleanup)(struct obd_device *dev,
892                             enum obd_cleanup_stage cleanup_stage);
893         int (*o_cleanup)(struct obd_device *dev);
894         int (*o_process_config)(struct obd_device *dev, obd_count len,
895                                 void *data);
896         int (*o_postrecov)(struct obd_device *dev);
897         int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
898                           int priority);
899         int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
900         /* connect to the target device with given connection
901          * data. @ocd->ocd_connect_flags is modified to reflect flags actually
902          * granted by the target, which are guaranteed to be a subset of flags
903          * asked for. If @ocd == NULL, use default parameters. */
904         int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
905                          struct obd_uuid *cluuid, struct obd_connect_data *ocd,
906                          void *localdata);
907         int (*o_reconnect)(struct obd_export *exp, struct obd_device *src,
908                            struct obd_uuid *cluuid,
909                            struct obd_connect_data *ocd);
910         int (*o_disconnect)(struct obd_export *exp);
911
912         int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
913                         __u64 max_age);
914         int (*o_statfs_async)(struct obd_device *obd, struct obd_info *oinfo,
915                               __u64 max_age, struct ptlrpc_request_set *set);
916         int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
917                         struct lov_stripe_md *mem_src);
918         int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
919                           struct lov_mds_md *disk_src, int disk_len);
920         int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
921                          struct lov_stripe_md *mem_tgt);
922         int (*o_preallocate)(struct lustre_handle *, obd_count *req,
923                              obd_id *ids);
924         int (*o_precreate)(struct obd_export *exp, int need_create);
925         int (*o_create)(struct obd_export *exp,  struct obdo *oa,
926                         struct lov_stripe_md **ea, struct obd_trans_info *oti);
927         int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
928                          struct lov_stripe_md *ea, struct obd_trans_info *oti,
929                          struct obd_export *md_exp);
930         int (*o_setattr)(struct obd_export *exp, struct obd_info *oinfo,
931                          struct obd_trans_info *oti);
932         int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
933                                struct obd_trans_info *oti,
934                                struct ptlrpc_request_set *rqset);
935         int (*o_getattr)(struct obd_export *exp, struct obd_info *oinfo);
936         int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
937                                struct ptlrpc_request_set *set);
938         int (*o_brw)(int rw, struct obd_export *exp, struct obd_info *oinfo,
939                      obd_count oa_bufs, struct brw_page *pgarr,
940                      struct obd_trans_info *oti);
941         int (*o_brw_async)(int rw, struct obd_export *exp,
942                            struct obd_info *oinfo, obd_count oa_bufs,
943                            struct brw_page *pgarr, struct obd_trans_info *oti,
944                            struct ptlrpc_request_set *);
945         int (*o_prep_async_page)(struct obd_export *exp,
946                                  struct lov_stripe_md *lsm,
947                                  struct lov_oinfo *loi,
948                                  cfs_page_t *page, obd_off offset, 
949                                  struct obd_async_page_ops *ops, void *data,
950                                  void **res, int nocache,
951                                  struct lustre_handle *lockh);
952         int (*o_queue_async_io)(struct obd_export *exp,
953                                 struct lov_stripe_md *lsm,
954                                 struct lov_oinfo *loi, void *cookie,
955                                 int cmd, obd_off off, int count,
956                                 obd_flag brw_flags, obd_flag async_flags);
957         int (*o_queue_group_io)(struct obd_export *exp,
958                                 struct lov_stripe_md *lsm,
959                                 struct lov_oinfo *loi,
960                                 struct obd_io_group *oig,
961                                 void *cookie, int cmd, obd_off off, int count,
962                                 obd_flag brw_flags, obd_flag async_flags);
963         int (*o_trigger_group_io)(struct obd_export *exp,
964                                   struct lov_stripe_md *lsm,
965                                   struct lov_oinfo *loi,
966                                   struct obd_io_group *oig);
967         int (*o_set_async_flags)(struct obd_export *exp,
968                                 struct lov_stripe_md *lsm,
969                                 struct lov_oinfo *loi, void *cookie,
970                                 obd_flag async_flags);
971         int (*o_teardown_async_page)(struct obd_export *exp,
972                                      struct lov_stripe_md *lsm,
973                                      struct lov_oinfo *loi, void *cookie);
974         int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
975                            struct ost_lvb *lvb, int kms_only);
976         int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
977                             obd_off size, int shrink);
978         int (*o_punch)(struct obd_export *exp, struct obd_info *oinfo,
979                        struct obd_trans_info *oti,
980                        struct ptlrpc_request_set *rqset);
981         int (*o_sync)(struct obd_export *exp, struct obdo *oa,
982                       struct lov_stripe_md *ea, obd_size start, obd_size end);
983         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
984                          struct lov_stripe_md *src, obd_size start,
985                          obd_size end, struct obd_trans_info *oti);
986         int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
987                       struct lustre_handle *srconn, struct lov_stripe_md *src,
988                       obd_size start, obd_size end, struct obd_trans_info *);
989         int (*o_iterate)(struct lustre_handle *conn,
990                          int (*)(obd_id, obd_gr, void *),
991                          obd_id *startid, obd_gr group, void *data);
992         int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
993                         int objcount, struct obd_ioobj *obj,
994                         int niocount, struct niobuf_remote *remote,
995                         struct niobuf_local *local, struct obd_trans_info *oti);
996         int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
997                           int objcount, struct obd_ioobj *obj,
998                           int niocount, struct niobuf_local *local,
999                           struct obd_trans_info *oti, int rc);
1000         int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo,
1001                          struct ldlm_enqueue_info *einfo,
1002                          struct ptlrpc_request_set *rqset);
1003         int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
1004                        ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
1005                        struct lustre_handle *lockh);
1006         int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
1007                                ldlm_iterator_t it, void *data);
1008         int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
1009                         __u32 mode, struct lustre_handle *);
1010         int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
1011                                int flags, void *opaque);
1012         int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
1013                          int join);
1014         int (*o_init_export)(struct obd_export *exp);
1015         int (*o_destroy_export)(struct obd_export *exp);
1016         int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *,
1017                              int cmd, obd_off *);
1018
1019         /* llog related obd_methods */
1020         int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
1021                            int count, struct llog_catid *logid, 
1022                            struct obd_uuid *uuid);
1023         int (*o_llog_finish)(struct obd_device *obd, int count);
1024
1025         /* metadata-only methods */
1026         int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
1027                      struct obd_client_handle *, int flag);
1028         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
1029
1030         int (*o_import_event)(struct obd_device *, struct obd_import *,
1031                               enum obd_import_event);
1032
1033         int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
1034                         enum obd_notify_event ev, void *data);
1035
1036         int (*o_health_check)(struct obd_device *);
1037
1038         /* quota methods */
1039         int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
1040         int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
1041         int (*o_quota_adjust_qunit)(struct obd_export *exp,
1042                                     struct quota_adjust_qunit *oqaq);
1043
1044
1045         int (*o_ping)(struct obd_export *exp);
1046
1047         int (*o_register_page_removal_cb)(struct obd_export *exp,
1048                                           obd_page_removal_cb_t cb,
1049                                           obd_pin_extent_cb pin_cb);
1050         int (*o_unregister_page_removal_cb)(struct obd_export *exp,
1051                                             obd_page_removal_cb_t cb);
1052         int (*o_register_lock_cancel_cb)(struct obd_export *exp,
1053                                        obd_lock_cancel_cb cb);
1054         int (*o_unregister_lock_cancel_cb)(struct obd_export *exp,
1055                                          obd_lock_cancel_cb cb);
1056         
1057         /*
1058          * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
1059          * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
1060          * Also, add a wrapper function in include/linux/obd_class.h. */
1061 };
1062
1063 struct lsm_operations {
1064         void (*lsm_free)(struct lov_stripe_md *);
1065         int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
1066                            struct obd_export *md_exp);
1067         void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
1068                                      unsigned long *);
1069         void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
1070                                      unsigned long *);
1071         obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
1072         obd_off (*lsm_stripe_offset_by_offset)(struct lov_stripe_md *, obd_off);
1073         int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
1074         int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
1075         int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
1076                                int *stripe_count);
1077         int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
1078                              struct lov_mds_md *lmm);
1079 };
1080
1081 extern struct lsm_operations lsm_plain_ops;
1082 extern struct lsm_operations lsm_join_ops;
1083 static inline struct lsm_operations *lsm_op_find(int magic)
1084 {
1085         switch(magic) {
1086         case LOV_MAGIC:
1087                return &lsm_plain_ops;
1088         case LOV_MAGIC_JOIN:
1089                return &lsm_join_ops;
1090         default:
1091                CERROR("Cannot recognize lsm_magic %d", magic);
1092                return NULL;
1093         }
1094 }
1095
1096 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
1097
1098 /* Requests for obd_extent_calc() */
1099 #define OBD_CALC_STRIPE_START   1
1100 #define OBD_CALC_STRIPE_END     2
1101
1102 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
1103                                          int error)
1104 {
1105         if (error) {
1106                 CERROR("%s: transno "LPD64" commit error: %d\n",
1107                        obd->obd_name, transno, error);
1108                 return;
1109         }
1110         CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
1111                obd->obd_name, transno);
1112         if (transno > obd->obd_last_committed) {
1113                 obd->obd_last_committed = transno;
1114                 ptlrpc_commit_replies (obd);
1115         }
1116 }
1117
1118 static inline void init_obd_quota_ops(quota_interface_t *interface,
1119                                       struct obd_ops *obd_ops)
1120 {
1121         if (!interface)
1122                 return;
1123
1124         LASSERT(obd_ops);
1125         obd_ops->o_quotacheck = QUOTA_OP(interface, check);
1126         obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
1127         obd_ops->o_quota_adjust_qunit = QUOTA_OP(interface, adjust_qunit);
1128 }
1129
1130 #endif /* __OBD_H */