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_lib.h>
63 #include <lustre/lustre_idl.h>
64 #include <lustre_export.h>
65 #include <lustre_quota.h>
66 #include <class_hash.h>
68 #include <libcfs/bitmap.h>
71 #define MAX_OBD_DEVICES 8192
73 /* this is really local to the OSC */
74 struct loi_oap_pages {
75 struct list_head lop_pending;
76 struct list_head lop_urgent;
77 struct list_head lop_pending_group;
87 struct lov_oinfo { /* per-stripe data structure */
88 __u64 loi_id; /* object ID on the target OST */
89 __u64 loi_gr; /* object group on the target OST */
90 int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */
91 int loi_ost_gen; /* generation of this loi_ost_idx */
93 /* used by the osc to keep track of what objects to build into rpcs */
94 struct loi_oap_pages loi_read_lop;
95 struct loi_oap_pages loi_write_lop;
96 struct list_head loi_ready_item;
97 struct list_head loi_hp_ready_item;
98 struct list_head loi_write_item;
99 struct list_head loi_read_item;
101 unsigned long loi_kms_valid:1;
102 __u64 loi_kms; /* known minimum size */
103 struct ost_lvb loi_lvb;
104 struct osc_async_rc loi_ar;
107 static inline void loi_init(struct lov_oinfo *loi)
109 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending);
110 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_urgent);
111 CFS_INIT_LIST_HEAD(&loi->loi_read_lop.lop_pending_group);
112 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending);
113 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_urgent);
114 CFS_INIT_LIST_HEAD(&loi->loi_write_lop.lop_pending_group);
115 CFS_INIT_LIST_HEAD(&loi->loi_ready_item);
116 CFS_INIT_LIST_HEAD(&loi->loi_hp_ready_item);
117 CFS_INIT_LIST_HEAD(&loi->loi_write_item);
118 CFS_INIT_LIST_HEAD(&loi->loi_read_item);
121 /*extent array item for describing the joined file extent info*/
123 __u64 le_start; /* extent start */
124 __u64 le_len; /* extent length */
125 int le_loi_idx; /* extent #1 loi's index in lsm loi array */
126 int le_stripe_count; /* extent stripe count*/
129 /*Lov array info for describing joined file array EA info*/
130 struct lov_array_info {
131 struct llog_logid lai_array_id; /* MDS med llog object id */
132 unsigned lai_ext_count; /* number of extent count */
133 struct lov_extent *lai_ext_array; /* extent desc array */
136 struct lov_stripe_md {
138 void *lsm_lock_owner; /* debugging */
141 /* Public members. */
142 __u64 lw_object_id; /* lov object id */
143 __u64 lw_object_gr; /* lov object group */
144 __u64 lw_maxbytes; /* maximum possible file size */
146 /* LOV-private members start here -- only for use in lov/. */
148 __u32 lw_stripe_size; /* size of the stripe */
149 __u32 lw_pattern; /* striping pattern (RAID0, RAID1) */
150 unsigned lw_stripe_count; /* number of objects being striped over */
151 char lw_pool_name[LOV_MAXPOOLNAME]; /* pool name */
154 struct lov_array_info *lsm_array; /*Only for joined file array info*/
155 struct lov_oinfo *lsm_oinfo[0];
158 #define lsm_object_id lsm_wire.lw_object_id
159 #define lsm_object_gr lsm_wire.lw_object_gr
160 #define lsm_maxbytes lsm_wire.lw_maxbytes
161 #define lsm_magic lsm_wire.lw_magic
162 #define lsm_stripe_size lsm_wire.lw_stripe_size
163 #define lsm_pattern lsm_wire.lw_pattern
164 #define lsm_stripe_count lsm_wire.lw_stripe_count
165 #define lsm_pool_name lsm_wire.lw_pool_name
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;
198 /* compare all relevant fields. */
199 static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1,
200 struct lov_stripe_md *m2)
203 * ->lsm_wire contains padding, but it should be zeroed out during
206 return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof m1->lsm_wire);
209 void lov_stripe_lock(struct lov_stripe_md *md);
210 void lov_stripe_unlock(struct lov_stripe_md *md);
213 struct list_head typ_chain;
214 struct obd_ops *typ_ops;
215 cfs_proc_dir_entry_t *typ_procroot;
218 spinlock_t obd_type_lock;
229 ASYNC_READY = 0x1, /* ap_make_ready will not be called before this
230 page is added to an rpc */
231 ASYNC_URGENT = 0x2, /* page must be put into an RPC before return */
232 ASYNC_COUNT_STABLE = 0x4, /* ap_refresh_count will not be called
233 to give the caller a chance to update
234 or cancel the size of the io */
235 ASYNC_GROUP_SYNC = 0x8, /* ap_completion will not be called, instead
236 the page is accounted for in the
237 obd_io_group given to
238 obd_queue_group_io */
242 struct obd_async_page_ops {
243 int (*ap_make_ready)(void *data, int cmd);
244 int (*ap_refresh_count)(void *data, int cmd);
245 void (*ap_fill_obdo)(void *data, int cmd, struct obdo *oa);
246 void (*ap_update_obdo)(void *data, int cmd, struct obdo *oa,
248 int (*ap_completion)(void *data, int cmd, struct obdo *oa, int rc);
251 /* the `oig' is passed down from a caller of obd rw methods. the callee
252 * records enough state such that the caller can sleep on the oig and
253 * be woken when all the callees have finished their work */
254 struct obd_io_group {
256 atomic_t oig_refcount;
259 struct list_head oig_occ_list;
260 cfs_waitq_t oig_waitq;
263 /* the oig callback context lets the callee of obd rw methods register
264 * for callbacks from the caller. */
265 struct oig_callback_context {
266 struct list_head occ_oig_item;
267 /* called when the caller has received a signal while sleeping.
268 * callees of this method are encouraged to abort their state
269 * in the oig. This may be called multiple times. */
270 void (*occ_interrupted)(struct oig_callback_context *occ);
271 unsigned long interrupted:1;
274 /* Individual type definitions */
276 struct ost_server_data;
278 /* hold common fields for "target" device */
279 struct obd_device_target {
280 struct super_block *obt_sb;
281 /** last_rcvd file */
282 struct file *obt_rcvd_filp;
283 /** server data in last_rcvd file */
284 struct lr_server_data *obt_lsd;
285 /** Lock protecting client bitmap */
286 spinlock_t obt_client_bitmap_lock;
287 /** Bitmap of known clients */
288 unsigned long *obt_client_bitmap;
289 /** Server last transaction number */
290 __u64 obt_last_transno;
291 /** Lock protecting last transaction number */
292 spinlock_t obt_translock;
293 /** Number of mounts */
294 __u64 obt_mount_count;
295 atomic_t obt_quotachecking;
296 struct lustre_quota_ctxt obt_qctxt;
297 lustre_quota_version_t obt_qfmt;
298 __u32 obt_stale_export_age;
299 spinlock_t obt_trans_table_lock;
302 typedef void (*obd_pin_extent_cb)(void *data);
303 typedef int (*obd_page_removal_cb_t)(void *data, int discard);
304 typedef int (*obd_lock_cancel_cb)(struct ldlm_lock *,struct ldlm_lock_desc *,
307 #define FILTER_GROUP_LLOG 1
308 #define FILTER_GROUP_ECHO 2
316 /* NB this field MUST be first */
317 struct obd_device_target fo_obt;
318 const char *fo_fstype;
319 struct vfsmount *fo_vfsmnt;
320 cfs_dentry_t *fo_dentry_O;
321 cfs_dentry_t **fo_dentry_O_groups;
322 cfs_dentry_t **fo_dentry_O_sub;
323 spinlock_t fo_objidlock; /* protect fo_lastobjid */
324 struct file *fo_health_check_filp;
326 int fo_destroy_in_progress;
327 struct semaphore fo_create_lock;
329 struct list_head fo_export_list;
332 obd_size fo_tot_dirty; /* protected by obd_osfs_lock */
333 obd_size fo_tot_granted; /* all values in bytes */
334 obd_size fo_tot_pending;
336 obd_size fo_readcache_max_filesize;
338 int fo_writethrough_cache;
340 struct obd_import *fo_mdc_imp;
341 struct obd_uuid fo_mdc_uuid;
342 struct lustre_handle fo_mdc_conn;
343 struct file **fo_last_objid_files;
344 __u64 *fo_last_objids; /* last created objid for groups,
345 * protected by fo_objidlock */
347 struct semaphore fo_alloc_lock;
349 atomic_t fo_r_in_flight;
350 atomic_t fo_w_in_flight;
353 * per-filter pool of kiobuf's allocated by filter_common_setup() and
354 * torn down by filter_cleanup(). Contains OST_NUM_THREADS elements of
355 * which ->fo_iobuf_count were allocated.
357 * This pool contains kiobuf used by
358 * filter_{prep,commit}rw_{read,write}() and is shared by all OST
361 * Locking: none, each OST thread uses only one element, determined by
362 * its "ordinal number", ->t_id.
364 struct filter_iobuf **fo_iobuf_pool;
367 struct brw_stats fo_filter_stats;
368 struct lustre_quota_ctxt fo_quota_ctxt;
369 spinlock_t fo_quotacheck_lock;
370 atomic_t fo_quotachecking;
372 int fo_fmd_max_num; /* per exp filter_mod_data */
373 int fo_fmd_max_age; /* jiffies to fmd expiry */
374 int fo_syncjournal; /* sync journal on writes */
375 struct llog_commit_master *fo_lcm;
378 #define fo_translock fo_obt.obt_translock
379 #define fo_rcvd_filp fo_obt.obt_rcvd_filp
380 #define fo_fsd fo_obt.obt_lsd
381 #define fo_last_rcvd_slots fo_obt.obt_client_bitmap
382 #define fo_mount_count fo_obt.obt_mount_count
384 #define OSC_MAX_RIF_DEFAULT 8
385 #define OSC_MAX_RIF_MAX 256
386 #define OSC_MAX_DIRTY_DEFAULT (OSC_MAX_RIF_DEFAULT * 4)
387 #define OSC_MAX_DIRTY_MB_MAX 2048 /* arbitrary, but < MAX_LONG bytes */
388 #define OSC_DEFAULT_RESENDS 10
390 #define MDC_MAX_RIF_DEFAULT 8
391 #define MDC_MAX_RIF_MAX 512
397 struct rw_semaphore cl_sem;
398 struct obd_uuid cl_target_uuid;
399 struct obd_import *cl_import; /* ptlrpc connection state */
401 /* max_mds_easize is purely a performance thing so we don't have to
402 * call obd_size_diskmd() all the time. */
403 unsigned cl_default_mds_easize;
404 unsigned cl_max_mds_easize;
405 unsigned cl_max_mds_cookiesize;
407 //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */
408 void *cl_llcd_offset;
410 /* the grant values are protected by loi_list_lock below */
411 long cl_dirty; /* all _dirty_ in bytes */
412 long cl_dirty_max; /* allowed w/o rpc */
413 long cl_avail_grant; /* bytes of credit for ost */
414 long cl_lost_grant; /* lost credits (trunc) */
415 struct list_head cl_cache_waiters; /* waiting for cache/grant */
417 /* keep track of objects that have lois that contain pages which
418 * have been queued for async brw. this lock also protects the
419 * lists of osc_client_pages that hang off of the loi */
421 * ->cl_loi_list_lock protects consistency of
422 * ->cl_loi_{ready,read,write}_list. ->ap_make_ready() and
423 * ->ap_completion() call-backs are executed under this lock. As we
424 * cannot guarantee that these call-backs never block on all platforms
425 * (as a matter of fact they do block on Mac OS X), type of
426 * ->cl_loi_list_lock is platform dependent: it's a spin-lock on Linux
427 * and blocking mutex on Mac OS X. (Alternative is to make this lock
428 * blocking everywhere, but we don't want to slow down fast-path of
429 * our main platform.)
431 * Exact type of ->cl_loi_list_lock is defined in arch/obd.h together
432 * with client_obd_list_{un,}lock() and
433 * client_obd_list_lock_{init,done}() functions.
435 client_obd_lock_t cl_loi_list_lock;
436 struct list_head cl_loi_ready_list;
437 struct list_head cl_loi_hp_ready_list;
438 struct list_head cl_loi_write_list;
439 struct list_head cl_loi_read_list;
442 /* just a sum of the loi/lop pending numbers to be exported by /proc */
443 int cl_pending_w_pages;
444 int cl_pending_r_pages;
445 int cl_max_pages_per_rpc;
446 int cl_max_rpcs_in_flight;
447 struct obd_histogram cl_read_rpc_hist;
448 struct obd_histogram cl_write_rpc_hist;
449 struct obd_histogram cl_read_page_hist;
450 struct obd_histogram cl_write_page_hist;
451 struct obd_histogram cl_read_offset_hist;
452 struct obd_histogram cl_write_offset_hist;
454 /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */
455 atomic_t cl_destroy_in_flight;
456 cfs_waitq_t cl_destroy_waitq;
458 struct mdc_rpc_lock *cl_rpc_lock;
459 struct mdc_rpc_lock *cl_setattr_lock;
460 struct mdc_rpc_lock *cl_close_lock;
461 struct osc_creator cl_oscc;
464 struct semaphore cl_mgc_sem;
465 struct vfsmount *cl_mgc_vfsmnt;
466 struct dentry *cl_mgc_configs_dir;
467 atomic_t cl_mgc_refcount;
468 struct obd_export *cl_mgc_mgsexp;
470 /* checksumming for data sent over the network */
471 unsigned int cl_checksum:1; /* 0 = disabled, 1 = enabled */
472 /* supported checksum types that are worked out at connect time */
473 __u32 cl_supp_cksum_types;
474 /* checksum algorithm to be used */
475 cksum_type_t cl_cksum_type;
477 /* also protected by the poorly named _loi_list_lock lock above */
478 struct osc_async_rc cl_ar;
480 /* used by quotacheck */
481 int cl_qchk_stat; /* quotacheck stat of the peer */
483 /* sequence manager */
484 struct lu_client_seq *cl_seq;
486 atomic_t cl_resends; /* resend count */
487 /* Cache of triples */
488 struct lustre_cache *cl_cache;
489 obd_lock_cancel_cb cl_ext_lock_cancel_cb;
491 #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid)
493 #define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */
496 struct ptlrpc_service *mgs_service;
497 struct vfsmount *mgs_vfsmnt;
498 struct super_block *mgs_sb;
499 struct dentry *mgs_configs_dir;
500 struct dentry *mgs_fid_de;
501 struct list_head mgs_fs_db_list;
502 struct semaphore mgs_sem;
503 cfs_proc_dir_entry_t *mgs_proc_live;
507 /* NB this field MUST be first */
508 struct obd_device_target mds_obt;
509 struct ptlrpc_service *mds_service;
510 struct ptlrpc_service *mds_setattr_service;
511 struct ptlrpc_service *mds_readpage_service;
512 struct vfsmount *mds_vfsmnt;
513 cfs_dentry_t *mds_fid_de;
515 int mds_max_cookiesize;
517 unsigned long mds_atime_diff;
518 struct semaphore mds_epoch_sem;
519 struct ll_fid mds_rootfid;
520 cfs_dentry_t *mds_pending_dir;
521 cfs_dentry_t *mds_logs_dir;
522 cfs_dentry_t *mds_objects_dir;
523 struct llog_handle *mds_cfg_llh;
524 // struct llog_handle *mds_catalog;
525 struct obd_device *mds_osc_obd; /* XXX lov_obd */
526 struct obd_uuid mds_lov_uuid;
528 struct obd_export *mds_osc_exp; /* XXX lov_exp */
529 struct lov_desc mds_lov_desc;
531 /* mark pages dirty for write. */
532 bitmap_t *mds_lov_page_dirty;
533 /* array for store pages with obd_id */
534 void **mds_lov_page_array;
535 /* file for store objid */
536 struct file *mds_lov_objid_filp;
537 __u32 mds_lov_objid_count;
538 __u32 mds_lov_objid_max_index;
539 __u32 mds_lov_objid_lastpage;
540 __u32 mds_lov_objid_lastidx;
542 struct file *mds_health_check_filp;
543 struct upcall_cache *mds_group_hash;
545 struct lustre_quota_info mds_quota_info;
546 struct semaphore mds_qonoff_sem;
547 struct semaphore mds_health_sem;
548 unsigned long mds_fl_user_xattr:1,
552 mds_fl_target:1, /* mds have one or
554 mds_evict_ost_nids:1;
556 uid_t mds_squash_uid;
557 gid_t mds_squash_gid;
558 lnet_nid_t mds_nosquash_nid;
559 /* do we need permission sync */
560 unsigned int mds_sync_permission;
563 #define mds_transno_lock mds_obt.obt_translock
564 #define mds_rcvd_filp mds_obt.obt_rcvd_filp
565 #define mds_server_data mds_obt.obt_lsd
566 #define mds_client_bitmap mds_obt.obt_client_bitmap
567 #define mds_mount_count mds_obt.obt_mount_count
568 #define mds_last_transno mds_obt.obt_last_transno
571 #define mds_max_ost_index (0xFFFF)
572 #define MDS_LOV_ALLOC_SIZE (CFS_PAGE_SIZE)
574 #define OBJID_PER_PAGE() (MDS_LOV_ALLOC_SIZE / sizeof(obd_id))
576 #define MDS_LOV_OBJID_PAGES_COUNT (mds_max_ost_index/OBJID_PER_PAGE())
578 extern int mds_lov_init_objids(struct obd_device *obd);
579 extern void mds_lov_destroy_objids(struct obd_device *obd);
592 struct lustre_handle eo_nl_lock;
597 struct ptlrpc_service *ost_service;
598 struct ptlrpc_service *ost_create_service;
599 struct ptlrpc_service *ost_io_service;
600 struct semaphore ost_health_sem;
601 int ost_sync_on_lock_cancel;
604 struct echo_client_obd {
605 struct obd_export *ec_exp; /* the local connection to osc/lov */
607 struct list_head ec_objects;
613 struct obd_uuid lqo_uuid; /* ptlrpc's c_remote_uuid */
614 struct list_head lqo_oss_list; /* link to lov_qos */
615 __u64 lqo_bavail; /* total bytes avail on OSS */
616 __u64 lqo_penalty; /* current penalty */
617 __u64 lqo_penalty_per_obj; /* penalty decrease every obj*/
618 time_t lqo_used; /* last used time, seconds */
619 __u32 lqo_ost_count; /* number of osts on this oss */
623 struct lov_qos_oss *ltq_oss; /* oss info */
624 __u64 ltq_penalty; /* current penalty */
625 __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/
626 __u64 ltq_weight; /* net weighting */
627 time_t ltq_used; /* last used time, seconds */
628 unsigned int ltq_usable:1; /* usable for striping */
631 /* Generic subset of OSTs */
633 __u32 *op_array; /* array of index of
635 unsigned int op_count; /* number of OSTs in the array */
636 unsigned int op_size; /* allocated size of lp_array */
637 struct rw_semaphore op_rw_sem; /* to protect ost_pool use */
640 /* Round-robin allocator data */
642 __u32 lqr_start_idx; /* start index of new inode */
643 __u32 lqr_offset_idx; /* aliasing for start_idx */
644 int lqr_start_count; /* reseed counter */
645 struct ost_pool lqr_pool; /* round-robin optimized list */
646 unsigned long lqr_dirty:1; /* recalc round-robin list */
649 /* Stripe placement optimization */
651 struct list_head lq_oss_list; /* list of OSSs that targets use */
652 struct rw_semaphore lq_rw_sem;
653 __u32 lq_active_oss_count;
654 unsigned int lq_prio_free; /* priority for free space */
655 unsigned int lq_threshold_rr;/* priority for rr */
656 struct lov_qos_rr lq_rr; /* round robin qos data */
657 unsigned long lq_dirty:1, /* recalc qos data */
658 lq_same_space:1,/* the ost's all have approx.
659 the same space avail */
660 lq_reset:1; /* zero current penalties */
663 struct lov_tgt_desc {
664 struct list_head ltd_kill;
665 struct obd_uuid ltd_uuid;
666 struct obd_export *ltd_exp;
667 struct ltd_qos ltd_qos; /* qos info per target */
669 __u32 ltd_index; /* index in lov_obd->tgts */
670 unsigned long ltd_active:1,/* is this target up for requests */
671 ltd_activate:1,/* should this target be activated */
672 ltd_reap:1; /* should this target be deleted */
676 #define pool_tgt_size(_p) _p->pool_obds.op_size
677 #define pool_tgt_count(_p) _p->pool_obds.op_count
678 #define pool_tgt_array(_p) _p->pool_obds.op_array
679 #define pool_tgt_rw_sem(_p) _p->pool_obds.op_rw_sem
680 #define pool_tgt(_p, _i) _p->pool_lov->lov_tgts[_p->pool_obds.op_array[_i]]
683 char pool_name[LOV_MAXPOOLNAME + 1]; /* name of pool */
684 struct ost_pool pool_obds; /* pool members */
685 atomic_t pool_refcount; /* pool ref. counter */
686 struct lov_qos_rr pool_rr; /* round robin qos */
687 struct hlist_node pool_hash; /* access by poolname */
688 struct list_head pool_list; /* serial access */
689 cfs_proc_dir_entry_t *pool_proc_entry; /* file in /proc */
690 struct lov_obd *pool_lov; /* lov obd to which this
695 struct lov_desc desc;
696 struct lov_tgt_desc **lov_tgts; /* sparse array */
697 struct ost_pool lov_packed; /* all OSTs in a packed
699 struct semaphore lov_lock;
700 struct obd_connect_data lov_ocd;
701 struct lov_qos lov_qos; /* qos info per lov */
702 atomic_t lov_refcount;
703 __u32 lov_tgt_count; /* how many OBD's */
704 __u32 lov_active_tgt_count; /* how many active */
705 __u32 lov_death_row;/* tgts scheduled to be deleted */
706 __u32 lov_tgt_size; /* size of tgts array */
708 obd_page_removal_cb_t lov_page_removal_cb;
709 obd_pin_extent_cb lov_page_pin_cb;
710 obd_lock_cancel_cb lov_lock_cancel_cb;
712 lustre_hash_t *lov_pools_hash_body; /* used for key access */
713 struct list_head lov_pool_list; /* used for sequential access */
714 cfs_proc_dir_entry_t *lov_pool_proc_entry;
717 struct niobuf_local {
722 cfs_dentry_t *dentry;
727 /* obd device type names */
728 /* FIXME all the references to LUSTRE_MDS_NAME should be swapped with LUSTRE_MDT_NAME */
729 #define LUSTRE_MDS_NAME "mds"
730 #define LUSTRE_MDT_NAME "mdt"
731 #define LUSTRE_MDC_NAME "mdc"
732 #define LUSTRE_OSS_NAME "ost" /*FIXME change name to oss*/
733 #define LUSTRE_OST_NAME "obdfilter" /* FIXME change name to ost*/
734 #define LUSTRE_OSC_NAME "osc"
735 #define LUSTRE_LOV_NAME "lov"
736 #define LUSTRE_MGS_NAME "mgs"
737 #define LUSTRE_MGC_NAME "mgc"
739 #define LUSTRE_CACHEOBD_NAME "cobd"
740 #define LUSTRE_ECHO_NAME "obdecho"
741 #define LUSTRE_ECHO_CLIENT_NAME "echo_client"
743 /* Constant obd names (post-rename) */
744 #define LUSTRE_MDS_OBDNAME "MDS"
745 #define LUSTRE_OSS_OBDNAME "OSS"
746 #define LUSTRE_MGS_OBDNAME "MGS"
747 #define LUSTRE_MGC_OBDNAME "MGC"
749 /* Don't conflict with on-wire flags OBD_BRW_WRITE, etc */
750 #define N_LOCAL_TEMP_PAGE 0x10000000
752 struct obd_trans_info {
755 /* Only used on the server side for tracking acks. */
756 struct oti_req_ack_lock {
757 struct lustre_handle lock;
761 struct llog_cookie oti_onecookie;
762 struct llog_cookie *oti_logcookies;
765 /* initial thread handling transaction */
766 struct ptlrpc_thread * oti_thread;
769 __u64 oti_pre_version;
771 struct obd_uuid *oti_ost_uuid;
774 static inline void oti_init(struct obd_trans_info *oti,
775 struct ptlrpc_request *req)
779 memset(oti, 0, sizeof(*oti));
784 oti->oti_xid = req->rq_xid;
785 /* VBR: take versions from request */
786 if (req->rq_reqmsg != NULL &&
787 lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
788 __u64 *pre_version = lustre_msg_get_versions(req->rq_reqmsg);
789 /* b1.6 interoperability check. pre_versions may be NULL */
790 oti->oti_pre_version = pre_version ? pre_version[0] : 0;
791 oti->oti_transno = lustre_msg_get_transno(req->rq_reqmsg);
794 /* called from mds_create_objects */
795 if (req->rq_repmsg != NULL)
796 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
797 oti->oti_thread = req->rq_svc_thread;
798 if (req->rq_reqmsg != NULL)
799 oti->oti_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg);
802 static inline void oti_alloc_cookies(struct obd_trans_info *oti,int num_cookies)
807 if (num_cookies == 1)
808 oti->oti_logcookies = &oti->oti_onecookie;
810 OBD_ALLOC(oti->oti_logcookies,
811 num_cookies * sizeof(oti->oti_onecookie));
813 oti->oti_numcookies = num_cookies;
816 static inline void oti_free_cookies(struct obd_trans_info *oti)
818 if (!oti || !oti->oti_logcookies)
821 if (oti->oti_logcookies == &oti->oti_onecookie)
822 LASSERT(oti->oti_numcookies == 1);
824 OBD_FREE(oti->oti_logcookies,
825 oti->oti_numcookies * sizeof(oti->oti_onecookie));
826 oti->oti_logcookies = NULL;
827 oti->oti_numcookies = 0;
832 LLOG_CONFIG_ORIG_CTXT = 0,
833 LLOG_CONFIG_REPL_CTXT = 1,
834 LLOG_MDS_OST_ORIG_CTXT = 2,
835 LLOG_MDS_OST_REPL_CTXT = 3,
836 LLOG_SIZE_ORIG_CTXT = 4,
837 LLOG_SIZE_REPL_CTXT = 5,
838 LLOG_MD_ORIG_CTXT = 6,
839 LLOG_MD_REPL_CTXT = 7,
840 LLOG_RD1_ORIG_CTXT = 8,
841 LLOG_RD1_REPL_CTXT = 9,
842 LLOG_TEST_ORIG_CTXT = 10,
843 LLOG_TEST_REPL_CTXT = 11,
844 LLOG_LOVEA_ORIG_CTXT = 12,
845 LLOG_LOVEA_REPL_CTXT = 13,
850 * Events signalled through obd_notify() upcall-chain.
852 enum obd_notify_event {
853 /* DEVICE connect start */
855 /* Device activated */
857 /* Device deactivated */
859 /* Connect data for import were changed */
862 OBD_NOTIFY_SYNC_NONBLOCK,
864 /* Configuration event */
868 #define CONFIG_LOG 0x1 /* finished processing config log */
869 #define CONFIG_SYNC 0x2 /* mdt synced 1 ost */
870 #define CONFIG_TARGET 0x4 /* one target is added */
873 * Data structure used to pass obd_notify()-event to non-obd listeners (llite
874 * and liblustre being main examples).
876 struct obd_notify_upcall {
877 int (*onu_upcall)(struct obd_device *host, struct obd_device *watched,
878 enum obd_notify_event ev, void *owner);
879 /* Opaque datum supplied by upper layer listener */
883 /* corresponds to one of the obd's */
884 #define MAX_OBD_NAME 128
885 #define OBD_DEVICE_MAGIC 0XAB5CD6EF
886 #define OBD_DEV_BY_DEVNAME 0xffffd0de
888 struct obd_type *obd_type;
891 /* common and UUID name of this device */
892 char obd_name[MAX_OBD_NAME];
893 struct obd_uuid obd_uuid;
896 unsigned long obd_attached:1, /* finished attach */
897 obd_set_up:1, /* finished setup */
898 obd_recovering:1, /* there are recoverable clients */
899 obd_abort_recovery:1,/* recovery expired */
900 obd_version_recov:1, /* obd uses version checking */
901 obd_replayable:1, /* recovery is enabled; inform clients */
902 obd_no_transno:1, /* no committed-transno notification */
903 obd_no_recov:1, /* fail instead of retry messages */
904 obd_stopping:1, /* started cleanup */
905 obd_starting:1, /* started setup */
906 obd_force:1, /* cleanup with > 0 obd refcount */
907 obd_fail:1, /* cleanup with failover */
908 obd_async_recov:1, /* allow asyncronous orphan cleanup */
909 obd_no_conn:1, /* deny new connections */
910 obd_inactive:1; /* device active/inactive
911 * (for /proc/status only!!) */
912 /* uuid-export hash body */
913 struct lustre_hash *obd_uuid_hash;
914 /* nid-export hash body */
915 struct lustre_hash *obd_nid_hash;
917 struct lustre_hash *obd_nid_stats_hash;
918 struct list_head obd_nid_stats;
919 atomic_t obd_refcount;
920 cfs_waitq_t obd_refcount_waitq;
921 struct list_head obd_exports;
922 struct list_head obd_delayed_exports;
924 spinlock_t obd_nid_lock;
925 struct ldlm_namespace *obd_namespace;
926 struct ptlrpc_client obd_ldlm_client; /* XXX OST/MDS only */
927 /* a spinlock is OK for what we do now, may need a semaphore later */
928 spinlock_t obd_dev_lock;
929 struct semaphore obd_dev_sem;
930 __u64 obd_last_committed;
931 struct fsfilt_operations *obd_fsops;
932 spinlock_t obd_osfs_lock;
933 struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */
935 struct lvfs_run_ctxt obd_lvfs_ctxt;
937 struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS];
938 struct semaphore obd_llog_alloc;
939 struct semaphore obd_llog_cat_process;
940 cfs_waitq_t obd_llog_waitq;
942 struct obd_device *obd_observer;
943 struct obd_notify_upcall obd_upcall;
944 struct obd_export *obd_self_export;
945 /* list of exports in LRU order, for ping evictor, with obd_dev_lock */
946 struct list_head obd_exports_timed;
947 time_t obd_eviction_timer; /* for ping evictor */
949 /* XXX encapsulate all this recovery data into one struct */
950 svc_handler_t obd_recovery_handler;
951 int obd_max_recoverable_clients;
952 int obd_connected_clients;
953 int obd_recoverable_clients;
954 int obd_delayed_clients;
955 spinlock_t obd_processing_task_lock; /* BH lock (timer) */
956 pid_t obd_processing_task;
957 __u64 obd_next_recovery_transno;
958 int obd_replayed_requests;
959 int obd_requests_queued_for_recovery;
960 cfs_waitq_t obd_next_transno_waitq;
961 cfs_timer_t obd_recovery_timer;
962 struct list_head obd_recovery_queue;
963 struct list_head obd_delayed_reply_queue;
964 time_t obd_recovery_start; /* seconds */
965 time_t obd_recovery_end; /* seconds, for lprocfs_status */
967 time_t obd_recovery_max_time; /* seconds, bz13079 */
969 int obd_recovery_timeout;
972 struct obd_device_target obt;
973 struct filter_obd filter;
975 struct client_obd cli;
977 struct echo_client_obd echo_client;
978 struct echo_obd echo;
982 /* Fields used by LProcFS */
983 cfs_proc_dir_entry_t *obd_proc_entry;
984 cfs_proc_dir_entry_t *obd_proc_exports_entry;
985 cfs_proc_dir_entry_t *obd_svc_procroot;
986 struct lprocfs_stats *obd_stats;
987 struct lprocfs_stats *obd_svc_stats;
988 unsigned int obd_cntr_base;
989 atomic_t obd_evict_inprogress;
990 cfs_waitq_t obd_evict_inprogress_waitq;
992 /* Ldlm pool part. Save last calculated SLV and Limit. */
993 rwlock_t obd_pool_lock;
998 #define OBD_LLOG_FL_SENDNOW 0x0001
1000 enum obd_cleanup_stage {
1001 /* Special case hack for MDS LOVs */
1003 /* Precleanup stage 1, we must make sure all exports (other than the
1004 self-export) get destroyed. */
1005 OBD_CLEANUP_EXPORTS,
1006 /* Precleanup stage 2, do other type-specific cleanup requiring the
1008 OBD_CLEANUP_SELF_EXP,
1009 /* FIXME we should eliminate the "precleanup" function and make them stages
1010 of the "cleanup" function. */
1014 /* get/set_info keys */
1015 #define KEY_MDS_CONN "mds_conn"
1016 #define KEY_NEXT_ID "next_id"
1017 #define KEY_LOVDESC "lovdesc"
1018 #define KEY_INIT_RECOV "initial_recov"
1019 #define KEY_INIT_RECOV_BACKUP "init_recov_bk"
1020 #define KEY_LAST_ID "last_id"
1021 #define KEY_LOCK_TO_STRIPE "lock_to_stripe"
1022 #define KEY_CHECKSUM "checksum"
1023 #define KEY_READONLY "read-only"
1024 #define KEY_READONLY_166COMPAT "readonly"
1025 #define KEY_UNLINKED "unlinked"
1026 #define KEY_EVICT_BY_NID "evict_by_nid"
1027 #define KEY_REGISTER_TARGET "register_target"
1028 #define KEY_SET_FS "set_fs"
1029 #define KEY_CLEAR_FS "clear_fs"
1030 #define KEY_SET_INFO "set_info"
1031 #define KEY_BLOCKSIZE "blocksize"
1032 #define KEY_BLOCKSIZE_BITS "blocksize_bits"
1033 #define KEY_MAX_EASIZE "max_ea_size"
1034 #define KEY_FIEMAP "fiemap"
1036 #define KEY_ASYNC "async"
1037 #define KEY_CAPA_KEY "capa_key"
1040 struct module *o_owner;
1041 int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len,
1042 void *karg, void *uarg);
1043 int (*o_get_info)(struct obd_export *, __u32 keylen, void *key,
1044 __u32 *vallen, void *val, struct lov_stripe_md *lsm);
1045 int (*o_set_info_async)(struct obd_export *, __u32 keylen, void *key,
1046 __u32 vallen, void *val,
1047 struct ptlrpc_request_set *set);
1048 int (*o_attach)(struct obd_device *dev, obd_count len, void *data);
1049 int (*o_detach)(struct obd_device *dev);
1050 int (*o_setup) (struct obd_device *dev, obd_count len, void *data);
1051 int (*o_precleanup)(struct obd_device *dev,
1052 enum obd_cleanup_stage cleanup_stage);
1053 int (*o_cleanup)(struct obd_device *dev);
1054 int (*o_process_config)(struct obd_device *dev, obd_count len,
1056 int (*o_postrecov)(struct obd_device *dev);
1057 int (*o_add_conn)(struct obd_import *imp, struct obd_uuid *uuid,
1059 int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
1060 /* connect to the target device with given connection
1061 * data. @ocd->ocd_connect_flags is modified to reflect flags actually
1062 * granted by the target, which are guaranteed to be a subset of flags
1063 * asked for. If @ocd == NULL, use default parameters. */
1064 int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
1065 struct obd_uuid *cluuid, struct obd_connect_data *ocd,
1067 int (*o_reconnect)(struct obd_export *exp, struct obd_device *src,
1068 struct obd_uuid *cluuid,
1069 struct obd_connect_data *ocd,
1071 int (*o_disconnect)(struct obd_export *exp);
1073 /* Initialize/finalize fids infrastructure. */
1074 int (*o_fid_init)(struct obd_export *exp);
1075 int (*o_fid_fini)(struct obd_export *exp);
1077 int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
1078 __u64 max_age, __u32 flags);
1079 int (*o_statfs_async)(struct obd_device *obd, struct obd_info *oinfo,
1080 __u64 max_age, struct ptlrpc_request_set *set);
1081 int (*o_packmd)(struct obd_export *exp, struct lov_mds_md **disk_tgt,
1082 struct lov_stripe_md *mem_src);
1083 int (*o_unpackmd)(struct obd_export *exp,struct lov_stripe_md **mem_tgt,
1084 struct lov_mds_md *disk_src, int disk_len);
1085 int (*o_checkmd)(struct obd_export *exp, struct obd_export *md_exp,
1086 struct lov_stripe_md *mem_tgt);
1087 int (*o_preallocate)(struct lustre_handle *, obd_count *req,
1089 int (*o_precreate)(struct obd_export *exp);
1090 int (*o_create)(struct obd_export *exp, struct obdo *oa,
1091 struct lov_stripe_md **ea, struct obd_trans_info *oti);
1092 int (*o_destroy)(struct obd_export *exp, struct obdo *oa,
1093 struct lov_stripe_md *ea, struct obd_trans_info *oti,
1094 struct obd_export *md_exp);
1095 int (*o_setattr)(struct obd_export *exp, struct obd_info *oinfo,
1096 struct obd_trans_info *oti);
1097 int (*o_setattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1098 struct obd_trans_info *oti,
1099 struct ptlrpc_request_set *rqset);
1100 int (*o_getattr)(struct obd_export *exp, struct obd_info *oinfo);
1101 int (*o_getattr_async)(struct obd_export *exp, struct obd_info *oinfo,
1102 struct ptlrpc_request_set *set);
1103 int (*o_brw)(int rw, struct obd_export *exp, struct obd_info *oinfo,
1104 obd_count oa_bufs, struct brw_page *pgarr,
1105 struct obd_trans_info *oti);
1106 int (*o_brw_async)(int rw, struct obd_export *exp,
1107 struct obd_info *oinfo, obd_count oa_bufs,
1108 struct brw_page *pgarr, struct obd_trans_info *oti,
1109 struct ptlrpc_request_set *);
1110 int (*o_prep_async_page)(struct obd_export *exp,
1111 struct lov_stripe_md *lsm,
1112 struct lov_oinfo *loi,
1113 cfs_page_t *page, obd_off offset,
1114 struct obd_async_page_ops *ops, void *data,
1115 void **res, int nocache,
1116 struct lustre_handle *lockh);
1117 int (*o_reget_short_lock)(struct obd_export *exp,
1118 struct lov_stripe_md *lsm,
1120 obd_off start, obd_off end,
1122 int (*o_release_short_lock)(struct obd_export *exp,
1123 struct lov_stripe_md *lsm, obd_off end,
1124 void *cookie, int rw);
1125 int (*o_queue_async_io)(struct obd_export *exp,
1126 struct lov_stripe_md *lsm,
1127 struct lov_oinfo *loi, void *cookie,
1128 int cmd, obd_off off, int count,
1129 obd_flag brw_flags, obd_flag async_flags);
1130 int (*o_queue_group_io)(struct obd_export *exp,
1131 struct lov_stripe_md *lsm,
1132 struct lov_oinfo *loi,
1133 struct obd_io_group *oig,
1134 void *cookie, int cmd, obd_off off, int count,
1135 obd_flag brw_flags, obd_flag async_flags);
1136 int (*o_trigger_group_io)(struct obd_export *exp,
1137 struct lov_stripe_md *lsm,
1138 struct lov_oinfo *loi,
1139 struct obd_io_group *oig);
1140 int (*o_set_async_flags)(struct obd_export *exp,
1141 struct lov_stripe_md *lsm,
1142 struct lov_oinfo *loi, void *cookie,
1143 obd_flag async_flags);
1144 int (*o_teardown_async_page)(struct obd_export *exp,
1145 struct lov_stripe_md *lsm,
1146 struct lov_oinfo *loi, void *cookie);
1147 int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
1148 struct ost_lvb *lvb, int kms_only);
1149 int (*o_update_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
1150 struct ost_lvb *lvb, obd_flag valid);
1151 int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
1152 obd_off size, int shrink);
1153 int (*o_punch)(struct obd_export *exp, struct obd_info *oinfo,
1154 struct obd_trans_info *oti,
1155 struct ptlrpc_request_set *rqset);
1156 int (*o_sync)(struct obd_export *exp, struct obd_info *oinfo,
1157 obd_size start, obd_size end,
1158 struct ptlrpc_request_set *rqset);
1159 int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
1160 struct lov_stripe_md *src, obd_size start,
1161 obd_size end, struct obd_trans_info *oti);
1162 int (*o_copy)(struct lustre_handle *dstconn, struct lov_stripe_md *dst,
1163 struct lustre_handle *srconn, struct lov_stripe_md *src,
1164 obd_size start, obd_size end, struct obd_trans_info *);
1165 int (*o_iterate)(struct lustre_handle *conn,
1166 int (*)(obd_id, obd_gr, void *),
1167 obd_id *startid, obd_gr group, void *data);
1168 int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
1169 int objcount, struct obd_ioobj *obj,
1170 struct niobuf_remote *remote, int *nr_pages,
1171 struct niobuf_local *local,
1172 struct obd_trans_info *oti);
1173 int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
1174 int objcount, struct obd_ioobj *obj,
1175 struct niobuf_remote *remote, int pages,
1176 struct niobuf_local *local,
1177 struct obd_trans_info *oti, int rc);
1178 int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo,
1179 struct ldlm_enqueue_info *einfo,
1180 struct ptlrpc_request_set *rqset);
1181 int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
1182 ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
1183 struct lustre_handle *lockh, int *n_matches);
1184 int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
1185 ldlm_iterator_t it, void *data);
1186 int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
1187 __u32 mode, struct lustre_handle *);
1188 int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
1189 int flags, void *opaque);
1190 int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *,
1192 int (*o_init_export)(struct obd_export *exp);
1193 int (*o_destroy_export)(struct obd_export *exp);
1194 int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *,
1195 int cmd, obd_off *);
1197 /* llog related obd_methods */
1198 int (*o_llog_init)(struct obd_device *obd, struct obd_device *disk_obd,
1199 int count, struct llog_catid *logid,
1200 struct obd_uuid *uuid);
1201 int (*o_llog_finish)(struct obd_device *obd, int count);
1203 /* metadata-only methods */
1204 int (*o_pin)(struct obd_export *, struct ll_fid *,
1205 struct obd_client_handle *, int flag);
1206 int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
1208 int (*o_import_event)(struct obd_device *, struct obd_import *,
1209 enum obd_import_event);
1211 int (*o_notify)(struct obd_device *obd, struct obd_device *watched,
1212 enum obd_notify_event ev, void *data);
1214 int (*o_health_check)(struct obd_device *);
1217 int (*o_quotacheck)(struct obd_export *, struct obd_quotactl *);
1218 int (*o_quotactl)(struct obd_export *, struct obd_quotactl *);
1219 int (*o_quota_adjust_qunit)(struct obd_export *exp,
1220 struct quota_adjust_qunit *oqaq,
1221 struct lustre_quota_ctxt *qctxt);
1224 int (*o_ping)(struct obd_export *exp);
1226 int (*o_register_page_removal_cb)(struct obd_device *obd,
1227 obd_page_removal_cb_t cb,
1228 obd_pin_extent_cb pin_cb);
1229 int (*o_unregister_page_removal_cb)(struct obd_device *obd,
1230 obd_page_removal_cb_t cb);
1231 int (*o_register_lock_cancel_cb)(struct obd_device *obd,
1232 obd_lock_cancel_cb cb);
1233 int (*o_unregister_lock_cancel_cb)(struct obd_device *obd,
1234 obd_lock_cancel_cb cb);
1236 int (*o_pool_new)(struct obd_device *obd, char *poolname);
1237 int (*o_pool_del)(struct obd_device *obd, char *poolname);
1238 int (*o_pool_add)(struct obd_device *obd, char *poolname,
1240 int (*o_pool_rem)(struct obd_device *obd, char *poolname,
1243 * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
1244 * to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c.
1245 * Also, add a wrapper function in include/linux/obd_class.h. */
1248 struct lsm_operations {
1249 void (*lsm_free)(struct lov_stripe_md *);
1250 int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa,
1251 struct obd_export *md_exp);
1252 void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, obd_off *,
1254 void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, obd_off *,
1256 obd_off (*lsm_stripe_offset_by_index)(struct lov_stripe_md *, int);
1257 obd_off (*lsm_stripe_offset_by_offset)(struct lov_stripe_md *, obd_off);
1258 int (*lsm_stripe_index_by_offset)(struct lov_stripe_md *, obd_off);
1259 int (*lsm_revalidate) (struct lov_stripe_md *, struct obd_device *obd);
1260 int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes,
1262 int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm,
1263 struct lov_mds_md *lmm);
1266 extern struct lsm_operations lsm_v1_ops;
1267 extern struct lsm_operations lsm_join_ops;
1268 extern struct lsm_operations lsm_v3_ops;
1269 static inline struct lsm_operations *lsm_op_find(int magic)
1274 case LOV_MAGIC_JOIN:
1275 return &lsm_join_ops;
1279 CERROR("Cannot recognize lsm_magic %x\n", magic);
1284 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
1286 /* Requests for obd_extent_calc() */
1287 #define OBD_CALC_STRIPE_START 1
1288 #define OBD_CALC_STRIPE_END 2
1290 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
1291 struct obd_export *exp, int error)
1294 CERROR("%s: transno "LPU64" commit error: %d\n",
1295 obd->obd_name, transno, error);
1298 if (exp && transno > exp->exp_last_committed) {
1299 CDEBUG(D_HA, "%s: transno "LPU64" committed\n",
1300 obd->obd_name, transno);
1301 exp->exp_last_committed = transno;
1302 ptlrpc_commit_replies(exp);
1304 CDEBUG(D_INFO, "%s: transno "LPU64" committed\n",
1305 obd->obd_name, transno);
1307 if (transno > obd->obd_last_committed)
1308 obd->obd_last_committed = transno;
1311 static inline void init_obd_quota_ops(quota_interface_t *interface,
1312 struct obd_ops *obd_ops)
1318 obd_ops->o_quotacheck = QUOTA_OP(interface, check);
1319 obd_ops->o_quotactl = QUOTA_OP(interface, ctl);
1320 obd_ops->o_quota_adjust_qunit = QUOTA_OP(interface, adjust_qunit);
1328 /* Default preferred checksum algorithm to use (if supported by the server) */
1329 #define OSC_DEFAULT_CKSUM OBD_CKSUM_ADLER
1330 /* Adler-32 is supported */
1331 #define CHECKSUM_ADLER OBD_CKSUM_ADLER
1333 #define OSC_DEFAULT_CKSUM OBD_CKSUM_CRC32
1334 #define CHECKSUM_ADLER 0
1337 #define OBD_CKSUM_ALL (OBD_CKSUM_CRC32 | CHECKSUM_ADLER)
1339 /* Checksum algorithm names. Must be defined in the same order as the
1340 * OBD_CKSUM_* flags. */
1341 #define DECLARE_CKSUM_NAME char *cksum_name[] = {"crc32", "adler"}
1343 #endif /* __OBD_H */