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_lib.h>
31 #include <lustre/lustre_idl.h>
32 #include <lustre_export.h>
33 #include <lustre_quota.h>
35 #define MAX_OBD_DEVICES 8192
37 /* this is really local to the OSC */
38 struct loi_oap_pages {
39 struct list_head lop_pending;
40 struct list_head lop_urgent;
41 struct list_head lop_pending_group;
51 struct lov_oinfo { /* per-stripe data structure */
52 __u64 loi_id; /* object ID on the target OST */
53 __u64 loi_gr; /* object group on the target OST */
54 int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
55 int loi_ost_gen; /* generation of this loi_ost_idx */
57 /* used by the osc to keep track of what objects to build into rpcs */
58 struct loi_oap_pages loi_read_lop;
59 struct loi_oap_pages loi_write_lop;
60 /* _cli_ is poorly named, it should be _ready_ */
61 struct list_head loi_cli_item;
62 struct list_head loi_write_item;
63 struct list_head loi_read_item;
65 unsigned loi_kms_valid:1;
66 __u64 loi_kms; /* known minimum size */
67 struct ost_lvb loi_lvb;
68 struct osc_async_rc loi_ar;
71 static inline void loi_init(struct lov_oinfo *loi)
73 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
74 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
75 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
76 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
77 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
78 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
79 CFS_INIT_LIST_HEAD(&loi->loi_cli_item);
80 CFS_INIT_LIST_HEAD(&loi->loi_write_item);
81 CFS_INIT_LIST_HEAD(&loi->loi_read_item);
84 /*extent array item for describing the joined file extent info*/
86 __u64 le_start; /* extent start */
87 __u64 le_len; /* extent length */
88 int le_loi_idx; /* extent #1 loi's index in lsm loi array */
89 int le_stripe_count; /* extent stripe count*/
92 /*Lov array info for describing joined file array EA info*/
93 struct lov_array_info {
94 struct llog_logid lai_array_id; /* MDS med llog object id */
95 unsigned lai_ext_count; /* number of extent count */
96 struct lov_extent *lai_ext_array; /* extent desc array */
99 struct lov_stripe_md {
101 void *lsm_lock_owner; /* debugging */
104 /* Public members. */
105 __u64 lw_object_id; /* lov object id */
106 __u64 lw_object_gr; /* lov object group */
107 __u64 lw_maxbytes; /* maximum possible file size */
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_magic lsm_wire.lw_magic
124 #define lsm_stripe_size lsm_wire.lw_stripe_size
125 #define lsm_pattern lsm_wire.lw_pattern
126 #define lsm_stripe_count lsm_wire.lw_stripe_count
130 typedef int (*obd_enqueue_update_f)(struct obd_info *oinfo, int rc);
132 /* obd info for a particular level (lov, osc). */
134 /* Lock policy. It keeps an extent which is specific for a particular
135 * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy,
136 * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */
137 ldlm_policy_data_t oi_policy;
138 /* Flags used while lock handling. The flags obtained on the enqueue
139 * request are set here, therefore they are request specific. */
141 /* Lock handle specific for every OSC lock. */
142 struct lustre_handle *oi_lockh;
143 /* lsm data specific for every OSC. */
144 struct lov_stripe_md *oi_md;
145 /* obdo data specific for every OSC, if needed at all. */
147 /* statfs data specific for every OSC, if needed at all. */
148 struct obd_statfs *oi_osfs;
149 /* An update callback which is called to update some data on upper
150 * level. E.g. it is used for update lsm->lsm_oinfo at every recieved
151 * request in osc level for enqueue requests. It is also possible to
152 * update some caller data from LOV layer if needed. */
153 obd_enqueue_update_f oi_cb_up;
156 /* compare all relevant fields. */
157 static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
158 struct lov_stripe_md *m2)
161 * ->lsm_wire contains padding, but it should be zeroed out during
164 return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof m1->lsm_wire);
167 void lov_stripe_lock(struct lov_stripe_md *md);
168 void lov_stripe_unlock(struct lov_stripe_md *md);
171 struct list_head typ_chain;
172 struct obd_ops *typ_ops;
173 cfs_proc_dir_entry_t *typ_procroot;
176 spinlock_t obd_type_lock;
187 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
188 page is added to an rpc */
189 ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
190 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
191 to give the caller a chance to update
192 or cancel the size of the io */
193 ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
194 the page is accounted for in the
195 obd_io_group given to
196 obd_queue_group_io */
199 struct obd_async_page_ops {
200 int (*ap_make_ready)(void *data, int cmd);
201 int (*ap_refresh_count)(void *data, int cmd);
202 void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
203 void (*ap_update_obdo)(void *data, int cmd, struct obdo *oa,
205 int (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
208 /* the `oig' is passed down from a caller of obd rw methods. the callee
209 * records enough state such that the caller can sleep on the oig and
210 * be woken when all the callees have finished their work */
211 struct obd_io_group {
213 atomic_t oig_refcount;
216 struct list_head oig_occ_list;
217 cfs_waitq_t oig_waitq;
220 /* the oig callback context lets the callee of obd rw methods register
221 * for callbacks from the caller. */
222 struct oig_callback_context {
223 struct list_head occ_oig_item;
224 /* called when the caller has received a signal while sleeping.
225 * callees of this method are encouraged to abort their state
226 * in the oig. This may be called multiple times. */
227 void (*occ_interrupted)(struct oig_callback_context *occ);
228 unsigned int interrupted:1;
231 /* Individual type definitions */
233 struct ost_server_data;
235 /* hold common fields for "target" device */
236 struct obd_device_target {
237 struct super_block *obt_sb;
238 atomic_t obt_quotachecking;
239 struct lustre_quota_ctxt obt_qctxt;
242 #define FILTER_GROUP_LLOG 1
243 #define FILTER_GROUP_ECHO 2
251 /* NB this field MUST be first */
252 struct obd_device_target fo_obt;
253 const char *fo_fstype;
254 struct vfsmount *fo_vfsmnt;
255 cfs_dentry_t *fo_dentry_O;
256 cfs_dentry_t **fo_dentry_O_groups;
257 cfs_dentry_t **fo_dentry_O_sub;
258 spinlock_t fo_objidlock; /* protect fo_lastobjid */
259 spinlock_t fo_translock; /* protect fsd_last_transno */
260 struct file *fo_rcvd_filp;
261 struct file *fo_health_check_filp;
262 struct lr_server_data *fo_fsd;
263 unsigned long *fo_last_rcvd_slots;
264 __u64 fo_mount_count;
266 int fo_destroy_in_progress;
267 struct semaphore fo_create_lock;
269 struct list_head fo_export_list;
272 obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
273 obd_size fo_tot_granted; /* all values in bytes */
274 obd_size fo_tot_pending;
276 obd_size fo_readcache_max_filesize;
278 struct obd_import *fo_mdc_imp;
279 struct obd_uuid fo_mdc_uuid;
280 struct lustre_handle fo_mdc_conn;
281 struct file **fo_last_objid_files;
282 __u64 *fo_last_objids; /* last created objid for groups,
283 * protected by fo_objidlock */
285 struct semaphore fo_alloc_lock;
287 atomic_t fo_r_in_flight;
288 atomic_t fo_w_in_flight;
291 * per-filter pool of kiobuf's allocated by filter_common_setup() and
292 * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
293 * which ->fo_iobuf_count were allocated.
295 * This pool contains kiobuf used by
296 * filter_{prep,commit}rw_{read,write}() and is shared by all OST
299 * Locking: none, each OST thread uses only one element, determined by
300 * its "ordinal number", ->t_id.
302 struct filter_iobuf **fo_iobuf_pool;
305 struct brw_stats fo_filter_stats;
306 struct lustre_quota_ctxt fo_quota_ctxt;
307 spinlock_t fo_quotacheck_lock;
308 atomic_t fo_quotachecking;
310 int fo_fmd_max_num; /* per exp filter_mod_data */
311 int fo_fmd_max_age; /* jiffies to fmd expiry */
314 #define OSC_MAX_RIF_DEFAULT 8
315 #define OSC_MAX_RIF_MAX 256
316 #define OSC_MAX_DIRTY_DEFAULT (OSC_MAX_RIF_DEFAULT * 4)
317 #define OSC_MAX_DIRTY_MB_MAX 2048 /* arbitrary, but < MAX_LONG bytes */
319 #define MDC_MAX_RIF_DEFAULT 8
320 #define MDC_MAX_RIF_MAX 512
325 struct semaphore cl_sem;
326 struct obd_uuid cl_target_uuid;
327 struct obd_import *cl_import; /* ptlrpc connection state */
329 /* max_mds_easize is purely a performance thing so we don't have to
330 * call obd_size_diskmd() all the time. */
331 int cl_default_mds_easize;
332 int cl_max_mds_easize;
333 int cl_max_mds_cookiesize;
335 //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
336 void *cl_llcd_offset;
338 /* the grant values are protected by loi_list_lock below */
339 long cl_dirty; /* all _dirty_ in bytes */
340 long cl_dirty_max; /* allowed w/o rpc */
341 long cl_avail_grant; /* bytes of credit for ost */
342 long cl_lost_grant; /* lost credits (trunc) */
343 struct list_head cl_cache_waiters; /* waiting for cache/grant */
345 /* keep track of objects that have lois that contain pages which
346 * have been queued for async brw. this lock also protects the
347 * lists of osc_client_pages that hang off of the loi */
349 * ->cl_loi_list_lock protects consistency of
350 * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
351 * ->ap_completion() call-backs are executed under this lock. As we
352 * cannot guarantee that these call-backs never block on all platforms
353 * (as a matter of fact they do block on Mac OS X), type of
354 * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
355 * and blocking mutex on Mac OS X. (Alternative is to make this lock
356 * blocking everywhere, but we don't want to slow down fast-path of
357 * our main platform.)
359 * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
360 * with client_obd_list_{un,}lock() and
361 * client_obd_list_lock_{init,done}() functions.
363 client_obd_lock_t cl_loi_list_lock;
364 struct list_head cl_loi_ready_list;
365 struct list_head cl_loi_write_list;
366 struct list_head cl_loi_read_list;
369 /* just a sum of the loi/lop pending numbers to be exported by /proc */
370 int cl_pending_w_pages;
371 int cl_pending_r_pages;
372 int cl_max_pages_per_rpc;
373 int cl_max_rpcs_in_flight;
374 struct obd_histogram cl_read_rpc_hist;
375 struct obd_histogram cl_write_rpc_hist;
376 struct obd_histogram cl_read_page_hist;
377 struct obd_histogram cl_write_page_hist;
378 struct obd_histogram cl_read_offset_hist;
379 struct obd_histogram cl_write_offset_hist;
381 struct mdc_rpc_lock *cl_rpc_lock;
382 struct mdc_rpc_lock *cl_setattr_lock;
383 struct mdc_rpc_lock *cl_close_lock;
384 struct osc_creator cl_oscc;
387 struct semaphore cl_mgc_sem;
388 struct vfsmount *cl_mgc_vfsmnt;
389 struct dentry *cl_mgc_configs_dir;
390 atomic_t cl_mgc_refcount;
391 struct obd_export *cl_mgc_mgsexp;
394 unsigned int cl_checksum:1; /* debug checksums */
396 /* also protected by the poorly named _loi_list_lock lock above */
397 struct osc_async_rc cl_ar;
399 /* used by quotacheck */
400 int cl_qchk_stat; /* quotacheck stat of the peer */
402 #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
404 #define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */
407 struct ptlrpc_service *mgs_service;
408 struct vfsmount *mgs_vfsmnt;
409 struct super_block *mgs_sb;
410 struct dentry *mgs_configs_dir;
411 struct dentry *mgs_fid_de;
412 struct list_head mgs_fs_db_list;
413 struct semaphore mgs_sem;
414 cfs_proc_dir_entry_t *mgs_proc_live;
418 /* NB this field MUST be first */
419 struct obd_device_target mds_obt;
420 struct ptlrpc_service *mds_service;
421 struct ptlrpc_service *mds_setattr_service;
422 struct ptlrpc_service *mds_readpage_service;
423 struct vfsmount *mds_vfsmnt;
424 cfs_dentry_t *mds_fid_de;
426 int mds_max_cookiesize;
427 struct file *mds_rcvd_filp;
428 spinlock_t mds_transno_lock;
429 __u64 mds_last_transno;
430 __u64 mds_mount_count;
432 unsigned long mds_atime_diff;
433 struct semaphore mds_epoch_sem;
434 struct ll_fid mds_rootfid;
435 struct lr_server_data *mds_server_data;
436 cfs_dentry_t *mds_pending_dir;
437 cfs_dentry_t *mds_logs_dir;
438 cfs_dentry_t *mds_objects_dir;
439 struct llog_handle *mds_cfg_llh;
440 // struct llog_handle *mds_catalog;
441 struct obd_device *mds_osc_obd; /* XXX lov_obd */
442 struct obd_uuid mds_lov_uuid;
444 struct obd_export *mds_osc_exp; /* XXX lov_exp */
445 struct lov_desc mds_lov_desc;
446 obd_id *mds_lov_objids;
447 int mds_lov_objids_size;
448 __u32 mds_lov_objids_in_file;
449 unsigned int mds_lov_objids_dirty:1;
450 int mds_lov_nextid_set;
451 struct file *mds_lov_objid_filp;
452 struct file *mds_health_check_filp;
453 unsigned long *mds_client_bitmap;
454 struct upcall_cache *mds_group_hash;
456 struct lustre_quota_info mds_quota_info;
457 struct semaphore mds_qonoff_sem;
458 struct semaphore mds_health_sem;
459 unsigned long mds_lov_objids_valid:1,
468 struct lustre_handle eo_nl_lock;
473 struct ptlrpc_service *ost_service;
474 struct ptlrpc_service *ost_create_service;
475 struct ptlrpc_service *ost_io_service;
476 struct semaphore ost_health_sem;
479 struct echo_client_obd {
480 struct obd_export *ec_exp; /* the local connection to osc/lov */
482 struct list_head ec_objects;
488 struct obd_uuid lqo_uuid; /* ptlrpc's c_remote_uuid */
489 struct list_head lqo_oss_list; /* link to lov_qos */
490 __u32 lqo_ost_count; /* number of osts on this oss */
491 __u64 lqo_bavail; /* total bytes avail on OSS */
492 __u64 lqo_penalty; /* current penalty */
493 __u64 lqo_penalty_per_obj; /* penalty decrease every obj*/
497 struct lov_qos_oss *ltq_oss; /* oss info */
498 __u64 ltq_penalty; /* current penalty */
499 __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/
500 __u64 ltq_weight; /* net weighting */
501 unsigned int ltq_usable:1; /* usable for striping */
505 struct list_head lq_oss_list; /* list of OSSs that targets use */
506 struct rw_semaphore lq_rw_sem;
507 __u32 lq_active_oss_count;
508 __u32 *lq_rr_array; /* round-robin optimized list */
509 unsigned int lq_rr_size; /* rr array size */
510 unsigned int lq_prio_free; /* priority for free space */
511 unsigned int lq_dirty:1, /* recalc qos data */
512 lq_dirty_rr:1, /* recalc round-robin list */
513 lq_same_space:1,/* the ost's all have approx.
514 the same space avail */
515 lq_reset:1; /* zero current penalties */
518 struct lov_tgt_desc {
519 struct obd_uuid ltd_uuid;
520 struct obd_export *ltd_exp;
521 struct ltd_qos ltd_qos; /* qos info per target */
523 __u32 ltd_index; /* index in lov_obd->tgts */
524 unsigned int ltd_active:1,/* is this target up for requests */
525 ltd_activate:1,/* should this target be activated */
526 ltd_reap:1; /* should this target be deleted */
530 struct lov_desc desc;
531 struct lov_tgt_desc **lov_tgts;
532 struct semaphore lov_lock;
533 struct obd_connect_data lov_ocd;
534 struct lov_qos lov_qos; /* qos info per lov */
535 atomic_t lov_refcount;
536 __u32 lov_tgt_count; /* how many OBD's */
537 __u32 lov_active_tgt_count; /* how many active */
538 __u32 lov_death_row;/* tgts scheduled to be deleted */
539 __u32 lov_tgt_size; /* size of tgts array */
540 __u32 lov_start_idx; /* start index of new inode */
541 __u32 lov_offset_idx; /* aliasing for start_idx */
542 int lov_start_count;/* reseed counter */
546 struct niobuf_local {
551 cfs_dentry_t *dentry;
556 /* obd device type names */
557 /* FIXME all the references to LUSTRE_MDS_NAME should be swapped with LUSTRE_MDT_NAME */
558 #define LUSTRE_MDS_NAME "mds"
559 #define LUSTRE_MDT_NAME "mdt"
560 #define LUSTRE_MDC_NAME "mdc"
561 #define LUSTRE_OSS_NAME "ost" /*FIXME change name to oss*/
562 #define LUSTRE_OST_NAME "obdfilter" /* FIXME change name to ost*/
563 #define LUSTRE_OSC_NAME "osc"
564 #define LUSTRE_LOV_NAME "lov"
565 #define LUSTRE_MGS_NAME "mgs"
566 #define LUSTRE_MGC_NAME "mgc"
568 #define LUSTRE_CACHEOBD_NAME "cobd"
569 #define LUSTRE_ECHO_NAME "obdecho"
570 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
572 /* Constant obd names (post-rename) */
573 #define LUSTRE_MDS_OBDNAME "MDS"
574 #define LUSTRE_OSS_OBDNAME "OSS"
575 #define LUSTRE_MGS_OBDNAME "MGS"
576 #define LUSTRE_MGC_OBDNAME "MGC"
578 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
579 #define N_LOCAL_TEMP_PAGE 0x10000000
581 struct obd_trans_info {
585 /* Only used on the server side for tracking acks. */
586 struct oti_req_ack_lock {
587 struct lustre_handle lock;
591 struct llog_cookie oti_onecookie;
592 struct llog_cookie *oti_logcookies;
595 /* initial thread handling transaction */
600 static inline void oti_init(struct obd_trans_info *oti,
601 struct ptlrpc_request *req)
605 memset(oti, 0, sizeof *oti);
610 oti->oti_xid = req->rq_xid;
612 if (req->rq_repmsg && req->rq_reqmsg != 0)
613 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
614 oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
615 oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
618 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
623 if (num_cookies == 1)
624 oti->oti_logcookies = &oti->oti_onecookie;
626 OBD_ALLOC(oti->oti_logcookies,
627 num_cookies * sizeof(oti->oti_onecookie));
629 oti->oti_numcookies = num_cookies;
632 static inline void oti_free_cookies(struct obd_trans_info *oti)
634 if (!oti || !oti->oti_logcookies)
637 if (oti->oti_logcookies == &oti->oti_onecookie)
638 LASSERT(oti->oti_numcookies == 1);
640 OBD_FREE(oti->oti_logcookies,
641 oti->oti_numcookies * sizeof(oti->oti_onecookie));
642 oti->oti_logcookies = NULL;
643 oti->oti_numcookies = 0;
648 LLOG_CONFIG_ORIG_CTXT = 0,
649 LLOG_CONFIG_REPL_CTXT = 1,
650 LLOG_MDS_OST_ORIG_CTXT = 2,
651 LLOG_MDS_OST_REPL_CTXT = 3,
652 LLOG_SIZE_ORIG_CTXT = 4,
653 LLOG_SIZE_REPL_CTXT = 5,
654 LLOG_MD_ORIG_CTXT = 6,
655 LLOG_MD_REPL_CTXT = 7,
656 LLOG_RD1_ORIG_CTXT = 8,
657 LLOG_RD1_REPL_CTXT = 9,
658 LLOG_TEST_ORIG_CTXT = 10,
659 LLOG_TEST_REPL_CTXT = 11,
660 LLOG_LOVEA_ORIG_CTXT = 12,
661 LLOG_LOVEA_REPL_CTXT = 13,
666 * Events signalled through obd_notify() upcall-chain.
668 enum obd_notify_event {
669 /* Device activated */
671 /* Device deactivated */
673 /* Connect data for import were changed */
676 OBD_NOTIFY_SYNC_NONBLOCK,
678 /* Configuration event */
683 * Data structure used to pass obd_notify()-event to non-obd listeners (llite
684 * and liblustre being main examples).
686 struct obd_notify_upcall {
687 int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
688 enum obd_notify_event ev, void *owner);
689 /* Opaque datum supplied by upper layer listener */
693 /* corresponds to one of the obd's */
694 #define MAX_OBD_NAME 128
695 #define OBD_DEVICE_MAGIC 0XAB5CD6EF
697 struct obd_type *obd_type;
700 /* common and UUID name of this device */
701 char obd_name[MAX_OBD_NAME];
702 struct obd_uuid obd_uuid;
705 unsigned int obd_attached:1, /* finished attach */
706 obd_set_up:1, /* finished setup */
707 obd_recovering:1, /* there are recoverable clients */
708 obd_abort_recovery:1,/* somebody ioctl'ed us to abort */
709 obd_replayable:1, /* recovery is enabled; inform clients */
710 obd_no_transno:1, /* no committed-transno notification */
711 obd_no_recov:1, /* fail instead of retry messages */
712 obd_stopping:1, /* started cleanup */
713 obd_starting:1, /* started setup */
714 obd_force:1, /* cleanup with > 0 obd refcount */
715 obd_fail:1, /* cleanup with failover */
716 obd_async_recov:1, /* allow asyncronous orphan cleanup */
717 obd_no_conn:1; /* deny new connections */
718 atomic_t obd_refcount;
719 cfs_waitq_t obd_refcount_waitq;
720 struct list_head obd_exports;
722 struct ldlm_namespace *obd_namespace;
723 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
724 /* a spinlock is OK for what we do now, may need a semaphore later */
725 spinlock_t obd_dev_lock;
726 struct semaphore obd_dev_sem;
727 __u64 obd_last_committed;
728 struct fsfilt_operations *obd_fsops;
729 spinlock_t obd_osfs_lock;
730 struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
732 struct lvfs_run_ctxt obd_lvfs_ctxt;
733 struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
734 struct obd_device *obd_observer;
735 struct obd_notify_upcall obd_upcall;
736 struct obd_export *obd_self_export;
737 /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
738 struct list_head obd_exports_timed;
739 time_t obd_eviction_timer; /* for ping evictor */
741 /* XXX encapsulate all this recovery data into one struct */
742 svc_handler_t obd_recovery_handler;
743 int obd_max_recoverable_clients;
744 int obd_connected_clients;
745 int obd_recoverable_clients;
746 spinlock_t obd_processing_task_lock; /* BH lock (timer) */
747 pid_t obd_processing_task;
748 __u64 obd_next_recovery_transno;
749 int obd_replayed_requests;
750 int obd_requests_queued_for_recovery;
751 cfs_waitq_t obd_next_transno_waitq;
752 struct list_head obd_uncommitted_replies;
753 spinlock_t obd_uncommitted_replies_lock;
754 cfs_timer_t obd_recovery_timer;
755 struct list_head obd_recovery_queue;
756 struct list_head obd_delayed_reply_queue;
757 time_t obd_recovery_start;
758 time_t obd_recovery_end;
761 struct obd_device_target obt;
762 struct filter_obd filter;
764 struct client_obd cli;
766 struct echo_client_obd echo_client;
767 struct echo_obd echo;
771 /* Fields used by LProcFS */
772 cfs_proc_dir_entry_t *obd_proc_entry;
773 cfs_proc_dir_entry_t *obd_proc_exports;
774 cfs_proc_dir_entry_t *obd_svc_procroot;
775 struct lprocfs_stats *obd_stats;
776 struct lprocfs_stats *obd_svc_stats;
777 unsigned int obd_cntr_base;
778 struct semaphore obd_proc_exp_sem;
781 #define OBD_OPT_FORCE 0x0001
782 #define OBD_OPT_FAILOVER 0x0002
784 #define OBD_LLOG_FL_SENDNOW 0x0001
786 enum obd_cleanup_stage {
787 /* Special case hack for MDS LOVs */
789 /* Precleanup stage 1, we must make sure all exports (other than the
790 self-export) get destroyed. */
792 /* Precleanup stage 2, do other type-specific cleanup requiring the
794 OBD_CLEANUP_SELF_EXP,
795 /* FIXME we should eliminate the "precleanup" function and make them stages
796 of the "cleanup" function. */
800 /* get/set_info keys */
801 #define KEY_MDS_CONN "mds_conn"
802 #define KEY_NEXT_ID "next_id"
803 #define KEY_LOVDESC "lovdesc"
804 #define KEY_INIT_RECOV "initial_recov"
805 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"
808 struct module *o_owner;
809 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
810 void *karg, void *uarg);
811 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
812 __u32 *vallen, void *val);
813 int (*o_set_info_async)(struct obd_export *, __u32 keylen, void *key,
814 __u32 vallen, void *val,
815 struct ptlrpc_request_set *set);
816 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
817 int (*o_detach)(struct obd_device *dev);
818 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
819 int (*o_precleanup)(struct obd_device *dev,
820 enum obd_cleanup_stage cleanup_stage);
821 int (*o_cleanup)(struct obd_device *dev);
822 int (*o_process_config)(struct obd_device *dev, obd_count len,
824 int (*o_postrecov)(struct obd_device *dev);
825 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
827 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
828 /* connect to the target device with given connection
829 * data. @ocd->ocd_connect_flags is modified to reflect flags actually
830 * granted by the target, which are guaranteed to be a subset of flags
831 * asked for. If @ocd == NULL, use default parameters. */
832 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
833 struct obd_uuid *cluuid, struct obd_connect_data *ocd);
834 int (*o_reconnect)(struct obd_export *exp, struct obd_device *src,
835 struct obd_uuid *cluuid,
836 struct obd_connect_data *ocd);
837 int (*o_disconnect)(struct obd_export *exp);
839 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
841 int (*o_statfs_async)(struct obd_device *obd, struct obd_info *oinfo,
842 __u64 max_age, struct ptlrpc_request_set *set);
843 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
844 struct lov_stripe_md *mem_src);
845 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
846 struct lov_mds_md *disk_src, int disk_len);
847 int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
848 struct lov_stripe_md *mem_tgt);
849 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
851 int (*o_create)(struct obd_export *exp, struct obdo *oa,
852 struct lov_stripe_md **ea, struct obd_trans_info *oti);
853 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
854 struct lov_stripe_md *ea, struct obd_trans_info *oti,
855 struct obd_export *md_exp);
856 int (*o_setattr)(struct obd_export *exp, struct obd_info *oinfo,
857 struct obd_trans_info *oti);
858 int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
859 struct obd_trans_info *oti,
860 struct ptlrpc_request_set *rqset);
861 int (*o_getattr)(struct obd_export *exp, struct obd_info *oinfo);
862 int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
863 struct ptlrpc_request_set *set);
864 int (*o_brw)(int rw, struct obd_export *exp, struct obd_info *oinfo,
865 obd_count oa_bufs, struct brw_page *pgarr,
866 struct obd_trans_info *oti);
867 int (*o_brw_async)(int rw, struct obd_export *exp,
868 struct obd_info *oinfo, obd_count oa_bufs,
869 struct brw_page *pgarr, struct obd_trans_info *oti,
870 struct ptlrpc_request_set *);
871 int (*o_prep_async_page)(struct obd_export *exp,
872 struct lov_stripe_md *lsm,
873 struct lov_oinfo *loi,
874 cfs_page_t *page, obd_off offset,
875 struct obd_async_page_ops *ops, void *data,
877 int (*o_queue_async_io)(struct obd_export *exp,
878 struct lov_stripe_md *lsm,
879 struct lov_oinfo *loi, void *cookie,
880 int cmd, obd_off off, int count,
881 obd_flag brw_flags, obd_flag async_flags);
882 int (*o_queue_group_io)(struct obd_export *exp,
883 struct lov_stripe_md *lsm,
884 struct lov_oinfo *loi,
885 struct obd_io_group *oig,
886 void *cookie, int cmd, obd_off off, int count,
887 obd_flag brw_flags, obd_flag async_flags);
888 int (*o_trigger_group_io)(struct obd_export *exp,
889 struct lov_stripe_md *lsm,
890 struct lov_oinfo *loi,
891 struct obd_io_group *oig);
892 int (*o_set_async_flags)(struct obd_export *exp,
893 struct lov_stripe_md *lsm,
894 struct lov_oinfo *loi, void *cookie,
895 obd_flag async_flags);
896 int (*o_teardown_async_page)(struct obd_export *exp,
897 struct lov_stripe_md *lsm,
898 struct lov_oinfo *loi, void *cookie);
899 int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
900 struct ost_lvb *lvb, int kms_only);
901 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
902 obd_off size, int shrink);
903 int (*o_punch)(struct obd_export *exp, struct obd_info *oinfo,
904 struct obd_trans_info *oti,
905 struct ptlrpc_request_set *rqset);
906 int (*o_sync)(struct obd_export *exp, struct obdo *oa,
907 struct lov_stripe_md *ea, obd_size start, obd_size end);
908 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
909 struct lov_stripe_md *src, obd_size start,
910 obd_size end, struct obd_trans_info *oti);
911 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
912 struct lustre_handle *srconn, struct lov_stripe_md *src,
913 obd_size start, obd_size end, struct obd_trans_info *);
914 int (*o_iterate)(struct lustre_handle *conn,
915 int (*)(obd_id, obd_gr, void *),
916 obd_id *startid, obd_gr group, void *data);
917 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
918 int objcount, struct obd_ioobj *obj,
919 int niocount, struct niobuf_remote *remote,
920 struct niobuf_local *local, struct obd_trans_info *oti);
921 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
922 int objcount, struct obd_ioobj *obj,
923 int niocount, struct niobuf_local *local,
924 struct obd_trans_info *oti, int rc);
925 int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo,
926 struct ldlm_enqueue_info *einfo,
927 struct ptlrpc_request_set *rqset);
928 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
929 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
930 struct lustre_handle *lockh);
931 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
932 ldlm_iterator_t it, void *data);
933 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
934 __u32 mode, struct lustre_handle *);
935 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
936 int flags, void *opaque);
937 int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
939 int (*o_init_export)(struct obd_export *exp);
940 int (*o_destroy_export)(struct obd_export *exp);
941 int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *,
944 /* llog related obd_methods */
945 int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
946 int count, struct llog_catid *logid,
947 struct obd_uuid *uuid);
948 int (*o_llog_finish)(struct obd_device *obd, int count);
950 /* metadata-only methods */
951 int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
952 struct obd_client_handle *, int flag);
953 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
955 int (*o_import_event)(struct obd_device *, struct obd_import *,
956 enum obd_import_event);
958 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
959 enum obd_notify_event ev, void *data);
961 int (*o_health_check)(struct obd_device *);
964 int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
965 int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
967 int (*o_ping)(struct obd_export *exp);
969 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
970 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
971 * Also, add a wrapper function in include/linux/obd_class.h. */
974 struct lsm_operations {
975 void (*lsm_free)(struct lov_stripe_md *);
976 int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
977 struct obd_export *md_exp);
978 void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
980 void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
982 obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
983 obd_off (*lsm_stripe_offset_by_offset)(struct lov_stripe_md *, obd_off);
984 int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
985 int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
986 int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
988 int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
989 struct lov_mds_md *lmm);
992 extern struct lsm_operations lsm_plain_ops;
993 extern struct lsm_operations lsm_join_ops;
994 static inline struct lsm_operations *lsm_op_find(int magic)
998 return &lsm_plain_ops;
1000 return &lsm_join_ops;
1002 CERROR("Cannot recognize lsm_magic %d", magic);
1007 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
1009 /* Requests for obd_extent_calc() */
1010 #define OBD_CALC_STRIPE_START 1
1011 #define OBD_CALC_STRIPE_END 2
1013 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
1017 CERROR("%s: transno "LPD64" commit error: %d\n",
1018 obd->obd_name, transno, error);
1021 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
1022 obd->obd_name, transno);
1023 if (transno > obd->obd_last_committed) {
1024 obd->obd_last_committed = transno;
1025 ptlrpc_commit_replies (obd);
1029 static inline void init_obd_quota_ops(quota_interface_t *interface,
1030 struct obd_ops *obd_ops)
1036 obd_ops->o_quotacheck = QUOTA_OP(interface, check);
1037 obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
1040 #endif /* __OBD_H */