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