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;
406 struct obd_device *md_osc_obd; /* XXX lov_obd */
407 struct obd_uuid md_lov_uuid;
408 struct obd_export *md_osc_exp; /* XXX lov_exp */
409 struct lov_desc md_lov_desc;
410 obd_id *md_lov_objids;
411 int md_lov_objids_size;
412 __u32 md_lov_objids_in_file;
413 unsigned int md_lov_objids_dirty:1;
414 int md_lov_nextid_set;
415 struct file *md_lov_objid_filp;
416 unsigned long md_lov_objids_valid:1;
419 #define mds_osc_obd mds_lov_info.md_osc_obd
420 #define mds_lov_uuid mds_lov_info.md_lov_uuid
421 #define mds_osc_exp mds_lov_info.md_osc_exp
422 #define mds_lov_desc mds_lov_info.md_lov_desc
423 #define mds_lov_objids mds_lov_info.md_lov_objids
424 #define mds_lov_objids_size mds_lov_info.md_lov_objids_size
425 #define mds_lov_objids_in_file mds_lov_info.md_lov_objids_in_file
426 #define mds_lov_objids_dirty mds_lov_info.md_lov_objids_dirty
427 #define mds_lov_nextid_set mds_lov_info.md_lov_nextid_set
428 #define mds_lov_objid_filp mds_lov_info.md_lov_objid_filp
429 #define mds_lov_objids_valid mds_lov_info.md_lov_objids_valid
432 /* NB this field MUST be first */
433 struct obd_device_target mds_obt;
434 struct ptlrpc_service *mds_service;
435 struct ptlrpc_service *mds_setattr_service;
436 struct ptlrpc_service *mds_readpage_service;
437 struct vfsmount *mds_vfsmnt;
438 cfs_dentry_t *mds_fid_de;
440 int mds_max_cookiesize;
441 struct file *mds_rcvd_filp;
442 spinlock_t mds_transno_lock;
443 __u64 mds_last_transno;
444 __u64 mds_mount_count;
446 unsigned long mds_atime_diff;
447 struct semaphore mds_epoch_sem;
448 struct ll_fid mds_rootfid;
449 struct lr_server_data *mds_server_data;
450 cfs_dentry_t *mds_pending_dir;
451 cfs_dentry_t *mds_logs_dir;
452 cfs_dentry_t *mds_objects_dir;
453 struct llog_handle *mds_cfg_llh;
454 // struct llog_handle *mds_catalog;
455 struct md_lov_info mds_lov_info;
457 struct file *mds_health_check_filp;
458 unsigned long *mds_client_bitmap;
459 struct semaphore mds_orphan_recovery_sem;
460 struct upcall_cache *mds_group_hash;
462 struct lustre_quota_info mds_quota_info;
463 struct semaphore mds_qonoff_sem;
464 struct semaphore mds_health_sem;
465 unsigned long mds_fl_user_xattr:1,
473 struct lustre_handle eo_nl_lock;
478 struct ptlrpc_service *ost_service;
479 struct ptlrpc_service *ost_create_service;
480 struct ptlrpc_service *ost_io_service;
481 struct semaphore ost_health_sem;
484 struct echo_client_obd {
485 struct obd_export *ec_exp; /* the local connection to osc/lov */
487 struct list_head ec_objects;
492 struct lov_tgt_desc {
493 struct obd_uuid uuid;
495 struct obd_export *ltd_exp;
496 unsigned int active:1, /* is this target up for requests */
497 reap:1; /* should this target be deleted */
498 int index; /* index of target array in lov_obd */
499 struct list_head qos_bavail_list; /* link entry to lov_obd */
503 struct semaphore lov_lock;
505 struct lov_desc desc;
506 struct obd_connect_data ocd;
509 int death_row; /* Do we have tgts scheduled to be deleted?
510 (Make this a linked list?) */
511 struct list_head qos_bavail_list; /* tgts list, sorted by available
512 space, protected by lov_lock */
513 struct lov_tgt_desc *tgts;
516 struct lmv_tgt_desc {
517 struct obd_uuid uuid;
518 struct obd_export *ltd_exp;
519 int active; /* is this target up for requests */
525 struct lu_client_fld lmv_fld;
527 struct lmv_desc desc;
528 struct obd_uuid cluuid;
529 struct obd_export *exp;
536 struct semaphore init_sem;
538 struct lmv_tgt_desc *tgts;
541 struct obd_connect_data *datas;
544 struct obd_connect_data conn_data;
547 struct niobuf_local {
552 cfs_dentry_t *dentry;
557 #define LUSTRE_OPC_MKDIR (1 << 0)
558 #define LUSTRE_OPC_SYMLINK (1 << 1)
559 #define LUSTRE_OPC_MKNOD (1 << 2)
560 #define LUSTRE_OPC_CREATE (1 << 3)
562 struct lu_placement_hint {
563 struct qstr *ph_pname;
564 struct qstr *ph_cname;
568 #define LUSTRE_FLD_NAME "fld"
569 #define LUSTRE_SEQ_NAME "seq"
571 /* device types (not names--FIXME) */
572 /* FIXME all the references to these defines need to be updated */
573 #define LUSTRE_MDS_NAME "mds"
574 #define LUSTRE_MDT_NAME "mdt"
576 /* new MDS layers. Prototype */
577 #define LUSTRE_MDT0_NAME "mdt0"
578 #define LUSTRE_CMM0_NAME "cmm0"
579 #define LUSTRE_MDD0_NAME "mdd0"
580 #define LUSTRE_OSD0_NAME "osd0"
581 #define LUSTRE_MDC0_NAME "mdc0"
583 #define LUSTRE_MDC_NAME "mdc"
584 #define LUSTRE_LOV_NAME "lov"
585 #define LUSTRE_LMV_NAME "lmv"
587 /* FIXME just the names need to be changed */
588 #define LUSTRE_OSS_NAME "ost" /* FIXME oss */
589 #define LUSTRE_OST_NAME "obdfilter" /* FIXME ost */
590 #define LUSTRE_OSTSAN_NAME "sanobdfilter"
592 #define LUSTRE_OSC_NAME "osc"
593 #define LUSTRE_FILTER_NAME "filter"
594 #define LUSTRE_SANOSC_NAME "sanosc"
595 #define LUSTRE_SANOST_NAME "sanost"
596 #define LUSTRE_MGS_NAME "mgs"
597 #define LUSTRE_MGC_NAME "mgc"
599 #define LUSTRE_ECHO_NAME "obdecho"
600 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
602 #define LUSTRE_MGS_OBDNAME "MGS"
603 #define LUSTRE_MGC_OBDNAME "MGC"
605 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
606 #define N_LOCAL_TEMP_PAGE 0x10000000
608 struct obd_trans_info {
611 /* Only used on the server side for tracking acks. */
612 struct oti_req_ack_lock {
613 struct lustre_handle lock;
617 struct llog_cookie oti_onecookie;
618 struct llog_cookie *oti_logcookies;
621 /* initial thread handling transaction */
625 static inline void oti_init(struct obd_trans_info *oti,
626 struct ptlrpc_request *req)
630 memset(oti, 0, sizeof *oti);
635 if (req->rq_repmsg && req->rq_reqmsg != 0)
636 oti->oti_transno = req->rq_repmsg->transno;
637 oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
640 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
645 if (num_cookies == 1)
646 oti->oti_logcookies = &oti->oti_onecookie;
648 OBD_ALLOC(oti->oti_logcookies,
649 num_cookies * sizeof(oti->oti_onecookie));
651 oti->oti_numcookies = num_cookies;
654 static inline void oti_free_cookies(struct obd_trans_info *oti)
656 if (!oti || !oti->oti_logcookies)
659 if (oti->oti_logcookies == &oti->oti_onecookie)
660 LASSERT(oti->oti_numcookies == 1);
662 OBD_FREE(oti->oti_logcookies,
663 oti->oti_numcookies * sizeof(oti->oti_onecookie));
664 oti->oti_logcookies = NULL;
665 oti->oti_numcookies = 0;
670 LLOG_CONFIG_ORIG_CTXT = 0,
671 LLOG_CONFIG_REPL_CTXT = 1,
672 LLOG_MDS_OST_ORIG_CTXT = 2,
673 LLOG_MDS_OST_REPL_CTXT = 3,
674 LLOG_SIZE_ORIG_CTXT = 4,
675 LLOG_SIZE_REPL_CTXT = 5,
676 LLOG_MD_ORIG_CTXT = 6,
677 LLOG_MD_REPL_CTXT = 7,
678 LLOG_RD1_ORIG_CTXT = 8,
679 LLOG_RD1_REPL_CTXT = 9,
680 LLOG_TEST_ORIG_CTXT = 10,
681 LLOG_TEST_REPL_CTXT = 11,
682 LLOG_LOVEA_ORIG_CTXT = 12,
683 LLOG_LOVEA_REPL_CTXT = 13,
688 * Events signalled through obd_notify() upcall-chain.
690 enum obd_notify_event {
691 /* Device activated */
693 /* Device deactivated */
695 /* Connect data for import were changed */
698 OBD_NOTIFY_SYNC_NONBLOCK,
702 #include <lu_object.h>
704 * Data structure used to pass obd_notify()-event to non-obd listeners (llite
705 * and liblustre being main examples).
707 struct obd_notify_upcall {
708 int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
709 enum obd_notify_event ev, void *owner);
710 /* Opaque datum supplied by upper layer listener */
714 /* corresponds to one of the obd's */
716 struct obd_type *obd_type;
717 /* common and UUID name of this device */
719 struct obd_uuid obd_uuid;
721 struct lu_device *obd_lu_dev;
724 unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
725 obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
726 obd_no_recov:1, obd_stopping:1, obd_starting:1,
727 obd_force:1, obd_fail:1, obd_async_recov:1;
728 atomic_t obd_refcount;
729 cfs_waitq_t obd_refcount_waitq;
730 cfs_proc_dir_entry_t *obd_proc_entry;
731 struct list_head obd_exports;
733 struct ldlm_namespace *obd_namespace;
734 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
735 /* a spinlock is OK for what we do now, may need a semaphore later */
736 spinlock_t obd_dev_lock;
737 __u64 obd_last_committed;
738 struct fsfilt_operations *obd_fsops;
739 spinlock_t obd_osfs_lock;
740 struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
741 cfs_time_t obd_osfs_age;
742 struct lvfs_run_ctxt obd_lvfs_ctxt;
743 struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
744 struct obd_device *obd_observer;
745 struct obd_notify_upcall obd_upcall;
746 struct obd_export *obd_self_export;
747 /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
748 struct list_head obd_exports_timed;
749 time_t obd_eviction_timer; /* for ping evictor */
751 /* XXX encapsulate all this recovery data into one struct */
752 svc_handler_t obd_recovery_handler;
753 int obd_max_recoverable_clients;
754 int obd_connected_clients;
755 int obd_recoverable_clients;
756 spinlock_t obd_processing_task_lock;
757 pid_t obd_processing_task;
758 __u64 obd_next_recovery_transno;
759 int obd_replayed_requests;
760 int obd_requests_queued_for_recovery;
761 cfs_waitq_t obd_next_transno_waitq;
762 struct list_head obd_uncommitted_replies;
763 spinlock_t obd_uncommitted_replies_lock;
764 cfs_timer_t obd_recovery_timer;
765 struct list_head obd_recovery_queue;
766 struct list_head obd_delayed_reply_queue;
767 time_t obd_recovery_start;
768 time_t obd_recovery_end;
771 struct obd_device_target obt;
772 struct filter_obd filter;
774 struct client_obd cli;
776 struct echo_client_obd echo_client;
777 struct echo_obd echo;
782 /* Fields used by LProcFS */
783 unsigned int obd_cntr_base;
784 struct lprocfs_stats *obd_stats;
786 unsigned int md_cntr_base;
787 struct lprocfs_stats *md_stats;
789 cfs_proc_dir_entry_t *obd_svc_procroot;
790 struct lprocfs_stats *obd_svc_stats;
793 #define OBD_OPT_FORCE 0x0001
794 #define OBD_OPT_FAILOVER 0x0002
796 #define OBD_LLOG_FL_SENDNOW 0x0001
798 enum obd_cleanup_stage {
799 /* Special case hack for MDS LOVs */
801 /* Precleanup stage 1, we must make sure all exports (other than the
802 self-export) get destroyed. */
804 /* Precleanup stage 2, do other type-specific cleanup requiring the
806 OBD_CLEANUP_SELF_EXP,
807 /* FIXME we should eliminate the "precleanup" function and make them stages
808 of the "cleanup" function. */
812 /* get/set_info keys */
813 #define KEY_MDS_CONN "mds_conn"
814 #define KEY_NEXT_ID "next_id"
815 #define KEY_LOVDESC "lovdesc"
816 #define KEY_INIT_RECOV "initial_recov"
817 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"
820 struct module *o_owner;
821 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
822 void *karg, void *uarg);
823 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
824 __u32 *vallen, void *val);
825 int (*o_set_info_async)(struct obd_export *, __u32 keylen, void *key,
826 __u32 vallen, void *val,
827 struct ptlrpc_request_set *set);
828 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
829 int (*o_detach)(struct obd_device *dev);
830 int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg);
831 int (*o_precleanup)(struct obd_device *dev,
832 enum obd_cleanup_stage cleanup_stage);
833 int (*o_cleanup)(struct obd_device *dev);
834 int (*o_process_config)(struct obd_device *dev, obd_count len,
836 int (*o_postrecov)(struct obd_device *dev);
837 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
839 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
840 /* connect to the target device with given connection
841 * data. @ocd->ocd_connect_flags is modified to reflect flags actually
842 * granted by the target, which are guaranteed to be a subset of flags
843 * asked for. If @ocd == NULL, use default parameters. */
844 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
845 struct obd_uuid *cluuid, struct obd_connect_data *ocd);
846 int (*o_reconnect)(struct obd_export *exp, struct obd_device *src,
847 struct obd_uuid *cluuid,
848 struct obd_connect_data *ocd);
849 int (*o_disconnect)(struct obd_export *exp);
851 /* maybe later these should be moved into separate fid_ops */
852 int (*o_fid_init)(struct obd_export *exp);
853 int (*o_fid_fini)(struct obd_export *exp);
855 int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
856 struct lu_placement_hint *hint);
858 int (*o_fid_delete)(struct obd_export *exp, struct lu_fid *fid);
860 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
861 unsigned long max_age);
862 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
863 struct lov_stripe_md *mem_src);
864 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
865 struct lov_mds_md *disk_src, int disk_len);
866 int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
867 struct lov_stripe_md *mem_tgt);
868 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
870 int (*o_create)(struct obd_export *exp, struct obdo *oa,
871 struct lov_stripe_md **ea, struct obd_trans_info *oti);
872 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
873 struct lov_stripe_md *ea, struct obd_trans_info *oti,
874 struct obd_export *md_exp);
875 int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
876 struct lov_stripe_md *ea, struct obd_trans_info *oti);
877 int (*o_setattr_async)(struct obd_export *exp, struct obdo *oa,
878 struct lov_stripe_md *ea, struct obd_trans_info *oti);
879 int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
880 struct lov_stripe_md *ea);
881 int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
882 struct lov_stripe_md *ea,
883 struct ptlrpc_request_set *set);
884 int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
885 struct lov_stripe_md *ea, obd_count oa_bufs,
886 struct brw_page *pgarr, struct obd_trans_info *oti);
887 int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
888 struct lov_stripe_md *ea, obd_count oa_bufs,
889 struct brw_page *pgarr, struct ptlrpc_request_set *,
890 struct obd_trans_info *oti);
891 int (*o_prep_async_page)(struct obd_export *exp,
892 struct lov_stripe_md *lsm,
893 struct lov_oinfo *loi,
894 struct page *page, obd_off offset,
895 struct obd_async_page_ops *ops, void *data,
897 int (*o_queue_async_io)(struct obd_export *exp,
898 struct lov_stripe_md *lsm,
899 struct lov_oinfo *loi, void *cookie,
900 int cmd, obd_off off, int count,
901 obd_flag brw_flags, obd_flag async_flags);
902 int (*o_queue_group_io)(struct obd_export *exp,
903 struct lov_stripe_md *lsm,
904 struct lov_oinfo *loi,
905 struct obd_io_group *oig,
906 void *cookie, int cmd, obd_off off, int count,
907 obd_flag brw_flags, obd_flag async_flags);
908 int (*o_trigger_group_io)(struct obd_export *exp,
909 struct lov_stripe_md *lsm,
910 struct lov_oinfo *loi,
911 struct obd_io_group *oig);
912 int (*o_set_async_flags)(struct obd_export *exp,
913 struct lov_stripe_md *lsm,
914 struct lov_oinfo *loi, void *cookie,
915 obd_flag async_flags);
916 int (*o_teardown_async_page)(struct obd_export *exp,
917 struct lov_stripe_md *lsm,
918 struct lov_oinfo *loi, void *cookie);
919 int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
920 struct ost_lvb *lvb, int kms_only);
921 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
922 obd_off size, int shrink);
923 int (*o_punch)(struct obd_export *exp, struct obdo *oa,
924 struct lov_stripe_md *ea, obd_size start,
925 obd_size end, struct obd_trans_info *oti);
926 int (*o_sync)(struct obd_export *exp, struct obdo *oa,
927 struct lov_stripe_md *ea, obd_size start, obd_size end);
928 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
929 struct lov_stripe_md *src, obd_size start,
930 obd_size end, struct obd_trans_info *oti);
931 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
932 struct lustre_handle *srconn, struct lov_stripe_md *src,
933 obd_size start, obd_size end, struct obd_trans_info *);
934 int (*o_iterate)(struct lustre_handle *conn,
935 int (*)(obd_id, obd_gr, void *),
936 obd_id *startid, obd_gr group, void *data);
937 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
938 int objcount, struct obd_ioobj *obj,
939 int niocount, struct niobuf_remote *remote,
940 struct niobuf_local *local, struct obd_trans_info *oti);
941 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
942 int objcount, struct obd_ioobj *obj,
943 int niocount, struct niobuf_local *local,
944 struct obd_trans_info *oti, int rc);
945 int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
946 __u32 type, ldlm_policy_data_t *, __u32 mode,
947 int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
948 void *data, __u32 lvb_len, void *lvb_swabber,
949 struct lustre_handle *lockh);
950 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
951 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
952 struct lustre_handle *lockh);
953 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
954 ldlm_iterator_t it, void *data);
955 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
956 __u32 mode, struct lustre_handle *);
957 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
958 int flags, void *opaque);
959 int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
961 int (*o_san_preprw)(int cmd, struct obd_export *exp,
962 struct obdo *oa, int objcount,
963 struct obd_ioobj *obj, int niocount,
964 struct niobuf_remote *remote);
965 int (*o_init_export)(struct obd_export *exp);
966 int (*o_destroy_export)(struct obd_export *exp);
968 /* llog related obd_methods */
969 int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
970 int count, struct llog_catid *logid);
971 int (*o_llog_finish)(struct obd_device *obd, int count);
973 /* metadata-only methods */
974 int (*o_pin)(struct obd_export *, struct lu_fid *fid,
975 struct obd_client_handle *, int flag);
976 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
978 int (*o_import_event)(struct obd_device *, struct obd_import *,
979 enum obd_import_event);
981 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
982 enum obd_notify_event ev, void *data);
984 int (*o_health_check)(struct obd_device *);
987 int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
988 int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
991 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
992 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
993 * Also, add a wrapper function in include/linux/obd_class.h.
995 * Also note that if you add it to the END, you also have to change
996 * the num_stats calculation.
1002 int (*m_getstatus)(struct obd_export *, struct lu_fid *);
1003 int (*m_change_cbdata)(struct obd_export *, struct lu_fid *,
1004 ldlm_iterator_t, void *);
1005 int (*m_close)(struct obd_export *, struct md_op_data *,
1006 struct obd_client_handle *, struct ptlrpc_request **);
1007 int (*m_create)(struct obd_export *, struct md_op_data *,
1008 const void *, int, int, __u32, __u32, __u32,
1009 __u64, struct ptlrpc_request **);
1010 int (*m_done_writing)(struct obd_export *, struct md_op_data *);
1011 int (*m_enqueue)(struct obd_export *, int, struct lookup_intent *,
1012 int, struct md_op_data *, struct lustre_handle *,
1013 void *, int, ldlm_completion_callback,
1014 ldlm_blocking_callback, void *, int);
1015 int (*m_getattr)(struct obd_export *, struct lu_fid *,
1016 obd_valid, int, struct ptlrpc_request **);
1017 int (*m_getattr_name)(struct obd_export *, struct lu_fid *,
1018 const char *, int, obd_valid,
1019 int, struct ptlrpc_request **);
1020 int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
1021 void *, int, struct lookup_intent *, int,
1022 struct ptlrpc_request **,
1023 ldlm_blocking_callback, int);
1024 int (*m_link)(struct obd_export *, struct md_op_data *,
1025 struct ptlrpc_request **);
1026 int (*m_rename)(struct obd_export *, struct md_op_data *,
1027 const char *, int, const char *, int,
1028 struct ptlrpc_request **);
1029 int (*m_setattr)(struct obd_export *, struct md_op_data *,
1030 struct iattr *, void *, int , void *, int,
1031 struct ptlrpc_request **);
1032 int (*m_sync)(struct obd_export *, struct lu_fid *,
1033 struct ptlrpc_request **);
1034 int (*m_readpage)(struct obd_export *, struct lu_fid *,
1035 __u64, struct page *, struct ptlrpc_request **);
1036 int (*m_unlink)(struct obd_export *, struct md_op_data *,
1037 struct ptlrpc_request **);
1039 int (*m_setxattr)(struct obd_export *, struct lu_fid *,
1040 obd_valid, const char *, const char *,
1041 int, int, int, struct ptlrpc_request **);
1043 int (*m_getxattr)(struct obd_export *, struct lu_fid *,
1044 obd_valid, const char *, const char *,
1045 int, int, int, struct ptlrpc_request **);
1047 int (*m_init_ea_size)(struct obd_export *, int, int, int);
1049 int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
1050 int, struct obd_export *, struct lustre_md *);
1052 int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
1054 int (*m_set_open_replay_data)(struct obd_export *,
1055 struct obd_client_handle *,
1056 struct ptlrpc_request *);
1057 int (*m_clear_open_replay_data)(struct obd_export *,
1058 struct obd_client_handle *);
1059 int (*m_set_lock_data)(struct obd_export *, __u64 *, void *);
1061 int (*m_lock_match)(struct obd_export *, int, struct lu_fid *,
1062 ldlm_type_t, ldlm_policy_data_t *, ldlm_mode_t,
1063 struct lustre_handle *);
1065 int (*m_cancel_unused)(struct obd_export *, struct lu_fid *,
1066 int flags, void *opaque);
1069 * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
1070 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
1071 * wrapper function in include/linux/obd_class.h.
1075 struct lsm_operations {
1076 void (*lsm_free)(struct lov_stripe_md *);
1077 int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
1078 struct obd_export *md_exp);
1079 void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
1081 void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
1083 obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
1084 int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
1085 int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
1086 int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
1088 int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
1089 struct lov_mds_md *lmm);
1092 extern struct lsm_operations lsm_plain_ops;
1093 extern struct lsm_operations lsm_join_ops;
1094 static inline struct lsm_operations *lsm_op_find(int magic)
1098 return &lsm_plain_ops;
1099 case LOV_MAGIC_JOIN:
1100 return &lsm_join_ops;
1102 CERROR("Cannot recognize lsm_magic %d", magic);
1107 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
1109 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
1113 CERROR("%s: transno "LPD64" commit error: %d\n",
1114 obd->obd_name, transno, error);
1117 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
1118 obd->obd_name, transno);
1119 if (transno > obd->obd_last_committed) {
1120 obd->obd_last_committed = transno;
1121 ptlrpc_commit_replies (obd);
1125 static inline void init_obd_quota_ops(quota_interface_t *interface,
1126 struct obd_ops *obd_ops)
1132 obd_ops->o_quotacheck = QUOTA_OP(interface, check);
1133 obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
1136 #endif /* __OBD_H */