1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
8 #define IOC_OSC_TYPE 'h'
9 #define IOC_OSC_MIN_NR 20
10 #define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
11 #define IOC_OSC_MAX_NR 50
13 #define IOC_MDC_TYPE 'i'
14 #define IOC_MDC_MIN_NR 20
15 #define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
16 /* Moved to lustre_user.h
17 #define IOC_MDC_GETSTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *) */
18 #define IOC_MDC_MAX_NR 50
21 # include <linux/fs.h>
22 # include <linux/list.h>
23 # include <linux/sched.h> /* for struct task_struct, for current.h */
24 # include <asm/current.h> /* for smp_lock.h */
25 # include <linux/smp_lock.h>
26 # include <linux/proc_fs.h>
27 # include <linux/mount.h>
30 #include <linux/lustre_lib.h>
31 #include <linux/lustre_idl.h>
32 #include <linux/lustre_export.h>
33 #include <linux/lustre_quota.h>
35 #include <linux/lu_object.h>
37 /* this is really local to the OSC */
38 struct loi_oap_pages {
39 struct list_head lop_pending;
41 struct list_head lop_urgent;
42 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 INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
74 INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
75 INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
76 INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
77 INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
78 INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
79 INIT_LIST_HEAD(&loi->loi_cli_item);
80 INIT_LIST_HEAD(&loi->loi_write_item);
81 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 id */
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_ops;
146 struct proc_dir_entry *typ_procroot;
149 struct lu_device_type *typ_lu;
160 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
161 page is added to an rpc */
163 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
164 to give the caller a chance to update
165 or cancel the size of the io */
166 ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
167 the page is accounted for in the
168 obd_io_group given to
169 obd_queue_group_io */
172 struct obd_async_page_ops {
173 int (*ap_make_ready)(void *data, int cmd);
174 int (*ap_refresh_count)(void *data, int cmd);
175 void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
176 void (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
179 /* the `oig' is passed down from a caller of obd rw methods. the callee
180 * records enough state such that the caller can sleep on the oig and
181 * be woken when all the callees have finished their work */
182 struct obd_io_group {
184 atomic_t oig_refcount;
187 struct list_head oig_occ_list;
188 wait_queue_head_t oig_waitq;
191 /* the oig callback context lets the callee of obd rw methods register
192 * for callbacks from the caller. */
193 struct oig_callback_context {
194 struct list_head occ_oig_item;
195 /* called when the caller has received a signal while sleeping.
196 * callees of this method are encouraged to abort their state
197 * in the oig. This may be called multiple times. */
198 void (*occ_interrupted)(struct oig_callback_context *occ);
199 unsigned int interrupted:1;
202 /* if we find more consumers this could be generalized */
203 #define OBD_HIST_MAX 32
204 struct obd_histogram {
206 unsigned long oh_buckets[OBD_HIST_MAX];
209 /* Individual type definitions */
211 struct ost_server_data;
213 /* hold common fields for "target" device */
214 struct obd_device_target {
215 struct super_block *obt_sb;
216 atomic_t obt_quotachecking;
217 struct lustre_quota_ctxt obt_qctxt;
220 #define FILTER_GROUP_LLOG 1
221 #define FILTER_GROUP_ECHO 2
229 /* NB this field MUST be first */
230 struct obd_device_target fo_obt;
231 const char *fo_fstype;
232 struct vfsmount *fo_vfsmnt;
233 struct dentry *fo_dentry_O;
234 struct dentry **fo_dentry_O_groups;
235 struct dentry **fo_dentry_O_sub;
236 spinlock_t fo_objidlock; /* protect fo_lastobjid */
237 spinlock_t fo_translock; /* protect fsd_last_transno */
238 struct file *fo_rcvd_filp;
239 struct file *fo_health_check_filp;
240 struct lr_server_data *fo_fsd;
241 unsigned long *fo_last_rcvd_slots;
242 __u64 fo_mount_count;
244 int fo_destroy_in_progress;
245 struct semaphore fo_create_lock;
247 struct list_head fo_export_list;
250 obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
251 obd_size fo_tot_granted; /* all values in bytes */
252 obd_size fo_tot_pending;
254 obd_size fo_readcache_max_filesize;
256 struct obd_import *fo_mdc_imp;
257 struct obd_uuid fo_mdc_uuid;
258 struct lustre_handle fo_mdc_conn;
259 struct file **fo_last_objid_files;
260 __u64 *fo_last_objids; /* last created objid for groups,
261 * protected by fo_objidlock */
263 struct semaphore fo_alloc_lock;
265 spinlock_t fo_stats_lock;
266 int fo_r_in_flight; /* protected by fo_stats_lock */
267 int fo_w_in_flight; /* protected by fo_stats_lock */
270 * per-filter pool of kiobuf's allocated by filter_common_setup() and
271 * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
272 * which ->fo_iobuf_count were allocated.
274 * This pool contains kiobuf used by
275 * filter_{prep,commit}rw_{read,write}() and is shared by all OST
278 * Locking: none, each OST thread uses only one element, determined by
279 * its "ordinal number", ->t_id.
281 struct filter_iobuf **fo_iobuf_pool;
284 struct obd_histogram fo_r_pages;
285 struct obd_histogram fo_w_pages;
286 struct obd_histogram fo_read_rpc_hist;
287 struct obd_histogram fo_write_rpc_hist;
288 struct obd_histogram fo_r_io_time;
289 struct obd_histogram fo_w_io_time;
290 struct obd_histogram fo_r_discont_pages;
291 struct obd_histogram fo_w_discont_pages;
292 struct obd_histogram fo_r_discont_blocks;
293 struct obd_histogram fo_w_discont_blocks;
294 struct obd_histogram fo_r_disk_iosize;
295 struct obd_histogram fo_w_disk_iosize;
297 struct lustre_quota_ctxt fo_quota_ctxt;
298 spinlock_t fo_quotacheck_lock;
299 atomic_t fo_quotachecking;
302 #define OSC_MAX_RIF_DEFAULT 8
303 #define OSC_MAX_RIF_MAX 256
304 #define OSC_MAX_DIRTY_DEFAULT (OSC_MAX_RIF_DEFAULT * 4)
305 #define OSC_MAX_DIRTY_MB_MAX 2048 /* totally arbitrary */
309 struct obd_import *cl_import;
310 struct semaphore cl_sem;
312 /* max_mds_easize is purely a performance thing so we don't have to
313 * call obd_size_diskmd() all the time. */
314 int cl_default_mds_easize;
315 int cl_max_mds_easize;
316 int cl_max_mds_cookiesize;
319 //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
320 void *cl_llcd_offset;
322 /* the grant values are protected by loi_list_lock below */
323 long cl_dirty; /* all _dirty_ in bytes */
324 long cl_dirty_max; /* allowed w/o rpc */
325 long cl_avail_grant; /* bytes of credit for ost */
326 long cl_lost_grant; /* lost credits (trunc) */
327 struct list_head cl_cache_waiters; /* waiting for cache/grant */
329 /* keep track of objects that have lois that contain pages which
330 * have been queued for async brw. this lock also protects the
331 * lists of osc_client_pages that hang off of the loi */
332 spinlock_t cl_loi_list_lock;
333 struct list_head cl_loi_ready_list;
334 struct list_head cl_loi_write_list;
335 struct list_head cl_loi_read_list;
338 /* just a sum of the loi/lop pending numbers to be exported by /proc */
339 int cl_pending_w_pages;
340 int cl_pending_r_pages;
341 int cl_max_pages_per_rpc;
342 int cl_max_rpcs_in_flight;
343 struct obd_histogram cl_read_rpc_hist;
344 struct obd_histogram cl_write_rpc_hist;
345 struct obd_histogram cl_read_page_hist;
346 struct obd_histogram cl_write_page_hist;
347 struct obd_histogram cl_read_offset_hist;
348 struct obd_histogram cl_write_offset_hist;
350 struct mdc_rpc_lock *cl_rpc_lock;
351 struct mdc_rpc_lock *cl_setattr_lock;
352 struct osc_creator cl_oscc;
355 struct semaphore cl_mgc_sem;
356 struct vfsmount *cl_mgc_vfsmnt;
357 struct dentry *cl_mgc_configs_dir;
358 atomic_t cl_mgc_refcount;
359 struct obd_export *cl_mgc_mgsexp;
362 unsigned int cl_checksum:1; /* debug checksums */
364 /* also protected by the poorly named _loi_list_lock lock above */
365 struct osc_async_rc cl_ar;
367 /* used by quotacheck */
368 int cl_qchk_stat; /* quotacheck stat of the peer */
369 struct ptlrpc_request_pool *cl_rq_pool; /* emergency pool of requests */
372 #define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */
375 struct ptlrpc_service *mgs_service;
376 struct vfsmount *mgs_vfsmnt;
377 struct super_block *mgs_sb;
378 struct dentry *mgs_configs_dir;
379 struct dentry *mgs_fid_de;
380 spinlock_t mgs_fs_db_lock; /* add/remove db's */
381 struct list_head mgs_fs_db_list;
382 struct semaphore mgs_log_sem; /* unused */
386 /* NB this field MUST be first */
387 struct obd_device_target mds_obt;
388 struct ptlrpc_service *mds_service;
389 struct ptlrpc_service *mds_setattr_service;
390 struct ptlrpc_service *mds_readpage_service;
391 struct vfsmount *mds_vfsmnt;
392 struct dentry *mds_fid_de;
394 int mds_max_cookiesize;
395 struct file *mds_rcvd_filp;
396 spinlock_t mds_transno_lock;
397 __u64 mds_last_transno;
398 __u64 mds_mount_count;
400 unsigned long mds_atime_diff;
401 struct semaphore mds_epoch_sem;
402 struct lu_fid mds_rootfid;
403 struct lr_server_data *mds_server_data;
404 struct dentry *mds_pending_dir;
405 struct dentry *mds_logs_dir;
406 struct dentry *mds_objects_dir;
407 struct llog_handle *mds_cfg_llh;
408 // struct llog_handle *mds_catalog;
409 struct obd_device *mds_osc_obd; /* XXX lov_obd */
410 struct obd_uuid mds_lov_uuid;
412 struct obd_export *mds_osc_exp; /* XXX lov_exp */
413 struct lov_desc mds_lov_desc;
414 obd_id *mds_lov_objids;
415 int mds_lov_objids_size;
416 __u32 mds_lov_objids_in_file;
417 unsigned int mds_lov_objids_dirty:1;
418 int mds_lov_nextid_set;
419 struct file *mds_lov_objid_filp;
420 struct file *mds_health_check_filp;
421 unsigned long *mds_client_bitmap;
422 struct semaphore mds_orphan_recovery_sem;
423 struct upcall_cache *mds_group_hash;
425 struct lustre_quota_info mds_quota_info;
426 struct semaphore mds_qonoff_sem;
427 struct semaphore mds_health_sem;
428 unsigned long mds_lov_objids_valid:1,
437 struct lustre_handle eo_nl_lock;
442 struct ptlrpc_service *ost_service;
443 struct ptlrpc_service *ost_create_service;
444 struct ptlrpc_service *ost_io_service;
445 struct semaphore ost_health_sem;
448 struct echo_client_obd {
449 struct obd_export *ec_exp; /* the local connection to osc/lov */
451 struct list_head ec_objects;
456 struct lov_tgt_desc {
457 struct obd_uuid uuid;
459 struct obd_export *ltd_exp;
460 unsigned int active:1, /* is this target up for requests */
461 reap:1; /* should this target be deleted */
465 struct semaphore lov_lock;
467 struct lov_desc desc;
468 struct obd_connect_data ocd;
471 int death_row; /* Do we have tgts scheduled to be deleted?
472 (Make this a linked list?) */
473 unsigned int lo_catalog_loaded:1;
474 struct lov_tgt_desc *tgts;
477 struct niobuf_local {
482 struct dentry *dentry;
488 /* device types (not names--FIXME) */
489 /* FIXME all the references to these defines need to be updated */
490 #define LUSTRE_MDS_NAME "mds"
491 #define LUSTRE_MDT_NAME "mdt"
492 #define LUSTRE_MDT0_NAME "mdt0"
493 #define LUSTRE_CMM0_NAME "cmm0"
495 #define LUSTRE_MDC_NAME "mdc"
497 /* FIXME just the names need to be changed */
498 #define LUSTRE_OSS_NAME "ost" /*FIXME oss*/
499 #define LUSTRE_OST_NAME "obdfilter" /* FIXME ost*/
500 #define LUSTRE_OSTSAN_NAME "sanobdfilter"
502 #define LUSTRE_OSC_NAME "osc"
503 #define LUSTRE_FILTER_NAME "filter"
504 #define LUSTRE_SANOSC_NAME "sanosc"
505 #define LUSTRE_SANOST_NAME "sanost"
506 #define LUSTRE_MGS_NAME "mgs"
507 #define LUSTRE_MGC_NAME "mgc"
509 #define LUSTRE_MGS_OBDNAME "MGS"
510 #define LUSTRE_MGC_OBDNAME "MGC"
513 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
514 #define N_LOCAL_TEMP_PAGE 0x10000000
516 struct obd_trans_info {
519 /* Only used on the server side for tracking acks. */
520 struct oti_req_ack_lock {
521 struct lustre_handle lock;
525 struct llog_cookie oti_onecookie;
526 struct llog_cookie *oti_logcookies;
529 /* initial thread handling transaction */
533 static inline void oti_init(struct obd_trans_info *oti,
534 struct ptlrpc_request *req)
538 memset(oti, 0, sizeof *oti);
543 if (req->rq_repmsg && req->rq_reqmsg != 0)
544 oti->oti_transno = req->rq_repmsg->transno;
545 oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
548 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
553 if (num_cookies == 1)
554 oti->oti_logcookies = &oti->oti_onecookie;
556 OBD_ALLOC(oti->oti_logcookies,
557 num_cookies * sizeof(oti->oti_onecookie));
559 oti->oti_numcookies = num_cookies;
562 static inline void oti_free_cookies(struct obd_trans_info *oti)
564 if (!oti || !oti->oti_logcookies)
567 if (oti->oti_logcookies == &oti->oti_onecookie)
568 LASSERT(oti->oti_numcookies == 1);
570 OBD_FREE(oti->oti_logcookies,
571 oti->oti_numcookies * sizeof(oti->oti_onecookie));
572 oti->oti_logcookies = NULL;
573 oti->oti_numcookies = 0;
578 LLOG_CONFIG_ORIG_CTXT = 0,
579 LLOG_CONFIG_REPL_CTXT = 1,
580 LLOG_MDS_OST_ORIG_CTXT = 2,
581 LLOG_MDS_OST_REPL_CTXT = 3,
582 LLOG_SIZE_ORIG_CTXT = 4,
583 LLOG_SIZE_REPL_CTXT = 5,
584 LLOG_MD_ORIG_CTXT = 6,
585 LLOG_MD_REPL_CTXT = 7,
586 LLOG_RD1_ORIG_CTXT = 8,
587 LLOG_RD1_REPL_CTXT = 9,
588 LLOG_TEST_ORIG_CTXT = 10,
589 LLOG_TEST_REPL_CTXT = 11,
590 LLOG_LOVEA_ORIG_CTXT = 12,
591 LLOG_LOVEA_REPL_CTXT = 13,
596 * Events signalled through obd_notify() upcall-chain.
598 enum obd_notify_event {
599 /* Device activated */
601 /* Device deactivated */
603 /* Connect data for import were changed */
606 OBD_NOTIFY_SYNC_NONBLOCK,
611 * Data structure used to pass obd_notify()-event to non-obd listeners (llite
612 * and liblustre being main examples).
614 struct obd_notify_upcall {
615 int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
616 enum obd_notify_event ev, void *owner);
617 /* Opaque datum supplied by upper layer listener */
622 /* corresponds to one of the obd's */
624 struct obd_type *obd_type;
625 /* common and UUID name of this device */
627 struct obd_uuid obd_uuid;
629 struct lu_device *obd_lu_dev;
632 unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
633 obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
634 obd_no_recov:1, obd_stopping:1, obd_starting:1,
635 obd_force:1, obd_fail:1, obd_async_recov:1;
636 atomic_t obd_refcount;
637 wait_queue_head_t obd_refcount_waitq;
638 struct proc_dir_entry *obd_proc_entry;
639 struct list_head obd_exports;
641 struct ldlm_namespace *obd_namespace;
642 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
643 /* a spinlock is OK for what we do now, may need a semaphore later */
644 spinlock_t obd_dev_lock;
645 __u64 obd_last_committed;
646 struct fsfilt_operations *obd_fsops;
647 spinlock_t obd_osfs_lock;
648 struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
649 unsigned long obd_osfs_age; /* jiffies */
650 struct lvfs_run_ctxt obd_lvfs_ctxt;
651 struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
652 struct obd_device *obd_observer;
653 struct obd_notify_upcall obd_upcall;
654 struct obd_export *obd_self_export;
655 /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
656 struct list_head obd_exports_timed;
657 time_t obd_eviction_timer; /* for ping evictor */
659 /* XXX encapsulate all this recovery data into one struct */
660 svc_handler_t obd_recovery_handler;
661 int obd_max_recoverable_clients;
662 int obd_connected_clients;
663 int obd_recoverable_clients;
664 spinlock_t obd_processing_task_lock;
665 pid_t obd_processing_task;
666 __u64 obd_next_recovery_transno;
667 int obd_replayed_requests;
668 int obd_requests_queued_for_recovery;
669 wait_queue_head_t obd_next_transno_waitq;
670 struct list_head obd_uncommitted_replies;
671 spinlock_t obd_uncommitted_replies_lock;
672 struct timer_list obd_recovery_timer;
673 struct list_head obd_recovery_queue;
674 struct list_head obd_delayed_reply_queue;
675 time_t obd_recovery_start;
676 time_t obd_recovery_end;
679 struct obd_device_target obt;
680 struct filter_obd filter;
682 struct client_obd cli;
684 struct echo_client_obd echo_client;
685 struct echo_obd echo;
689 /* Fields used by LProcFS */
690 unsigned int obd_cntr_base;
691 struct lprocfs_stats *obd_stats;
692 struct proc_dir_entry *obd_svc_procroot;
693 struct lprocfs_stats *obd_svc_stats;
696 #define OBD_OPT_FORCE 0x0001
697 #define OBD_OPT_FAILOVER 0x0002
699 #define OBD_LLOG_FL_SENDNOW 0x0001
702 /* Special case hack for MDS LOVs */
703 #define OBD_CLEANUP_EARLY 0
704 /* Precleanup stage 1, we must make sure all exports (other than the
705 self-export) get destroyed. */
706 #define OBD_CLEANUP_EXPORTS 1
707 /* Precleanup stage 2, do other type-specific cleanup requiring the
709 #define OBD_CLEANUP_SELF_EXP 2
710 /* FIXME we should eliminate the "precleanup" function and make them stages
711 of the "cleanup" function. */
712 #define OBD_CLEANUP_OBD 3
715 struct module *o_owner;
716 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
717 void *karg, void *uarg);
718 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
719 __u32 *vallen, void *val);
720 int (*o_set_info)(struct obd_export *, __u32 keylen, void *key,
721 __u32 vallen, void *val);
722 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
723 int (*o_detach)(struct obd_device *dev);
724 int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg);
725 int (*o_precleanup)(struct obd_device *dev, int cleanup_stage);
726 int (*o_cleanup)(struct obd_device *dev);
727 int (*o_process_config)(struct obd_device *dev, obd_count len,
729 int (*o_postrecov)(struct obd_device *dev);
730 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
732 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
733 /* connect to the target device with given connection
734 * data. @ocd->ocd_connect_flags is modified to reflect flags actually
735 * granted by the target, which are guaranteed to be a subset of flags
736 * asked for. If @ocd == NULL, use default parameters. */
737 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
738 struct obd_uuid *cluuid, struct obd_connect_data *ocd);
739 int (*o_reconnect)(struct obd_export *exp, struct obd_device *src,
740 struct obd_uuid *cluuid,
741 struct obd_connect_data *ocd);
742 int (*o_disconnect)(struct obd_export *exp);
744 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
745 unsigned long max_age);
746 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
747 struct lov_stripe_md *mem_src);
748 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
749 struct lov_mds_md *disk_src, int disk_len);
750 int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
751 struct lov_stripe_md *mem_tgt);
752 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
754 int (*o_create)(struct obd_export *exp, struct obdo *oa,
755 struct lov_stripe_md **ea, struct obd_trans_info *oti);
756 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
757 struct lov_stripe_md *ea, struct obd_trans_info *oti,
758 struct obd_export *md_exp);
759 int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
760 struct lov_stripe_md *ea, struct obd_trans_info *oti);
761 int (*o_setattr_async)(struct obd_export *exp, struct obdo *oa,
762 struct lov_stripe_md *ea, struct obd_trans_info *oti);
763 int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
764 struct lov_stripe_md *ea);
765 int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
766 struct lov_stripe_md *ea,
767 struct ptlrpc_request_set *set);
768 int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
769 struct lov_stripe_md *ea, obd_count oa_bufs,
770 struct brw_page *pgarr, struct obd_trans_info *oti);
771 int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
772 struct lov_stripe_md *ea, obd_count oa_bufs,
773 struct brw_page *pgarr, struct ptlrpc_request_set *,
774 struct obd_trans_info *oti);
775 int (*o_prep_async_page)(struct obd_export *exp,
776 struct lov_stripe_md *lsm,
777 struct lov_oinfo *loi,
778 struct page *page, obd_off offset,
779 struct obd_async_page_ops *ops, void *data,
781 int (*o_queue_async_io)(struct obd_export *exp,
782 struct lov_stripe_md *lsm,
783 struct lov_oinfo *loi, void *cookie,
784 int cmd, obd_off off, int count,
785 obd_flag brw_flags, obd_flag async_flags);
786 int (*o_queue_group_io)(struct obd_export *exp,
787 struct lov_stripe_md *lsm,
788 struct lov_oinfo *loi,
789 struct obd_io_group *oig,
790 void *cookie, int cmd, obd_off off, int count,
791 obd_flag brw_flags, obd_flag async_flags);
792 int (*o_trigger_group_io)(struct obd_export *exp,
793 struct lov_stripe_md *lsm,
794 struct lov_oinfo *loi,
795 struct obd_io_group *oig);
796 int (*o_set_async_flags)(struct obd_export *exp,
797 struct lov_stripe_md *lsm,
798 struct lov_oinfo *loi, void *cookie,
799 obd_flag async_flags);
800 int (*o_teardown_async_page)(struct obd_export *exp,
801 struct lov_stripe_md *lsm,
802 struct lov_oinfo *loi, void *cookie);
803 int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
804 struct ost_lvb *lvb, int kms_only);
805 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
806 obd_off size, int shrink);
807 int (*o_punch)(struct obd_export *exp, struct obdo *oa,
808 struct lov_stripe_md *ea, obd_size start,
809 obd_size end, struct obd_trans_info *oti);
810 int (*o_sync)(struct obd_export *exp, struct obdo *oa,
811 struct lov_stripe_md *ea, obd_size start, obd_size end);
812 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
813 struct lov_stripe_md *src, obd_size start,
814 obd_size end, struct obd_trans_info *oti);
815 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
816 struct lustre_handle *srconn, struct lov_stripe_md *src,
817 obd_size start, obd_size end, struct obd_trans_info *);
818 int (*o_iterate)(struct lustre_handle *conn,
819 int (*)(obd_id, obd_gr, void *),
820 obd_id *startid, obd_gr group, void *data);
821 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
822 int objcount, struct obd_ioobj *obj,
823 int niocount, struct niobuf_remote *remote,
824 struct niobuf_local *local, struct obd_trans_info *oti);
825 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
826 int objcount, struct obd_ioobj *obj,
827 int niocount, struct niobuf_local *local,
828 struct obd_trans_info *oti, int rc);
829 int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
830 __u32 type, ldlm_policy_data_t *, __u32 mode,
831 int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
832 void *data, __u32 lvb_len, void *lvb_swabber,
833 struct lustre_handle *lockh);
834 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
835 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
836 struct lustre_handle *lockh);
837 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
838 ldlm_iterator_t it, void *data);
839 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
840 __u32 mode, struct lustre_handle *);
841 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
842 int flags, void *opaque);
843 int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
845 int (*o_san_preprw)(int cmd, struct obd_export *exp,
846 struct obdo *oa, int objcount,
847 struct obd_ioobj *obj, int niocount,
848 struct niobuf_remote *remote);
849 int (*o_init_export)(struct obd_export *exp);
850 int (*o_destroy_export)(struct obd_export *exp);
852 /* llog related obd_methods */
853 int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
854 int count, struct llog_catid *logid);
855 int (*o_llog_finish)(struct obd_device *obd, int count);
857 /* metadata-only methods */
858 int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
859 struct obd_client_handle *, int flag);
860 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
862 int (*o_import_event)(struct obd_device *, struct obd_import *,
863 enum obd_import_event);
865 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
866 enum obd_notify_event ev, void *data);
868 int (*o_health_check)(struct obd_device *);
871 int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
872 int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
875 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
876 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
877 * Also, add a wrapper function in include/linux/obd_class.h.
879 * Also note that if you add it to the END, you also have to change
880 * the num_stats calculation.
885 struct lsm_operations {
886 void (*lsm_free)(struct lov_stripe_md *);
887 int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
888 struct obd_export *md_exp);
889 void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
891 void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
893 obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
894 int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
895 int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
896 int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
898 int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
899 struct lov_mds_md *lmm);
902 extern struct lsm_operations lsm_plain_ops;
903 extern struct lsm_operations lsm_join_ops;
904 static inline struct lsm_operations *lsm_op_find(int magic)
908 return &lsm_plain_ops;
910 return &lsm_join_ops;
912 CERROR("Cannot recognize lsm_magic %d", magic);
917 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
919 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
923 CERROR("%s: transno "LPD64" commit error: %d\n",
924 obd->obd_name, transno, error);
927 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
928 obd->obd_name, transno);
929 if (transno > obd->obd_last_committed) {
930 obd->obd_last_committed = transno;
931 ptlrpc_commit_replies (obd);
935 static inline void init_obd_quota_ops(quota_interface_t *interface,
936 struct obd_ops *obd_ops)
942 obd_ops->o_quotacheck = QUOTA_OP(interface, check);
943 obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
946 /* get/set_info keys */
947 #define KEY_MDS_CONN "mds_conn"
948 #define KEY_NEXT_ID "next_id"
949 #define KEY_LOVDESC "lovdesc"
950 #define KEY_INIT_RECOV "initial_recov"
951 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"