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 #include <linux/lvfs.h>
37 #include <linux/lustre_lib.h>
38 #include <linux/lustre_idl.h>
39 #include <linux/lustre_export.h>
41 /* this is really local to the OSC */
42 struct loi_oap_pages {
43 struct list_head lop_pending;
45 struct list_head lop_urgent;
46 struct list_head lop_pending_group;
49 struct lov_oinfo { /* per-stripe data structure */
50 __u64 loi_id; /* object ID on the target OST */
51 __u64 loi_gr; /* object group on the target OST */
52 int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
53 int loi_ost_gen; /* generation of this loi_ost_idx */
55 /* used by the osc to keep track of what objects to build into rpcs */
56 struct loi_oap_pages loi_read_lop;
57 struct loi_oap_pages loi_write_lop;
58 /* _cli_ is poorly named, it should be _ready_ */
59 struct list_head loi_cli_item;
60 struct list_head loi_write_item;
61 struct list_head loi_read_item;
63 unsigned loi_kms_valid:1;
64 __u64 loi_kms; /* known minimum size */
65 __u64 loi_rss; /* recently seen size */
66 __u64 loi_mtime; /* recently seen mtime */
67 __u64 loi_blocks; /* recently seen blocks */
70 static inline void loi_init(struct lov_oinfo *loi)
72 INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
73 INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
74 INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
75 INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
76 INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
77 INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
78 INIT_LIST_HEAD(&loi->loi_cli_item);
79 INIT_LIST_HEAD(&loi->loi_write_item);
80 INIT_LIST_HEAD(&loi->loi_read_item);
83 struct lov_stripe_md {
85 __u64 lsm_object_id; /* lov object id */
86 __u64 lsm_object_gr; /* lov object id */
87 __u64 lsm_maxbytes; /* maximum possible file size */
88 unsigned long lsm_xfersize; /* optimal transfer size */
90 /* LOV-private members start here -- only for use in lov/. */
92 __u32 lsm_stripe_size; /* size of the stripe */
93 __u32 lsm_pattern; /* striping pattern (RAID0, RAID1) */
94 unsigned lsm_stripe_count; /* number of objects being striped over */
95 struct lov_oinfo lsm_oinfo[0];
98 static inline void dump_lsm(int level, struct lov_stripe_md *lsm)
101 CDEBUG(level, "objid "LPX64"/"LPU64", maxbytes "LPX64", magic 0x%08X, "
102 "stripe_size %u, stripe_count %u\n",
103 lsm->lsm_object_id, lsm->lsm_object_gr, lsm->lsm_maxbytes,
104 lsm->lsm_magic, lsm->lsm_stripe_size, lsm->lsm_stripe_count);
105 for (i = 0; i < lsm->lsm_stripe_count; i++)
106 CDEBUG(level, "idx %u ostidx %u/%u object "LPU64"/"LPU64"\n",
107 i, lsm->lsm_oinfo[i].loi_ost_idx,
108 lsm->lsm_oinfo[i].loi_ost_gen,
109 lsm->lsm_oinfo[i].loi_id, lsm->lsm_oinfo[i].loi_gr);
113 struct list_head typ_chain;
114 struct obd_ops *typ_ops;
115 struct md_ops *typ_md_ops;
116 struct proc_dir_entry *typ_procroot;
122 obd_off disk_offset; /* modulo PAGE_SIZE */
123 obd_off page_offset; /* modulo PAGE_SIZE (obviously) */
130 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
131 page is added to an rpc */
133 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
134 to give the caller a chance to update
135 or cancel the size of the io */
136 ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
137 the page is accounted for in the
138 obd_io_group given to
139 obd_queue_group_io */
142 struct obd_async_page_ops {
143 int (*ap_make_ready)(void *data, int cmd);
144 int (*ap_refresh_count)(void *data, int cmd);
145 void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
146 void (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
149 /* the `oig' is passed down from a caller of obd rw methods. the callee
150 * records enough state such that the caller can sleep on the oig and
151 * be woken when all the callees have finished their work */
152 struct obd_io_group {
154 atomic_t oig_refcount;
157 struct list_head oig_occ_list;
158 wait_queue_head_t oig_waitq;
161 /* the oig callback context lets the callee of obd rw methods register
162 * for callbacks from the caller. */
163 struct oig_callback_context {
164 struct list_head occ_oig_item;
165 /* called when the caller has received a signal while sleeping.
166 * callees of this method are encouraged to abort their state
167 * in the oig. This may be called multiple times. */
168 void (*occ_interrupted)(struct oig_callback_context *occ);
172 /* if we find more consumers this could be generalized */
173 #define OBD_HIST_MAX 32
174 struct obd_histogram {
176 unsigned long oh_buckets[OBD_HIST_MAX];
179 /* reports average service time with the help of lprocfs_status.c */
180 struct obd_service_time {
186 struct ost_server_data;
188 #define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
190 #define FILTER_GROUP_LLOG 1
191 #define FILTER_GROUP_ECHO 2
192 #define FILTER_GROUP_FIRST_MDS 3
194 struct filter_subdirs {
195 struct dentry *dentry[FILTER_SUBDIR_COUNT];
198 struct filter_group_llog {
199 struct list_head list;
201 struct obd_llogs *llogs;
202 struct obd_export *exp;
206 const char *fo_fstype;
207 struct super_block *fo_sb;
208 struct vfsmount *fo_vfsmnt;
209 struct lvfs_obd_ctxt *fo_lvfs_ctxt;
212 struct dentry *fo_dentry_O; /* the "O"bject directory dentry */
213 struct dentry **fo_groups; /* dentries for each group dir */
214 struct filter_subdirs *fo_subdirs; /* subdir array per group */
215 __u64 *fo_last_objids; /* per-group last created objid */
216 struct file **fo_last_objid_files;
217 struct semaphore fo_init_lock; /* group initialization lock */
218 int fo_committed_group;
220 spinlock_t fo_objidlock; /* protect fo_lastobjid increment */
221 spinlock_t fo_lastidlock; /* protect last_id increment */
222 spinlock_t fo_translock; /* protect fsd_last_rcvd increment */
223 struct file *fo_rcvd_filp;
224 struct filter_server_data *fo_fsd;
225 unsigned long *fo_last_rcvd_slots;
226 __u64 fo_mount_count;
228 unsigned long fo_destroys_in_progress;
229 struct semaphore fo_create_locks[32];
231 struct file_operations *fo_fop;
232 struct inode_operations *fo_iop;
233 struct address_space_operations *fo_aops;
235 struct list_head fo_export_list;
238 obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
239 obd_size fo_tot_granted; /* all values in bytes */
240 obd_size fo_tot_pending;
242 obd_size fo_readcache_max_filesize;
244 struct obd_import *fo_mdc_imp;
245 struct obd_uuid fo_mdc_uuid;
246 struct lustre_handle fo_mdc_conn;
248 struct semaphore fo_alloc_lock;
250 struct obd_histogram fo_r_pages;
251 struct obd_histogram fo_w_pages;
252 struct obd_histogram fo_r_discont_pages;
253 struct obd_histogram fo_w_discont_pages;
254 struct obd_histogram fo_r_discont_blocks;
255 struct obd_histogram fo_w_discont_blocks;
257 struct list_head fo_llog_list;
258 spinlock_t fo_llog_list_lock;
260 /* which secure flavor from remote is denied */
261 spinlock_t fo_denylist_lock;
262 struct list_head fo_denylist;
266 struct mds_server_data;
268 #define OSC_MAX_RIF_DEFAULT 8
269 #define OSC_MAX_RIF_MAX 64
270 #define OSC_MAX_DIRTY_DEFAULT (4*OSC_MAX_RIF_DEFAULT*PTLRPC_MAX_BRW_SIZE>>20)
271 #define OSC_MAX_DIRTY_MB_MAX 512 /* totally arbitrary */
276 struct obd_import *cl_import;
277 struct semaphore cl_sem;
279 /* max_mds_easize is purely a performance thing so we don't have to
280 * call obd_size_wiremd() all the time. */
281 int cl_max_mds_easize;
282 int cl_max_mds_cookiesize;
285 /* security flavors */
287 unsigned long cl_sec_flags;
289 //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
290 void *cl_llcd_offset;
292 struct obd_device *cl_mgmtcli_obd;
294 /* the grant values are protected by loi_list_lock below */
295 long cl_dirty; /* all _dirty_ in bytes */
296 long cl_dirty_max; /* allowed w/o rpc */
297 long cl_avail_grant; /* bytes of credit for ost */
298 long cl_lost_grant; /* lost credits (trunc) */
299 struct list_head cl_cache_waiters; /* waiting for cache/grant */
301 /* keep track of objects that have lois that contain pages which
302 * have been queued for async brw. this lock also protects the
303 * lists of osc_client_pages that hang off of the loi */
304 spinlock_t cl_loi_list_lock;
305 struct list_head cl_loi_ready_list;
306 struct list_head cl_loi_write_list;
307 struct list_head cl_loi_read_list;
310 /* just a sum of the loi/lop pending numbers to be exported by /proc */
311 int cl_pending_w_pages;
312 int cl_pending_r_pages;
313 int cl_max_pages_per_rpc;
314 int cl_max_rpcs_in_flight;
315 struct obd_histogram cl_read_rpc_hist;
316 struct obd_histogram cl_write_rpc_hist;
317 struct obd_histogram cl_read_page_hist;
318 struct obd_histogram cl_write_page_hist;
319 struct obd_service_time cl_read_stime;
320 struct obd_service_time cl_write_stime;
321 struct obd_service_time cl_enter_stime;
323 struct mdc_rpc_lock *cl_rpc_lock;
324 struct mdc_rpc_lock *cl_setattr_lock;
325 struct mdc_rpc_lock *cl_close_lock;
326 struct osc_creator cl_oscc;
330 /* Like a client, with some hangers-on. Keep mc_client_obd first so that we
331 * can reuse the various client setup/connect functions. */
333 struct client_obd mc_client_obd; /* nested */
334 struct ptlrpc_thread *mc_ping_thread;
335 struct obd_export *mc_ping_exp; /* XXX single-target */
336 struct list_head mc_registered;
340 #define mc_import mc_client_obd.cl_import
343 struct ptlrpc_service *mds_service;
344 struct ptlrpc_service *mds_setattr_service;
345 struct ptlrpc_service *mds_readpage_service;
346 struct ptlrpc_service *mds_close_service;
347 struct super_block *mds_sb;
348 struct vfsmount *mds_vfsmnt;
349 struct dentry *mds_id_de;
350 struct lvfs_obd_ctxt *mds_lvfs_ctxt;
352 int mds_max_cookiesize;
353 struct file *mds_rcvd_filp;
354 struct file *mds_fid_filp;
355 struct file *mds_virtid_filp;
356 spinlock_t mds_transno_lock;
357 __u64 mds_last_transno;
358 __u64 mds_mount_count;
362 __u64 mds_virtid_fid;
363 spinlock_t mds_last_fid_lock;
365 struct semaphore mds_epoch_sem;
366 struct lustre_id mds_rootid;
367 struct mds_server_data *mds_server_data;
368 struct dentry *mds_pending_dir;
369 struct dentry *mds_logs_dir;
370 struct dentry *mds_objects_dir;
371 struct llog_handle *mds_cfg_llh;
373 struct obd_device *mds_dt_obd;
374 struct obd_uuid mds_dt_uuid;
375 struct obd_export *mds_dt_exp;
377 struct lov_desc mds_dt_desc;
379 spinlock_t mds_dt_lock;
380 obd_id *mds_dt_objids;
381 struct file *mds_dt_objid_filp;
382 int mds_dt_objids_valid;
384 unsigned long *mds_client_bitmap;
385 struct semaphore mds_orphan_recovery_sem;
388 int mds_config_version;
391 struct obd_device *mds_md_obd;
392 struct obd_export *mds_md_exp;
393 struct semaphore mds_md_sem;
394 struct obd_uuid mds_md_uuid;
395 int mds_md_connected;
397 struct ptlrpc_service *mds_create_service;
398 uid_t mds_squash_uid;
399 gid_t mds_squash_gid;
400 ptl_nid_t mds_nosquash_nid;
401 atomic_t mds_real_clients;
402 atomic_t mds_open_count;
403 struct dentry *mds_id_dir;
405 struct dentry *mds_unnamed_dir; /* for mdt_obd_create only */
407 /* security related */
410 /* which secure flavor from remote to this mds is denied */
411 spinlock_t mds_denylist_lock;
412 struct list_head mds_denylist;
413 struct semaphore mds_create_sem;
421 struct lustre_handle eo_nl_lock;
426 * this struct does double-duty acting as either a client or
427 * server instance .. maybe not wise.
431 struct ptlrpc_service *ptlbd_service;
434 struct ptlrpc_client bd_client;
435 struct obd_import *bd_import;
436 struct obd_uuid bd_server_uuid;
437 struct obd_export *bd_exp;
438 int refcount; /* XXX sigh */
442 spinlock_t recovd_lock;
443 struct list_head recovd_managed_items; /* items managed */
444 struct list_head recovd_troubled_items; /* items in recovery */
446 wait_queue_head_t recovd_recovery_waitq;
447 wait_queue_head_t recovd_ctl_waitq;
448 wait_queue_head_t recovd_waitq;
449 struct task_struct *recovd_thread;
455 struct ptlrpc_service *ost_service;
456 struct ptlrpc_service *ost_create_service;
457 struct ptlrpc_service *ost_destroy_service;
458 struct obd_service_time ost_stimes[6];
461 struct echo_client_obd {
462 struct obd_export *ec_exp; /* the local connection to osc/lov */
464 struct list_head ec_objects;
470 struct obd_export *master_exp; /* local connection to master obd */
471 struct obd_export *cache_exp; /* local connection to cache obd */
472 struct obd_export *cache_real_exp;
473 struct obd_export *master_real_exp;
474 struct obd_device *master;
475 struct obd_device *cache;
480 struct semaphore sem;
484 struct obd_export *cache_exp; /* local connection to cache obd */
485 struct obd_export *master_exp;
486 struct obd_device *cache_obd;
487 struct obd_device *master_obd;
489 struct cmobd_write_service *write_srv;
490 struct lov_desc master_desc; /* master device lovdesc */
494 struct super_block *cfobd_sb;
495 struct vfsmount *cfobd_vfsmnt;
496 struct dentry *cfobd_logs_dir;
497 struct dentry *cfobd_objects_dir;
498 struct dentry *cfobd_pending_dir;
499 struct llog_handle *cfobd_cfg_llh;
500 struct lvfs_obd_ctxt *cfobd_lvfs_ctxt;
503 struct lov_tgt_desc {
504 struct obd_uuid uuid;
506 struct obd_export *ltd_exp;
507 int active; /* is this target up for requests */
512 struct lov_desc desc;
515 int lo_catalog_loaded:1, async:1;
516 struct semaphore lov_llog_sem;
517 unsigned long lov_connect_flags;
518 struct lov_tgt_desc *tgts;
521 struct lmv_tgt_desc {
522 struct obd_uuid uuid;
523 struct obd_export *ltd_exp;
524 int active; /* is this target up for requests */
530 struct lmv_desc desc;
531 struct lmv_tgt_desc *tgts;
532 struct obd_uuid cluuid;
533 struct obd_export *exp;
541 struct semaphore init_sem;
542 struct obd_connect_data conn_data;
544 struct gks_crypto_key {
549 struct ptlrpc_service *gks_service;
550 struct crypto_tfm *gks_mac_tfm;
551 struct crypto_tfm *gks_key_tfm;
552 struct gks_crypto_key gks_key;
555 struct niobuf_local {
560 struct dentry *dentry;
565 #define OBD_MODE_ASYNC (1 << 0)
566 #define OBD_MODE_CROW (1 << 1)
568 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
569 #define N_LOCAL_TEMP_PAGE 0x10000000
571 struct obd_trans_info {
575 /* only used on the server side for tracking acks. */
576 struct oti_req_ack_lock {
577 struct lustre_handle lock;
581 struct llog_cookie oti_onecookie;
582 struct llog_cookie *oti_logcookies;
587 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
592 if (num_cookies == 1)
593 oti->oti_logcookies = &oti->oti_onecookie;
595 OBD_ALLOC(oti->oti_logcookies,
596 num_cookies * sizeof(oti->oti_onecookie));
598 oti->oti_numcookies = num_cookies;
601 static inline void oti_free_cookies(struct obd_trans_info *oti)
603 if (!oti || !oti->oti_logcookies)
606 if (oti->oti_logcookies == &oti->oti_onecookie)
607 LASSERT(oti->oti_numcookies == 1);
609 OBD_FREE(oti->oti_logcookies,
610 oti->oti_numcookies * sizeof(oti->oti_onecookie));
611 oti->oti_logcookies = NULL;
612 oti->oti_numcookies = 0;
617 LLOG_CONFIG_ORIG_CTXT = 0,
618 LLOG_CONFIG_REPL_CTXT = 1,
619 LLOG_UNLINK_ORIG_CTXT = 2,
620 LLOG_UNLINK_REPL_CTXT = 3,
621 LLOG_SIZE_ORIG_CTXT = 4,
622 LLOG_SIZE_REPL_CTXT = 5,
623 LLOG_MD_ORIG_CTXT = 6,
624 LLOG_MD_REPL_CTXT = 7,
625 LLOG_RD1_ORIG_CTXT = 8,
626 LLOG_RD1_REPL_CTXT = 9,
627 LLOG_TEST_ORIG_CTXT = 10,
628 LLOG_TEST_REPL_CTXT = 11,
629 LLOG_REINT_ORIG_CTXT = 12,
630 LLOG_AUDIT_ORIG_CTXT = 13,
635 struct llog_ctxt *llog_ctxt[LLOG_MAX_CTXTS];
638 struct target_recovery_data {
639 svc_handler_t trd_recovery_handler;
640 pid_t trd_processing_task;
641 struct completion trd_starting;
642 struct completion trd_finishing;
645 /* corresponds to one of the obd's */
647 struct obd_type *obd_type;
649 /* common and UUID name of this device */
651 struct obd_uuid obd_uuid;
654 unsigned int obd_attached:1, obd_set_up:1, obd_recovering:1,
655 obd_abort_recovery:1, obd_replayable:1, obd_no_transno:1,
656 obd_no_recov:1, obd_stopping:1;
657 atomic_t obd_refcount;
658 wait_queue_head_t obd_refcount_waitq;
659 struct proc_dir_entry *obd_proc_entry;
660 struct list_head obd_exports;
662 struct ldlm_namespace *obd_namespace;
663 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
664 /* a spinlock is OK for what we do now, may need a semaphore later */
665 spinlock_t obd_dev_lock;
666 __u64 obd_last_committed;
667 struct fsfilt_operations *obd_fsops;
668 spinlock_t obd_osfs_lock;
669 struct obd_statfs obd_osfs;
670 unsigned long obd_osfs_age;
671 struct lvfs_run_ctxt obd_lvfs_ctxt;
672 struct obd_llogs obd_llogs;
673 struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
674 struct obd_device *obd_observer;
675 struct obd_export *obd_self_export;
677 struct target_recovery_data obd_recovery_data;
678 /* XXX encapsulate all this recovery data into target_recovery_data */
679 int obd_max_recoverable_clients;
680 int obd_connected_clients;
681 int obd_recoverable_clients;
682 spinlock_t obd_processing_task_lock;
683 __u64 obd_next_recovery_transno;
684 int obd_replayed_requests;
685 int obd_replayed_locks;
686 int obd_requests_queued_for_recovery;
687 wait_queue_head_t obd_next_transno_waitq;
688 struct list_head obd_uncommitted_replies;
689 spinlock_t obd_uncommitted_replies_lock;
690 struct timer_list obd_recovery_timer;
691 time_t obd_recovery_start;
692 time_t obd_recovery_end;
694 atomic_t obd_req_replay_clients;
695 atomic_t obd_lock_replay_clients;
697 struct list_head obd_req_replay_queue;
698 struct list_head obd_lock_replay_queue;
699 struct list_head obd_final_req_queue;
700 int obd_recovery_stage;
703 struct filter_obd filter;
705 struct client_obd cli;
707 struct echo_client_obd echocli;
708 struct echo_obd echo;
709 struct recovd_obd recovd;
711 struct cache_obd cobd;
712 struct ptlbd_obd ptlbd;
713 struct mgmtcli_obd mgmtcli;
716 struct conf_obd conf;
720 /* fields used by LProcFS */
721 unsigned int obd_cntr_base;
722 struct lprocfs_stats *obd_stats;
723 unsigned int md_cntr_base;
724 struct lprocfs_stats *md_stats;
726 struct proc_dir_entry *obd_svc_procroot;
727 struct lprocfs_stats *obd_svc_stats;
730 #define OBD_OPT_FORCE (1 << 0)
731 #define OBD_OPT_FAILOVER (1 << 1)
732 #define OBD_OPT_REAL_CLIENT (1 << 2)
733 #define OBD_OPT_MDS_CONNECTION (1 << 3)
735 #define OBD_LLOG_FL_SENDNOW (1 << 0)
736 #define OBD_LLOG_FL_CREATE (1 << 1)
741 struct module *o_owner;
742 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
743 void *karg, void *uarg);
744 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
745 __u32 *vallen, void *val);
746 int (*o_set_info)(struct obd_export *, __u32 keylen, void *key,
747 __u32 vallen, void *val);
748 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
749 int (*o_detach)(struct obd_device *dev);
750 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
751 int (*o_precleanup)(struct obd_device *dev, int flags);
752 int (*o_cleanup)(struct obd_device *dev, int flags);
753 int (*o_process_config)(struct obd_device *dev, obd_count len,
755 int (*o_postrecov)(struct obd_device *dev);
756 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
758 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
759 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
760 struct obd_uuid *cluuid, struct obd_connect_data *data,
761 unsigned long flags);
762 int (*o_connect_post)(struct obd_export *exp, unsigned, unsigned long);
763 int (*o_disconnect)(struct obd_export *exp, unsigned long flags);
765 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
766 unsigned long max_age);
767 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
768 struct lov_stripe_md *mem_src);
769 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
770 struct lov_mds_md *disk_src, int disk_len);
771 int (*o_revalidate_md)(struct obd_export *exp, struct obdo *oa,
772 struct lov_stripe_md *ea,
773 struct obd_trans_info *oti);
774 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
776 int (*o_create)(struct obd_export *exp, struct obdo *oa,
777 void *acl, int acl_size,
778 struct lov_stripe_md **ea, struct obd_trans_info *oti);
779 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
780 struct lov_stripe_md *ea, struct obd_trans_info *oti);
781 int (*o_setattr)(struct obd_export *exp, struct obdo *oa,
782 struct lov_stripe_md *ea, struct obd_trans_info *oti);
783 int (*o_getattr)(struct obd_export *exp, struct obdo *oa,
784 struct lov_stripe_md *ea);
785 int (*o_getattr_async)(struct obd_export *exp, struct obdo *oa,
786 struct lov_stripe_md *ea,
787 struct ptlrpc_request_set *set);
788 int (*o_brw)(int rw, struct obd_export *exp, struct obdo *oa,
789 struct lov_stripe_md *ea, obd_count oa_bufs,
790 struct brw_page *pgarr, struct obd_trans_info *oti);
791 int (*o_brw_async)(int rw, struct obd_export *exp, struct obdo *oa,
792 struct lov_stripe_md *ea, obd_count oa_bufs,
793 struct brw_page *pgarr, struct ptlrpc_request_set *,
794 struct obd_trans_info *oti);
795 int (*o_prep_async_page)(struct obd_export *exp,
796 struct lov_stripe_md *lsm,
797 struct lov_oinfo *loi,
798 struct page *page, obd_off offset,
799 struct obd_async_page_ops *ops, void *data,
801 int (*o_queue_async_io)(struct obd_export *exp,
802 struct lov_stripe_md *lsm,
803 struct lov_oinfo *loi, void *cookie,
804 int cmd, obd_off off, int count,
805 obd_flags brw_flags, obd_flags async_flags);
806 int (*o_queue_group_io)(struct obd_export *exp,
807 struct lov_stripe_md *lsm,
808 struct lov_oinfo *loi,
809 struct obd_io_group *oig,
810 void *cookie, int cmd, obd_off off, int count,
811 obd_flags brw_flags, obd_flags async_flags);
812 int (*o_trigger_group_io)(struct obd_export *exp,
813 struct lov_stripe_md *lsm,
814 struct lov_oinfo *loi,
815 struct obd_io_group *oig);
816 int (*o_set_async_flags)(struct obd_export *exp,
817 struct lov_stripe_md *lsm,
818 struct lov_oinfo *loi, void *cookie,
819 obd_flags async_flags);
820 int (*o_teardown_async_page)(struct obd_export *exp,
821 struct lov_stripe_md *lsm,
822 struct lov_oinfo *loi, void *cookie);
823 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
824 obd_off size, int shrink);
825 int (*o_punch)(struct obd_export *exp, struct obdo *oa,
826 struct lov_stripe_md *ea, obd_size start,
827 obd_size end, struct obd_trans_info *oti);
828 int (*o_sync)(struct obd_export *exp, struct obdo *oa,
829 struct lov_stripe_md *ea, obd_size start, obd_size end);
830 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
831 struct lov_stripe_md *src, obd_size start,
832 obd_size end, struct obd_trans_info *oti);
833 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
834 struct lustre_handle *srconn, struct lov_stripe_md *src,
835 obd_size start, obd_size end, struct obd_trans_info *);
836 int (*o_iterate)(struct lustre_handle *conn,
837 int (*)(obd_id, obd_gr, void *),
838 obd_id *startid, obd_gr group, void *data);
839 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
840 int objcount, struct obd_ioobj *obj,
841 int niocount, struct niobuf_remote *remote,
842 struct niobuf_local *local, struct obd_trans_info *oti);
843 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
844 int objcount, struct obd_ioobj *obj,
845 int niocount, struct niobuf_local *local,
846 struct obd_trans_info *oti, int rc);
847 int (*o_do_cow)(struct obd_export *exp, struct obd_ioobj *obj,
848 int objcount, struct niobuf_remote *rnb);
849 int (*o_write_extents)(struct obd_export *exp, struct obd_ioobj *obj,
850 int objcount, int niocount,
851 struct niobuf_local *local,int rc);
852 int (*o_enqueue)(struct obd_export *, struct lov_stripe_md *,
853 __u32 type, ldlm_policy_data_t *, __u32 mode,
854 int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
855 void *data, __u32 lvb_len, void *lvb_swabber,
856 struct lustre_handle *lockh);
857 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
858 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
859 struct lustre_handle *lockh);
860 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
861 ldlm_iterator_t it, void *data);
862 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
863 __u32 mode, struct lustre_handle *);
864 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
865 int flags, void *opaque);
866 int (*o_san_preprw)(int cmd, struct obd_export *exp,
867 struct obdo *oa, int objcount,
868 struct obd_ioobj *obj, int niocount,
869 struct niobuf_remote *remote);
870 int (*o_init_export)(struct obd_export *exp);
871 int (*o_destroy_export)(struct obd_export *exp);
873 /* llog related obd_methods */
874 int (*o_llog_init)(struct obd_device *, struct obd_llogs *,
875 struct obd_device *, int, struct llog_catid *);
876 int (*o_llog_finish)(struct obd_device *, struct obd_llogs *, int);
877 int (*o_llog_connect)(struct obd_export *, struct llogd_conn_body *);
880 /* metadata-only methods */
881 int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
882 struct obd_client_handle *, int flag);
883 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
885 int (*o_import_event)(struct obd_device *, struct obd_import *,
886 enum obd_import_event);
888 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
889 int active, void *data);
891 int (*o_init_ea_size)(struct obd_export *, int, int);
894 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
895 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
896 * Also, add a wrapper function in include/linux/obd_class.h.
901 int (*m_getstatus)(struct obd_export *, struct lustre_id *);
902 int (*m_change_cbdata)(struct obd_export *, struct lustre_id *,
903 ldlm_iterator_t, void *);
904 int (*m_change_cbdata_name)(struct obd_export *, struct lustre_id *,
905 char *, int, struct lustre_id *,
906 ldlm_iterator_t, void *);
907 int (*m_close)(struct obd_export *, struct obdo *,
908 struct obd_client_handle *,
909 struct ptlrpc_request **);
910 int (*m_create)(struct obd_export *, struct mdc_op_data *,
911 const void *, int, int, __u32, __u32,
912 __u64, struct ptlrpc_request **);
913 int (*m_done_writing)(struct obd_export *, struct obdo *);
914 int (*m_enqueue)(struct obd_export *, int, struct lookup_intent *,
915 int, struct mdc_op_data *, struct lustre_handle *,
916 void *, int, ldlm_completion_callback,
917 ldlm_blocking_callback, void *);
918 int (*m_getattr)(struct obd_export *, struct lustre_id *,
919 __u64, const char *, const void *, unsigned int,
920 unsigned int, struct ptlrpc_request **);
921 int (*m_access_check)(struct obd_export *, struct lustre_id *,
922 struct ptlrpc_request **);
923 int (*m_getattr_lock)(struct obd_export *, struct lustre_id *,
925 unsigned int, struct ptlrpc_request **);
926 int (*m_intent_lock)(struct obd_export *,
927 struct lustre_id *, const char *, int,
928 void *, int, struct lustre_id *,
929 struct lookup_intent *, int,
930 struct ptlrpc_request **,
931 ldlm_blocking_callback);
932 int (*m_link)(struct obd_export *, struct mdc_op_data *,
933 struct ptlrpc_request **);
934 int (*m_rename)(struct obd_export *, struct mdc_op_data *,
935 const char *, int, const char *, int,
936 struct ptlrpc_request **);
937 int (*m_setattr)(struct obd_export *, struct mdc_op_data *,
938 struct iattr *, void *, int , void *, int,
939 void *, int, struct ptlrpc_request **);
940 int (*m_sync)(struct obd_export *, struct lustre_id *,
941 struct ptlrpc_request **);
942 int (*m_readpage)(struct obd_export *, struct lustre_id *,
943 __u64, struct page *, struct ptlrpc_request **);
944 int (*m_unlink)(struct obd_export *, struct mdc_op_data *,
945 struct ptlrpc_request **);
946 int (*m_valid_attrs)(struct obd_export *, struct lustre_id *);
948 struct obd_device *(*m_get_real_obd)(struct obd_export *, struct lustre_id *);
950 int (*m_req2lustre_md)(struct obd_export *exp,
951 struct ptlrpc_request *req, unsigned int offset,
952 struct obd_export *osc_exp, struct lustre_md *md);
953 int (*m_set_open_replay_data)(struct obd_export *exp,
954 struct obd_client_handle *och,
955 struct ptlrpc_request *open_req);
956 int (*m_clear_open_replay_data)(struct obd_export *exp,
957 struct obd_client_handle *och);
958 int (*m_store_inode_generation)(struct obd_export *exp,
959 struct ptlrpc_request *req, int reqoff,
961 int (*m_set_lock_data)(struct obd_export *exp, __u64 *l, void *data);
963 int (*m_delete_inode)(struct obd_export *, struct lustre_id *);
966 * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
967 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
968 * wrapper function in include/linux/obd_class.h.
972 static inline void obd_transno_commit_cb(struct obd_device *obd,
973 __u64 transno, int error)
976 CERROR("%s: transno "LPD64" commit error: %d\n",
977 obd->obd_name, transno, error);
981 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
982 obd->obd_name, transno);
984 if (transno > obd->obd_last_committed) {
985 obd->obd_last_committed = transno;
986 ptlrpc_commit_replies (obd);