1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
40 #if defined(__linux__)
41 #include <linux/obd.h>
42 #elif defined(__APPLE__)
43 #include <darwin/obd.h>
44 #elif defined(__WINNT__)
45 #include <winnt/obd.h>
47 #error Unsupported operating system.
50 #define IOC_OSC_TYPE 'h'
51 #define IOC_OSC_MIN_NR 20
52 #define IOC_OSC_SET_ACTIVE _IOWR(IOC_OSC_TYPE, 21, struct obd_device *)
53 #define IOC_OSC_MAX_NR 50
55 #define IOC_MDC_TYPE 'i'
56 #define IOC_MDC_MIN_NR 20
57 /* Moved to lustre_user.h
58 #define IOC_MDC_LOOKUP _IOWR(IOC_MDC_TYPE, 20, struct obd_ioctl_data *)
59 #define IOC_MDC_GETSTRIPE _IOWR(IOC_MDC_TYPE, 21, struct lov_mds_md *) */
60 #define IOC_MDC_MAX_NR 50
62 #include <lustre/lustre_idl.h>
63 #include <lu_object.h>
64 #include <lustre_lib.h>
65 #include <lustre_export.h>
66 #include <lustre_quota.h>
67 #include <lustre_fld.h>
68 #include <lustre_capa.h>
69 #include <class_hash.h>
71 #include <libcfs/bitmap.h>
74 #define MAX_OBD_DEVICES 8192
76 /* this is really local to the OSC */
77 struct loi_oap_pages {
78 struct list_head lop_pending;
79 struct list_head lop_urgent;
80 struct list_head lop_pending_group;
90 struct lov_oinfo { /* per-stripe data structure */
91 __u64 loi_id; /* object ID on the target OST */
92 __u64 loi_gr; /* object group on the target OST */
93 int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
94 int loi_ost_gen; /* generation of this loi_ost_idx */
96 /* used by the osc to keep track of what objects to build into rpcs */
97 struct loi_oap_pages loi_read_lop;
98 struct loi_oap_pages loi_write_lop;
99 /* _cli_ is poorly named, it should be _ready_ */
100 struct list_head loi_cli_item;
101 struct list_head loi_write_item;
102 struct list_head loi_read_item;
104 unsigned long loi_kms_valid:1;
105 __u64 loi_kms; /* known minimum size */
106 struct ost_lvb loi_lvb;
107 struct osc_async_rc loi_ar;
110 static inline void loi_init(struct lov_oinfo *loi)
112 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
113 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
114 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
115 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
116 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
117 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
118 CFS_INIT_LIST_HEAD(&loi->loi_cli_item);
119 CFS_INIT_LIST_HEAD(&loi->loi_write_item);
120 CFS_INIT_LIST_HEAD(&loi->loi_read_item);
123 /*extent array item for describing the joined file extent info*/
125 __u64 le_start; /* extent start */
126 __u64 le_len; /* extent length */
127 int le_loi_idx; /* extent #1 loi's index in lsm loi array */
128 int le_stripe_count; /* extent stripe count*/
131 /*Lov array info for describing joined file array EA info*/
132 struct lov_array_info {
133 struct llog_logid lai_array_id; /* MDS med llog object id */
134 unsigned lai_ext_count; /* number of extent count */
135 struct lov_extent *lai_ext_array; /* extent desc array */
138 struct lov_stripe_md {
140 pid_t lsm_lock_owner; /* debugging */
143 /* Public members. */
144 __u64 lw_object_id; /* lov object id */
145 __u64 lw_object_gr; /* lov object group */
146 __u64 lw_maxbytes; /* maximum possible file size */
148 /* LOV-private members start here -- only for use in lov/. */
150 __u32 lw_stripe_size; /* size of the stripe */
151 __u32 lw_pattern; /* striping pattern (RAID0, RAID1) */
152 unsigned lw_stripe_count; /* number of objects being striped over */
155 struct lov_array_info *lsm_array; /*Only for joined file array info*/
156 struct lov_oinfo *lsm_oinfo[0];
159 #define lsm_object_id lsm_wire.lw_object_id
160 #define lsm_object_gr lsm_wire.lw_object_gr
161 #define lsm_maxbytes lsm_wire.lw_maxbytes
162 #define lsm_magic lsm_wire.lw_magic
163 #define lsm_stripe_size lsm_wire.lw_stripe_size
164 #define lsm_pattern lsm_wire.lw_pattern
165 #define lsm_stripe_count lsm_wire.lw_stripe_count
169 typedef int (*obd_enqueue_update_f)(struct obd_info *oinfo, int rc);
171 /* obd info for a particular level (lov, osc). */
173 /* Lock policy. It keeps an extent which is specific for a particular
174 * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy,
175 * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */
176 ldlm_policy_data_t oi_policy;
177 /* Flags used for set request specific flags:
178 - while lock handling, the flags obtained on the enqueue
179 request are set here.
180 - while stats, the flags used for control delay/resend.
183 /* Lock handle specific for every OSC lock. */
184 struct lustre_handle *oi_lockh;
185 /* lsm data specific for every OSC. */
186 struct lov_stripe_md *oi_md;
187 /* obdo data specific for every OSC, if needed at all. */
189 /* statfs data specific for every OSC, if needed at all. */
190 struct obd_statfs *oi_osfs;
191 /* An update callback which is called to update some data on upper
192 * level. E.g. it is used for update lsm->lsm_oinfo at every recieved
193 * request in osc level for enqueue requests. It is also possible to
194 * update some caller data from LOV layer if needed. */
195 obd_enqueue_update_f oi_cb_up;
196 /* oss capability, its type is obd_capa in client to avoid copy.
197 * in contrary its type is lustre_capa in OSS. */
201 /* compare all relevant fields. */
202 static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
203 struct lov_stripe_md *m2)
206 * ->lsm_wire contains padding, but it should be zeroed out during
209 return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof m1->lsm_wire);
212 void lov_stripe_lock(struct lov_stripe_md *md);
213 void lov_stripe_unlock(struct lov_stripe_md *md);
216 struct list_head typ_chain;
217 struct obd_ops *typ_dt_ops;
218 struct md_ops *typ_md_ops;
219 cfs_proc_dir_entry_t *typ_procroot;
222 struct lu_device_type *typ_lu;
223 spinlock_t obd_type_lock;
234 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
235 page is added to an rpc */
236 ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
237 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
238 to give the caller a chance to update
239 or cancel the size of the io */
240 ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
241 the page is accounted for in the
242 obd_io_group given to
243 obd_queue_group_io */
246 struct obd_async_page_ops {
247 int (*ap_make_ready)(void *data, int cmd);
248 int (*ap_refresh_count)(void *data, int cmd);
249 void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
250 void (*ap_update_obdo)(void *data, int cmd, struct obdo *oa,
252 int (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
253 struct obd_capa *(*ap_lookup_capa)(void *data, int cmd);
256 /* the `oig' is passed down from a caller of obd rw methods. the callee
257 * records enough state such that the caller can sleep on the oig and
258 * be woken when all the callees have finished their work */
259 struct obd_io_group {
261 atomic_t oig_refcount;
264 struct list_head oig_occ_list;
265 cfs_waitq_t oig_waitq;
268 /* the oig callback context lets the callee of obd rw methods register
269 * for callbacks from the caller. */
270 struct oig_callback_context {
271 struct list_head occ_oig_item;
272 /* called when the caller has received a signal while sleeping.
273 * callees of this method are encouraged to abort their state
274 * in the oig. This may be called multiple times. */
275 void (*occ_interrupted)(struct oig_callback_context *occ);
276 unsigned long interrupted:1;
279 /* Individual type definitions */
281 struct ost_server_data;
283 /* hold common fields for "target" device */
284 struct obd_device_target {
285 struct super_block *obt_sb;
286 atomic_t obt_quotachecking;
287 struct lustre_quota_ctxt obt_qctxt;
290 typedef void (*obd_pin_extent_cb)(void *data);
291 typedef int (*obd_page_removal_cb_t)(void *data, int discard);
292 typedef int (*obd_lock_cancel_cb)(struct ldlm_lock *,struct ldlm_lock_desc *,
297 LLOG_CONFIG_ORIG_CTXT = 0,
298 LLOG_CONFIG_REPL_CTXT,
299 LLOG_MDS_OST_ORIG_CTXT,
300 LLOG_MDS_OST_REPL_CTXT,
307 LLOG_LOVEA_ORIG_CTXT,
308 LLOG_LOVEA_REPL_CTXT,
312 #define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */
314 struct filter_subdirs {
315 cfs_dentry_t *dentry[FILTER_SUBDIR_COUNT];
325 /* NB this field MUST be first */
326 struct obd_device_target fo_obt;
327 const char *fo_fstype;
328 struct vfsmount *fo_vfsmnt;
331 cfs_dentry_t *fo_dentry_O;
332 cfs_dentry_t **fo_dentry_O_groups;
333 struct filter_subdirs *fo_dentry_O_sub;
334 struct semaphore fo_init_lock; /* group initialization lock */
335 int fo_committed_group;
338 spinlock_t fo_objidlock; /* protect fo_lastobjid */
339 spinlock_t fo_translock; /* protect fsd_last_transno */
340 struct file *fo_rcvd_filp;
341 struct file *fo_health_check_filp;
342 struct lr_server_data *fo_fsd;
343 unsigned long *fo_last_rcvd_slots;
344 __u64 fo_mount_count;
346 unsigned long fo_destroys_in_progress;
347 struct semaphore fo_create_locks[FILTER_SUBDIR_COUNT];
349 struct list_head fo_export_list;
352 obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
353 obd_size fo_tot_granted; /* all values in bytes */
354 obd_size fo_tot_pending;
356 obd_size fo_readcache_max_filesize;
358 struct obd_import *fo_mdc_imp;
359 struct obd_uuid fo_mdc_uuid;
360 struct lustre_handle fo_mdc_conn;
361 struct file **fo_last_objid_files;
362 __u64 *fo_last_objids; /* last created objid for groups,
363 * protected by fo_objidlock */
365 struct semaphore fo_alloc_lock;
367 atomic_t fo_r_in_flight;
368 atomic_t fo_w_in_flight;
371 * per-filter pool of kiobuf's allocated by filter_common_setup() and
372 * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
373 * which ->fo_iobuf_count were allocated.
375 * This pool contains kiobuf used by
376 * filter_{prep,commit}rw_{read,write}() and is shared by all OST
379 * Locking: none, each OST thread uses only one element, determined by
380 * its "ordinal number", ->t_id.
382 struct filter_iobuf **fo_iobuf_pool;
385 struct list_head fo_llog_list;
386 spinlock_t fo_llog_list_lock;
388 struct brw_stats fo_filter_stats;
389 struct lustre_quota_ctxt fo_quota_ctxt;
390 spinlock_t fo_quotacheck_lock;
391 atomic_t fo_quotachecking;
393 int fo_fmd_max_num; /* per exp filter_mod_data */
394 int fo_fmd_max_age; /* jiffies to fmd expiry */
397 rwlock_t fo_sptlrpc_lock;
398 struct sptlrpc_rule_set fo_sptlrpc_rset;
400 /* capability related */
401 unsigned int fo_fl_oss_capa;
402 struct list_head fo_capa_keys;
403 struct hlist_head *fo_capa_hash;
404 struct llog_commit_master *fo_lcm;
407 #define OSC_MAX_RIF_DEFAULT 8
408 #define OSC_MAX_RIF_MAX 256
409 #define OSC_MAX_DIRTY_DEFAULT (OSC_MAX_RIF_DEFAULT * 4)
410 #define OSC_MAX_DIRTY_MB_MAX 2048 /* arbitrary, but < MAX_LONG bytes */
411 #define OSC_DEFAULT_RESENDS 10
413 #define MDC_MAX_RIF_DEFAULT 8
414 #define MDC_MAX_RIF_MAX 512
420 struct rw_semaphore cl_sem;
421 struct obd_uuid cl_target_uuid;
422 struct obd_import *cl_import; /* ptlrpc connection state */
424 /* max_mds_easize is purely a performance thing so we don't have to
425 * call obd_size_diskmd() all the time. */
426 int cl_default_mds_easize;
427 int cl_max_mds_easize;
428 int cl_max_mds_cookiesize;
430 /* security configuration */
431 struct sptlrpc_rule_set cl_sptlrpc_rset;
432 enum lustre_sec_part cl_sec_part;
434 //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
435 void *cl_llcd_offset;
437 /* the grant values are protected by loi_list_lock below */
438 long cl_dirty; /* all _dirty_ in bytes */
439 long cl_dirty_max; /* allowed w/o rpc */
440 long cl_avail_grant; /* bytes of credit for ost */
441 long cl_lost_grant; /* lost credits (trunc) */
442 struct list_head cl_cache_waiters; /* waiting for cache/grant */
444 /* keep track of objects that have lois that contain pages which
445 * have been queued for async brw. this lock also protects the
446 * lists of osc_client_pages that hang off of the loi */
448 * ->cl_loi_list_lock protects consistency of
449 * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
450 * ->ap_completion() call-backs are executed under this lock. As we
451 * cannot guarantee that these call-backs never block on all platforms
452 * (as a matter of fact they do block on Mac OS X), type of
453 * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
454 * and blocking mutex on Mac OS X. (Alternative is to make this lock
455 * blocking everywhere, but we don't want to slow down fast-path of
456 * our main platform.)
458 * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
459 * with client_obd_list_{un,}lock() and
460 * client_obd_list_lock_{init,done}() functions.
462 client_obd_lock_t cl_loi_list_lock;
463 struct list_head cl_loi_ready_list;
464 struct list_head cl_loi_write_list;
465 struct list_head cl_loi_read_list;
468 /* just a sum of the loi/lop pending numbers to be exported by /proc */
469 int cl_pending_w_pages;
470 int cl_pending_r_pages;
471 int cl_max_pages_per_rpc;
472 int cl_max_rpcs_in_flight;
473 struct obd_histogram cl_read_rpc_hist;
474 struct obd_histogram cl_write_rpc_hist;
475 struct obd_histogram cl_read_page_hist;
476 struct obd_histogram cl_write_page_hist;
477 struct obd_histogram cl_read_offset_hist;
478 struct obd_histogram cl_write_offset_hist;
480 /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */
481 atomic_t cl_destroy_in_flight;
482 cfs_waitq_t cl_destroy_waitq;
484 struct mdc_rpc_lock *cl_rpc_lock;
485 struct mdc_rpc_lock *cl_setattr_lock;
486 struct mdc_rpc_lock *cl_close_lock;
487 struct osc_creator cl_oscc;
490 struct semaphore cl_mgc_sem;
491 struct vfsmount *cl_mgc_vfsmnt;
492 struct dentry *cl_mgc_configs_dir;
493 atomic_t cl_mgc_refcount;
494 struct obd_export *cl_mgc_mgsexp;
496 /* checksumming for data sent over the network */
497 unsigned int cl_checksum:1; /* 0 = disabled, 1 = enabled */
498 /* supported checksum types that are worked out at connect time */
499 __u32 cl_supp_cksum_types;
500 /* checksum algorithm to be used */
501 cksum_type_t cl_cksum_type;
503 /* also protected by the poorly named _loi_list_lock lock above */
504 struct osc_async_rc cl_ar;
506 /* used by quotacheck */
507 int cl_qchk_stat; /* quotacheck stat of the peer */
509 /* sequence manager */
510 struct lu_client_seq *cl_seq;
512 atomic_t cl_resends; /* resend count */
514 /* Cache of triples */
515 struct lustre_cache *cl_cache;
516 obd_lock_cancel_cb cl_ext_lock_cancel_cb;
518 #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
520 #define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */
523 struct ptlrpc_service *mgs_service;
524 struct vfsmount *mgs_vfsmnt;
525 struct super_block *mgs_sb;
526 struct dentry *mgs_configs_dir;
527 struct dentry *mgs_fid_de;
528 struct list_head mgs_fs_db_list;
529 struct semaphore mgs_sem;
530 cfs_proc_dir_entry_t *mgs_proc_live;
534 /* NB this field MUST be first */
535 struct obd_device_target mds_obt;
536 struct ptlrpc_service *mds_service;
537 struct ptlrpc_service *mds_setattr_service;
538 struct ptlrpc_service *mds_readpage_service;
539 struct vfsmount *mds_vfsmnt;
540 cfs_dentry_t *mds_fid_de;
542 int mds_max_cookiesize;
543 struct file *mds_rcvd_filp;
544 spinlock_t mds_transno_lock;
545 __u64 mds_last_transno;
546 __u64 mds_mount_count;
548 unsigned long mds_atime_diff;
549 struct semaphore mds_epoch_sem;
550 struct ll_fid mds_rootfid;
551 struct lr_server_data *mds_server_data;
552 cfs_dentry_t *mds_pending_dir;
553 cfs_dentry_t *mds_logs_dir;
554 cfs_dentry_t *mds_objects_dir;
555 struct llog_handle *mds_cfg_llh;
556 struct obd_device *mds_osc_obd; /* XXX lov_obd */
557 struct obd_uuid mds_lov_uuid;
559 struct obd_export *mds_osc_exp; /* XXX lov_exp */
560 struct lov_desc mds_lov_desc;
563 /* mark pages dirty for write. */
564 bitmap_t *mds_lov_page_dirty;
565 /* array for store pages with obd_id */
566 void **mds_lov_page_array;
567 /* file for store objid */
568 struct file *mds_lov_objid_filp;
569 __u32 mds_lov_objid_count;
570 __u32 mds_lov_objid_lastpage;
571 __u32 mds_lov_objid_lastidx;
573 struct file *mds_health_check_filp;
574 unsigned long *mds_client_bitmap;
575 // struct upcall_cache *mds_group_hash;
577 struct lustre_quota_info mds_quota_info;
578 struct semaphore mds_qonoff_sem;
579 struct semaphore mds_health_sem;
580 unsigned long mds_fl_user_xattr:1,
582 mds_evict_ost_nids:1,
586 struct upcall_cache *mds_identity_cache;
588 /* for capability keys update */
589 struct lustre_capa_key *mds_capa_keys;
590 struct rw_semaphore mds_notify_lock;
594 extern __u32 mds_max_ost_index;
596 #define MDS_LOV_ALLOC_SIZE (CFS_PAGE_SIZE)
598 #define OBJID_PER_PAGE() (MDS_LOV_ALLOC_SIZE / sizeof(obd_id))
600 #define MDS_LOV_OBJID_PAGES_COUNT (mds_max_ost_index/OBJID_PER_PAGE())
602 extern int mds_lov_init_objids(struct obd_device *obd);
603 extern void mds_lov_destroy_objids(struct obd_device *obd);
616 struct lustre_handle eo_nl_lock;
621 struct ptlrpc_service *ost_service;
622 struct ptlrpc_service *ost_create_service;
623 struct ptlrpc_service *ost_io_service;
624 struct semaphore ost_health_sem;
627 struct echo_client_obd {
628 struct obd_export *ec_exp; /* the local connection to osc/lov */
630 struct list_head ec_objects;
636 struct obd_uuid lqo_uuid; /* ptlrpc's c_remote_uuid */
637 struct list_head lqo_oss_list; /* link to lov_qos */
638 __u32 lqo_ost_count; /* number of osts on this oss */
639 __u64 lqo_bavail; /* total bytes avail on OSS */
640 __u64 lqo_penalty; /* current penalty */
641 __u64 lqo_penalty_per_obj; /* penalty decrease every obj*/
645 struct lov_qos_oss *ltq_oss; /* oss info */
646 __u64 ltq_penalty; /* current penalty */
647 __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/
648 __u64 ltq_weight; /* net weighting */
649 unsigned int ltq_usable:1; /* usable for striping */
653 struct list_head lq_oss_list; /* list of OSSs that targets use */
654 struct rw_semaphore lq_rw_sem;
655 __u32 lq_active_oss_count;
656 __u32 *lq_rr_array; /* round-robin optimized list */
657 unsigned int lq_rr_size; /* rr array size */
658 unsigned int lq_prio_free; /* priority for free space */
659 unsigned long lq_dirty:1, /* recalc qos data */
660 lq_dirty_rr:1, /* recalc round-robin list */
661 lq_same_space:1,/* the ost's all have approx.
662 the same space avail */
663 lq_reset:1; /* zero current penalties */
666 struct lov_tgt_desc {
667 struct obd_uuid ltd_uuid;
668 struct obd_export *ltd_exp;
669 struct ltd_qos ltd_qos; /* qos info per target */
671 __u32 ltd_index; /* index in lov_obd->tgts */
672 unsigned long ltd_active:1,/* is this target up for requests */
673 ltd_activate:1,/* should this target be activated */
674 ltd_reap:1; /* should this target be deleted */
678 struct lov_desc desc;
679 struct lov_tgt_desc **lov_tgts;
680 struct semaphore lov_lock;
681 struct obd_connect_data lov_ocd;
682 struct lov_qos lov_qos; /* qos info per lov */
683 atomic_t lov_refcount;
684 __u32 lov_tgt_count; /* how many OBD's */
685 __u32 lov_active_tgt_count; /* how many active */
686 __u32 lov_death_row;/* tgts scheduled to be deleted */
687 __u32 lov_tgt_size; /* size of tgts array */
688 __u32 lov_start_idx; /* start index of new inode */
689 __u32 lov_offset_idx; /* aliasing for start_idx */
690 int lov_start_count;/* reseed counter */
692 obd_page_removal_cb_t lov_page_removal_cb;
693 obd_pin_extent_cb lov_page_pin_cb;
694 obd_lock_cancel_cb lov_lock_cancel_cb;
697 struct lmv_tgt_desc {
698 struct obd_uuid ltd_uuid;
699 struct obd_export *ltd_exp;
700 int ltd_active; /* is this target up for requests */
702 struct semaphore ltd_fid_sem;
707 struct lu_client_fld lmv_fld;
709 struct lmv_desc desc;
710 struct obd_uuid cluuid;
711 struct obd_export *exp;
718 struct semaphore init_sem;
720 struct lmv_tgt_desc *tgts;
723 struct obd_connect_data *datas;
726 struct obd_connect_data conn_data;
729 struct niobuf_local {
734 cfs_dentry_t *dentry;
739 #define LUSTRE_FLD_NAME "fld"
740 #define LUSTRE_SEQ_NAME "seq"
742 #define LUSTRE_CMM_NAME "cmm"
743 #define LUSTRE_MDD_NAME "mdd"
744 #define LUSTRE_OSD_NAME "osd"
745 #define LUSTRE_LMV_NAME "lmv"
746 #define LUSTRE_CMM_MDC_NAME "cmm-mdc"
748 /* obd device type names */
749 /* FIXME all the references to LUSTRE_MDS_NAME should be swapped with LUSTRE_MDT_NAME */
750 #define LUSTRE_MDS_NAME "mds"
751 #define LUSTRE_MDT_NAME "mdt"
752 #define LUSTRE_MDC_NAME "mdc"
753 #define LUSTRE_OSS_NAME "ost" /* FIXME change name to oss */
754 #define LUSTRE_OST_NAME "obdfilter" /* FIXME change name to ost */
755 #define LUSTRE_OSC_NAME "osc"
756 #define LUSTRE_LOV_NAME "lov"
757 #define LUSTRE_MGS_NAME "mgs"
758 #define LUSTRE_MGC_NAME "mgc"
760 #define LUSTRE_CACHEOBD_NAME "cobd"
761 #define LUSTRE_ECHO_NAME "obdecho"
762 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
764 /* Constant obd names (post-rename) */
765 #define LUSTRE_MDS_OBDNAME "MDS"
766 #define LUSTRE_OSS_OBDNAME "OSS"
767 #define LUSTRE_MGS_OBDNAME "MGS"
768 #define LUSTRE_MGC_OBDNAME "MGC"
770 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
771 #define N_LOCAL_TEMP_PAGE 0x10000000
773 struct obd_trans_info {
776 /* Only used on the server side for tracking acks. */
777 struct oti_req_ack_lock {
778 struct lustre_handle lock;
782 struct llog_cookie oti_onecookie;
783 struct llog_cookie *oti_logcookies;
786 /* initial thread handling transaction */
790 struct obd_uuid *oti_ost_uuid;
793 static inline void oti_init(struct obd_trans_info *oti,
794 struct ptlrpc_request *req)
798 memset(oti, 0, sizeof(*oti));
803 oti->oti_xid = req->rq_xid;
805 if (req->rq_repmsg != NULL)
806 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
807 oti->oti_thread_id = req->rq_svc_thread ? req->rq_svc_thread->t_id : -1;
808 if (req->rq_reqmsg != NULL)
809 oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
812 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
817 if (num_cookies == 1)
818 oti->oti_logcookies = &oti->oti_onecookie;
820 OBD_ALLOC(oti->oti_logcookies,
821 num_cookies * sizeof(oti->oti_onecookie));
823 oti->oti_numcookies = num_cookies;
826 static inline void oti_free_cookies(struct obd_trans_info *oti)
828 if (!oti || !oti->oti_logcookies)
831 if (oti->oti_logcookies == &oti->oti_onecookie)
832 LASSERT(oti->oti_numcookies == 1);
834 OBD_FREE(oti->oti_logcookies,
835 oti->oti_numcookies * sizeof(oti->oti_onecookie));
836 oti->oti_logcookies = NULL;
837 oti->oti_numcookies = 0;
841 * Events signalled through obd_notify() upcall-chain.
843 enum obd_notify_event {
844 /* Device activated */
846 /* Device deactivated */
848 /* Device disconnected */
850 /* Connect data for import were changed */
853 OBD_NOTIFY_SYNC_NONBLOCK,
855 /* Configuration event */
859 /* bit-mask flags for config events */
861 CONFIG_LOG = 0x1, /* finished processing config log */
862 CONFIG_SYNC = 0x2 /* mdt synced 1 ost */
866 * Data structure used to pass obd_notify()-event to non-obd listeners (llite
867 * and liblustre being main examples).
869 struct obd_notify_upcall {
870 int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
871 enum obd_notify_event ev, void *owner);
872 /* Opaque datum supplied by upper layer listener */
876 struct target_recovery_data {
877 svc_handler_t trd_recovery_handler;
878 pid_t trd_processing_task;
879 struct completion trd_starting;
880 struct completion trd_finishing;
883 #define OBD_LLOG_GROUP 0
886 FILTER_GROUP_LLOG = 1,
891 struct obd_llog_group {
892 struct list_head olg_list;
894 struct llog_ctxt *olg_ctxts[LLOG_MAX_CTXTS];
895 cfs_waitq_t olg_waitq;
897 struct obd_export *olg_exp;
898 int olg_initializing;
901 /* corresponds to one of the obd's */
902 #define MAX_OBD_NAME 128
903 #define OBD_DEVICE_MAGIC 0XAB5CD6EF
905 struct obd_type *obd_type;
908 /* common and UUID name of this device */
909 char obd_name[MAX_OBD_NAME];
910 struct obd_uuid obd_uuid;
912 struct lu_device *obd_lu_dev;
915 unsigned long obd_attached:1, /* finished attach */
916 obd_set_up:1, /* finished setup */
917 obd_recovering:1, /* there are recoverable clients */
918 obd_abort_recovery:1,/* somebody ioctl'ed us to abort */
919 obd_replayable:1, /* recovery is enabled; inform clients */
920 obd_no_transno:1, /* no committed-transno notification */
921 obd_no_recov:1, /* fail instead of retry messages */
922 obd_req_replaying:1, /* replaying requests */
923 obd_stopping:1, /* started cleanup */
924 obd_starting:1, /* started setup */
925 obd_force:1, /* cleanup with > 0 obd refcount */
926 obd_fail:1, /* cleanup with failover */
927 obd_async_recov:1, /* allow asyncronous orphan cleanup */
928 obd_no_conn:1, /* deny new connections */
929 obd_inactive:1; /* device active/inactive
930 * (for /proc/status only!!) */
931 /* uuid-export hash body */
932 struct lustre_class_hash_body *obd_uuid_hash_body;
933 /* nid-export hash body */
934 struct lustre_class_hash_body *obd_nid_hash_body;
936 struct lustre_class_hash_body *obd_nid_stats_hash_body;
937 struct list_head obd_nid_stats;
938 atomic_t obd_refcount;
939 cfs_waitq_t obd_refcount_waitq;
940 struct list_head obd_exports;
942 spinlock_t obd_nid_lock;
943 struct ldlm_namespace *obd_namespace;
944 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
945 /* a spinlock is OK for what we do now, may need a semaphore later */
946 spinlock_t obd_dev_lock;
947 struct semaphore obd_dev_sem;
948 __u64 obd_last_committed;
949 struct fsfilt_operations *obd_fsops;
950 spinlock_t obd_osfs_lock;
951 struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
953 struct lvfs_run_ctxt obd_lvfs_ctxt;
954 struct obd_llog_group obd_olg; /* default llog group */
955 struct obd_device *obd_observer;
956 struct obd_notify_upcall obd_upcall;
957 struct obd_export *obd_self_export;
958 /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
959 struct list_head obd_exports_timed;
960 time_t obd_eviction_timer; /* for ping evictor */
962 /* XXX encapsulate all this recovery data into one struct */
963 svc_handler_t obd_recovery_handler;
964 pid_t obd_processing_task;
966 int obd_max_recoverable_clients;
967 int obd_connected_clients;
968 int obd_recoverable_clients;
969 spinlock_t obd_processing_task_lock; /* BH lock (timer) */
970 __u64 obd_next_recovery_transno;
971 int obd_replayed_requests;
972 int obd_requests_queued_for_recovery;
973 cfs_waitq_t obd_next_transno_waitq;
974 struct list_head obd_uncommitted_replies;
975 spinlock_t obd_uncommitted_replies_lock;
976 cfs_timer_t obd_recovery_timer;
977 time_t obd_recovery_start; /* seconds */
978 time_t obd_recovery_end; /* seconds, for lprocfs_status */
979 time_t obd_recovery_max_time; /* seconds, bz13079 */
980 int obd_recovery_timeout;
982 /* new recovery stuff from CMD2 */
983 struct target_recovery_data obd_recovery_data;
984 int obd_replayed_locks;
985 atomic_t obd_req_replay_clients;
986 atomic_t obd_lock_replay_clients;
987 struct list_head obd_req_replay_queue;
988 struct list_head obd_lock_replay_queue;
989 struct list_head obd_final_req_queue;
990 int obd_recovery_stage;
993 struct obd_device_target obt;
994 struct filter_obd filter;
996 struct client_obd cli;
998 struct echo_client_obd echo_client;
999 struct echo_obd echo;
1004 /* Fields used by LProcFS */
1005 unsigned int obd_cntr_base;
1006 struct lprocfs_stats *obd_stats;
1008 unsigned int md_cntr_base;
1009 struct lprocfs_stats *md_stats;
1011 cfs_proc_dir_entry_t *obd_proc_entry;
1012 cfs_proc_dir_entry_t *obd_proc_exports_entry;
1013 cfs_proc_dir_entry_t *obd_svc_procroot;
1014 struct lprocfs_stats *obd_svc_stats;
1015 atomic_t obd_evict_inprogress;
1016 cfs_waitq_t obd_evict_inprogress_waitq;
1019 * Ldlm pool part. Save last calculated SLV and Limit.
1021 rwlock_t obd_pool_lock;
1026 #define OBD_OPT_FORCE 0x0001
1027 #define OBD_OPT_FAILOVER 0x0002
1029 #define OBD_LLOG_FL_SENDNOW 0x0001
1031 enum obd_cleanup_stage {
1032 /* Special case hack for MDS LOVs */
1034 /* can be directly mapped to .ldto_device_fini() */
1035 OBD_CLEANUP_EXPORTS,
1038 /* get/set_info keys */
1039 #define KEY_READ_ONLY "read-only"
1040 #define KEY_MDS_CONN "mds_conn"
1041 #define KEY_NEXT_ID "next_id"
1042 #define KEY_LOVDESC "lovdesc"
1043 #define KEY_INIT_RECOV "initial_recov"
1044 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"
1045 #define KEY_FLUSH_CTX "flush_ctx"
1046 #define KEY_CAPA_KEY "capa_key"
1047 #define KEY_CONN_DATA "conn_data"
1048 #define KEY_MAX_EASIZE "max_easize"
1049 #define KEY_REVIMP_UPD "revimp_update"
1050 #define KEY_LOV_IDX "lov_idx"
1051 #define KEY_LAST_ID "last_id"
1052 #define KEY_READONLY "read-only"
1053 #define KEY_LOCK_TO_STRIPE "lock_to_stripe"
1054 #define KEY_CHECKSUM "checksum"
1055 #define KEY_UNLINKED "unlinked"
1056 #define KEY_EVICT_BY_NID "evict_by_nid"
1057 #define KEY_REGISTER_TARGET "register_target"
1058 #define KEY_SET_FS "set_fs"
1059 #define KEY_CLEAR_FS "clear_fs"
1060 #define KEY_BLOCKSIZE "blocksize"
1061 #define KEY_BLOCKSIZE_BITS "blocksize_bits"
1062 #define KEY_FIEMAP "FIEMAP"
1064 #define KEY_INTERMDS "inter_mds"
1065 #define KEY_ASYNC "async"
1069 static inline int it_to_lock_mode(struct lookup_intent *it)
1071 /* CREAT needs to be tested before open (both could be set) */
1072 if (it->it_op & IT_CREAT)
1074 else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_LOOKUP))
1077 LASSERTF(0, "Invalid it_op: %d\n", it->it_op);
1082 struct lu_fid op_fid1; /* operation fid1 (usualy parent) */
1083 struct lu_fid op_fid2; /* operation fid2 (usualy child) */
1084 struct lu_fid op_fid3; /* 2 extra fids to find conflicting */
1085 struct lu_fid op_fid4; /* to the operation locks. */
1086 mdsno_t op_mds; /* what mds server open will go to */
1087 struct lustre_handle op_handle;
1089 const char *op_name;
1092 struct lmv_stripe_md *op_mea1;
1093 struct lmv_stripe_md *op_mea2;
1094 __u32 op_suppgids[2];
1100 /* iattr fields and blocks. */
1101 struct iattr op_attr;
1103 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
1104 unsigned int op_attr_flags;
1107 loff_t op_attr_blocks;
1109 /* Size-on-MDS epoch and flags. */
1114 struct obd_capa *op_capa1;
1115 struct obd_capa *op_capa2;
1117 /* Various operation flags. */
1120 /* Operation type */
1124 struct md_enqueue_info;
1125 /* metadata stat-ahead */
1126 typedef int (* md_enqueue_cb_t)(struct ptlrpc_request *req,
1127 struct md_enqueue_info *minfo,
1130 struct md_enqueue_info {
1131 struct md_op_data mi_data;
1132 struct lookup_intent mi_it;
1133 struct lustre_handle mi_lockh;
1134 struct dentry *mi_dentry;
1135 md_enqueue_cb_t mi_cb;
1136 unsigned int mi_generation;
1141 struct module *o_owner;
1142 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
1143 void *karg, void *uarg);
1144 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
1145 __u32 *vallen, void *val, struct lov_stripe_md *lsm);
1146 int (*o_set_info_async)(struct obd_export *, __u32 keylen, void *key,
1147 __u32 vallen, void *val,
1148 struct ptlrpc_request_set *set);
1149 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
1150 int (*o_detach)(struct obd_device *dev);
1151 int (*o_setup) (struct obd_device *dev, struct lustre_cfg *cfg);
1152 int (*o_precleanup)(struct obd_device *dev,
1153 enum obd_cleanup_stage cleanup_stage);
1154 int (*o_cleanup)(struct obd_device *dev);
1155 int (*o_process_config)(struct obd_device *dev, obd_count len,
1157 int (*o_postrecov)(struct obd_device *dev);
1158 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
1160 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
1161 /* connect to the target device with given connection
1162 * data. @ocd->ocd_connect_flags is modified to reflect flags actually
1163 * granted by the target, which are guaranteed to be a subset of flags
1164 * asked for. If @ocd == NULL, use default parameters. */
1165 int (*o_connect)(const struct lu_env *env,
1166 struct lustre_handle *conn, struct obd_device *src,
1167 struct obd_uuid *cluuid, struct obd_connect_data *ocd,
1169 int (*o_reconnect)(const struct lu_env *env,
1170 struct obd_export *exp, struct obd_device *src,
1171 struct obd_uuid *cluuid,
1172 struct obd_connect_data *ocd);
1173 int (*o_disconnect)(struct obd_export *exp);
1175 /* Initialize/finalize fids infrastructure. */
1176 int (*o_fid_init)(struct obd_export *exp);
1177 int (*o_fid_fini)(struct obd_export *exp);
1179 /* Allocate new fid according to passed @hint. */
1180 int (*o_fid_alloc)(struct obd_export *exp, struct lu_fid *fid,
1181 struct md_op_data *op_data);
1184 * Object with @fid is getting deleted, we may want to do something
1187 int (*o_fid_delete)(struct obd_export *exp, const struct lu_fid *fid);
1189 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
1190 __u64 max_age, __u32 flags);
1191 int (*o_statfs_async)(struct obd_device *obd, struct obd_info *oinfo,
1192 __u64 max_age, struct ptlrpc_request_set *set);
1193 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
1194 struct lov_stripe_md *mem_src);
1195 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
1196 struct lov_mds_md *disk_src, int disk_len);
1197 int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
1198 struct lov_stripe_md *mem_tgt);
1199 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
1201 /* FIXME: add fid capability support for create & destroy! */
1202 int (*o_precreate)(struct obd_export *exp);
1203 int (*o_create)(struct obd_export *exp, struct obdo *oa,
1204 struct lov_stripe_md **ea, struct obd_trans_info *oti);
1205 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
1206 struct lov_stripe_md *ea, struct obd_trans_info *oti,
1207 struct obd_export *md_exp);
1208 int (*o_setattr)(struct obd_export *exp, struct obd_info *oinfo,
1209 struct obd_trans_info *oti);
1210 int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1211 struct obd_trans_info *oti,
1212 struct ptlrpc_request_set *rqset);
1213 int (*o_getattr)(struct obd_export *exp, struct obd_info *oinfo);
1214 int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1215 struct ptlrpc_request_set *set);
1216 int (*o_brw)(int rw, struct obd_export *exp, struct obd_info *oinfo,
1217 obd_count oa_bufs, struct brw_page *pgarr,
1218 struct obd_trans_info *oti);
1219 int (*o_brw_async)(int rw, struct obd_export *exp,
1220 struct obd_info *oinfo, obd_count oa_bufs,
1221 struct brw_page *pgarr, struct obd_trans_info *oti,
1222 struct ptlrpc_request_set *);
1223 int (*o_prep_async_page)(struct obd_export *exp,
1224 struct lov_stripe_md *lsm,
1225 struct lov_oinfo *loi,
1226 cfs_page_t *page, obd_off offset,
1227 struct obd_async_page_ops *ops, void *data,
1228 void **res, int nocache,
1229 struct lustre_handle *lockh);
1230 int (*o_reget_short_lock)(struct obd_export *exp,
1231 struct lov_stripe_md *lsm,
1233 obd_off start, obd_off end,
1235 int (*o_release_short_lock)(struct obd_export *exp,
1236 struct lov_stripe_md *lsm, obd_off end,
1237 void *cookie, int rw);
1238 int (*o_queue_async_io)(struct obd_export *exp,
1239 struct lov_stripe_md *lsm,
1240 struct lov_oinfo *loi, void *cookie,
1241 int cmd, obd_off off, int count,
1242 obd_flag brw_flags, obd_flag async_flags);
1243 int (*o_queue_group_io)(struct obd_export *exp,
1244 struct lov_stripe_md *lsm,
1245 struct lov_oinfo *loi,
1246 struct obd_io_group *oig,
1247 void *cookie, int cmd, obd_off off, int count,
1248 obd_flag brw_flags, obd_flag async_flags);
1249 int (*o_trigger_group_io)(struct obd_export *exp,
1250 struct lov_stripe_md *lsm,
1251 struct lov_oinfo *loi,
1252 struct obd_io_group *oig);
1253 int (*o_set_async_flags)(struct obd_export *exp,
1254 struct lov_stripe_md *lsm,
1255 struct lov_oinfo *loi, void *cookie,
1256 obd_flag async_flags);
1257 int (*o_teardown_async_page)(struct obd_export *exp,
1258 struct lov_stripe_md *lsm,
1259 struct lov_oinfo *loi, void *cookie);
1260 int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
1261 struct ost_lvb *lvb, int kms_only);
1262 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
1263 obd_off size, int shrink);
1264 int (*o_punch)(struct obd_export *exp, struct obd_info *oinfo,
1265 struct obd_trans_info *oti,
1266 struct ptlrpc_request_set *rqset);
1267 int (*o_sync)(struct obd_export *exp, struct obdo *oa,
1268 struct lov_stripe_md *ea, obd_size start, obd_size end,
1270 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
1271 struct lov_stripe_md *src, obd_size start,
1272 obd_size end, struct obd_trans_info *oti);
1273 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
1274 struct lustre_handle *srconn, struct lov_stripe_md *src,
1275 obd_size start, obd_size end, struct obd_trans_info *);
1276 int (*o_iterate)(struct lustre_handle *conn,
1277 int (*)(obd_id, obd_gr, void *),
1278 obd_id *startid, obd_gr group, void *data);
1279 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
1280 int objcount, struct obd_ioobj *obj,
1281 int niocount, struct niobuf_remote *remote,
1282 struct niobuf_local *local, struct obd_trans_info *oti,
1283 struct lustre_capa *capa);
1284 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
1285 int objcount, struct obd_ioobj *obj,
1286 int niocount, struct niobuf_local *local,
1287 struct obd_trans_info *oti, int rc);
1288 int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo,
1289 struct ldlm_enqueue_info *einfo,
1290 struct ptlrpc_request_set *rqset);
1291 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
1292 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
1293 struct lustre_handle *lockh);
1294 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
1295 ldlm_iterator_t it, void *data);
1296 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
1297 __u32 mode, struct lustre_handle *);
1298 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
1299 int flags, void *opaque);
1300 int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
1302 int (*o_init_export)(struct obd_export *exp);
1303 int (*o_destroy_export)(struct obd_export *exp);
1304 int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *,
1305 int cmd, obd_off *);
1307 /* llog related obd_methods */
1308 int (*o_llog_init)(struct obd_device *obd, struct obd_llog_group *grp,
1309 struct obd_device *disk_obd, int count,
1310 struct llog_catid *logid, struct obd_uuid *uuid);
1311 int (*o_llog_finish)(struct obd_device *obd, int count);
1312 int (*o_llog_connect)(struct obd_export *, struct llogd_conn_body *);
1314 /* metadata-only methods */
1315 int (*o_pin)(struct obd_export *, const struct lu_fid *fid,
1316 struct obd_capa *, struct obd_client_handle *, int flag);
1317 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
1319 int (*o_import_event)(struct obd_device *, struct obd_import *,
1320 enum obd_import_event);
1322 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
1323 enum obd_notify_event ev, void *data);
1325 int (*o_health_check)(struct obd_device *);
1328 int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
1329 int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
1331 int (*o_ping)(struct obd_export *exp);
1333 int (*o_register_page_removal_cb)(struct obd_export *exp,
1334 obd_page_removal_cb_t cb,
1335 obd_pin_extent_cb pin_cb);
1336 int (*o_unregister_page_removal_cb)(struct obd_export *exp,
1337 obd_page_removal_cb_t cb);
1338 int (*o_register_lock_cancel_cb)(struct obd_export *exp,
1339 obd_lock_cancel_cb cb);
1340 int (*o_unregister_lock_cancel_cb)(struct obd_export *exp,
1341 obd_lock_cancel_cb cb);
1344 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
1345 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
1346 * Also, add a wrapper function in include/linux/obd_class.h. */
1349 /* TODO: lmv_stripe_md should contain mds capabilities for all slave fids */
1350 struct lmv_stripe_md {
1355 struct lu_fid mea_ids[0];
1359 LUSTRE_OPC_MKDIR = (1 << 0),
1360 LUSTRE_OPC_SYMLINK = (1 << 1),
1361 LUSTRE_OPC_MKNOD = (1 << 2),
1362 LUSTRE_OPC_CREATE = (1 << 3),
1363 LUSTRE_OPC_ANY = (1 << 4)
1366 /* lmv structures */
1367 #define MEA_MAGIC_LAST_CHAR 0xb2221ca1
1368 #define MEA_MAGIC_ALL_CHARS 0xb222a11c
1369 #define MEA_MAGIC_HASH_SEGMENT 0xb222a11b
1371 #define MAX_HASH_SIZE_32 0x7fffffffUL
1372 #define MAX_HASH_SIZE 0x7fffffffffffffffULL
1373 #define MAX_HASH_HIGHEST_BIT 0x1000000000000000
1376 struct mdt_body *body;
1377 struct lov_stripe_md *lsm;
1378 struct lmv_stripe_md *mea;
1379 #ifdef CONFIG_FS_POSIX_ACL
1380 struct posix_acl *posix_acl;
1382 struct mdt_remote_perm *remote_perm;
1383 struct obd_capa *mds_capa;
1384 struct obd_capa *oss_capa;
1387 struct md_open_data {
1388 struct obd_client_handle *mod_och;
1389 struct list_head mod_replay_list;
1392 struct lookup_intent;
1395 int (*m_getstatus)(struct obd_export *, struct lu_fid *,
1396 struct obd_capa **);
1397 int (*m_change_cbdata)(struct obd_export *, const struct lu_fid *,
1398 ldlm_iterator_t, void *);
1399 int (*m_close)(struct obd_export *, struct md_op_data *,
1400 struct md_open_data *, struct ptlrpc_request **);
1401 int (*m_create)(struct obd_export *, struct md_op_data *,
1402 const void *, int, int, __u32, __u32, __u32,
1403 __u64, struct ptlrpc_request **);
1404 int (*m_done_writing)(struct obd_export *, struct md_op_data *,
1405 struct md_open_data *);
1406 int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *,
1407 struct lookup_intent *, struct md_op_data *,
1408 struct lustre_handle *, void *, int, int);
1409 int (*m_getattr)(struct obd_export *, const struct lu_fid *,
1410 struct obd_capa *, obd_valid, int,
1411 struct ptlrpc_request **);
1412 int (*m_getattr_name)(struct obd_export *, const struct lu_fid *,
1413 struct obd_capa *, const char *, int, obd_valid,
1414 int, __u32, struct ptlrpc_request **);
1415 int (*m_intent_lock)(struct obd_export *, struct md_op_data *,
1416 void *, int, struct lookup_intent *, int,
1417 struct ptlrpc_request **,
1418 ldlm_blocking_callback, int);
1419 int (*m_link)(struct obd_export *, struct md_op_data *,
1420 struct ptlrpc_request **);
1421 int (*m_rename)(struct obd_export *, struct md_op_data *,
1422 const char *, int, const char *, int,
1423 struct ptlrpc_request **);
1424 int (*m_is_subdir)(struct obd_export *, const struct lu_fid *,
1425 const struct lu_fid *,
1426 struct ptlrpc_request **);
1427 int (*m_setattr)(struct obd_export *, struct md_op_data *, void *,
1428 int , void *, int, struct ptlrpc_request **,
1429 struct md_open_data **mod);
1430 int (*m_sync)(struct obd_export *, const struct lu_fid *,
1431 struct obd_capa *, struct ptlrpc_request **);
1432 int (*m_readpage)(struct obd_export *, const struct lu_fid *,
1433 struct obd_capa *, __u64, struct page *,
1434 struct ptlrpc_request **);
1436 int (*m_unlink)(struct obd_export *, struct md_op_data *,
1437 struct ptlrpc_request **);
1439 int (*m_setxattr)(struct obd_export *, const struct lu_fid *,
1440 struct obd_capa *, obd_valid, const char *,
1441 const char *, int, int, int, __u32,
1442 struct ptlrpc_request **);
1444 int (*m_getxattr)(struct obd_export *, const struct lu_fid *,
1445 struct obd_capa *, obd_valid, const char *,
1446 const char *, int, int, int,
1447 struct ptlrpc_request **);
1449 int (*m_init_ea_size)(struct obd_export *, int, int, int);
1451 int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *,
1452 struct obd_export *, struct obd_export *,
1453 struct lustre_md *);
1455 int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *);
1457 int (*m_set_open_replay_data)(struct obd_export *,
1458 struct obd_client_handle *,
1459 struct ptlrpc_request *);
1460 int (*m_clear_open_replay_data)(struct obd_export *,
1461 struct obd_client_handle *);
1462 int (*m_set_lock_data)(struct obd_export *, __u64 *, void *);
1464 ldlm_mode_t (*m_lock_match)(struct obd_export *, int,
1465 const struct lu_fid *, ldlm_type_t,
1466 ldlm_policy_data_t *, ldlm_mode_t,
1467 struct lustre_handle *);
1469 int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
1470 ldlm_policy_data_t *, ldlm_mode_t, int flags,
1472 int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
1473 renew_capa_cb_t cb);
1475 int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *,
1476 struct obd_capa *, __u32,
1477 struct ptlrpc_request **);
1479 int (*m_intent_getattr_async)(struct obd_export *,
1480 struct md_enqueue_info *,
1481 struct ldlm_enqueue_info *);
1483 int (*m_revalidate_lock)(struct obd_export *,
1484 struct lookup_intent *,
1488 * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to
1489 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
1490 * wrapper function in include/linux/obd_class.h.
1494 struct lsm_operations {
1495 void (*lsm_free)(struct lov_stripe_md *);
1496 int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
1497 struct obd_export *md_exp);
1498 void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
1500 void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
1502 obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
1503 obd_off (*lsm_stripe_offset_by_offset)(struct lov_stripe_md *, obd_off);
1504 int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
1505 int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
1506 int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
1508 int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
1509 struct lov_mds_md *lmm);
1512 extern struct lsm_operations lsm_plain_ops;
1513 extern struct lsm_operations lsm_join_ops;
1514 static inline struct lsm_operations *lsm_op_find(int magic)
1518 return &lsm_plain_ops;
1519 case LOV_MAGIC_JOIN:
1520 return &lsm_join_ops;
1522 CERROR("Cannot recognize lsm_magic %d\n", magic);
1527 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
1529 /* Requests for obd_extent_calc() */
1530 #define OBD_CALC_STRIPE_START 1
1531 #define OBD_CALC_STRIPE_END 2
1533 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
1537 CERROR("%s: transno "LPU64" commit error: %d\n",
1538 obd->obd_name, transno, error);
1541 if (transno > obd->obd_last_committed) {
1542 CDEBUG(D_HA, "%s: transno "LPD64" committed\n",
1543 obd->obd_name, transno);
1544 obd->obd_last_committed = transno;
1545 ptlrpc_commit_replies (obd);
1547 CDEBUG(D_INFO, "%s: transno "LPD64" committed\n",
1548 obd->obd_name, transno);
1552 static inline void init_obd_quota_ops(quota_interface_t *interface,
1553 struct obd_ops *obd_ops)
1559 obd_ops->o_quotacheck = QUOTA_OP(interface, check);
1560 obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
1563 static inline __u64 oinfo_mdsno(struct obd_info *oinfo)
1565 return oinfo->oi_oa->o_gr - FILTER_GROUP_MDS0;
1568 static inline struct lustre_capa *oinfo_capa(struct obd_info *oinfo)
1570 return oinfo->oi_capa;
1573 #endif /* __OBD_H */