1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
10 #elif defined(__APPLE__)
11 #include <darwin/obd.h>
12 #elif defined(__WINNT__)
13 #include <winnt/obd.h>
15 #error Unsupported operating system.
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
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
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 #include <lustre_capa.h>
37 #include <class_hash.h>
39 #include <libcfs/bitmap.h>
42 #define MAX_OBD_DEVICES 8192
44 /* this is really local to the OSC */
45 struct loi_oap_pages {
46 struct list_head lop_pending;
47 struct list_head lop_urgent;
48 struct list_head lop_pending_group;
58 struct lov_oinfo { /* per-stripe data structure */
59 __u64 loi_id; /* object ID on the target OST */
60 __u64 loi_gr; /* object group on the target OST */
61 int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
62 int loi_ost_gen; /* generation of this loi_ost_idx */
64 /* used by the osc to keep track of what objects to build into rpcs */
65 struct loi_oap_pages loi_read_lop;
66 struct loi_oap_pages loi_write_lop;
67 /* _cli_ is poorly named, it should be _ready_ */
68 struct list_head loi_cli_item;
69 struct list_head loi_write_item;
70 struct list_head loi_read_item;
72 unsigned long loi_kms_valid:1;
73 __u64 loi_kms; /* known minimum size */
74 struct ost_lvb loi_lvb;
75 struct osc_async_rc loi_ar;
78 static inline void loi_init(struct lov_oinfo *loi)
80 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
81 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
82 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
83 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
84 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
85 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
86 CFS_INIT_LIST_HEAD(&loi->loi_cli_item);
87 CFS_INIT_LIST_HEAD(&loi->loi_write_item);
88 CFS_INIT_LIST_HEAD(&loi->loi_read_item);
91 /*extent array item for describing the joined file extent info*/
93 __u64 le_start; /* extent start */
94 __u64 le_len; /* extent length */
95 int le_loi_idx; /* extent #1 loi's index in lsm loi array */
96 int le_stripe_count; /* extent stripe count*/
99 /*Lov array info for describing joined file array EA info*/
100 struct lov_array_info {
101 struct llog_logid lai_array_id; /* MDS med llog object id */
102 unsigned lai_ext_count; /* number of extent count */
103 struct lov_extent *lai_ext_array; /* extent desc array */
106 struct lov_stripe_md {
108 void *lsm_lock_owner; /* debugging */
111 /* Public members. */
112 __u64 lw_object_id; /* lov object id */
113 __u64 lw_object_gr; /* lov object group */
114 __u64 lw_maxbytes; /* maximum possible file size */
116 /* LOV-private members start here -- only for use in lov/. */
118 __u32 lw_stripe_size; /* size of the stripe */
119 __u32 lw_pattern; /* striping pattern (RAID0, RAID1) */
120 unsigned lw_stripe_count; /* number of objects being striped over */
123 struct lov_array_info *lsm_array; /*Only for joined file array info*/
124 struct lov_oinfo *lsm_oinfo[0];
127 #define lsm_object_id lsm_wire.lw_object_id
128 #define lsm_object_gr lsm_wire.lw_object_gr
129 #define lsm_maxbytes lsm_wire.lw_maxbytes
130 #define lsm_magic lsm_wire.lw_magic
131 #define lsm_stripe_size lsm_wire.lw_stripe_size
132 #define lsm_pattern lsm_wire.lw_pattern
133 #define lsm_stripe_count lsm_wire.lw_stripe_count
137 typedef int (*obd_enqueue_update_f)(struct obd_info *oinfo, int rc);
139 /* obd info for a particular level (lov, osc). */
141 /* Lock policy. It keeps an extent which is specific for a particular
142 * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy,
143 * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */
144 ldlm_policy_data_t oi_policy;
145 /* Flags used while lock handling. The flags obtained on the enqueue
146 * request are set here, therefore they are request specific. */
148 /* Lock handle specific for every OSC lock. */
149 struct lustre_handle *oi_lockh;
150 /* lsm data specific for every OSC. */
151 struct lov_stripe_md *oi_md;
152 /* obdo data specific for every OSC, if needed at all. */
154 /* statfs data specific for every OSC, if needed at all. */
155 struct obd_statfs *oi_osfs;
156 /* An update callback which is called to update some data on upper
157 * level. E.g. it is used for update lsm->lsm_oinfo at every recieved
158 * request in osc level for enqueue requests. It is also possible to
159 * update some caller data from LOV layer if needed. */
160 obd_enqueue_update_f oi_cb_up;
161 /* oss capability, its type is obd_capa in client to avoid copy.
162 * in contrary its type is lustre_capa in OSS. */
166 /* compare all relevant fields. */
167 static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
168 struct lov_stripe_md *m2)
171 * ->lsm_wire contains padding, but it should be zeroed out during
174 return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof m1->lsm_wire);
177 void lov_stripe_lock(struct lov_stripe_md *md);
178 void lov_stripe_unlock(struct lov_stripe_md *md);
181 struct list_head typ_chain;
182 struct obd_ops *typ_dt_ops;
183 struct md_ops *typ_md_ops;
184 cfs_proc_dir_entry_t *typ_procroot;
187 struct lu_device_type *typ_lu;
188 spinlock_t obd_type_lock;
199 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
200 page is added to an rpc */
201 ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
202 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
203 to give the caller a chance to update
204 or cancel the size of the io */
205 ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
206 the page is accounted for in the
207 obd_io_group given to
208 obd_queue_group_io */
211 struct obd_async_page_ops {
212 int (*ap_make_ready)(void *data, int cmd);
213 int (*ap_refresh_count)(void *data, int cmd);
214 void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
215 void (*ap_update_obdo)(void *data, int cmd, struct obdo *oa,
217 int (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
218 struct obd_capa *(*ap_lookup_capa)(void *data, int cmd);
221 /* the `oig' is passed down from a caller of obd rw methods. the callee
222 * records enough state such that the caller can sleep on the oig and
223 * be woken when all the callees have finished their work */
224 struct obd_io_group {
226 atomic_t oig_refcount;
229 struct list_head oig_occ_list;
230 cfs_waitq_t oig_waitq;
233 /* the oig callback context lets the callee of obd rw methods register
234 * for callbacks from the caller. */
235 struct oig_callback_context {
236 struct list_head occ_oig_item;
237 /* called when the caller has received a signal while sleeping.
238 * callees of this method are encouraged to abort their state
239 * in the oig. This may be called multiple times. */
240 void (*occ_interrupted)(struct oig_callback_context *occ);
241 unsigned long interrupted:1;
244 /* Individual type definitions */
246 struct ost_server_data;
248 /* hold common fields for "target" device */
249 struct obd_device_target {
250 struct super_block *obt_sb;
251 atomic_t obt_quotachecking;
252 struct lustre_quota_ctxt obt_qctxt;
257 LLOG_CONFIG_ORIG_CTXT = 0,
258 LLOG_CONFIG_REPL_CTXT = 1,
259 LLOG_MDS_OST_ORIG_CTXT = 2,
260 LLOG_MDS_OST_REPL_CTXT = 3,
261 LLOG_SIZE_ORIG_CTXT = 4,
262 LLOG_SIZE_REPL_CTXT = 5,
263 LLOG_MD_ORIG_CTXT = 6,
264 LLOG_MD_REPL_CTXT = 7,
265 LLOG_RD1_ORIG_CTXT = 8,
266 LLOG_RD1_REPL_CTXT = 9,
267 LLOG_TEST_ORIG_CTXT = 10,
268 LLOG_TEST_REPL_CTXT = 11,
269 LLOG_LOVEA_ORIG_CTXT = 12,
270 LLOG_LOVEA_REPL_CTXT = 13,
274 #define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
276 #define FILTER_GROUP_LLOG 1
277 #define FILTER_GROUP_ECHO 2
278 #define FILTER_GROUP_MDS0 3
280 struct filter_subdirs {
281 cfs_dentry_t *dentry[FILTER_SUBDIR_COUNT];
291 struct llog_ctxt *llog_ctxt[LLOG_MAX_CTXTS];
294 struct filter_group_llog {
295 struct list_head list;
297 struct obd_llogs *llogs;
298 struct obd_export *exp;
302 /* NB this field MUST be first */
303 struct obd_device_target fo_obt;
304 const char *fo_fstype;
305 struct vfsmount *fo_vfsmnt;
308 cfs_dentry_t *fo_dentry_O;
309 cfs_dentry_t **fo_dentry_O_groups;
310 struct filter_subdirs *fo_dentry_O_sub;
311 struct semaphore fo_init_lock; /* group initialization lock */
312 int fo_committed_group;
315 spinlock_t fo_objidlock; /* protect fo_lastobjid */
316 spinlock_t fo_translock; /* protect fsd_last_transno */
317 struct file *fo_rcvd_filp;
318 struct file *fo_health_check_filp;
319 struct lr_server_data *fo_fsd;
320 unsigned long *fo_last_rcvd_slots;
321 __u64 fo_mount_count;
323 unsigned long fo_destroys_in_progress;
324 struct semaphore fo_create_locks[FILTER_SUBDIR_COUNT];
326 struct list_head fo_export_list;
329 obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
330 obd_size fo_tot_granted; /* all values in bytes */
331 obd_size fo_tot_pending;
333 obd_size fo_readcache_max_filesize;
335 struct obd_import *fo_mdc_imp;
336 struct obd_uuid fo_mdc_uuid;
337 struct lustre_handle fo_mdc_conn;
338 struct file **fo_last_objid_files;
339 __u64 *fo_last_objids; /* last created objid for groups,
340 * protected by fo_objidlock */
342 struct semaphore fo_alloc_lock;
344 atomic_t fo_r_in_flight;
345 atomic_t fo_w_in_flight;
348 * per-filter pool of kiobuf's allocated by filter_common_setup() and
349 * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
350 * which ->fo_iobuf_count were allocated.
352 * This pool contains kiobuf used by
353 * filter_{prep,commit}rw_{read,write}() and is shared by all OST
356 * Locking: none, each OST thread uses only one element, determined by
357 * its "ordinal number", ->t_id.
359 struct filter_iobuf **fo_iobuf_pool;
362 struct list_head fo_llog_list;
363 spinlock_t fo_llog_list_lock;
365 struct brw_stats fo_filter_stats;
366 struct lustre_quota_ctxt fo_quota_ctxt;
367 spinlock_t fo_quotacheck_lock;
368 atomic_t fo_quotachecking;
370 int fo_fmd_max_num; /* per exp filter_mod_data */
371 int fo_fmd_max_age; /* jiffies to fmd expiry */
374 rwlock_t fo_sptlrpc_lock;
375 struct sptlrpc_rule_set fo_sptlrpc_rset;
377 /* capability related */
378 unsigned int fo_fl_oss_capa;
379 struct list_head fo_capa_keys;
380 struct hlist_head *fo_capa_hash;
383 #define OSC_MAX_RIF_DEFAULT 8
384 #define OSC_MAX_RIF_MAX 256
385 #define OSC_MAX_DIRTY_DEFAULT (OSC_MAX_RIF_DEFAULT * 4)
386 #define OSC_MAX_DIRTY_MB_MAX 2048 /* arbitrary, but < MAX_LONG bytes */
387 #define OSC_DEFAULT_RESENDS 10
389 #define MDC_MAX_RIF_DEFAULT 8
390 #define MDC_MAX_RIF_MAX 512
395 struct semaphore cl_sem;
396 struct obd_uuid cl_target_uuid;
397 struct obd_import *cl_import; /* ptlrpc connection state */
399 /* max_mds_easize is purely a performance thing so we don't have to
400 * call obd_size_diskmd() all the time. */
401 int cl_default_mds_easize;
402 int cl_max_mds_easize;
403 int cl_max_mds_cookiesize;
405 /* security configuration */
406 struct sptlrpc_rule_set cl_sptlrpc_rset;
407 enum lustre_sec_part cl_sec_part;
409 //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
410 void *cl_llcd_offset;
412 /* the grant values are protected by loi_list_lock below */
413 long cl_dirty; /* all _dirty_ in bytes */
414 long cl_dirty_max; /* allowed w/o rpc */
415 long cl_avail_grant; /* bytes of credit for ost */
416 long cl_lost_grant; /* lost credits (trunc) */
417 struct list_head cl_cache_waiters; /* waiting for cache/grant */
419 /* keep track of objects that have lois that contain pages which
420 * have been queued for async brw. this lock also protects the
421 * lists of osc_client_pages that hang off of the loi */
423 * ->cl_loi_list_lock protects consistency of
424 * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
425 * ->ap_completion() call-backs are executed under this lock. As we
426 * cannot guarantee that these call-backs never block on all platforms
427 * (as a matter of fact they do block on Mac OS X), type of
428 * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
429 * and blocking mutex on Mac OS X. (Alternative is to make this lock
430 * blocking everywhere, but we don't want to slow down fast-path of
431 * our main platform.)
433 * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
434 * with client_obd_list_{un,}lock() and
435 * client_obd_list_lock_{init,done}() functions.
437 client_obd_lock_t cl_loi_list_lock;
438 struct list_head cl_loi_ready_list;
439 struct list_head cl_loi_write_list;
440 struct list_head cl_loi_read_list;
443 /* just a sum of the loi/lop pending numbers to be exported by /proc */
444 int cl_pending_w_pages;
445 int cl_pending_r_pages;
446 int cl_max_pages_per_rpc;
447 int cl_max_rpcs_in_flight;
448 struct obd_histogram cl_read_rpc_hist;
449 struct obd_histogram cl_write_rpc_hist;
450 struct obd_histogram cl_read_page_hist;
451 struct obd_histogram cl_write_page_hist;
452 struct obd_histogram cl_read_offset_hist;
453 struct obd_histogram cl_write_offset_hist;
455 /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */
456 atomic_t cl_destroy_in_flight;
457 cfs_waitq_t cl_destroy_waitq;
459 struct mdc_rpc_lock *cl_rpc_lock;
460 struct mdc_rpc_lock *cl_setattr_lock;
461 struct mdc_rpc_lock *cl_close_lock;
462 struct osc_creator cl_oscc;
465 struct semaphore cl_mgc_sem;
466 struct vfsmount *cl_mgc_vfsmnt;
467 struct dentry *cl_mgc_configs_dir;
468 atomic_t cl_mgc_refcount;
469 struct obd_export *cl_mgc_mgsexp;
472 unsigned long cl_checksum:1; /* debug checksums */
474 /* also protected by the poorly named _loi_list_lock lock above */
475 struct osc_async_rc cl_ar;
477 /* used by quotacheck */
478 int cl_qchk_stat; /* quotacheck stat of the peer */
480 /* sequence manager */
481 struct lu_client_seq *cl_seq;
483 atomic_t cl_resends; /* resend count */
485 #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
487 #define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */
490 struct ptlrpc_service *mgs_service;
491 struct vfsmount *mgs_vfsmnt;
492 struct super_block *mgs_sb;
493 struct dentry *mgs_configs_dir;
494 struct dentry *mgs_fid_de;
495 struct list_head mgs_fs_db_list;
496 struct semaphore mgs_sem;
497 cfs_proc_dir_entry_t *mgs_proc_live;
501 /* NB this field MUST be first */
502 struct obd_device_target mds_obt;
503 struct ptlrpc_service *mds_service;
504 struct ptlrpc_service *mds_setattr_service;
505 struct ptlrpc_service *mds_readpage_service;
506 struct vfsmount *mds_vfsmnt;
507 cfs_dentry_t *mds_fid_de;
509 int mds_max_cookiesize;
510 struct file *mds_rcvd_filp;
511 spinlock_t mds_transno_lock;
512 __u64 mds_last_transno;
513 __u64 mds_mount_count;
515 unsigned long mds_atime_diff;
516 struct semaphore mds_epoch_sem;
517 struct ll_fid mds_rootfid;
518 struct lr_server_data *mds_server_data;
519 cfs_dentry_t *mds_pending_dir;
520 cfs_dentry_t *mds_logs_dir;
521 cfs_dentry_t *mds_objects_dir;
522 struct llog_handle *mds_cfg_llh;
523 // struct llog_handle *mds_catalog;
524 struct obd_device *mds_osc_obd; /* XXX lov_obd */
525 struct obd_uuid mds_lov_uuid;
527 struct obd_export *mds_osc_exp; /* XXX lov_exp */
528 struct lov_desc mds_lov_desc;
531 /* mark pages dirty for write. */
532 bitmap_t *mds_lov_page_dirty;
533 /* array for store pages with obd_id */
534 void **mds_lov_page_array;
535 /* file for store objid */
536 struct file *mds_lov_objid_filp;
537 __u32 mds_lov_objid_count;
538 __u32 mds_lov_objid_lastpage;
539 __u32 mds_lov_objid_lastidx;
541 struct file *mds_health_check_filp;
542 unsigned long *mds_client_bitmap;
543 // struct upcall_cache *mds_group_hash;
545 struct lustre_quota_info mds_quota_info;
546 struct semaphore mds_qonoff_sem;
547 struct semaphore mds_health_sem;
548 unsigned long mds_fl_user_xattr:1,
550 mds_evict_ost_nids:1,
554 struct upcall_cache *mds_identity_cache;
556 /* for capability keys update */
557 struct lustre_capa_key *mds_capa_keys;
561 extern __u32 mds_max_ost_index;
563 #define MDS_LOV_ALLOC_SIZE (CFS_PAGE_SIZE)
565 #define OBJID_PER_PAGE() (MDS_LOV_ALLOC_SIZE / sizeof(obd_id))
567 #define MDS_LOV_OBJID_PAGES_COUNT (mds_max_ost_index/OBJID_PER_PAGE())
569 extern int mds_lov_init_objids(struct obd_device *obd);
570 extern void mds_lov_destroy_objids(struct obd_device *obd);
583 struct lustre_handle eo_nl_lock;
588 struct ptlrpc_service *ost_service;
589 struct ptlrpc_service *ost_create_service;
590 struct ptlrpc_service *ost_io_service;
591 struct semaphore ost_health_sem;
594 struct echo_client_obd {
595 struct obd_export *ec_exp; /* the local connection to osc/lov */
597 struct list_head ec_objects;
603 struct obd_uuid lqo_uuid; /* ptlrpc's c_remote_uuid */
604 struct list_head lqo_oss_list; /* link to lov_qos */
605 __u32 lqo_ost_count; /* number of osts on this oss */
606 __u64 lqo_bavail; /* total bytes avail on OSS */
607 __u64 lqo_penalty; /* current penalty */
608 __u64 lqo_penalty_per_obj; /* penalty decrease every obj*/
612 struct lov_qos_oss *ltq_oss; /* oss info */
613 __u64 ltq_penalty; /* current penalty */
614 __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/
615 __u64 ltq_weight; /* net weighting */
616 unsigned int ltq_usable:1; /* usable for striping */
620 struct list_head lq_oss_list; /* list of OSSs that targets use */
621 struct rw_semaphore lq_rw_sem;
622 __u32 lq_active_oss_count;
623 __u32 *lq_rr_array; /* round-robin optimized list */
624 unsigned int lq_rr_size; /* rr array size */
625 unsigned int lq_prio_free; /* priority for free space */
626 unsigned long lq_dirty:1, /* recalc qos data */
627 lq_dirty_rr:1, /* recalc round-robin list */
628 lq_same_space:1,/* the ost's all have approx.
629 the same space avail */
630 lq_reset:1; /* zero current penalties */
633 struct lov_tgt_desc {
634 struct obd_uuid ltd_uuid;
635 struct obd_export *ltd_exp;
636 struct ltd_qos ltd_qos; /* qos info per target */
638 __u32 ltd_index; /* index in lov_obd->tgts */
639 unsigned long ltd_active:1,/* is this target up for requests */
640 ltd_activate:1,/* should this target be activated */
641 ltd_reap:1; /* should this target be deleted */
645 struct lov_desc desc;
646 struct lov_tgt_desc **lov_tgts;
647 struct semaphore lov_lock;
648 struct obd_connect_data lov_ocd;
649 struct lov_qos lov_qos; /* qos info per lov */
650 atomic_t lov_refcount;
651 __u32 lov_tgt_count; /* how many OBD's */
652 __u32 lov_active_tgt_count; /* how many active */
653 __u32 lov_death_row;/* tgts scheduled to be deleted */
654 __u32 lov_tgt_size; /* size of tgts array */
655 __u32 lov_start_idx; /* start index of new inode */
656 __u32 lov_offset_idx; /* aliasing for start_idx */
657 int lov_start_count;/* reseed counter */
661 struct lmv_tgt_desc {
662 struct obd_uuid ltd_uuid;
663 struct obd_export *ltd_exp;
664 int ltd_active; /* is this target up for requests */
666 struct semaphore ltd_fid_sem;
671 struct lu_client_fld lmv_fld;
673 struct lmv_desc desc;
674 struct obd_uuid cluuid;
675 struct obd_export *exp;
682 struct semaphore init_sem;
684 struct lmv_tgt_desc *tgts;
687 struct obd_connect_data *datas;
690 struct obd_connect_data conn_data;
693 struct niobuf_local {
698 cfs_dentry_t *dentry;
703 #define LUSTRE_FLD_NAME "fld"
704 #define LUSTRE_SEQ_NAME "seq"
706 #define LUSTRE_CMM_NAME "cmm"
707 #define LUSTRE_MDD_NAME "mdd"
708 #define LUSTRE_OSD_NAME "osd"
709 #define LUSTRE_LMV_NAME "lmv"
710 #define LUSTRE_CMM_MDC_NAME "cmm-mdc"
712 /* obd device type names */
713 /* FIXME all the references to LUSTRE_MDS_NAME should be swapped with LUSTRE_MDT_NAME */
714 #define LUSTRE_MDS_NAME "mds"
715 #define LUSTRE_MDT_NAME "mdt"
716 #define LUSTRE_MDC_NAME "mdc"
717 #define LUSTRE_OSS_NAME "ost" /* FIXME change name to oss */
718 #define LUSTRE_OST_NAME "obdfilter" /* FIXME change name to ost */
719 #define LUSTRE_OSC_NAME "osc"
720 #define LUSTRE_LOV_NAME "lov"
721 #define LUSTRE_MGS_NAME "mgs"
722 #define LUSTRE_MGC_NAME "mgc"
724 #define LUSTRE_CACHEOBD_NAME "cobd"
725 #define LUSTRE_ECHO_NAME "obdecho"
726 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
728 /* Constant obd names (post-rename) */
729 #define LUSTRE_MDS_OBDNAME "MDS"
730 #define LUSTRE_OSS_OBDNAME "OSS"
731 #define LUSTRE_MGS_OBDNAME "MGS"
732 #define LUSTRE_MGC_OBDNAME "MGC"
734 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
735 #define N_LOCAL_TEMP_PAGE 0x10000000
737 struct obd_trans_info {
740 /* Only used on the server side for tracking acks. */
741 struct oti_req_ack_lock {
742 struct lustre_handle lock;
746 struct llog_cookie oti_onecookie;
747 struct llog_cookie *oti_logcookies;
750 /* initial thread handling transaction */
755 static inline void oti_init(struct obd_trans_info *oti,
756 struct ptlrpc_request *req)
760 memset(oti, 0, sizeof *oti);
765 oti->oti_xid = req->rq_xid;
767 if (req->rq_repmsg && req->rq_reqmsg != 0)
768 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
769 oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
770 oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
773 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
778 if (num_cookies == 1)
779 oti->oti_logcookies = &oti->oti_onecookie;
781 OBD_ALLOC(oti->oti_logcookies,
782 num_cookies * sizeof(oti->oti_onecookie));
784 oti->oti_numcookies = num_cookies;
787 static inline void oti_free_cookies(struct obd_trans_info *oti)
789 if (!oti || !oti->oti_logcookies)
792 if (oti->oti_logcookies == &oti->oti_onecookie)
793 LASSERT(oti->oti_numcookies == 1);
795 OBD_FREE(oti->oti_logcookies,
796 oti->oti_numcookies * sizeof(oti->oti_onecookie));
797 oti->oti_logcookies = NULL;
798 oti->oti_numcookies = 0;
802 * Events signalled through obd_notify() upcall-chain.
804 enum obd_notify_event {
805 /* Device activated */
807 /* Device deactivated */
809 /* Device disconnected */
811 /* Connect data for import were changed */
814 OBD_NOTIFY_SYNC_NONBLOCK,
816 /* Configuration event */
820 /* bit-mask flags for config events */
822 CONFIG_LOG = 0x1, /* finished processing config log */
823 CONFIG_SYNC = 0x2 /* mdt synced 1 ost */
827 * Data structure used to pass obd_notify()-event to non-obd listeners (llite
828 * and liblustre being main examples).
830 struct obd_notify_upcall {
831 int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
832 enum obd_notify_event ev, void *owner);
833 /* Opaque datum supplied by upper layer listener */
837 struct target_recovery_data {
838 svc_handler_t trd_recovery_handler;
839 pid_t trd_processing_task;
840 struct completion trd_starting;
841 struct completion trd_finishing;
844 /* corresponds to one of the obd's */
845 #define MAX_OBD_NAME 128
846 #define OBD_DEVICE_MAGIC 0XAB5CD6EF
848 struct obd_type *obd_type;
851 /* common and UUID name of this device */
852 char obd_name[MAX_OBD_NAME];
853 struct obd_uuid obd_uuid;
855 struct lu_device *obd_lu_dev;
858 unsigned long obd_attached:1, /* finished attach */
859 obd_set_up:1, /* finished setup */
860 obd_recovering:1, /* there are recoverable clients */
861 obd_abort_recovery:1,/* somebody ioctl'ed us to abort */
862 obd_replayable:1, /* recovery is enabled; inform clients */
863 obd_no_transno:1, /* no committed-transno notification */
864 obd_no_recov:1, /* fail instead of retry messages */
865 obd_req_replaying:1, /* replaying requests */
866 obd_stopping:1, /* started cleanup */
867 obd_starting:1, /* started setup */
868 obd_force:1, /* cleanup with > 0 obd refcount */
869 obd_fail:1, /* cleanup with failover */
870 obd_async_recov:1, /* allow asyncronous orphan cleanup */
871 obd_no_conn:1, /* deny new connections */
872 obd_inactive:1; /* device active/inactive
873 * (for /proc/status only!!) */
874 /* uuid-export hash body */
875 struct lustre_class_hash_body *obd_uuid_hash_body;
876 /* nid-export hash body */
877 struct lustre_class_hash_body *obd_nid_hash_body;
878 atomic_t obd_refcount;
879 cfs_waitq_t obd_refcount_waitq;
880 struct list_head obd_exports;
882 struct ldlm_namespace *obd_namespace;
883 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
884 /* a spinlock is OK for what we do now, may need a semaphore later */
885 spinlock_t obd_dev_lock;
886 struct semaphore obd_dev_sem;
887 __u64 obd_last_committed;
888 struct fsfilt_operations *obd_fsops;
889 spinlock_t obd_osfs_lock;
890 struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
892 struct lvfs_run_ctxt obd_lvfs_ctxt;
893 struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
894 struct obd_device *obd_observer;
895 struct obd_notify_upcall obd_upcall;
896 struct obd_export *obd_self_export;
897 /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
898 struct list_head obd_exports_timed;
899 time_t obd_eviction_timer; /* for ping evictor */
901 /* XXX encapsulate all this recovery data into one struct */
902 svc_handler_t obd_recovery_handler;
903 pid_t obd_processing_task;
905 int obd_max_recoverable_clients;
906 int obd_connected_clients;
907 int obd_recoverable_clients;
908 spinlock_t obd_processing_task_lock; /* BH lock (timer) */
909 __u64 obd_next_recovery_transno;
910 int obd_replayed_requests;
911 int obd_requests_queued_for_recovery;
912 cfs_waitq_t obd_next_transno_waitq;
913 struct list_head obd_uncommitted_replies;
914 spinlock_t obd_uncommitted_replies_lock;
915 cfs_timer_t obd_recovery_timer;
916 time_t obd_recovery_start; /* seconds */
917 time_t obd_recovery_end; /* seconds */
918 time_t obd_recovery_max_time; /* seconds, bz13079 */
920 /* new recovery stuff from CMD2 */
921 struct target_recovery_data obd_recovery_data;
922 int obd_replayed_locks;
923 atomic_t obd_req_replay_clients;
924 atomic_t obd_lock_replay_clients;
925 struct list_head obd_req_replay_queue;
926 struct list_head obd_lock_replay_queue;
927 struct list_head obd_final_req_queue;
928 int obd_recovery_stage;
931 struct obd_device_target obt;
932 struct filter_obd filter;
934 struct client_obd cli;
936 struct echo_client_obd echo_client;
937 struct echo_obd echo;
942 /* Fields used by LProcFS */
943 unsigned int obd_cntr_base;
944 struct lprocfs_stats *obd_stats;
946 unsigned int md_cntr_base;
947 struct lprocfs_stats *md_stats;
949 cfs_proc_dir_entry_t *obd_proc_entry;
950 cfs_proc_dir_entry_t *obd_proc_exports;
951 cfs_proc_dir_entry_t *obd_svc_procroot;
952 struct lprocfs_stats *obd_svc_stats;
953 struct semaphore obd_proc_exp_sem;
954 atomic_t obd_evict_inprogress;
955 cfs_waitq_t obd_evict_inprogress_waitq;
958 #define OBD_OPT_FORCE 0x0001
959 #define OBD_OPT_FAILOVER 0x0002
961 #define OBD_LLOG_FL_SENDNOW 0x0001
963 enum obd_cleanup_stage {
964 /* Special case hack for MDS LOVs */
966 /* Precleanup stage 1, we must make sure all exports (other than the
967 self-export) get destroyed. */
969 /* Precleanup stage 2, do other type-specific cleanup requiring the
971 OBD_CLEANUP_SELF_EXP,
972 /* FIXME we should eliminate the "precleanup" function and make them stages
973 of the "cleanup" function. */
977 /* get/set_info keys */
978 #define KEY_READ_ONLY "read-only"
979 #define KEY_MDS_CONN "mds_conn"
980 #define KEY_NEXT_ID "next_id"
981 #define KEY_LOVDESC "lovdesc"
982 #define KEY_INIT_RECOV "initial_recov"
983 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"
984 #define KEY_FLUSH_CTX "flush_ctx"
985 #define KEY_CAPA_KEY "capa_key"
986 #define KEY_CONN_DATA "conn_data"
987 #define KEY_MAX_EASIZE "max_easize"
988 #define KEY_REVIMP_UPD "revimp_update"
989 #define KEY_LOV_IDX "lov_idx"
990 #define KEY_LAST_ID "last_id"
991 #define KEY_LOCK_TO_STRIPE "lock_to_stripe"
992 #define KEY_BLOCKSIZE "blocksize"
993 #define KEY_BLOCKSIZE_BITS "blocksize_bits"
998 struct lu_fid op_fid1; /* operation fid1 (usualy parent) */
999 struct lu_fid op_fid2; /* operation fid2 (usualy child) */
1000 struct lu_fid op_fid3; /* 2 extra fids to find conflicting */
1001 struct lu_fid op_fid4; /* to the operation locks. */
1002 mdsno_t op_mds; /* what mds server open will go to */
1003 struct lustre_handle op_handle;
1005 const char *op_name;
1008 struct lmv_stripe_md *op_mea1;
1009 struct lmv_stripe_md *op_mea2;
1010 __u32 op_suppgids[2];
1016 /* iattr fields and blocks. */
1017 struct iattr op_attr;
1019 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
1020 unsigned int op_attr_flags;
1023 loff_t op_attr_blocks;
1025 /* Size-on-MDS epoch and flags. */
1030 struct obd_capa *op_capa1;
1031 struct obd_capa *op_capa2;
1033 /* Various operation flags. */
1036 /* Operation type */
1041 struct module *o_owner;
1042 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
1043 void *karg, void *uarg);
1044 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
1045 __u32 *vallen, void *val);
1046 int (*o_set_info_async)(struct obd_export *, __u32 keylen, void *key,
1047 __u32 vallen, void *val,
1048 struct ptlrpc_request_set *set);
1049 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
1050 int (*o_detach)(struct obd_device *dev);
1051 int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg);
1052 int (*o_precleanup)(struct obd_device *dev,
1053 enum obd_cleanup_stage cleanup_stage);
1054 int (*o_cleanup)(struct obd_device *dev);
1055 int (*o_process_config)(struct obd_device *dev, obd_count len,
1057 int (*o_postrecov)(struct obd_device *dev);
1058 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
1060 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
1061 /* connect to the target device with given connection
1062 * data. @ocd->ocd_connect_flags is modified to reflect flags actually
1063 * granted by the target, which are guaranteed to be a subset of flags
1064 * asked for. If @ocd == NULL, use default parameters. */
1065 int (*o_connect)(const struct lu_env *env,
1066 struct lustre_handle *conn, struct obd_device *src,
1067 struct obd_uuid *cluuid, struct obd_connect_data *ocd);
1068 int (*o_reconnect)(const struct lu_env *env,
1069 struct obd_export *exp, struct obd_device *src,
1070 struct obd_uuid *cluuid,
1071 struct obd_connect_data *ocd);
1072 int (*o_disconnect)(struct obd_export *exp);
1074 /* Initialize/finalize fids infrastructure. */
1075 int (*o_fid_init)(struct obd_export *exp);
1076 int (*o_fid_fini)(struct obd_export *exp);
1078 /* Allocate new fid according to passed @hint. */
1079 int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
1080 struct md_op_data *op_data);
1083 * Object with @fid is getting deleted, we may want to do something
1086 int (*o_fid_delete)(struct obd_export *exp, const struct lu_fid *fid);
1088 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
1090 int (*o_statfs_async)(struct obd_device *obd, struct obd_info *oinfo,
1091 __u64 max_age, struct ptlrpc_request_set *set);
1092 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
1093 struct lov_stripe_md *mem_src);
1094 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
1095 struct lov_mds_md *disk_src, int disk_len);
1096 int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
1097 struct lov_stripe_md *mem_tgt);
1098 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
1100 /* FIXME: add fid capability support for create & destroy! */
1101 int (*o_precreate)(struct obd_export *exp);
1102 int (*o_create)(struct obd_export *exp, struct obdo *oa,
1103 struct lov_stripe_md **ea, struct obd_trans_info *oti);
1104 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
1105 struct lov_stripe_md *ea, struct obd_trans_info *oti,
1106 struct obd_export *md_exp);
1107 int (*o_setattr)(struct obd_export *exp, struct obd_info *oinfo,
1108 struct obd_trans_info *oti);
1109 int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1110 struct obd_trans_info *oti,
1111 struct ptlrpc_request_set *rqset);
1112 int (*o_getattr)(struct obd_export *exp, struct obd_info *oinfo);
1113 int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1114 struct ptlrpc_request_set *set);
1115 int (*o_brw)(int rw, struct obd_export *exp, struct obd_info *oinfo,
1116 obd_count oa_bufs, struct brw_page *pgarr,
1117 struct obd_trans_info *oti);
1118 int (*o_brw_async)(int rw, struct obd_export *exp,
1119 struct obd_info *oinfo, obd_count oa_bufs,
1120 struct brw_page *pgarr, struct obd_trans_info *oti,
1121 struct ptlrpc_request_set *);
1122 int (*o_prep_async_page)(struct obd_export *exp,
1123 struct lov_stripe_md *lsm,
1124 struct lov_oinfo *loi,
1125 cfs_page_t *page, obd_off offset,
1126 struct obd_async_page_ops *ops, void *data,
1128 int (*o_queue_async_io)(struct obd_export *exp,
1129 struct lov_stripe_md *lsm,
1130 struct lov_oinfo *loi, void *cookie,
1131 int cmd, obd_off off, int count,
1132 obd_flag brw_flags, obd_flag async_flags);
1133 int (*o_queue_group_io)(struct obd_export *exp,
1134 struct lov_stripe_md *lsm,
1135 struct lov_oinfo *loi,
1136 struct obd_io_group *oig,
1137 void *cookie, int cmd, obd_off off, int count,
1138 obd_flag brw_flags, obd_flag async_flags);
1139 int (*o_trigger_group_io)(struct obd_export *exp,
1140 struct lov_stripe_md *lsm,
1141 struct lov_oinfo *loi,
1142 struct obd_io_group *oig);
1143 int (*o_set_async_flags)(struct obd_export *exp,
1144 struct lov_stripe_md *lsm,
1145 struct lov_oinfo *loi, void *cookie,
1146 obd_flag async_flags);
1147 int (*o_teardown_async_page)(struct obd_export *exp,
1148 struct lov_stripe_md *lsm,
1149 struct lov_oinfo *loi, void *cookie);
1150 int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
1151 struct ost_lvb *lvb, int kms_only);
1152 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
1153 obd_off size, int shrink);
1154 int (*o_punch)(struct obd_export *exp, struct obd_info *oinfo,
1155 struct obd_trans_info *oti,
1156 struct ptlrpc_request_set *rqset);
1157 int (*o_sync)(struct obd_export *exp, struct obdo *oa,
1158 struct lov_stripe_md *ea, obd_size start, obd_size end,
1160 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
1161 struct lov_stripe_md *src, obd_size start,
1162 obd_size end, struct obd_trans_info *oti);
1163 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
1164 struct lustre_handle *srconn, struct lov_stripe_md *src,
1165 obd_size start, obd_size end, struct obd_trans_info *);
1166 int (*o_iterate)(struct lustre_handle *conn,
1167 int (*)(obd_id, obd_gr, void *),
1168 obd_id *startid, obd_gr group, void *data);
1169 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
1170 int objcount, struct obd_ioobj *obj,
1171 int niocount, struct niobuf_remote *remote,
1172 struct niobuf_local *local, struct obd_trans_info *oti,
1173 struct lustre_capa *capa);
1174 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
1175 int objcount, struct obd_ioobj *obj,
1176 int niocount, struct niobuf_local *local,
1177 struct obd_trans_info *oti, int rc);
1178 int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo,
1179 struct ldlm_enqueue_info *einfo,
1180 struct ptlrpc_request_set *rqset);
1181 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
1182 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
1183 struct lustre_handle *lockh);
1184 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
1185 ldlm_iterator_t it, void *data);
1186 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
1187 __u32 mode, struct lustre_handle *);
1188 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
1189 int flags, void *opaque);
1190 int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
1192 int (*o_init_export)(struct obd_export *exp);
1193 int (*o_destroy_export)(struct obd_export *exp);
1194 int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *,
1195 int cmd, obd_off *);
1197 /* llog related obd_methods */
1198 int (*o_llog_init)(struct obd_device *obd, struct obd_llogs *llog,
1199 struct obd_device *disk_obd, int count,
1200 struct llog_catid *logid, struct obd_uuid *uuid);
1201 int (*o_llog_finish)(struct obd_device *obd, int count);
1202 int (*o_llog_connect)(struct obd_export *, struct llogd_conn_body *);
1204 /* metadata-only methods */
1205 int (*o_pin)(struct obd_export *, const struct lu_fid *fid,
1206 struct obd_capa *, struct obd_client_handle *, int flag);
1207 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
1209 int (*o_import_event)(struct obd_device *, struct obd_import *,
1210 enum obd_import_event);
1212 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
1213 enum obd_notify_event ev, void *data);
1215 int (*o_health_check)(struct obd_device *);
1218 int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
1219 int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
1221 int (*o_ping)(struct obd_export *exp);
1223 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
1224 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
1225 * Also, add a wrapper function in include/linux/obd_class.h. */
1228 /* TODO: lmv_stripe_md should contain mds capabilities for all slave fids */
1229 struct lmv_stripe_md {
1234 struct lu_fid mea_ids[0];
1238 LUSTRE_OPC_MKDIR = (1 << 0),
1239 LUSTRE_OPC_SYMLINK = (1 << 1),
1240 LUSTRE_OPC_MKNOD = (1 << 2),
1241 LUSTRE_OPC_CREATE = (1 << 3),
1242 LUSTRE_OPC_ANY = (1 << 4)
1245 /* lmv structures */
1246 #define MEA_MAGIC_LAST_CHAR 0xb2221ca1
1247 #define MEA_MAGIC_ALL_CHARS 0xb222a11c
1248 #define MEA_MAGIC_HASH_SEGMENT 0xb222a11b
1250 #define MAX_HASH_SIZE 0x7fffffffUL
1251 #define MAX_HASH_HIGHEST_BIT 0x10000000
1254 struct mdt_body *body;
1255 struct lov_stripe_md *lsm;
1256 struct lmv_stripe_md *mea;
1257 #ifdef CONFIG_FS_POSIX_ACL
1258 struct posix_acl *posix_acl;
1260 struct mdt_remote_perm *remote_perm;
1261 struct obd_capa *mds_capa;
1262 struct obd_capa *oss_capa;
1265 struct md_open_data {
1266 struct obd_client_handle *mod_och;
1267 struct list_head mod_replay_list;
1270 struct lookup_intent;
1273 int (*m_getstatus)(struct obd_export *, struct lu_fid *,
1274 struct obd_capa **);
1275 int (*m_change_cbdata)(struct obd_export *, const struct lu_fid *,
1276 ldlm_iterator_t, void *);
1277 int (*m_close)(struct obd_export *, struct md_op_data *,
1278 struct md_open_data *, struct ptlrpc_request **);
1279 int (*m_create)(struct obd_export *, struct md_op_data *,
1280 const void *, int, int, __u32, __u32, __u32,
1281 __u64, struct ptlrpc_request **);
1282 int (*m_done_writing)(struct obd_export *, struct md_op_data *,
1283 struct md_open_data *);
1284 int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
1285 struct lookup_intent *, struct md_op_data *,
1286 struct lustre_handle *, void *, int, int);
1287 int (*m_getattr)(struct obd_export *, const struct lu_fid *,
1288 struct obd_capa *, obd_valid, int,
1289 struct ptlrpc_request **);
1290 int (*m_getattr_name)(struct obd_export *, const struct lu_fid *,
1291 struct obd_capa *, const char *, int, obd_valid,
1292 int, __u32, struct ptlrpc_request **);
1293 int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
1294 void *, int, struct lookup_intent *, int,
1295 struct ptlrpc_request **,
1296 ldlm_blocking_callback, int);
1297 int (*m_link)(struct obd_export *, struct md_op_data *,
1298 struct ptlrpc_request **);
1299 int (*m_rename)(struct obd_export *, struct md_op_data *,
1300 const char *, int, const char *, int,
1301 struct ptlrpc_request **);
1302 int (*m_is_subdir)(struct obd_export *, const struct lu_fid *,
1303 const struct lu_fid *,
1304 struct ptlrpc_request **);
1305 int (*m_setattr)(struct obd_export *, struct md_op_data *, void *,
1306 int , void *, int, struct ptlrpc_request **,
1307 struct md_open_data **mod);
1308 int (*m_sync)(struct obd_export *, const struct lu_fid *,
1309 struct obd_capa *, struct ptlrpc_request **);
1310 int (*m_readpage)(struct obd_export *, const struct lu_fid *,
1311 struct obd_capa *, __u64, struct page *,
1312 struct ptlrpc_request **);
1314 int (*m_unlink)(struct obd_export *, struct md_op_data *,
1315 struct ptlrpc_request **);
1317 int (*m_setxattr)(struct obd_export *, const struct lu_fid *,
1318 struct obd_capa *, obd_valid, const char *,
1319 const char *, int, int, int, __u32,
1320 struct ptlrpc_request **);
1322 int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
1323 struct obd_capa *, obd_valid, const char *,
1324 const char *, int, int, int,
1325 struct ptlrpc_request **);
1327 int (*m_init_ea_size)(struct obd_export *, int, int, int);
1329 int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
1330 struct obd_export *, struct obd_export *,
1331 struct lustre_md *);
1333 int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
1335 int (*m_set_open_replay_data)(struct obd_export *,
1336 struct obd_client_handle *,
1337 struct ptlrpc_request *);
1338 int (*m_clear_open_replay_data)(struct obd_export *,
1339 struct obd_client_handle *);
1340 int (*m_set_lock_data)(struct obd_export *, __u64 *, void *);
1342 ldlm_mode_t (*m_lock_match)(struct obd_export *, int,
1343 const struct lu_fid *, ldlm_type_t,
1344 ldlm_policy_data_t *, ldlm_mode_t,
1345 struct lustre_handle *);
1347 int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
1348 ldlm_policy_data_t *, ldlm_mode_t, int flags,
1350 int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
1351 renew_capa_cb_t cb);
1353 int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
1354 struct obd_capa *, __u32,
1355 struct ptlrpc_request **);
1358 * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
1359 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
1360 * wrapper function in include/linux/obd_class.h.
1364 struct lsm_operations {
1365 void (*lsm_free)(struct lov_stripe_md *);
1366 int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
1367 struct obd_export *md_exp);
1368 void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
1370 void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
1372 obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
1373 obd_off (*lsm_stripe_offset_by_offset)(struct lov_stripe_md *, obd_off);
1374 int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
1375 int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
1376 int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
1378 int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
1379 struct lov_mds_md *lmm);
1382 extern struct lsm_operations lsm_plain_ops;
1383 extern struct lsm_operations lsm_join_ops;
1384 static inline struct lsm_operations *lsm_op_find(int magic)
1388 return &lsm_plain_ops;
1389 case LOV_MAGIC_JOIN:
1390 return &lsm_join_ops;
1392 CERROR("Cannot recognize lsm_magic %d\n", magic);
1397 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
1399 /* Requests for obd_extent_calc() */
1400 #define OBD_CALC_STRIPE_START 1
1401 #define OBD_CALC_STRIPE_END 2
1403 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
1407 CERROR("%s: transno "LPD64" commit error: %d\n",
1408 obd->obd_name, transno, error);
1411 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
1412 obd->obd_name, transno);
1413 if (transno > obd->obd_last_committed) {
1414 obd->obd_last_committed = transno;
1415 ptlrpc_commit_replies (obd);
1419 static inline void init_obd_quota_ops(quota_interface_t *interface,
1420 struct obd_ops *obd_ops)
1426 obd_ops->o_quotacheck = QUOTA_OP(interface, check);
1427 obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
1430 static inline __u64 oinfo_mdsno(struct obd_info *oinfo)
1432 return oinfo->oi_oa->o_gr - FILTER_GROUP_MDS0;
1435 static inline struct lustre_capa *oinfo_capa(struct obd_info *oinfo)
1437 return oinfo->oi_capa;
1440 #endif /* __OBD_H */