1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
13 #define IOC_OSC_TYPE 'h'
14 #define IOC_OSC_MIN_NR 20
15 #define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
16 #define IOC_OSC_CTL_RECOVERY _IOWR(IOC_OSC_TYPE, 22, struct obd_device *)
17 #define IOC_OSC_MAX_NR 50
19 #define IOC_MDC_TYPE 'i'
20 #define IOC_MDC_MIN_NR 20
21 #define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_device *)
22 /* Moved to lustre_user.h
23 #define IOC_MDC_GETSTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *) */
24 #define IOC_MDC_MAX_NR 50
27 # include <linux/fs.h>
28 # include <linux/list.h>
29 # include <linux/sched.h> /* for struct task_struct, for current.h */
30 # include <asm/current.h> /* for smp_lock.h */
31 # include <linux/smp_lock.h>
32 # include <linux/proc_fs.h>
33 # include <linux/mount.h>
36 #define OBD_MDS_DEVICENAME "mds"
37 #define OBD_MDT_DEVICENAME "mdt"
38 #define OBD_MDC_DEVICENAME "mdc"
39 #define OBD_LMV_DEVICENAME "lmv"
40 #define OBD_LOV_DEVICENAME "lov"
41 #define OBD_OST_DEVICENAME "ost"
42 #define OBD_OSC_DEVICENAME "osc"
44 #define OBD_LDLM_DEVICENAME "ldlm"
45 #define OBD_CACHE_DEVICENAME "cobd"
46 #define OBD_CMOBD_DEVICENAME "cmobd"
47 #define OBD_CONF_DEVICENAME "confobd"
49 #define OBD_SANOSC_DEVICENAME "sanosc"
50 #define OBD_SANOST_DEVICENAME "sanost"
52 #define OBD_ECHO_DEVICENAME "obdecho"
53 #define OBD_ECHO_CLIENT_DEVICENAME "echo_client"
55 #define OBD_FILTER_DEVICENAME "obdfilter"
56 #define OBD_FILTER_SAN_DEVICENAME "sanobdfilter"
58 #define OBD_MGMTCLI_DEVICENAME "mgmt_cli"
59 #define OBD_PTLBD_SV_DEVICENAME "ptlbd_server"
60 #define OBD_PTLBD_CL_DEVICENAME "ptlbd_client"
62 #include <linux/lvfs.h>
63 #include <linux/lustre_lib.h>
64 #include <linux/lustre_idl.h>
65 #include <linux/lustre_export.h>
66 #include <linux/lustre_sec.h>
68 /* this is really local to the OSC */
69 struct loi_oap_pages {
70 struct list_head lop_pending;
72 struct list_head lop_urgent;
73 struct list_head lop_pending_group;
76 struct lov_oinfo { /* per-stripe data structure */
77 __u64 loi_id; /* object ID on the target OST */
78 __u64 loi_gr; /* object group on the target OST */
79 int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
80 int loi_ost_gen; /* generation of this loi_ost_idx */
82 /* used by the osc to keep track of what objects to build into rpcs */
83 struct loi_oap_pages loi_read_lop;
84 struct loi_oap_pages loi_write_lop;
85 /* _cli_ is poorly named, it should be _ready_ */
86 struct list_head loi_cli_item;
87 struct list_head loi_write_item;
88 struct list_head loi_read_item;
90 unsigned loi_kms_valid:1;
91 __u64 loi_kms; /* known minimum size */
92 __u64 loi_rss; /* recently seen size */
93 __u64 loi_mtime; /* recently seen mtime */
94 __u64 loi_blocks; /* recently seen blocks */
97 static inline void loi_init(struct lov_oinfo *loi)
99 INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
100 INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
101 INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
102 INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
103 INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
104 INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
105 INIT_LIST_HEAD(&loi->loi_cli_item);
106 INIT_LIST_HEAD(&loi->loi_write_item);
107 INIT_LIST_HEAD(&loi->loi_read_item);
110 struct lov_stripe_md {
111 /* Public members. */
112 __u64 lsm_object_id; /* lov object id */
113 __u64 lsm_object_gr; /* lov object id */
114 __u64 lsm_maxbytes; /* maximum possible file size */
115 unsigned long lsm_xfersize; /* optimal transfer size */
117 /* LOV-private members start here -- only for use in lov/. */
119 __u32 lsm_stripe_size; /* size of the stripe */
120 __u32 lsm_pattern; /* striping pattern (RAID0, RAID1) */
121 unsigned lsm_stripe_count; /* number of objects being striped over */
122 struct lov_oinfo lsm_oinfo[0];
125 static inline void dump_lsm(int level, struct lov_stripe_md *lsm)
128 CDEBUG(level, "objid "LPX64"/"LPU64", maxbytes "LPX64", magic 0x%08X, "
129 "stripe_size %u, stripe_count %u\n",
130 lsm->lsm_object_id, lsm->lsm_object_gr, lsm->lsm_maxbytes,
131 lsm->lsm_magic, lsm->lsm_stripe_size, lsm->lsm_stripe_count);
132 for (i = 0; i < lsm->lsm_stripe_count; i++)
133 CDEBUG(level, "idx %u ostidx %u/%u object "LPU64"/"LPU64"\n",
134 i, lsm->lsm_oinfo[i].loi_ost_idx,
135 lsm->lsm_oinfo[i].loi_ost_gen,
136 lsm->lsm_oinfo[i].loi_id, lsm->lsm_oinfo[i].loi_gr);
140 struct list_head typ_chain;
141 struct obd_ops *typ_ops;
142 struct md_ops *typ_md_ops;
143 struct proc_dir_entry *typ_procroot;
149 obd_off disk_offset; /* modulo PAGE_SIZE */
150 obd_off page_offset; /* modulo PAGE_SIZE (obviously) */
157 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
158 page is added to an rpc */
160 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
161 to give the caller a chance to update
162 or cancel the size of the io */
163 ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
164 the page is accounted for in the
165 obd_io_group given to
166 obd_queue_group_io */
169 struct obd_async_page_ops {
170 int (*ap_make_ready)(void *data, int cmd);
171 int (*ap_refresh_count)(void *data, int cmd);
172 void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
173 void (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
176 /* the `oig' is passed down from a caller of obd rw methods. the callee
177 * records enough state such that the caller can sleep on the oig and
178 * be woken when all the callees have finished their work */
179 struct obd_io_group {
181 atomic_t oig_refcount;
184 struct list_head oig_occ_list;
185 wait_queue_head_t oig_waitq;
188 /* the oig callback context lets the callee of obd rw methods register
189 * for callbacks from the caller. */
190 struct oig_callback_context {
191 struct list_head occ_oig_item;
192 /* called when the caller has received a signal while sleeping.
193 * callees of this method are encouraged to abort their state
194 * in the oig. This may be called multiple times. */
195 void (*occ_interrupted)(struct oig_callback_context *occ);
199 /* if we find more consumers this could be generalized */
200 #define OBD_HIST_MAX 32
201 struct obd_histogram {
203 unsigned long oh_buckets[OBD_HIST_MAX];
206 /* reports average service time with the help of lprocfs_status.c */
207 struct obd_service_time {
212 struct ost_server_data;
214 #define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
216 #define FILTER_GROUP_LLOG 1
217 #define FILTER_GROUP_ECHO 2
218 #define FILTER_GROUP_FIRST_MDS 3
220 struct filter_subdirs {
221 struct dentry *dentry[FILTER_SUBDIR_COUNT];
224 struct filter_group_llog {
225 struct list_head list;
227 struct obd_llogs *llogs;
228 struct obd_export *exp;
232 const char *fo_fstype;
233 struct super_block *fo_sb;
234 struct vfsmount *fo_vfsmnt;
235 struct lvfs_obd_ctxt *fo_lvfs_ctxt;
238 struct dentry *fo_dentry_O; /* the "O"bject directory dentry */
239 struct dentry **fo_groups; /* dentries for each group dir */
240 struct filter_subdirs *fo_subdirs; /* subdir array per group */
241 __u64 *fo_last_objids; /* per-group last created objid */
242 struct file **fo_last_objid_files;
243 struct semaphore fo_init_lock; /* group initialization lock */
244 int fo_committed_group;
246 spinlock_t fo_objidlock; /* protect fo_lastobjid increment */
247 spinlock_t fo_lastidlock; /* protect last_id increment */
248 spinlock_t fo_translock; /* protect fsd_last_rcvd increment */
249 struct file *fo_rcvd_filp;
250 struct filter_server_data *fo_fsd;
251 unsigned long *fo_last_rcvd_slots;
252 __u64 fo_mount_count;
254 unsigned long fo_destroys_in_progress;
255 struct semaphore fo_create_locks[32];
257 struct file_operations *fo_fop;
258 struct inode_operations *fo_iop;
259 struct address_space_operations *fo_aops;
261 struct list_head fo_export_list;
264 obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
265 obd_size fo_tot_granted; /* all values in bytes */
266 obd_size fo_tot_pending;
268 obd_size fo_readcache_max_filesize;
270 struct obd_import *fo_mdc_imp;
271 struct obd_uuid fo_mdc_uuid;
272 struct lustre_handle fo_mdc_conn;
274 struct semaphore fo_alloc_lock;
276 struct obd_histogram fo_r_pages;
277 struct obd_histogram fo_w_pages;
278 struct obd_histogram fo_r_discont_pages;
279 struct obd_histogram fo_w_discont_pages;
280 struct obd_histogram fo_r_discont_blocks;
281 struct obd_histogram fo_w_discont_blocks;
283 struct list_head fo_llog_list;
284 spinlock_t fo_llog_list_lock;
286 /* which secure flavor from remote is denied */
287 spinlock_t fo_denylist_lock;
288 struct list_head fo_denylist;
290 /* capability related */
292 spinlock_t fo_capa_lock;
294 struct list_head fo_capa_keys;
297 struct mds_server_data;
299 #define OSC_MAX_RIF_DEFAULT 8
300 #define OSC_MAX_RIF_MAX 64
301 #define OSC_MAX_DIRTY_DEFAULT (4*OSC_MAX_RIF_DEFAULT*PTLRPC_MAX_BRW_SIZE>>20)
302 #define OSC_MAX_DIRTY_MB_MAX 512 /* totally arbitrary */
306 struct obd_import *cl_import;
307 struct semaphore cl_sem;
309 /* max_mds_easize is purely a performance thing so we don't have to
310 * call obd_size_wiremd() all the time. */
311 int cl_max_mds_easize;
312 int cl_max_mds_cookiesize;
315 /* security flavors */
317 unsigned long cl_sec_flags;
319 //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
320 void *cl_llcd_offset;
322 struct obd_device *cl_mgmtcli_obd;
324 /* the grant values are protected by loi_list_lock below */
325 long cl_dirty; /* all _dirty_ in bytes */
326 long cl_dirty_max; /* allowed w/o rpc */
327 long cl_avail_grant; /* bytes of credit for ost */
328 long cl_lost_grant; /* lost credits (trunc) */
329 struct list_head cl_cache_waiters; /* waiting for cache/grant */
331 /* keep track of objects that have lois that contain pages which
332 * have been queued for async brw. this lock also protects the
333 * lists of osc_client_pages that hang off of the loi */
334 spinlock_t cl_loi_list_lock;
335 struct list_head cl_loi_ready_list;
336 struct list_head cl_loi_write_list;
337 struct list_head cl_loi_read_list;
340 /* just a sum of the loi/lop pending numbers to be exported by /proc */
341 int cl_pending_w_pages;
342 int cl_pending_r_pages;
343 int cl_max_pages_per_rpc;
344 int cl_max_rpcs_in_flight;
345 struct obd_histogram cl_read_rpc_hist;
346 struct obd_histogram cl_write_rpc_hist;
347 struct obd_histogram cl_read_page_hist;
348 struct obd_histogram cl_write_page_hist;
349 struct obd_service_time cl_read_stime;
350 struct obd_service_time cl_write_stime;
351 struct obd_service_time cl_enter_stime;
353 struct mdc_rpc_lock *cl_rpc_lock;
354 struct mdc_rpc_lock *cl_setattr_lock;
355 struct mdc_rpc_lock *cl_close_lock;
356 struct osc_creator cl_oscc;
359 int cl_dstr_in_flight;
360 int cl_max_dstr_in_flight;
361 wait_queue_head_t cl_wait_for_destroy_slot;
364 struct timeval cl_last_write_time;
365 unsigned long cl_write_gap_sum;
366 unsigned long cl_write_gaps;
367 unsigned long cl_write_num;
368 unsigned long cl_read_num;
369 unsigned long cl_cache_wait_num;
370 unsigned long cl_cache_wait_sum;
372 unsigned long cl_dirty_num;
373 unsigned long cl_dirty_sum;
374 unsigned long cl_dirty_av;
376 unsigned long cl_dirty_dmax;
377 unsigned long cl_dirty_dmin;
379 unsigned long cl_sync_rpcs;
382 /* Like a client, with some hangers-on. Keep mc_client_obd first so that we
383 * can reuse the various client setup/connect functions. */
385 struct client_obd mc_client_obd; /* nested */
386 struct ptlrpc_thread *mc_ping_thread;
387 struct obd_export *mc_ping_exp; /* XXX single-target */
388 struct list_head mc_registered;
392 #define mc_import mc_client_obd.cl_import
395 struct ptlrpc_service *mds_service;
396 struct ptlrpc_service *mds_setattr_service;
397 struct ptlrpc_service *mds_readpage_service;
398 struct ptlrpc_service *mds_close_service;
399 struct super_block *mds_sb;
400 struct vfsmount *mds_vfsmnt;
401 struct dentry *mds_id_de;
402 struct lvfs_obd_ctxt *mds_lvfs_ctxt;
404 int mds_max_cookiesize;
405 struct file *mds_rcvd_filp;
406 struct file *mds_fid_filp;
407 struct file *mds_virtid_filp;
408 spinlock_t mds_transno_lock;
409 __u64 mds_last_transno;
410 __u64 mds_mount_count;
414 __u64 mds_virtid_fid;
415 spinlock_t mds_last_fid_lock;
417 struct semaphore mds_epoch_sem;
418 struct lustre_id mds_rootid;
419 struct mds_server_data *mds_server_data;
420 struct dentry *mds_pending_dir;
421 struct dentry *mds_logs_dir;
422 struct dentry *mds_objects_dir;
423 struct llog_handle *mds_cfg_llh;
425 struct obd_device *mds_dt_obd;
426 struct obd_uuid mds_dt_uuid;
427 struct obd_export *mds_dt_exp;
429 struct lov_desc mds_dt_desc;
431 spinlock_t mds_dt_lock;
432 obd_id *mds_dt_objids;
433 struct file *mds_dt_objid_filp;
434 int mds_dt_objids_valid;
436 unsigned long *mds_client_bitmap;
437 struct semaphore mds_orphan_recovery_sem;
440 int mds_config_version;
443 struct obd_device *mds_md_obd;
444 struct obd_export *mds_md_exp;
445 struct semaphore mds_md_sem;
446 struct obd_uuid mds_md_uuid;
447 int mds_md_connected;
449 struct ptlrpc_service *mds_create_service;
450 uid_t mds_squash_uid;
451 gid_t mds_squash_gid;
452 ptl_nid_t mds_nosquash_nid;
453 atomic_t mds_real_clients;
454 atomic_t mds_open_count;
455 struct dentry *mds_id_dir;
457 struct dentry *mds_unnamed_dir; /* for mdt_obd_create only */
459 /* security related */
463 /* which secure flavor from remote to this mds is denied */
464 spinlock_t mds_denylist_lock;
465 struct list_head mds_denylist;
467 /* fid->ino mapping related fields */
468 spinlock_t mds_fidmap_lock;
469 struct hlist_head *mds_fidmap_table;
470 unsigned long mds_fidmap_size;
472 /* cache fid extents stuff */
473 spinlock_t mds_fidext_lock;
474 __u64 mds_fidext_thumb;
477 /* capability related */
478 int mds_capa_stat; /* 1: on, 0: off */
479 unsigned long mds_capa_timeout; /* sec */
481 struct mds_capa_key mds_capa_keys[2]; /* red & black key */
482 int mds_capa_key_idx; /* the red key index */
483 struct file *mds_capa_keys_filp;
484 unsigned long mds_capa_key_timeout; /* sec */
491 struct lustre_handle eo_nl_lock;
496 * this struct does double-duty acting as either a client or
497 * server instance .. maybe not wise.
501 struct ptlrpc_service *ptlbd_service;
504 struct ptlrpc_client bd_client;
505 struct obd_import *bd_import;
506 struct obd_uuid bd_server_uuid;
507 struct obd_export *bd_exp;
508 int refcount; /* XXX sigh */
512 spinlock_t recovd_lock;
513 struct list_head recovd_managed_items; /* items managed */
514 struct list_head recovd_troubled_items; /* items in recovery */
516 wait_queue_head_t recovd_recovery_waitq;
517 wait_queue_head_t recovd_ctl_waitq;
518 wait_queue_head_t recovd_waitq;
519 struct task_struct *recovd_thread;
525 struct ptlrpc_service *ost_service;
526 struct ptlrpc_service *ost_create_service;
527 struct ptlrpc_service *ost_destroy_service;
528 struct obd_service_time ost_stimes[6];
531 struct echo_client_obd {
532 struct obd_export *ec_exp; /* the local connection to osc/lov */
534 struct list_head ec_objects;
540 struct obd_export *master_exp; /* local connection to master obd */
541 struct obd_export *cache_exp; /* local connection to cache obd */
542 struct obd_export *cache_real_exp;
543 struct obd_export *master_real_exp;
544 struct obd_device *master;
545 struct obd_device *cache;
550 struct semaphore sem;
551 struct lov_desc dt_desc; /* data lovdesc */
555 struct obd_export *cache_exp; /* local connection to cache obd */
556 struct obd_export *master_exp;
557 struct obd_device *cache_obd;
558 struct obd_device *master_obd;
560 struct cmobd_write_service *write_srv;
561 struct lov_desc master_desc; /* master device lovdesc */
565 struct super_block *cfobd_sb;
566 struct vfsmount *cfobd_vfsmnt;
567 struct dentry *cfobd_logs_dir;
568 struct dentry *cfobd_objects_dir;
569 struct dentry *cfobd_pending_dir;
570 struct llog_handle *cfobd_cfg_llh;
571 struct lvfs_obd_ctxt *cfobd_lvfs_ctxt;
575 LTD_ACTIVE = 0x1, /* is this target up for requests */
576 LTD_DEL_PENDING = 0x2, /* delete event pending for this tgt */
579 struct lov_tgt_desc {
580 struct obd_uuid uuid;
582 struct obd_export *ltd_exp;
583 unsigned int ltd_flags;
589 struct lov_desc desc;
592 int lo_catalog_loaded:1, async:1;
593 struct semaphore lov_llog_sem;
594 unsigned long lov_connect_flags;
595 wait_queue_head_t lov_tgt_waitq;
596 struct lov_tgt_desc *tgts;
599 struct lmv_tgt_desc {
600 struct obd_uuid uuid;
601 struct obd_export *ltd_exp;
602 int active; /* is this target up for requests */
608 struct lmv_desc desc;
609 struct lmv_tgt_desc *tgts;
610 struct obd_uuid cluuid;
611 struct obd_export *exp;
619 struct semaphore init_sem;
620 struct obd_connect_data conn_data;
622 struct gks_crypto_key {
627 struct ptlrpc_service *gks_service;
628 struct crypto_tfm *gks_mac_tfm;
629 struct crypto_tfm *gks_key_tfm;
630 struct gks_crypto_key gks_key;
633 struct niobuf_local {
638 struct dentry *dentry;
643 #define OBD_MODE_ASYNC (1 << 0)
644 #define OBD_MODE_CROW (1 << 1)
646 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
647 #define N_LOCAL_TEMP_PAGE 0x10000000
649 struct obd_trans_info {
653 /* only used on the server side for tracking acks. */
654 struct oti_req_ack_lock {
655 struct lustre_handle lock;
659 struct llog_cookie oti_onecookie;
660 struct llog_cookie *oti_logcookies;
663 /* save nid for security purposes like audit */
667 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
672 if (num_cookies == 1)
673 oti->oti_logcookies = &oti->oti_onecookie;
675 OBD_ALLOC(oti->oti_logcookies,
676 num_cookies * sizeof(oti->oti_onecookie));
678 oti->oti_numcookies = num_cookies;
681 static inline void oti_free_cookies(struct obd_trans_info *oti)
683 if (!oti || !oti->oti_logcookies)
686 if (oti->oti_logcookies == &oti->oti_onecookie)
687 LASSERT(oti->oti_numcookies == 1);
689 OBD_FREE(oti->oti_logcookies,
690 oti->oti_numcookies * sizeof(oti->oti_onecookie));
691 oti->oti_logcookies = NULL;
692 oti->oti_numcookies = 0;
697 LLOG_CONFIG_ORIG_CTXT = 0,
698 LLOG_CONFIG_REPL_CTXT = 1,
699 LLOG_UNLINK_ORIG_CTXT = 2,
700 LLOG_UNLINK_REPL_CTXT = 3,
701 LLOG_SIZE_ORIG_CTXT = 4,
702 LLOG_SIZE_REPL_CTXT = 5,
703 LLOG_MD_ORIG_CTXT = 6,
704 LLOG_MD_REPL_CTXT = 7,
705 LLOG_RD1_ORIG_CTXT = 8,
706 LLOG_RD1_REPL_CTXT = 9,
707 LLOG_TEST_ORIG_CTXT = 10,
708 LLOG_TEST_REPL_CTXT = 11,
709 LLOG_REINT_ORIG_CTXT = 12,
710 LLOG_AUDIT_ORIG_CTXT = 13,
715 struct llog_ctxt *llog_ctxt[LLOG_MAX_CTXTS];
718 struct target_recovery_data {
719 svc_handler_t trd_recovery_handler;
720 pid_t trd_processing_task;
721 struct completion trd_starting;
722 struct completion trd_finishing;
725 /* corresponds to one of the obd's */
727 struct obd_type *obd_type;
729 /* common and UUID name of this device */
731 struct obd_uuid obd_uuid;
734 unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
735 obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
736 obd_no_recov:1, obd_stopping:1, obd_req_replaying:1;
737 atomic_t obd_refcount;
738 wait_queue_head_t obd_refcount_waitq;
739 struct proc_dir_entry *obd_proc_entry;
740 struct list_head obd_exports;
742 struct ldlm_namespace *obd_namespace;
743 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
744 /* a spinlock is OK for what we do now, may need a semaphore later */
745 spinlock_t obd_dev_lock;
746 __u64 obd_last_committed;
747 struct fsfilt_operations *obd_fsops;
748 spinlock_t obd_osfs_lock;
749 struct obd_statfs obd_osfs;
750 unsigned long obd_osfs_age;
751 struct lvfs_run_ctxt obd_lvfs_ctxt;
752 struct obd_llogs obd_llogs;
753 struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
754 struct obd_device *obd_observer;
755 struct obd_export *obd_self_export;
757 struct target_recovery_data obd_recovery_data;
758 /* XXX encapsulate all this recovery data into target_recovery_data */
759 int obd_max_recoverable_clients;
760 int obd_connected_clients;
761 int obd_recoverable_clients;
762 spinlock_t obd_processing_task_lock;
763 __u64 obd_next_recovery_transno;
764 int obd_replayed_requests;
765 int obd_replayed_locks;
766 int obd_requests_queued_for_recovery;
767 wait_queue_head_t obd_next_transno_waitq;
768 struct list_head obd_uncommitted_replies;
769 spinlock_t obd_uncommitted_replies_lock;
770 struct timer_list obd_recovery_timer;
771 time_t obd_recovery_start;
772 time_t obd_recovery_end;
774 atomic_t obd_req_replay_clients;
775 atomic_t obd_lock_replay_clients;
777 struct list_head obd_req_replay_queue;
778 struct list_head obd_lock_replay_queue;
779 struct list_head obd_final_req_queue;
780 int obd_recovery_stage;
783 struct filter_obd filter;
785 struct client_obd cli;
787 struct echo_client_obd echocli;
788 struct echo_obd echo;
789 struct recovd_obd recovd;
791 struct cache_obd cobd;
792 struct ptlbd_obd ptlbd;
793 struct mgmtcli_obd mgmtcli;
796 struct conf_obd conf;
800 /* fields used by LProcFS */
801 unsigned int obd_cntr_base;
802 struct lprocfs_stats *obd_stats;
803 unsigned int md_cntr_base;
804 struct lprocfs_stats *md_stats;
806 struct proc_dir_entry *obd_svc_procroot;
807 struct lprocfs_stats *obd_svc_stats;
810 #define OBD_OPT_FORCE (1 << 0)
811 #define OBD_OPT_FAILOVER (1 << 1)
812 #define OBD_OPT_REAL_CLIENT (1 << 2)
813 #define OBD_OPT_MDS_CONNECTION (1 << 3)
815 #define OBD_LLOG_FL_SENDNOW (1 << 0)
816 #define OBD_LLOG_FL_CREATE (1 << 1)
821 struct module *o_owner;
822 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
823 void *karg, void *uarg);
824 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
825 __u32 *vallen, void *val);
826 int (*o_set_info)(struct obd_export *, __u32 keylen, void *key,
827 __u32 vallen, void *val);
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, obd_count len, void *data);
831 int (*o_precleanup)(struct obd_device *dev, int flags);
832 int (*o_cleanup)(struct obd_device *dev, int flags);
833 int (*o_process_config)(struct obd_device *dev, obd_count len,
835 int (*o_postrecov)(struct obd_device *dev);
836 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
838 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
839 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
840 struct obd_uuid *cluuid, struct obd_connect_data *data,
841 unsigned long flags);
842 int (*o_connect_post)(struct obd_export *exp, unsigned, unsigned long);
843 int (*o_disconnect)(struct obd_export *exp, unsigned long flags);
845 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
846 unsigned long max_age);
847 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
848 struct lov_stripe_md *mem_src);
849 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
850 struct lov_mds_md *disk_src, int disk_len);
851 int (*o_revalidate_md)(struct obd_export *exp, struct obdo *oa,
852 struct lov_stripe_md *ea,
853 struct obd_trans_info *oti);
854 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
856 int (*o_create)(struct obd_export *exp, struct obdo *oa,
857 void *acl, int acl_size,
858 struct lov_stripe_md **ea, struct obd_trans_info *oti);
859 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
860 struct lov_stripe_md *ea, struct obd_trans_info *oti);
861 int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
862 struct lov_stripe_md *ea, struct obd_trans_info *oti,
863 struct lustre_capa *capa);
864 int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
865 struct lov_stripe_md *ea);
866 int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
867 struct lov_stripe_md *ea,
868 struct ptlrpc_request_set *set);
869 int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
870 struct lov_stripe_md *ea, obd_count oa_bufs,
871 struct brw_page *pgarr, struct obd_trans_info *oti);
872 int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
873 struct lov_stripe_md *ea, obd_count oa_bufs,
874 struct brw_page *pgarr, struct ptlrpc_request_set *,
875 struct obd_trans_info *oti);
876 int (*o_prep_async_page)(struct obd_export *exp,
877 struct lov_stripe_md *lsm,
878 struct lov_oinfo *loi,
879 struct page *page, obd_off offset,
880 struct obd_async_page_ops *ops, void *data,
882 int (*o_queue_async_io)(struct obd_export *exp,
883 struct lov_stripe_md *lsm,
884 struct lov_oinfo *loi, void *cookie,
885 int cmd, obd_off off, int count,
886 obd_flags brw_flags, obd_flags async_flags);
887 int (*o_queue_group_io)(struct obd_export *exp,
888 struct lov_stripe_md *lsm,
889 struct lov_oinfo *loi,
890 struct obd_io_group *oig,
891 void *cookie, int cmd, obd_off off, int count,
892 obd_flags brw_flags, obd_flags async_flags);
893 int (*o_trigger_group_io)(struct obd_export *exp,
894 struct lov_stripe_md *lsm,
895 struct lov_oinfo *loi,
896 struct obd_io_group *oig);
897 int (*o_set_async_flags)(struct obd_export *exp,
898 struct lov_stripe_md *lsm,
899 struct lov_oinfo *loi, void *cookie,
900 obd_flags async_flags);
901 int (*o_teardown_async_page)(struct obd_export *exp,
902 struct lov_stripe_md *lsm,
903 struct lov_oinfo *loi, void *cookie);
904 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
905 obd_off size, int shrink);
906 int (*o_punch)(struct obd_export *exp, struct obdo *oa,
907 struct lov_stripe_md *ea, obd_size start,
908 obd_size end, struct obd_trans_info *oti,
909 struct lustre_capa *capa);
910 int (*o_sync)(struct obd_export *exp, struct obdo *oa,
911 struct lov_stripe_md *ea, obd_size start, obd_size end);
912 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
913 struct lov_stripe_md *src, obd_size start,
914 obd_size end, struct obd_trans_info *oti);
915 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
916 struct lustre_handle *srconn, struct lov_stripe_md *src,
917 obd_size start, obd_size end, struct obd_trans_info *);
918 int (*o_iterate)(struct lustre_handle *conn,
919 int (*)(obd_id, obd_gr, void *),
920 obd_id *startid, obd_gr group, void *data);
921 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
922 int objcount, struct obd_ioobj *obj,
923 int niocount, struct niobuf_remote *remote,
924 struct niobuf_local *local, struct obd_trans_info *oti,
925 struct lustre_capa *capa);
926 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
927 int objcount, struct obd_ioobj *obj,
928 int niocount, struct niobuf_local *local,
929 struct obd_trans_info *oti, int rc);
930 int (*o_do_cow)(struct obd_export *exp, struct obd_ioobj *obj,
931 int objcount, struct niobuf_remote *rnb);
932 int (*o_write_extents)(struct obd_export *exp, struct obd_ioobj *obj,
933 int objcount, int niocount,
934 struct niobuf_local *local,int rc);
935 int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
936 __u32 type, ldlm_policy_data_t *, __u32 mode,
937 int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
938 void *data, __u32 lvb_len, void *lvb_swabber,
939 struct lustre_handle *lockh);
940 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
941 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
942 struct lustre_handle *lockh);
943 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
944 ldlm_iterator_t it, void *data);
945 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
946 __u32 mode, struct lustre_handle *);
947 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
948 int flags, void *opaque);
949 int (*o_san_preprw)(int cmd, struct obd_export *exp,
950 struct obdo *oa, int objcount,
951 struct obd_ioobj *obj, int niocount,
952 struct niobuf_remote *remote);
953 int (*o_init_export)(struct obd_export *exp);
954 int (*o_destroy_export)(struct obd_export *exp);
956 /* llog related obd_methods */
957 int (*o_llog_init)(struct obd_device *, struct obd_llogs *,
958 struct obd_device *, int, struct llog_catid *);
959 int (*o_llog_finish)(struct obd_device *, struct obd_llogs *, int);
960 int (*o_llog_connect)(struct obd_export *, struct llogd_conn_body *);
963 /* metadata-only methods */
964 int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
965 struct obd_client_handle *, int flag);
966 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
968 int (*o_import_event)(struct obd_device *, struct obd_import *,
969 enum obd_import_event);
971 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
972 int active, void *data);
974 int (*o_init_ea_size)(struct obd_export *, int, int);
977 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
978 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
979 * Also, add a wrapper function in include/linux/obd_class.h.
984 int (*m_getstatus)(struct obd_export *, struct lustre_id *);
985 int (*m_change_cbdata)(struct obd_export *, struct lustre_id *,
986 ldlm_iterator_t, void *);
987 int (*m_change_cbdata_name)(struct obd_export *, struct lustre_id *,
988 char *, int, struct lustre_id *,
989 ldlm_iterator_t, void *);
990 int (*m_close)(struct obd_export *, struct mdc_op_data *,
991 struct obd_client_handle *, struct ptlrpc_request **);
992 int (*m_create)(struct obd_export *, struct mdc_op_data *,
993 const void *, int, int, __u32, __u32,
994 __u64, struct ptlrpc_request **);
995 int (*m_done_writing)(struct obd_export *, struct obdo *);
996 int (*m_enqueue)(struct obd_export *, int, struct lookup_intent *,
997 int, struct mdc_op_data *, struct lustre_handle *,
998 void *, int, ldlm_completion_callback,
999 ldlm_blocking_callback, void *);
1000 int (*m_getattr)(struct obd_export *, struct lustre_id *,
1001 __u64, const char *, const void *, unsigned int,
1002 unsigned int, struct obd_capa *,
1003 struct ptlrpc_request **);
1004 int (*m_access_check)(struct obd_export *, struct lustre_id *,
1005 struct ptlrpc_request **);
1006 int (*m_getattr_lock)(struct obd_export *, struct lustre_id *,
1008 unsigned int, struct ptlrpc_request **);
1009 int (*m_intent_lock)(struct obd_export *,
1010 struct lustre_id *, const char *, int,
1011 void *, int, struct lustre_id *,
1012 struct lookup_intent *, int,
1013 struct ptlrpc_request **,
1014 ldlm_blocking_callback);
1015 int (*m_link)(struct obd_export *, struct mdc_op_data *,
1016 struct ptlrpc_request **);
1017 int (*m_rename)(struct obd_export *, struct mdc_op_data *,
1018 const char *, int, const char *, int,
1019 struct ptlrpc_request **);
1020 int (*m_setattr)(struct obd_export *, struct mdc_op_data *,
1021 struct iattr *, void *, int , void *, int,
1022 void *, int, struct ptlrpc_request **);
1023 int (*m_sync)(struct obd_export *, struct lustre_id *,
1024 struct ptlrpc_request **);
1025 int (*m_readpage)(struct obd_export *, struct lustre_id *,
1026 __u64, struct page *, struct ptlrpc_request **);
1027 int (*m_unlink)(struct obd_export *, struct mdc_op_data *,
1028 struct ptlrpc_request **);
1029 int (*m_valid_attrs)(struct obd_export *, struct lustre_id *);
1031 struct obd_device *(*m_get_real_obd)(struct obd_export *, struct lustre_id *);
1033 int (*m_req2lustre_md)(struct obd_export *exp,
1034 struct ptlrpc_request *req, unsigned int offset,
1035 struct obd_export *osc_exp, struct lustre_md *md);
1036 int (*m_set_open_replay_data)(struct obd_export *exp,
1037 struct obd_client_handle *och,
1038 struct ptlrpc_request *open_req);
1039 int (*m_clear_open_replay_data)(struct obd_export *exp,
1040 struct obd_client_handle *och);
1041 int (*m_store_inode_generation)(struct obd_export *exp,
1042 struct ptlrpc_request *req, int reqoff,
1044 int (*m_set_lock_data)(struct obd_export *exp, __u64 *l, void *data);
1046 int (*m_delete_inode)(struct obd_export *, struct lustre_id *);
1049 * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
1050 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
1051 * wrapper function in include/linux/obd_class.h.
1055 static inline void obd_transno_commit_cb(struct obd_device *obd,
1056 __u64 transno, int error)
1059 CERROR("%s: transno "LPD64" commit error: %d\n",
1060 obd->obd_name, transno, error);
1064 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
1065 obd->obd_name, transno);
1067 if (transno > obd->obd_last_committed) {
1068 obd->obd_last_committed = transno;
1069 ptlrpc_commit_replies (obd);
1073 static inline int obd_md_type(struct obd_device *obd)
1075 if (!strcmp(obd->obd_type->typ_name, OBD_MDC_DEVICENAME) ||
1076 !strcmp(obd->obd_type->typ_name, OBD_LMV_DEVICENAME))
1082 static inline int obd_dt_type(struct obd_device *obd)
1084 if (!strcmp(obd->obd_type->typ_name, OBD_LOV_DEVICENAME) ||
1085 !strcmp(obd->obd_type->typ_name, OBD_OSC_DEVICENAME))
1091 #endif /* __OBD_H */