Whamcloud - gitweb
pass lu_context to ->o_connect() method
[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_device *)
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/lustre_idl.h>
31 #include <lu_object.h>
32 #include <lustre_lib.h>
33 #include <lustre_export.h>
34 #include <lustre_quota.h>
35 #include <lustre_fld.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 osc_async_rc {
46         int     ar_rc;
47         int     ar_force_sync;
48         int     ar_min_xid;
49 };
50
51 struct lov_oinfo {                 /* per-stripe data structure */
52         __u64 loi_id;              /* object ID on the target OST */
53         __u64 loi_gr;              /* object group on the target OST */
54         int loi_ost_idx;           /* OST stripe index in lov_tgt_desc->tgts */
55         int loi_ost_gen;           /* generation of this loi_ost_idx */
56
57         /* used by the osc to keep track of what objects to build into rpcs */
58         struct loi_oap_pages loi_read_lop;
59         struct loi_oap_pages loi_write_lop;
60         /* _cli_ is poorly named, it should be _ready_ */
61         struct list_head loi_cli_item;
62         struct list_head loi_write_item;
63         struct list_head loi_read_item;
64
65         unsigned loi_kms_valid:1;
66         __u64 loi_kms;             /* known minimum size */
67         struct ost_lvb loi_lvb;
68         struct osc_async_rc     loi_ar;
69 };
70
71 static inline void loi_init(struct lov_oinfo *loi)
72 {
73         CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
74         CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
75         CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
76         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
77         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
78         CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
79         CFS_INIT_LIST_HEAD(&loi->loi_cli_item);
80         CFS_INIT_LIST_HEAD(&loi->loi_write_item);
81         CFS_INIT_LIST_HEAD(&loi->loi_read_item);
82 }
83
84 /*extent array item for describing the joined file extent info*/
85 struct lov_extent {
86         __u64 le_start;            /* extent start */
87         __u64 le_len;              /* extent length */
88         int   le_loi_idx;          /* extent #1 loi's index in lsm loi array */
89         int   le_stripe_count;     /* extent stripe count*/
90 };
91
92 /*Lov array info for describing joined file array EA info*/
93 struct lov_array_info {
94         struct llog_logid    lai_array_id;    /* MDS med llog object id */
95         unsigned             lai_ext_count; /* number of extent count */
96         struct lov_extent    *lai_ext_array; /* extent desc array */
97 };
98
99 struct lov_stripe_md {
100         spinlock_t       lsm_lock;
101         void            *lsm_lock_owner; /* debugging */
102
103         struct {
104                 /* Public members. */
105                 __u64 lw_object_id;        /* lov object id */
106                 __u64 lw_object_gr;        /* lov object group */
107                 __u64 lw_maxbytes;         /* maximum possible file size */
108                 unsigned long lw_xfersize; /* optimal transfer size */
109
110                 /* LOV-private members start here -- only for use in lov/. */
111                 __u32 lw_magic;
112                 __u32 lw_stripe_size;      /* size of the stripe */
113                 __u32 lw_pattern;          /* striping pattern (RAID0, RAID1) */
114                 unsigned lw_stripe_count;  /* number of objects being striped over */
115         } lsm_wire;
116
117         struct lov_array_info *lsm_array; /*Only for joined file array info*/
118         struct lov_oinfo lsm_oinfo[0];
119 };
120
121 #define lsm_object_id    lsm_wire.lw_object_id
122 #define lsm_object_gr    lsm_wire.lw_object_gr
123 #define lsm_maxbytes     lsm_wire.lw_maxbytes
124 #define lsm_xfersize     lsm_wire.lw_xfersize
125 #define lsm_magic        lsm_wire.lw_magic
126 #define lsm_stripe_size  lsm_wire.lw_stripe_size
127 #define lsm_pattern      lsm_wire.lw_pattern
128 #define lsm_stripe_count lsm_wire.lw_stripe_count
129
130 /* compare all relevant fields. */
131 static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
132                                     struct lov_stripe_md *m2)
133 {
134         /*
135          * ->lsm_wire contains padding, but it should be zeroed out during
136          * allocation.
137          */
138         return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof m1->lsm_wire);
139 }
140
141 void lov_stripe_lock(struct lov_stripe_md *md);
142 void lov_stripe_unlock(struct lov_stripe_md *md);
143
144 struct obd_type {
145         struct list_head typ_chain;
146         struct obd_ops *typ_dt_ops;
147         struct md_ops *typ_md_ops;
148         struct proc_dir_entry *typ_procroot;
149         char *typ_name;
150         int  typ_refcnt;
151         struct lu_device_type *typ_lu;
152 };
153
154 struct brw_page {
155         obd_off  off;
156         cfs_page_t *pg;
157         int count;
158         obd_flag flag;
159 };
160
161 enum async_flags {
162         ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
163                               page is added to an rpc */
164         ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
165         ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
166                                      to give the caller a chance to update
167                                      or cancel the size of the io */
168         ASYNC_GROUP_SYNC = 0x8,  /* ap_completion will not be called, instead
169                                     the page is accounted for in the
170                                     obd_io_group given to
171                                     obd_queue_group_io */
172 };
173
174 struct obd_async_page_ops {
175         int  (*ap_make_ready)(void *data, int cmd);
176         int  (*ap_refresh_count)(void *data, int cmd);
177         void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
178         void (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
179 };
180
181 /* the `oig' is passed down from a caller of obd rw methods.  the callee
182  * records enough state such that the caller can sleep on the oig and
183  * be woken when all the callees have finished their work */
184 struct obd_io_group {
185         spinlock_t      oig_lock;
186         atomic_t        oig_refcount;
187         int             oig_pending;
188         int             oig_rc;
189         struct list_head oig_occ_list;
190         cfs_waitq_t     oig_waitq;
191 };
192
193 /* the oig callback context lets the callee of obd rw methods register
194  * for callbacks from the caller. */
195 struct oig_callback_context {
196         struct list_head occ_oig_item;
197         /* called when the caller has received a signal while sleeping.
198          * callees of this method are encouraged to abort their state
199          * in the oig.  This may be called multiple times. */
200         void (*occ_interrupted)(struct oig_callback_context *occ);
201         unsigned int interrupted:1;
202 };
203
204 /* if we find more consumers this could be generalized */
205 #define OBD_HIST_MAX 32
206 struct obd_histogram {
207         spinlock_t      oh_lock;
208         unsigned long   oh_buckets[OBD_HIST_MAX];
209 };
210
211 /* Individual type definitions */
212
213 struct ost_server_data;
214
215 /* hold common fields for "target" device */
216 struct obd_device_target {
217         struct super_block       *obt_sb;
218         atomic_t                  obt_quotachecking;
219         struct lustre_quota_ctxt  obt_qctxt;
220 };
221
222 #define FILTER_GROUP_LLOG 1
223 #define FILTER_GROUP_ECHO 2
224
225 struct filter_ext {
226         __u64                fe_start;
227         __u64                fe_end;
228 };
229
230 struct filter_obd {
231         /* NB this field MUST be first */
232         struct obd_device_target fo_obt;
233         const char          *fo_fstype;
234         struct vfsmount     *fo_vfsmnt;
235         cfs_dentry_t        *fo_dentry_O;
236         cfs_dentry_t       **fo_dentry_O_groups;
237         cfs_dentry_t       **fo_dentry_O_sub;
238         spinlock_t           fo_objidlock;      /* protect fo_lastobjid */
239         spinlock_t           fo_translock;      /* protect fsd_last_transno */
240         struct file         *fo_rcvd_filp;
241         struct file         *fo_health_check_filp;
242         struct lr_server_data *fo_fsd;
243         unsigned long       *fo_last_rcvd_slots;
244         __u64                fo_mount_count;
245
246         int                  fo_destroy_in_progress;
247         struct semaphore     fo_create_lock;
248
249         struct list_head     fo_export_list;
250         int                  fo_subdir_count;
251
252         obd_size             fo_tot_dirty;      /* protected by obd_osfs_lock */
253         obd_size             fo_tot_granted;    /* all values in bytes */
254         obd_size             fo_tot_pending;
255
256         obd_size             fo_readcache_max_filesize;
257
258         struct obd_import   *fo_mdc_imp;
259         struct obd_uuid      fo_mdc_uuid;
260         struct lustre_handle fo_mdc_conn;
261         struct file        **fo_last_objid_files;
262         __u64               *fo_last_objids; /* last created objid for groups,
263                                               * protected by fo_objidlock */
264
265         struct semaphore     fo_alloc_lock;
266
267         spinlock_t fo_stats_lock;
268         int fo_r_in_flight; /* protected by fo_stats_lock */
269         int fo_w_in_flight; /* protected by fo_stats_lock */
270
271         /*
272          * per-filter pool of kiobuf's allocated by filter_common_setup() and
273          * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
274          * which ->fo_iobuf_count were allocated.
275          *
276          * This pool contains kiobuf used by
277          * filter_{prep,commit}rw_{read,write}() and is shared by all OST
278          * threads.
279          *
280          * Locking: none, each OST thread uses only one element, determined by
281          * its "ordinal number", ->t_id.
282          */
283         struct filter_iobuf    **fo_iobuf_pool;
284         int                      fo_iobuf_count;
285
286         struct obd_histogram     fo_r_pages;
287         struct obd_histogram     fo_w_pages;
288         struct obd_histogram     fo_read_rpc_hist;
289         struct obd_histogram     fo_write_rpc_hist;
290         struct obd_histogram     fo_r_io_time;
291         struct obd_histogram     fo_w_io_time;
292         struct obd_histogram     fo_r_discont_pages;
293         struct obd_histogram     fo_w_discont_pages;
294         struct obd_histogram     fo_r_discont_blocks;
295         struct obd_histogram     fo_w_discont_blocks;
296         struct obd_histogram     fo_r_disk_iosize;
297         struct obd_histogram     fo_w_disk_iosize;
298
299         struct lustre_quota_ctxt fo_quota_ctxt;
300         spinlock_t               fo_quotacheck_lock;
301         atomic_t                 fo_quotachecking;
302 };
303
304 #define OSC_MAX_RIF_DEFAULT       8
305 #define OSC_MAX_RIF_MAX         256
306 #define OSC_MAX_DIRTY_DEFAULT  (OSC_MAX_RIF_DEFAULT * 4)
307 #define OSC_MAX_DIRTY_MB_MAX   2048     /* totally arbitrary */
308
309 struct mdc_rpc_lock;
310 struct obd_import;
311 struct client_obd {
312         struct semaphore         cl_sem;
313         struct obd_uuid          cl_target_uuid;
314         struct obd_import       *cl_import; /* ptlrpc connection state */
315         int                      cl_conn_count;
316         /* max_mds_easize is purely a performance thing so we don't have to
317          * call obd_size_diskmd() all the time. */
318         int                      cl_default_mds_easize;
319         int                      cl_max_mds_easize;
320         int                      cl_max_mds_cookiesize;
321         kdev_t                   cl_sandev;
322
323         //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
324         void                    *cl_llcd_offset;
325
326         /* the grant values are protected by loi_list_lock below */
327         long                     cl_dirty;         /* all _dirty_ in bytes */
328         long                     cl_dirty_max;     /* allowed w/o rpc */
329         long                     cl_avail_grant;   /* bytes of credit for ost */
330         long                     cl_lost_grant;    /* lost credits (trunc) */
331         struct list_head         cl_cache_waiters; /* waiting for cache/grant */
332
333         /* keep track of objects that have lois that contain pages which
334          * have been queued for async brw.  this lock also protects the
335          * lists of osc_client_pages that hang off of the loi */
336         /*
337          * ->cl_loi_list_lock protects consistency of
338          * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
339          * ->ap_completion() call-backs are executed under this lock. As we
340          * cannot guarantee that these call-backs never block on all platforms
341          * (as a matter of fact they do block on Mac OS X), type of
342          * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
343          * and blocking mutex on Mac OS X. (Alternative is to make this lock
344          * blocking everywhere, but we don't want to slow down fast-path of
345          * our main platform.)
346          *
347          * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
348          * with client_obd_list_{un,}lock() and
349          * client_obd_list_lock_{init,done}() functions.
350          */
351         client_obd_lock_t        cl_loi_list_lock;
352         struct list_head         cl_loi_ready_list;
353         struct list_head         cl_loi_write_list;
354         struct list_head         cl_loi_read_list;
355         int                      cl_r_in_flight;
356         int                      cl_w_in_flight;
357         /* just a sum of the loi/lop pending numbers to be exported by /proc */
358         int                      cl_pending_w_pages;
359         int                      cl_pending_r_pages;
360         int                      cl_max_pages_per_rpc;
361         int                      cl_max_rpcs_in_flight;
362         struct obd_histogram     cl_read_rpc_hist;
363         struct obd_histogram     cl_write_rpc_hist;
364         struct obd_histogram     cl_read_page_hist;
365         struct obd_histogram     cl_write_page_hist;
366         struct obd_histogram     cl_read_offset_hist;
367         struct obd_histogram     cl_write_offset_hist;
368
369         struct mdc_rpc_lock     *cl_rpc_lock;
370         struct mdc_rpc_lock     *cl_setattr_lock;
371         struct osc_creator       cl_oscc;
372
373         /* mgc datastruct */
374         struct semaphore         cl_mgc_sem;
375         struct vfsmount         *cl_mgc_vfsmnt;
376         struct dentry           *cl_mgc_configs_dir;
377         atomic_t                 cl_mgc_refcount;
378         struct obd_export       *cl_mgc_mgsexp;
379
380         /* Flags section */
381         unsigned int             cl_checksum:1; /* debug checksums */
382
383         /* also protected by the poorly named _loi_list_lock lock above */
384         struct osc_async_rc      cl_ar;
385
386         /* used by quotacheck */
387         int                      cl_qchk_stat; /* quotacheck stat of the peer */
388
389         /* sequence manager */
390         struct lu_client_seq    *cl_seq;
391 };
392 #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
393
394 #define CL_NOT_QUOTACHECKED 1   /* client->cl_qchk_stat init value */
395
396 struct mgs_obd {
397         struct ptlrpc_service           *mgs_service;
398         struct vfsmount                 *mgs_vfsmnt;
399         struct super_block              *mgs_sb;
400         struct dentry                   *mgs_configs_dir;
401         struct dentry                   *mgs_fid_de;
402         struct list_head                 mgs_fs_db_list;
403         struct semaphore                 mgs_sem;
404 };
405
406 struct md_lov_info;
407
408 struct md_lov_ops {
409         int (*ml_read_objids)(struct obd_device *obd, struct md_lov_info *mli,
410                               const void *ctxt);
411         int (*ml_write_objids)(struct obd_device *obd, struct md_lov_info *mli,
412                                const void *ctxt);
413 };
414 struct md_lov_info {
415         struct obd_device               *md_lov_obd; /* XXX lov_obd */
416         struct obd_uuid                  md_lov_uuid;
417         struct obd_export               *md_lov_exp; /* XXX lov_exp */
418         struct lov_desc                  md_lov_desc;
419         obd_id                          *md_lov_objids;
420         int                              md_lov_objids_size;
421         __u32                            md_lov_objids_in_file;
422         unsigned int                     md_lov_objids_dirty:1;
423         int                              md_lov_nextid_set;
424         void                            *md_lov_objid_obj;
425         struct lu_fid                    md_lov_objid_fid;
426         unsigned long                    md_lov_objids_valid:1;
427         int                              md_lov_max_mdsize;
428         int                              md_lov_max_cookiesize;
429         struct semaphore                 md_lov_orphan_recovery_sem;
430         struct md_lov_ops                *md_lov_ops;
431 };
432
433 #define mds_osc_obd             mds_lov_info.md_lov_obd
434 #define mds_lov_uuid            mds_lov_info.md_lov_uuid
435 #define mds_osc_exp             mds_lov_info.md_lov_exp
436 #define mds_lov_desc            mds_lov_info.md_lov_desc
437 #define mds_lov_objids          mds_lov_info.md_lov_objids
438 #define mds_lov_objids_size     mds_lov_info.md_lov_objids_size
439 #define mds_lov_objids_in_file  mds_lov_info.md_lov_objids_in_file
440 #define mds_lov_objids_dirty    mds_lov_info.md_lov_objids_dirty
441 #define mds_lov_nextid_set      mds_lov_info.md_lov_nextid_set
442 #define mds_lov_objid_filp      mds_lov_info.md_lov_objid_obj
443 #define mds_lov_objids_valid    mds_lov_info.md_lov_objids_valid
444 #define mds_max_mdsize          mds_lov_info.md_lov_max_mdsize
445 #define mds_max_cookiesize      mds_lov_info.md_lov_max_cookiesize
446 #define mds_orphan_recovery_sem mds_lov_info.md_lov_orphan_recovery_sem
447
448 struct mds_obd {
449         /* NB this field MUST be first */
450         struct obd_device_target         mds_obt;
451         struct ptlrpc_service           *mds_service;
452         struct ptlrpc_service           *mds_setattr_service;
453         struct ptlrpc_service           *mds_readpage_service;
454         struct vfsmount                 *mds_vfsmnt;
455         cfs_dentry_t                    *mds_fid_de;
456         struct file                     *mds_rcvd_filp;
457         spinlock_t                       mds_transno_lock;
458         __u64                            mds_last_transno;
459         __u64                            mds_mount_count;
460         __u64                            mds_io_epoch;
461         unsigned long                    mds_atime_diff;
462         struct semaphore                 mds_epoch_sem;
463         struct ll_fid                    mds_rootfid;
464         struct lr_server_data           *mds_server_data;
465         cfs_dentry_t                    *mds_pending_dir;
466         cfs_dentry_t                    *mds_logs_dir;
467         cfs_dentry_t                    *mds_objects_dir;
468         struct llog_handle              *mds_cfg_llh;
469 //        struct llog_handle              *mds_catalog;
470         struct md_lov_info              mds_lov_info;
471         char                            *mds_profile;
472         struct file                     *mds_health_check_filp;
473         unsigned long                   *mds_client_bitmap;
474         struct upcall_cache             *mds_group_hash;
475
476         struct lustre_quota_info         mds_quota_info;
477         struct semaphore                 mds_qonoff_sem;
478         struct semaphore                 mds_health_sem;
479         unsigned long                    mds_fl_user_xattr:1,
480                                          mds_fl_acl:1;
481 };
482
483 struct echo_obd {
484         struct obdo          eo_oa;
485         spinlock_t           eo_lock;
486         __u64                eo_lastino;
487         struct lustre_handle eo_nl_lock;
488         atomic_t             eo_prep;
489 };
490
491 struct ost_obd {
492         struct ptlrpc_service *ost_service;
493         struct ptlrpc_service *ost_create_service;
494         struct ptlrpc_service *ost_io_service;
495         struct semaphore       ost_health_sem;
496 };
497
498 struct echo_client_obd {
499         struct obd_export   *ec_exp;   /* the local connection to osc/lov */
500         spinlock_t           ec_lock;
501         struct list_head     ec_objects;
502         int                  ec_nstripes;
503         __u64                ec_unique;
504 };
505
506 struct lov_tgt_desc {
507         struct obd_uuid          uuid;
508         __u32                    ltd_gen;
509         struct obd_export       *ltd_exp;
510         unsigned int             active:1, /* is this target up for requests */
511                                  reap:1;   /* should this target be deleted */
512         int                      index;  /* index of target array in lov_obd */
513         struct list_head         qos_bavail_list; /* link entry to lov_obd */
514 };
515
516 struct lov_obd {
517         struct semaphore lov_lock;
518         atomic_t refcount;
519         struct lov_desc desc;
520         struct obd_connect_data ocd;
521         int bufsize;
522         int connects;
523         int death_row;      /* Do we have tgts scheduled to be deleted?
524                                (Make this a linked list?) */
525         struct list_head qos_bavail_list; /* tgts list, sorted by available
526                                              space, protected by lov_lock */
527         struct lov_tgt_desc *tgts;
528 };
529
530 struct lmv_tgt_desc {
531         struct obd_uuid         uuid;
532         struct obd_export       *ltd_exp;
533         int                     active;   /* is this target up for requests */
534         int                     idx;
535 };
536
537 struct lmv_obd {
538         int                     refcount;
539         struct lu_client_fld    lmv_fld;
540         spinlock_t              lmv_lock;
541         struct lmv_desc         desc;
542         struct obd_uuid         cluuid;
543         struct obd_export       *exp;
544
545         int                     connected;
546         int                     max_easize;
547         int                     max_def_easize;
548         int                     max_cookiesize;
549         int                     server_timeout;
550         struct semaphore        init_sem;
551
552         struct lmv_tgt_desc     *tgts;
553         int                     tgts_size;
554
555         struct obd_connect_data *datas;
556         int                     datas_size;
557
558         struct obd_connect_data conn_data;
559 };
560
561 struct niobuf_local {
562         __u64 offset;
563         __u32 len;
564         __u32 flags;
565         cfs_page_t    *page;
566         cfs_dentry_t  *dentry;
567         int lnb_grant_used;
568         int rc;
569 };
570
571 #define LUSTRE_OPC_MKDIR     (1 << 0)
572 #define LUSTRE_OPC_SYMLINK   (1 << 1)
573 #define LUSTRE_OPC_MKNOD     (1 << 2)
574 #define LUSTRE_OPC_CREATE    (1 << 3)
575
576 struct lu_placement_hint {
577         struct qstr *ph_pname;
578         struct qstr *ph_cname;
579         int          ph_opc;
580 };
581
582 #define LUSTRE_FLD_NAME  "fld"
583 #define LUSTRE_SEQ_NAME  "seq"
584
585 /* device types (not names--FIXME) */
586 /* FIXME all the references to these defines need to be updated */
587 #define LUSTRE_MDS_NAME  "mds"
588 #define LUSTRE_MDT_NAME  "mdt"
589
590 /* new MDS layers. Prototype */
591 #define LUSTRE_MDT0_NAME "mdt0"
592 #define LUSTRE_CMM0_NAME "cmm0"
593 #define LUSTRE_MDD0_NAME "mdd0"
594 #define LUSTRE_OSD0_NAME "osd0"
595 #define LUSTRE_MDC0_NAME "mdc0"
596
597 #define LUSTRE_MDC_NAME  "mdc"
598 #define LUSTRE_LOV_NAME  "lov"
599 #define LUSTRE_LMV_NAME  "lmv"
600
601 /* FIXME just the names need to be changed */
602 #define LUSTRE_OSS_NAME "ost"       /* FIXME oss */
603 #define LUSTRE_OST_NAME "obdfilter" /* FIXME ost */
604 #define LUSTRE_OSTSAN_NAME "sanobdfilter"
605
606 #define LUSTRE_OSC_NAME "osc"
607 #define LUSTRE_FILTER_NAME "filter"
608 #define LUSTRE_SANOSC_NAME "sanosc"
609 #define LUSTRE_SANOST_NAME "sanost"
610 #define LUSTRE_MGS_NAME "mgs"
611 #define LUSTRE_MGC_NAME "mgc"
612
613 #define LUSTRE_ECHO_NAME        "obdecho"
614 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
615
616 #define LUSTRE_MGS_OBDNAME "MGS"
617 #define LUSTRE_MGC_OBDNAME "MGC"
618
619 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
620 #define N_LOCAL_TEMP_PAGE 0x10000000
621
622 struct obd_trans_info {
623         __u64                    oti_transno;
624         __u64                   *oti_objid;
625         /* Only used on the server side for tracking acks. */
626         struct oti_req_ack_lock {
627                 struct lustre_handle lock;
628                 __u32                mode;
629         }                        oti_ack_locks[4];
630         void                    *oti_handle;
631         struct llog_cookie       oti_onecookie;
632         struct llog_cookie      *oti_logcookies;
633         int                      oti_numcookies;
634
635         /* initial thread handling transaction */
636         int                      oti_thread_id;
637 };
638
639 static inline void oti_init(struct obd_trans_info *oti,
640                             struct ptlrpc_request *req)
641 {
642         if (oti == NULL)
643                 return;
644         memset(oti, 0, sizeof *oti);
645
646         if (req == NULL)
647                 return;
648
649         if (req->rq_repmsg && req->rq_reqmsg != 0)
650                 oti->oti_transno = req->rq_repmsg->transno;
651         oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
652 }
653
654 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
655 {
656         if (!oti)
657                 return;
658
659         if (num_cookies == 1)
660                 oti->oti_logcookies = &oti->oti_onecookie;
661         else
662                 OBD_ALLOC(oti->oti_logcookies,
663                           num_cookies * sizeof(oti->oti_onecookie));
664
665         oti->oti_numcookies = num_cookies;
666 }
667
668 static inline void oti_free_cookies(struct obd_trans_info *oti)
669 {
670         if (!oti || !oti->oti_logcookies)
671                 return;
672
673         if (oti->oti_logcookies == &oti->oti_onecookie)
674                 LASSERT(oti->oti_numcookies == 1);
675         else
676                 OBD_FREE(oti->oti_logcookies,
677                          oti->oti_numcookies * sizeof(oti->oti_onecookie));
678         oti->oti_logcookies = NULL;
679         oti->oti_numcookies = 0;
680 }
681
682 /* llog contexts */
683 enum llog_ctxt_id {
684         LLOG_CONFIG_ORIG_CTXT  =  0,
685         LLOG_CONFIG_REPL_CTXT  =  1,
686         LLOG_MDS_OST_ORIG_CTXT =  2,
687         LLOG_MDS_OST_REPL_CTXT =  3,
688         LLOG_SIZE_ORIG_CTXT    =  4,
689         LLOG_SIZE_REPL_CTXT    =  5,
690         LLOG_MD_ORIG_CTXT      =  6,
691         LLOG_MD_REPL_CTXT      =  7,
692         LLOG_RD1_ORIG_CTXT     =  8,
693         LLOG_RD1_REPL_CTXT     =  9,
694         LLOG_TEST_ORIG_CTXT    = 10,
695         LLOG_TEST_REPL_CTXT    = 11,
696         LLOG_LOVEA_ORIG_CTXT   = 12,
697         LLOG_LOVEA_REPL_CTXT   = 13,
698         LLOG_MAX_CTXTS
699 };
700
701 /*
702  * Events signalled through obd_notify() upcall-chain.
703  */
704 enum obd_notify_event {
705         /* Device activated */
706         OBD_NOTIFY_ACTIVE,
707         /* Device deactivated */
708         OBD_NOTIFY_INACTIVE,
709         /* Connect data for import were changed */
710         OBD_NOTIFY_OCD,
711         /* Sync request */
712         OBD_NOTIFY_SYNC_NONBLOCK,
713         OBD_NOTIFY_SYNC
714 };
715
716 #include <lu_object.h>
717 /*
718  * Data structure used to pass obd_notify()-event to non-obd listeners (llite
719  * and liblustre being main examples).
720  */
721 struct obd_notify_upcall {
722         int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
723                           enum obd_notify_event ev, void *owner);
724         /* Opaque datum supplied by upper layer listener */
725         void *onu_owner;
726 };
727
728 /* corresponds to one of the obd's */
729 struct obd_device {
730         struct obd_type        *obd_type;
731         /* common and UUID name of this device */
732         char                   *obd_name;
733         struct obd_uuid         obd_uuid;
734
735         struct lu_device       *obd_lu_dev;
736
737         int                     obd_minor;
738         unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
739                 obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
740                 obd_no_recov:1, obd_stopping:1, obd_starting:1,
741                 obd_force:1, obd_fail:1, obd_async_recov:1;
742         atomic_t obd_refcount;
743         cfs_waitq_t             obd_refcount_waitq;
744         cfs_proc_dir_entry_t  *obd_proc_entry;
745         struct list_head        obd_exports;
746         int                     obd_num_exports;
747         struct ldlm_namespace  *obd_namespace;
748         struct ptlrpc_client    obd_ldlm_client; /* XXX OST/MDS only */
749         /* a spinlock is OK for what we do now, may need a semaphore later */
750         spinlock_t              obd_dev_lock;
751         __u64                   obd_last_committed;
752         struct fsfilt_operations *obd_fsops;
753         spinlock_t              obd_osfs_lock;
754         struct obd_statfs       obd_osfs;       /* locked by obd_osfs_lock */
755         cfs_time_t              obd_osfs_age;
756         struct lvfs_run_ctxt    obd_lvfs_ctxt;
757         struct llog_ctxt        *obd_llog_ctxt[LLOG_MAX_CTXTS];
758         struct obd_device       *obd_observer;
759         struct obd_notify_upcall obd_upcall;
760         struct obd_export       *obd_self_export;
761         /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
762         struct list_head        obd_exports_timed;
763         time_t                  obd_eviction_timer; /* for ping evictor */
764
765         /* XXX encapsulate all this recovery data into one struct */
766         svc_handler_t                    obd_recovery_handler;
767         int                              obd_max_recoverable_clients;
768         int                              obd_connected_clients;
769         int                              obd_recoverable_clients;
770         spinlock_t                       obd_processing_task_lock;
771         pid_t                            obd_processing_task;
772         __u64                            obd_next_recovery_transno;
773         int                              obd_replayed_requests;
774         int                              obd_requests_queued_for_recovery;
775         cfs_waitq_t                      obd_next_transno_waitq;
776         struct list_head                 obd_uncommitted_replies;
777         spinlock_t                       obd_uncommitted_replies_lock;
778         cfs_timer_t                      obd_recovery_timer;
779         struct list_head                 obd_recovery_queue;
780         struct list_head                 obd_delayed_reply_queue;
781         time_t                           obd_recovery_start;
782         time_t                           obd_recovery_end;
783
784         union {
785                 struct obd_device_target obt;
786                 struct filter_obd filter;
787                 struct mds_obd mds;
788                 struct client_obd cli;
789                 struct ost_obd ost;
790                 struct echo_client_obd echo_client;
791                 struct echo_obd echo;
792                 struct lov_obd lov;
793                 struct lmv_obd lmv;
794                 struct mgs_obd mgs;
795         } u;
796         /* Fields used by LProcFS */
797         unsigned int           obd_cntr_base;
798         struct lprocfs_stats  *obd_stats;
799
800         unsigned int           md_cntr_base;
801         struct lprocfs_stats  *md_stats;
802
803         cfs_proc_dir_entry_t  *obd_svc_procroot;
804         struct lprocfs_stats  *obd_svc_stats;
805 };
806
807 #define OBD_OPT_FORCE           0x0001
808 #define OBD_OPT_FAILOVER        0x0002
809
810 #define OBD_LLOG_FL_SENDNOW     0x0001
811
812 enum obd_cleanup_stage {
813 /* Special case hack for MDS LOVs */
814         OBD_CLEANUP_EARLY,
815 /* Precleanup stage 1, we must make sure all exports (other than the
816    self-export) get destroyed. */
817         OBD_CLEANUP_EXPORTS,
818 /* Precleanup stage 2,  do other type-specific cleanup requiring the
819    self-export. */
820         OBD_CLEANUP_SELF_EXP,
821 /* FIXME we should eliminate the "precleanup" function and make them stages
822    of the "cleanup" function. */
823         OBD_CLEANUP_OBD,
824 };
825
826 /* get/set_info keys */
827 #define KEY_MDS_CONN "mds_conn"
828 #define KEY_NEXT_ID  "next_id"
829 #define KEY_LOVDESC  "lovdesc"
830 #define KEY_INIT_RECOV "initial_recov"
831 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"
832
833 struct lu_context;
834
835 struct obd_ops {
836         struct module *o_owner;
837         int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
838                            void *karg, void *uarg);
839         int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
840                           __u32 *vallen, void *val);
841         int (*o_set_info_async)(struct obd_export *, __u32 keylen, void *key,
842                                 __u32 vallen, void *val,
843                                 struct ptlrpc_request_set *set);
844         int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
845         int (*o_detach)(struct obd_device *dev);
846         int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg);
847         int (*o_precleanup)(struct obd_device *dev,
848                             enum obd_cleanup_stage cleanup_stage);
849         int (*o_cleanup)(struct obd_device *dev);
850         int (*o_process_config)(struct obd_device *dev, obd_count len,
851                                 void *data);
852         int (*o_postrecov)(struct obd_device *dev);
853         int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
854                           int priority);
855         int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
856         /* connect to the target device with given connection
857          * data. @ocd->ocd_connect_flags is modified to reflect flags actually
858          * granted by the target, which are guaranteed to be a subset of flags
859          * asked for. If @ocd == NULL, use default parameters. */
860         int (*o_connect)(const struct lu_context *ctx,
861                          struct lustre_handle *conn, struct obd_device *src,
862                          struct obd_uuid *cluuid, struct obd_connect_data *ocd);
863         int (*o_reconnect)(struct obd_export *exp, struct obd_device *src,
864                            struct obd_uuid *cluuid,
865                            struct obd_connect_data *ocd);
866         int (*o_disconnect)(struct obd_export *exp);
867
868         /* maybe later these should be moved into separate fid_ops */
869         int (*o_fid_init)(struct obd_export *exp);
870         int (*o_fid_fini)(struct obd_export *exp);
871
872         int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
873                            struct lu_placement_hint *hint);
874
875         int (*o_fid_delete)(struct obd_export *exp, struct lu_fid *fid);
876
877         int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
878                         unsigned long max_age);
879         int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
880                         struct lov_stripe_md *mem_src);
881         int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
882                           struct lov_mds_md *disk_src, int disk_len);
883         int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
884                          struct lov_stripe_md *mem_tgt);
885         int (*o_preallocate)(struct lustre_handle *, obd_count *req,
886                              obd_id *ids);
887         int (*o_create)(struct obd_export *exp,  struct obdo *oa,
888                         struct lov_stripe_md **ea, struct obd_trans_info *oti);
889         int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
890                          struct lov_stripe_md *ea, struct obd_trans_info *oti,
891                          struct obd_export *md_exp);
892         int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
893                          struct lov_stripe_md *ea, struct obd_trans_info *oti);
894         int (*o_setattr_async)(struct obd_export *exp, struct obdo *oa,
895                          struct lov_stripe_md *ea, struct obd_trans_info *oti);
896         int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
897                          struct lov_stripe_md *ea);
898         int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
899                                struct lov_stripe_md *ea,
900                                struct ptlrpc_request_set *set);
901         int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
902                      struct lov_stripe_md *ea, obd_count oa_bufs,
903                      struct brw_page *pgarr, struct obd_trans_info *oti);
904         int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
905                            struct lov_stripe_md *ea, obd_count oa_bufs,
906                            struct brw_page *pgarr, struct ptlrpc_request_set *,
907                            struct obd_trans_info *oti);
908         int (*o_prep_async_page)(struct obd_export *exp,
909                                  struct lov_stripe_md *lsm,
910                                  struct lov_oinfo *loi,
911                                  struct page *page, obd_off offset,
912                                  struct obd_async_page_ops *ops, void *data,
913                                  void **res);
914         int (*o_queue_async_io)(struct obd_export *exp,
915                                 struct lov_stripe_md *lsm,
916                                 struct lov_oinfo *loi, void *cookie,
917                                 int cmd, obd_off off, int count,
918                                 obd_flag brw_flags, obd_flag async_flags);
919         int (*o_queue_group_io)(struct obd_export *exp,
920                                 struct lov_stripe_md *lsm,
921                                 struct lov_oinfo *loi,
922                                 struct obd_io_group *oig,
923                                 void *cookie, int cmd, obd_off off, int count,
924                                 obd_flag brw_flags, obd_flag async_flags);
925         int (*o_trigger_group_io)(struct obd_export *exp,
926                                   struct lov_stripe_md *lsm,
927                                   struct lov_oinfo *loi,
928                                   struct obd_io_group *oig);
929         int (*o_set_async_flags)(struct obd_export *exp,
930                                 struct lov_stripe_md *lsm,
931                                 struct lov_oinfo *loi, void *cookie,
932                                 obd_flag async_flags);
933         int (*o_teardown_async_page)(struct obd_export *exp,
934                                      struct lov_stripe_md *lsm,
935                                      struct lov_oinfo *loi, void *cookie);
936         int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
937                            struct ost_lvb *lvb, int kms_only);
938         int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
939                             obd_off size, int shrink);
940         int (*o_punch)(struct obd_export *exp, struct obdo *oa,
941                        struct lov_stripe_md *ea, obd_size start,
942                        obd_size end, struct obd_trans_info *oti);
943         int (*o_sync)(struct obd_export *exp, struct obdo *oa,
944                       struct lov_stripe_md *ea, obd_size start, obd_size end);
945         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
946                          struct lov_stripe_md *src, obd_size start,
947                          obd_size end, struct obd_trans_info *oti);
948         int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
949                       struct lustre_handle *srconn, struct lov_stripe_md *src,
950                       obd_size start, obd_size end, struct obd_trans_info *);
951         int (*o_iterate)(struct lustre_handle *conn,
952                          int (*)(obd_id, obd_gr, void *),
953                          obd_id *startid, obd_gr group, void *data);
954         int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
955                         int objcount, struct obd_ioobj *obj,
956                         int niocount, struct niobuf_remote *remote,
957                         struct niobuf_local *local, struct obd_trans_info *oti);
958         int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
959                           int objcount, struct obd_ioobj *obj,
960                           int niocount, struct niobuf_local *local,
961                           struct obd_trans_info *oti, int rc);
962         int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
963                          __u32 type, ldlm_policy_data_t *, __u32 mode,
964                          int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
965                          void *data, __u32 lvb_len, void *lvb_swabber,
966                          struct lustre_handle *lockh);
967         int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
968                        ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
969                        struct lustre_handle *lockh);
970         int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
971                                ldlm_iterator_t it, void *data);
972         int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
973                         __u32 mode, struct lustre_handle *);
974         int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
975                                int flags, void *opaque);
976         int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
977                          int join);
978         int (*o_san_preprw)(int cmd, struct obd_export *exp,
979                             struct obdo *oa, int objcount,
980                             struct obd_ioobj *obj, int niocount,
981                             struct niobuf_remote *remote);
982         int (*o_init_export)(struct obd_export *exp);
983         int (*o_destroy_export)(struct obd_export *exp);
984
985         /* llog related obd_methods */
986         int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
987                            int count, struct llog_catid *logid);
988         int (*o_llog_finish)(struct obd_device *obd, int count);
989
990         /* metadata-only methods */
991         int (*o_pin)(struct obd_export *, struct lu_fid *fid,
992                      struct obd_client_handle *, int flag);
993         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
994
995         int (*o_import_event)(struct obd_device *, struct obd_import *,
996                               enum obd_import_event);
997
998         int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
999                         enum obd_notify_event ev, void *data);
1000
1001         int (*o_health_check)(struct obd_device *);
1002
1003         /* quota methods */
1004         int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
1005         int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
1006
1007         /*
1008          * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
1009          * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
1010          * Also, add a wrapper function in include/linux/obd_class.h.
1011          *
1012          * Also note that if you add it to the END, you also have to change
1013          * the num_stats calculation.
1014          *
1015          */
1016 };
1017
1018 struct md_ops {
1019         int (*m_getstatus)(struct obd_export *, struct lu_fid *);
1020         int (*m_change_cbdata)(struct obd_export *, struct lu_fid *,
1021                                ldlm_iterator_t, void *);
1022         int (*m_close)(struct obd_export *, struct md_op_data *,
1023                        struct obd_client_handle *, struct ptlrpc_request **);
1024         int (*m_create)(struct obd_export *, struct md_op_data *,
1025                         const void *, int, int, __u32, __u32, __u32,
1026                         __u64, struct ptlrpc_request **);
1027         int (*m_done_writing)(struct obd_export *, struct md_op_data *);
1028         int (*m_enqueue)(struct obd_export *, int, struct lookup_intent *,
1029                          int, struct md_op_data *, struct lustre_handle *,
1030                          void *, int, ldlm_completion_callback,
1031                          ldlm_blocking_callback, void *, int);
1032         int (*m_getattr)(struct obd_export *, struct lu_fid *,
1033                          obd_valid, int, struct ptlrpc_request **);
1034         int (*m_getattr_name)(struct obd_export *, struct lu_fid *,
1035                               const char *, int, obd_valid,
1036                               int, struct ptlrpc_request **);
1037         int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
1038                              void *, int, struct lookup_intent *, int,
1039                              struct ptlrpc_request **,
1040                              ldlm_blocking_callback, int);
1041         int (*m_link)(struct obd_export *, struct md_op_data *,
1042                       struct ptlrpc_request **);
1043         int (*m_rename)(struct obd_export *, struct md_op_data *,
1044                         const char *, int, const char *, int,
1045                         struct ptlrpc_request **);
1046         int (*m_setattr)(struct obd_export *, struct md_op_data *,
1047                          struct iattr *, void *, int , void *, int,
1048                          struct ptlrpc_request **);
1049         int (*m_sync)(struct obd_export *, struct lu_fid *,
1050                       struct ptlrpc_request **);
1051         int (*m_readpage)(struct obd_export *, struct lu_fid *,
1052                           __u64, struct page *, struct ptlrpc_request **);
1053         int (*m_unlink)(struct obd_export *, struct md_op_data *,
1054                         struct ptlrpc_request **);
1055
1056         int (*m_setxattr)(struct obd_export *, struct lu_fid *,
1057                           obd_valid, const char *, const char *,
1058                           int, int, int, struct ptlrpc_request **);
1059
1060         int (*m_getxattr)(struct obd_export *, struct lu_fid *,
1061                           obd_valid, const char *, const char *,
1062                           int, int, int, struct ptlrpc_request **);
1063
1064         int (*m_init_ea_size)(struct obd_export *, int, int, int);
1065
1066         int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
1067                                int, struct obd_export *, struct lustre_md *);
1068
1069         int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
1070
1071         int (*m_set_open_replay_data)(struct obd_export *,
1072                                       struct obd_client_handle *,
1073                                       struct ptlrpc_request *);
1074         int (*m_clear_open_replay_data)(struct obd_export *,
1075                                         struct obd_client_handle *);
1076         int (*m_set_lock_data)(struct obd_export *, __u64 *, void *);
1077
1078         int (*m_lock_match)(struct obd_export *, int, struct lu_fid *,
1079                             ldlm_type_t, ldlm_policy_data_t *, ldlm_mode_t,
1080                             struct lustre_handle *);
1081
1082         int (*m_cancel_unused)(struct obd_export *, struct lu_fid *,
1083                                int flags, void *opaque);
1084
1085         /*
1086          * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
1087          * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
1088          * wrapper function in include/linux/obd_class.h.
1089          */
1090 };
1091
1092 struct lsm_operations {
1093         void (*lsm_free)(struct lov_stripe_md *);
1094         int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
1095                            struct obd_export *md_exp);
1096         void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
1097                                      unsigned long *);
1098         void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
1099                                      unsigned long *);
1100         obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
1101         int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
1102         int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
1103         int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
1104                                int *stripe_count);
1105         int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
1106                              struct lov_mds_md *lmm);
1107 };
1108
1109 extern struct lsm_operations lsm_plain_ops;
1110 extern struct lsm_operations lsm_join_ops;
1111 static inline struct lsm_operations *lsm_op_find(int magic)
1112 {
1113         switch(magic) {
1114         case LOV_MAGIC:
1115                return &lsm_plain_ops;
1116         case LOV_MAGIC_JOIN:
1117                return &lsm_join_ops;
1118         default:
1119                CERROR("Cannot recognize lsm_magic %d", magic);
1120                return NULL;
1121         }
1122 }
1123
1124 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
1125
1126 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
1127                                          int error)
1128 {
1129         if (error) {
1130                 CERROR("%s: transno "LPD64" commit error: %d\n",
1131                        obd->obd_name, transno, error);
1132                 return;
1133         }
1134         CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
1135                obd->obd_name, transno);
1136         if (transno > obd->obd_last_committed) {
1137                 obd->obd_last_committed = transno;
1138                 ptlrpc_commit_replies (obd);
1139         }
1140 }
1141
1142 static inline void init_obd_quota_ops(quota_interface_t *interface,
1143                                       struct obd_ops *obd_ops)
1144 {
1145         if (!interface)
1146                 return;
1147
1148         LASSERT(obd_ops);
1149         obd_ops->o_quotacheck = QUOTA_OP(interface, check);
1150         obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
1151 }
1152
1153 #endif /* __OBD_H */