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 #include <obd_support.h>
41 #include <lustre_import.h>
42 #include <lustre_net.h>
44 #include <lustre_lib.h>
45 #include <lustre/lustre_idl.h>
46 #include <lprocfs_status.h>
48 #if defined(__linux__)
49 #include <linux/obd_class.h>
50 #elif defined(__APPLE__)
51 #include <darwin/obd_class.h>
52 #elif defined(__WINNT__)
53 #include <winnt/obd_class.h>
55 #error Unsupported operating system.
58 /* OBD Device Declarations */
59 extern struct obd_device *obd_devs[MAX_OBD_DEVICES];
60 extern spinlock_t obd_dev_lock;
61 extern cfs_mem_cache_t *obd_lvfs_ctxt_cache;
63 /* OBD Operations Declarations */
64 extern struct obd_device *class_conn2obd(struct lustre_handle *);
65 extern struct obd_device *class_exp2obd(struct obd_export *);
68 struct obd_export *class_conn2export(struct lustre_handle *);
69 int class_register_type(struct obd_ops *ops, struct lprocfs_vars *,
71 int class_unregister_type(const char *nm);
73 struct obd_device *class_newdev(const char *type_name, const char *name);
74 void class_release_dev(struct obd_device *obd);
76 int class_name2dev(const char *name);
77 struct obd_device *class_name2obd(const char *name);
78 int class_uuid2dev(struct obd_uuid *uuid);
79 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
80 void class_obd_list(void);
81 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
82 const char * typ_name,
83 struct obd_uuid *grp_uuid);
84 struct obd_device * class_find_client_notype(struct obd_uuid *tgt_uuid,
85 struct obd_uuid *grp_uuid);
86 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
88 struct obd_device * class_num2obd(int num);
90 int oig_init(struct obd_io_group **oig);
91 int oig_add_one(struct obd_io_group *oig, struct oig_callback_context *occ);
92 void oig_complete_one(struct obd_io_group *oig,
93 struct oig_callback_context *occ, int rc);
94 void oig_release(struct obd_io_group *oig);
95 int oig_wait(struct obd_io_group *oig);
97 char *obd_export_nid2str(struct obd_export *exp);
99 int obd_export_evict_by_nid(struct obd_device *obd, char *nid);
100 int obd_export_evict_by_uuid(struct obd_device *obd, char *uuid);
102 int obd_zombie_impexp_init(void);
103 void obd_zombie_impexp_stop(void);
104 void obd_zombie_impexp_cull(void);
107 int class_process_config(struct lustre_cfg *lcfg);
108 int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
109 struct lustre_cfg *lcfg, void *data);
110 int class_attach(struct lustre_cfg *lcfg);
111 int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
112 int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
113 int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
114 struct obd_device *class_incref(struct obd_device *obd);
115 void class_decref(struct obd_device *obd);
119 extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);
121 static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
123 memset(lvars, 0, sizeof(*lvars));
127 #define CFG_F_START 0x01 /* Set when we start updating from a log */
128 #define CFG_F_MARKER 0x02 /* We are within a maker */
129 #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */
130 #define CFG_F_COMPAT146 0x08 /* Allow old-style logs */
131 #define CFG_F_EXCLUDE 0x10 /* OST exclusion list */
133 /* Passed as data param to class_config_parse_llog */
134 struct config_llog_instance {
136 struct super_block *cfg_sb;
137 struct obd_uuid cfg_uuid;
138 int cfg_last_idx; /* for partial llog processing */
141 int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
142 struct config_llog_instance *cfg);
143 int class_config_dump_llog(struct llog_ctxt *ctxt, char *name,
144 struct config_llog_instance *cfg);
146 /* list of active configuration logs */
147 struct config_llog_data {
149 struct ldlm_res_id cld_resid;
150 struct config_llog_instance cld_cfg;
151 struct list_head cld_list_chain;
152 atomic_t cld_refcount;
153 struct obd_export *cld_mgcexp;
154 unsigned int cld_stopping:1; /* we were told to stop watching */
155 unsigned int cld_lostlock:1; /* lock not requeued */
158 struct lustre_profile {
159 struct list_head lp_list;
165 struct lustre_profile *class_get_profile(char * prof);
166 void class_del_profile(char *prof);
167 void class_del_profiles(void);
169 #define class_export_rpc_get(exp) \
171 atomic_inc(&(exp)->exp_rpc_count); \
172 CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \
173 (exp), atomic_read(&(exp)->exp_rpc_count)); \
174 class_export_get(exp); \
177 #define class_export_rpc_put(exp) \
179 atomic_dec(&(exp)->exp_rpc_count); \
180 CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \
181 (exp), atomic_read(&(exp)->exp_rpc_count)); \
182 class_export_put(exp); \
186 #define class_export_get(exp) \
188 struct obd_export *exp_ = exp; \
189 atomic_inc(&exp_->exp_refcount); \
190 CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp_, \
191 atomic_read(&exp_->exp_refcount)); \
195 /* class_export_put() is non-blocking */
196 #define class_export_put(exp) \
198 LASSERT((exp) != NULL); \
199 CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", (exp), \
200 atomic_read(&(exp)->exp_refcount) - 1); \
201 LASSERT(atomic_read(&(exp)->exp_refcount) > 0); \
202 LASSERT(atomic_read(&(exp)->exp_refcount) < 0x5a5a5a); \
203 __class_export_put(exp); \
206 void __class_export_put(struct obd_export *);
207 struct obd_export *class_new_export(struct obd_device *obddev,
208 struct obd_uuid *cluuid);
209 void class_unlink_export(struct obd_export *exp);
211 struct obd_import *class_import_get(struct obd_import *);
212 void class_import_put(struct obd_import *);
213 struct obd_import *class_new_import(struct obd_device *obd);
214 void class_destroy_import(struct obd_import *exp);
216 struct obd_type *class_search_type(const char *name);
217 struct obd_type *class_get_type(const char *name);
218 void class_put_type(struct obd_type *type);
219 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
220 struct obd_uuid *cluuid);
221 int class_disconnect(struct obd_export *exp);
222 void class_fail_export(struct obd_export *exp);
223 void class_disconnect_exports(struct obd_device *obddev);
224 void class_set_export_delayed(struct obd_export *exp);
225 void class_handle_stale_exports(struct obd_device *obddev);
226 void class_disconnect_expired_exports(struct obd_device *obd);
227 void class_disconnect_stale_exports(struct obd_device *obddev,
228 enum obd_option flags);
229 int class_stale_export_list(struct obd_device *obd, struct obd_ioctl_data *data);
230 int class_manual_cleanup(struct obd_device *obd);
232 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
234 return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
235 (obd->obd_force ? OBD_OPT_FORCE : 0) |
236 (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) |
241 void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid);
242 void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj);
245 #define OBT(dev) (dev)->obd_type
246 #define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op
247 #define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op
249 /* Ensure obd_setup: used for cleanup which must be called
250 while obd is stopping */
251 #define OBD_CHECK_DEV(obd) \
254 CERROR("NULL device\n"); \
259 /* ensure obd_setup and !obd_stopping */
260 #define OBD_CHECK_DEV_ACTIVE(obd) \
262 OBD_CHECK_DEV(obd); \
263 if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
264 CERROR("Device %d not setup\n", \
272 #define OBD_COUNTER_OFFSET(op) \
273 ((offsetof(struct obd_ops, o_ ## op) - \
274 offsetof(struct obd_ops, o_iocontrol)) \
275 / sizeof(((struct obd_ops *)(0))->o_iocontrol))
277 #define OBD_COUNTER_INCREMENT(obdx, op) \
278 if ((obdx)->obd_stats != NULL) { \
279 unsigned int coffset; \
280 coffset = (unsigned int)((obdx)->obd_cntr_base) + \
281 OBD_COUNTER_OFFSET(op); \
282 LASSERT(coffset < (obdx)->obd_stats->ls_num); \
283 lprocfs_counter_incr((obdx)->obd_stats, coffset); \
286 #define EXP_COUNTER_INCREMENT(export, op) \
287 if ((export)->exp_obd->obd_stats != NULL) { \
288 unsigned int coffset; \
289 coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \
290 OBD_COUNTER_OFFSET(op); \
291 LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \
292 lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \
293 if ((export)->exp_nid_stats != NULL && \
294 (export)->exp_nid_stats->nid_stats != NULL) \
295 lprocfs_counter_incr( \
296 (export)->exp_nid_stats->nid_stats, coffset);\
300 #define OBD_COUNTER_OFFSET(op)
301 #define OBD_COUNTER_INCREMENT(obd, op)
302 #define EXP_COUNTER_INCREMENT(exp, op);
305 #define OBD_CHECK_OP(obd, op, err) \
307 if (!OBT(obd) || !OBP((obd), op)) {\
309 CERROR("obd_" #op ": dev %d no operation\n", \
315 #define EXP_CHECK_OP(exp, op) \
317 if ((exp) == NULL) { \
318 CERROR("obd_" #op ": NULL export\n"); \
321 if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \
322 CERROR("obd_" #op ": cleaned up obd\n"); \
323 RETURN(-EOPNOTSUPP); \
325 if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \
326 CERROR("obd_" #op ": dev %d no operation\n", \
327 (exp)->exp_obd->obd_minor); \
328 RETURN(-EOPNOTSUPP); \
332 #define CTXT_CHECK_OP(ctxt, op, err) \
334 if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \
336 CERROR("lop_" #op ": dev %d no operation\n", \
337 ctxt->loc_obd->obd_minor); \
342 static inline int class_devno_max(void)
344 return MAX_OBD_DEVICES;
347 static inline int obd_get_info(struct obd_export *exp, __u32 keylen,
348 void *key, __u32 *vallen, void *val,
349 struct lov_stripe_md *lsm)
354 EXP_CHECK_OP(exp, get_info);
355 EXP_COUNTER_INCREMENT(exp, get_info);
357 rc = OBP(exp->exp_obd, get_info)(exp, keylen, key, vallen, val, lsm);
361 static inline int obd_set_info_async(struct obd_export *exp, obd_count keylen,
362 void *key, obd_count vallen, void *val,
363 struct ptlrpc_request_set *set)
368 EXP_CHECK_OP(exp, set_info_async);
369 EXP_COUNTER_INCREMENT(exp, set_info_async);
371 rc = OBP(exp->exp_obd, set_info_async)(exp, keylen, key, vallen, val,
376 static inline int obd_setup(struct obd_device *obd, int datalen, void *data)
381 OBD_CHECK_OP(obd, setup, -EOPNOTSUPP);
382 OBD_COUNTER_INCREMENT(obd, setup);
384 rc = OBP(obd, setup)(obd, datalen, data);
388 static inline int obd_precleanup(struct obd_device *obd,
389 enum obd_cleanup_stage cleanup_stage)
394 OBD_CHECK_OP(obd, precleanup, 0);
395 OBD_COUNTER_INCREMENT(obd, precleanup);
397 rc = OBP(obd, precleanup)(obd, cleanup_stage);
401 static inline int obd_cleanup(struct obd_device *obd)
407 OBD_CHECK_OP(obd, cleanup, 0);
408 OBD_COUNTER_INCREMENT(obd, cleanup);
410 rc = OBP(obd, cleanup)(obd);
415 obd_process_config(struct obd_device *obd, int datalen, void *data)
420 OBD_CHECK_OP(obd, process_config, -EOPNOTSUPP);
421 OBD_COUNTER_INCREMENT(obd, process_config);
423 rc = OBP(obd, process_config)(obd, datalen, data);
427 /* Pack an in-memory MD struct for storage on disk.
428 * Returns +ve size of packed MD (0 for free), or -ve error.
430 * If @disk_tgt == NULL, MD size is returned (max size if @mem_src == NULL).
431 * If @*disk_tgt != NULL and @mem_src == NULL, @*disk_tgt will be freed.
432 * If @*disk_tgt == NULL, it will be allocated
434 static inline int obd_packmd(struct obd_export *exp,
435 struct lov_mds_md **disk_tgt,
436 struct lov_stripe_md *mem_src)
441 EXP_CHECK_OP(exp, packmd);
442 EXP_COUNTER_INCREMENT(exp, packmd);
444 rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src);
448 static inline int obd_size_diskmd(struct obd_export *exp,
449 struct lov_stripe_md *mem_src)
451 return obd_packmd(exp, NULL, mem_src);
454 /* helper functions */
455 static inline int obd_alloc_diskmd(struct obd_export *exp,
456 struct lov_mds_md **disk_tgt)
459 LASSERT(*disk_tgt == NULL);
460 return obd_packmd(exp, disk_tgt, NULL);
463 static inline int obd_free_diskmd(struct obd_export *exp,
464 struct lov_mds_md **disk_tgt)
468 return obd_packmd(exp, disk_tgt, NULL);
471 /* Unpack an MD struct from disk to in-memory format.
472 * Returns +ve size of unpacked MD (0 for free), or -ve error.
474 * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL).
475 * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed.
476 * If @*mem_tgt == NULL, it will be allocated
478 static inline int obd_unpackmd(struct obd_export *exp,
479 struct lov_stripe_md **mem_tgt,
480 struct lov_mds_md *disk_src,
486 EXP_CHECK_OP(exp, unpackmd);
487 EXP_COUNTER_INCREMENT(exp, unpackmd);
489 rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len);
493 /* helper functions */
494 static inline int obd_alloc_memmd(struct obd_export *exp,
495 struct lov_stripe_md **mem_tgt)
498 LASSERT(*mem_tgt == NULL);
499 return obd_unpackmd(exp, mem_tgt, NULL, 0);
502 static inline int obd_free_memmd(struct obd_export *exp,
503 struct lov_stripe_md **mem_tgt)
507 return obd_unpackmd(exp, mem_tgt, NULL, 0);
510 static inline int obd_checkmd(struct obd_export *exp,
511 struct obd_export *md_exp,
512 struct lov_stripe_md *mem_tgt)
517 EXP_CHECK_OP(exp, checkmd);
518 EXP_COUNTER_INCREMENT(exp, checkmd);
520 rc = OBP(exp->exp_obd, checkmd)(exp, md_exp, mem_tgt);
524 static inline int obd_precreate(struct obd_export *exp)
529 EXP_CHECK_OP(exp, precreate);
530 OBD_COUNTER_INCREMENT(exp->exp_obd, precreate);
532 rc = OBP(exp->exp_obd, precreate)(exp);
536 static inline int obd_create_async(struct obd_export *exp,
537 struct obd_info *oinfo,
538 struct lov_stripe_md **ea,
539 struct obd_trans_info *oti)
544 EXP_CHECK_OP(exp, create_async);
545 EXP_COUNTER_INCREMENT(exp, create_async);
547 rc = OBP(exp->exp_obd, create_async)(exp, oinfo, ea, oti);
551 static inline int obd_create(struct obd_export *exp, struct obdo *obdo,
552 struct lov_stripe_md **ea,
553 struct obd_trans_info *oti)
558 EXP_CHECK_OP(exp, create);
559 EXP_COUNTER_INCREMENT(exp, create);
561 rc = OBP(exp->exp_obd, create)(exp, obdo, ea, oti);
565 static inline int obd_destroy(struct obd_export *exp, struct obdo *obdo,
566 struct lov_stripe_md *ea,
567 struct obd_trans_info *oti,
568 struct obd_export *md_exp)
573 EXP_CHECK_OP(exp, destroy);
574 EXP_COUNTER_INCREMENT(exp, destroy);
576 rc = OBP(exp->exp_obd, destroy)(exp, obdo, ea, oti, md_exp);
580 static inline int obd_getattr(struct obd_export *exp, struct obd_info *oinfo)
585 EXP_CHECK_OP(exp, getattr);
586 EXP_COUNTER_INCREMENT(exp, getattr);
588 rc = OBP(exp->exp_obd, getattr)(exp, oinfo);
592 static inline int obd_getattr_async(struct obd_export *exp,
593 struct obd_info *oinfo,
594 struct ptlrpc_request_set *set)
599 EXP_CHECK_OP(exp, getattr_async);
600 EXP_COUNTER_INCREMENT(exp, getattr_async);
602 rc = OBP(exp->exp_obd, getattr_async)(exp, oinfo, set);
606 static inline int obd_setattr(struct obd_export *exp, struct obd_info *oinfo,
607 struct obd_trans_info *oti)
612 EXP_CHECK_OP(exp, setattr);
613 EXP_COUNTER_INCREMENT(exp, setattr);
615 rc = OBP(exp->exp_obd, setattr)(exp, oinfo, oti);
619 /* This performs all the requests set init/wait/destroy actions. */
620 static inline int obd_setattr_rqset(struct obd_export *exp,
621 struct obd_info *oinfo,
622 struct obd_trans_info *oti)
624 struct ptlrpc_request_set *set = NULL;
628 EXP_CHECK_OP(exp, setattr_async);
629 EXP_COUNTER_INCREMENT(exp, setattr_async);
631 set = ptlrpc_prep_set();
635 rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set);
637 rc = ptlrpc_set_wait(set);
638 ptlrpc_set_destroy(set);
642 /* This adds all the requests into @set if @set != NULL, otherwise
643 all requests are sent asynchronously without waiting for response. */
644 static inline int obd_setattr_async(struct obd_export *exp,
645 struct obd_info *oinfo,
646 struct obd_trans_info *oti,
647 struct ptlrpc_request_set *set)
652 EXP_CHECK_OP(exp, setattr_async);
653 EXP_COUNTER_INCREMENT(exp, setattr_async);
655 rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set);
659 static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
662 struct obd_device *obd = imp->imp_obd;
666 OBD_CHECK_DEV_ACTIVE(obd);
667 OBD_CHECK_OP(obd, add_conn, -EOPNOTSUPP);
668 OBD_COUNTER_INCREMENT(obd, add_conn);
670 rc = OBP(obd, add_conn)(imp, uuid, priority);
674 static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
676 struct obd_device *obd = imp->imp_obd;
680 OBD_CHECK_DEV_ACTIVE(obd);
681 OBD_CHECK_OP(obd, del_conn, -EOPNOTSUPP);
682 OBD_COUNTER_INCREMENT(obd, del_conn);
684 rc = OBP(obd, del_conn)(imp, uuid);
688 static inline int obd_connect(struct lustre_handle *conn,struct obd_device *obd,
689 struct obd_uuid *cluuid,
690 struct obd_connect_data *d,
694 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */
697 OBD_CHECK_DEV_ACTIVE(obd);
698 OBD_CHECK_OP(obd, connect, -EOPNOTSUPP);
699 OBD_COUNTER_INCREMENT(obd, connect);
701 rc = OBP(obd, connect)(conn, obd, cluuid, d, localdata);
702 /* check that only subset is granted */
703 LASSERT(ergo(d != NULL,
704 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
708 static inline int obd_reconnect(struct obd_export *exp,
709 struct obd_device *obd,
710 struct obd_uuid *cluuid,
711 struct obd_connect_data *d,
715 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */
718 OBD_CHECK_DEV_ACTIVE(obd);
719 OBD_CHECK_OP(obd, reconnect, 0);
720 OBD_COUNTER_INCREMENT(obd, reconnect);
722 rc = OBP(obd, reconnect)(exp, obd, cluuid, d, localdata);
723 /* check that only subset is granted */
724 LASSERT(ergo(d != NULL,
725 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
729 static inline int obd_disconnect(struct obd_export *exp)
734 EXP_CHECK_OP(exp, disconnect);
735 EXP_COUNTER_INCREMENT(exp, disconnect);
737 rc = OBP(exp->exp_obd, disconnect)(exp);
741 static inline int obd_fid_init(struct obd_export *exp)
746 OBD_CHECK_OP(exp->exp_obd, fid_init, 0);
747 EXP_COUNTER_INCREMENT(exp, fid_init);
749 rc = OBP(exp->exp_obd, fid_init)(exp);
753 static inline int obd_fid_fini(struct obd_export *exp)
758 OBD_CHECK_OP(exp->exp_obd, fid_fini, 0);
759 EXP_COUNTER_INCREMENT(exp, fid_fini);
761 rc = OBP(exp->exp_obd, fid_fini)(exp);
765 static inline int obd_ping(struct obd_export *exp)
770 OBD_CHECK_OP(exp->exp_obd, ping, 0);
771 EXP_COUNTER_INCREMENT(exp, ping);
773 rc = OBP(exp->exp_obd, ping)(exp);
777 static inline int obd_pool_new(struct obd_device *obd, char *poolname)
782 OBD_CHECK_OP(obd, pool_new, -EOPNOTSUPP);
783 OBD_COUNTER_INCREMENT(obd, pool_new);
785 rc = OBP(obd, pool_new)(obd, poolname);
789 static inline int obd_pool_del(struct obd_device *obd, char *poolname)
794 OBD_CHECK_OP(obd, pool_del, -EOPNOTSUPP);
795 OBD_COUNTER_INCREMENT(obd, pool_del);
797 rc = OBP(obd, pool_del)(obd, poolname);
801 static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname)
806 OBD_CHECK_OP(obd, pool_add, -EOPNOTSUPP);
807 OBD_COUNTER_INCREMENT(obd, pool_add);
809 rc = OBP(obd, pool_add)(obd, poolname, ostname);
813 static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname)
818 OBD_CHECK_OP(obd, pool_rem, -EOPNOTSUPP);
819 OBD_COUNTER_INCREMENT(obd, pool_rem);
821 rc = OBP(obd, pool_rem)(obd, poolname, ostname);
825 static inline void obd_getref(struct obd_device *obd)
828 if (OBT(obd) && OBP(obd, getref)) {
829 OBD_COUNTER_INCREMENT(obd, getref);
830 OBP(obd, getref)(obd);
835 static inline void obd_putref(struct obd_device *obd)
838 if (OBT(obd) && OBP(obd, putref)) {
839 OBD_COUNTER_INCREMENT(obd, putref);
840 OBP(obd, putref)(obd);
845 static inline int obd_init_export(struct obd_export *exp)
850 if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
851 OBP((exp)->exp_obd, init_export))
852 rc = OBP(exp->exp_obd, init_export)(exp);
856 static inline int obd_destroy_export(struct obd_export *exp)
859 if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
860 OBP((exp)->exp_obd, destroy_export))
861 OBP(exp->exp_obd, destroy_export)(exp);
865 static inline int obd_extent_calc(struct obd_export *exp,
866 struct lov_stripe_md *md,
867 int cmd, obd_off *offset)
871 EXP_CHECK_OP(exp, extent_calc);
872 rc = OBP(exp->exp_obd, extent_calc)(exp, md, cmd, offset);
876 static inline struct dentry *
877 obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
879 LASSERT(exp->exp_obd);
881 return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr,
886 #define time_before(t1, t2) ((long)t2 - (long)t1 > 0)
889 /* @max_age is the oldest time in jiffies that we accept using a cached data.
890 * If the cache is older than @max_age we will get a new value from the
891 * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */
892 static inline int obd_statfs_async(struct obd_device *obd,
893 struct obd_info *oinfo,
895 struct ptlrpc_request_set *rqset)
903 OBD_CHECK_OP(obd, statfs, -EOPNOTSUPP);
904 OBD_COUNTER_INCREMENT(obd, statfs);
906 CDEBUG(D_SUPER, "%s: osfs %p age "LPU64", max_age "LPU64"\n",
907 obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
908 if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
909 rc = OBP(obd, statfs_async)(obd, oinfo, max_age, rqset);
911 CDEBUG(D_SUPER,"%s: use %p cache blocks "LPU64"/"LPU64
912 " objects "LPU64"/"LPU64"\n",
913 obd->obd_name, &obd->obd_osfs,
914 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
915 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
916 spin_lock(&obd->obd_osfs_lock);
917 memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs));
918 spin_unlock(&obd->obd_osfs_lock);
919 oinfo->oi_flags |= OBD_STATFS_FROM_CACHE;
921 oinfo->oi_cb_up(oinfo, 0);
926 static inline int obd_statfs_rqset(struct obd_device *obd,
927 struct obd_statfs *osfs, __u64 max_age,
930 struct ptlrpc_request_set *set = NULL;
931 struct obd_info oinfo = { { { 0 } } };
935 set = ptlrpc_prep_set();
939 oinfo.oi_osfs = osfs;
940 oinfo.oi_flags = flags;
941 rc = obd_statfs_async(obd, &oinfo, max_age, set);
943 rc = ptlrpc_set_wait(set);
944 ptlrpc_set_destroy(set);
948 /* @max_age is the oldest time in jiffies that we accept using a cached data.
949 * If the cache is older than @max_age we will get a new value from the
950 * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */
951 static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
952 __u64 max_age, __u32 flags)
960 OBD_CHECK_OP(obd, statfs, -EOPNOTSUPP);
961 OBD_COUNTER_INCREMENT(obd, statfs);
963 CDEBUG(D_SUPER, "osfs "LPU64", max_age "LPU64"\n",
964 obd->obd_osfs_age, max_age);
965 if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
966 rc = OBP(obd, statfs)(obd, osfs, max_age, flags);
968 spin_lock(&obd->obd_osfs_lock);
969 memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
970 obd->obd_osfs_age = cfs_time_current_64();
971 spin_unlock(&obd->obd_osfs_lock);
974 CDEBUG(D_SUPER,"%s: use %p cache blocks "LPU64"/"LPU64
975 " objects "LPU64"/"LPU64"\n",
976 obd->obd_name, &obd->obd_osfs,
977 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
978 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
979 spin_lock(&obd->obd_osfs_lock);
980 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
981 spin_unlock(&obd->obd_osfs_lock);
986 static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo,
987 obd_size start, obd_size end)
989 struct ptlrpc_request_set *set = NULL;
993 OBD_CHECK_OP(exp->exp_obd, sync, -EOPNOTSUPP);
994 EXP_COUNTER_INCREMENT(exp, sync);
996 set = ptlrpc_prep_set();
1000 rc = OBP(exp->exp_obd, sync)(exp, oinfo, start, end, set);
1002 rc = ptlrpc_set_wait(set);
1003 ptlrpc_set_destroy(set);
1007 static inline int obd_sync(struct obd_export *exp, struct obd_info *oinfo,
1008 obd_size start, obd_size end,
1009 struct ptlrpc_request_set *set)
1014 OBD_CHECK_OP(exp->exp_obd, sync, -EOPNOTSUPP);
1015 EXP_COUNTER_INCREMENT(exp, sync);
1017 rc = OBP(exp->exp_obd, sync)(exp, oinfo, start, end, set);
1021 static inline int obd_punch_rqset(struct obd_export *exp,
1022 struct obd_info *oinfo,
1023 struct obd_trans_info *oti)
1025 struct ptlrpc_request_set *set = NULL;
1029 EXP_CHECK_OP(exp, punch);
1030 EXP_COUNTER_INCREMENT(exp, punch);
1032 set = ptlrpc_prep_set();
1036 rc = OBP(exp->exp_obd, punch)(exp, oinfo, oti, set);
1038 rc = ptlrpc_set_wait(set);
1039 ptlrpc_set_destroy(set);
1043 static inline int obd_punch(struct obd_export *exp, struct obd_info *oinfo,
1044 struct obd_trans_info *oti,
1045 struct ptlrpc_request_set *rqset)
1050 EXP_CHECK_OP(exp, punch);
1051 EXP_COUNTER_INCREMENT(exp, punch);
1053 rc = OBP(exp->exp_obd, punch)(exp, oinfo, oti, rqset);
1057 static inline int obd_brw(int cmd, struct obd_export *exp,
1058 struct obd_info *oinfo, obd_count oa_bufs,
1059 struct brw_page *pg, struct obd_trans_info *oti)
1064 EXP_CHECK_OP(exp, brw);
1065 EXP_COUNTER_INCREMENT(exp, brw);
1067 if (!(cmd & (OBD_BRW_RWMASK | OBD_BRW_CHECK))) {
1068 CERROR("obd_brw: cmd must be OBD_BRW_READ, OBD_BRW_WRITE, "
1069 "or OBD_BRW_CHECK\n");
1073 rc = OBP(exp->exp_obd, brw)(cmd, exp, oinfo, oa_bufs, pg, oti);
1077 static inline int obd_brw_async(int cmd, struct obd_export *exp,
1078 struct obd_info *oinfo, obd_count oa_bufs,
1079 struct brw_page *pg, struct obd_trans_info *oti,
1080 struct ptlrpc_request_set *set, int pshift)
1085 EXP_CHECK_OP(exp, brw_async);
1086 EXP_COUNTER_INCREMENT(exp, brw_async);
1088 if (!(cmd & OBD_BRW_RWMASK)) {
1089 CERROR("obd_brw: cmd must be OBD_BRW_READ or OBD_BRW_WRITE\n");
1093 rc = OBP(exp->exp_obd, brw_async)(cmd, exp, oinfo, oa_bufs,
1094 pg, oti,set, pshift);
1098 static inline int obd_brw_rqset(int cmd, struct obd_export *exp,
1099 struct obdo *oa, struct lov_stripe_md *lsm,
1100 obd_count oa_bufs, struct brw_page *pg,
1101 struct obd_trans_info *oti)
1103 struct ptlrpc_request_set *set = NULL;
1104 struct obd_info oinfo = { { { 0 } } };
1108 set = ptlrpc_prep_set();
1114 rc = obd_brw_async(cmd, exp, &oinfo, oa_bufs, pg, oti, set, 0);
1116 rc = ptlrpc_set_wait(set);
1118 CERROR("error from callback: rc = %d\n", rc);
1120 CDEBUG(rc == -ENOSPC ? D_INODE : D_ERROR,
1121 "error from obd_brw_async: rc = %d\n", rc);
1123 ptlrpc_set_destroy(set);
1127 /* flags used by obd_prep_async_page */
1128 #define OBD_PAGE_NO_CACHE 0x00000001 /* don't add to cache */
1129 #define OBD_FAST_LOCK 0x00000002 /* lockh refers to a "fast lock" */
1131 static inline int obd_prep_async_page(struct obd_export *exp,
1132 struct lov_stripe_md *lsm,
1133 struct lov_oinfo *loi,
1134 cfs_page_t *page, obd_off offset,
1135 struct obd_async_page_ops *ops,
1136 void *data, void **res, int flags,
1137 struct lustre_handle *lockh)
1142 OBD_CHECK_OP(exp->exp_obd, prep_async_page, -EOPNOTSUPP);
1143 EXP_COUNTER_INCREMENT(exp, prep_async_page);
1145 ret = OBP(exp->exp_obd, prep_async_page)(exp, lsm, loi, page, offset,
1146 ops, data, res, flags,
1151 static inline int obd_get_lock(struct obd_export *exp,
1152 struct lov_stripe_md *lsm, void **res, int rw,
1153 obd_off start, obd_off end,
1154 struct lustre_handle *lockh, int flags)
1158 OBD_CHECK_OP(exp->exp_obd, get_lock, -EOPNOTSUPP);
1159 EXP_COUNTER_INCREMENT(exp, get_lock);
1161 RETURN(OBP(exp->exp_obd, get_lock)(exp, lsm, res, rw, start, end,
1165 static inline int obd_queue_async_io(struct obd_export *exp,
1166 struct lov_stripe_md *lsm,
1167 struct lov_oinfo *loi, void *cookie,
1168 int cmd, obd_off off, int count,
1169 obd_flag brw_flags, obd_flag async_flags)
1174 OBD_CHECK_OP(exp->exp_obd, queue_async_io, -EOPNOTSUPP);
1175 EXP_COUNTER_INCREMENT(exp, queue_async_io);
1176 LASSERT(cmd & OBD_BRW_RWMASK);
1178 rc = OBP(exp->exp_obd, queue_async_io)(exp, lsm, loi, cookie, cmd, off,
1179 count, brw_flags, async_flags);
1183 static inline int obd_set_async_flags(struct obd_export *exp,
1184 struct lov_stripe_md *lsm,
1185 struct lov_oinfo *loi, void *cookie,
1186 obd_flag async_flags)
1191 OBD_CHECK_OP(exp->exp_obd, set_async_flags, -EOPNOTSUPP);
1192 EXP_COUNTER_INCREMENT(exp, set_async_flags);
1194 rc = OBP(exp->exp_obd, set_async_flags)(exp, lsm, loi, cookie,
1199 static inline int obd_queue_group_io(struct obd_export *exp,
1200 struct lov_stripe_md *lsm,
1201 struct lov_oinfo *loi,
1202 struct obd_io_group *oig,
1203 void *cookie, int cmd, obd_off off,
1204 int count, obd_flag brw_flags,
1205 obd_flag async_flags)
1210 OBD_CHECK_OP(exp->exp_obd, queue_group_io, -EOPNOTSUPP);
1211 EXP_COUNTER_INCREMENT(exp, queue_group_io);
1212 LASSERT(cmd & OBD_BRW_RWMASK);
1214 rc = OBP(exp->exp_obd, queue_group_io)(exp, lsm, loi, oig, cookie,
1215 cmd, off, count, brw_flags,
1220 static inline int obd_trigger_group_io(struct obd_export *exp,
1221 struct lov_stripe_md *lsm,
1222 struct lov_oinfo *loi,
1223 struct obd_io_group *oig)
1228 OBD_CHECK_OP(exp->exp_obd, trigger_group_io, -EOPNOTSUPP);
1229 EXP_COUNTER_INCREMENT(exp, trigger_group_io);
1231 rc = OBP(exp->exp_obd, trigger_group_io)(exp, lsm, loi, oig);
1235 static inline int obd_teardown_async_page(struct obd_export *exp,
1236 struct lov_stripe_md *lsm,
1237 struct lov_oinfo *loi, void *cookie)
1242 OBD_CHECK_OP(exp->exp_obd, teardown_async_page, -EOPNOTSUPP);
1243 EXP_COUNTER_INCREMENT(exp, teardown_async_page);
1245 rc = OBP(exp->exp_obd, teardown_async_page)(exp, lsm, loi, cookie);
1249 static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
1250 int objcount, struct obd_ioobj *obj,
1251 struct niobuf_remote *remote, int *pages,
1252 struct niobuf_local *local,
1253 struct obd_trans_info *oti)
1258 OBD_CHECK_OP(exp->exp_obd, preprw, -EOPNOTSUPP);
1259 EXP_COUNTER_INCREMENT(exp, preprw);
1261 rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, remote,
1266 static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
1267 int objcount, struct obd_ioobj *obj,
1268 struct niobuf_remote *rnb, int pages,
1269 struct niobuf_local *local,
1270 struct obd_trans_info *oti, int rc)
1274 OBD_CHECK_OP(exp->exp_obd, commitrw, -EOPNOTSUPP);
1275 EXP_COUNTER_INCREMENT(exp, commitrw);
1277 rc = OBP(exp->exp_obd, commitrw)(cmd, exp, oa, objcount, obj,
1278 rnb, pages, local, oti, rc);
1282 static inline int obd_merge_lvb(struct obd_export *exp,
1283 struct lov_stripe_md *lsm,
1284 struct ost_lvb *lvb, int kms_only)
1289 OBD_CHECK_OP(exp->exp_obd, merge_lvb, -EOPNOTSUPP);
1290 EXP_COUNTER_INCREMENT(exp, merge_lvb);
1292 rc = OBP(exp->exp_obd, merge_lvb)(exp, lsm, lvb, kms_only);
1296 static inline int obd_update_lvb(struct obd_export *exp,
1297 struct lov_stripe_md *lsm,
1298 struct ost_lvb *lvb, obd_flag valid)
1303 OBD_CHECK_OP(exp->exp_obd, update_lvb, -EOPNOTSUPP);
1304 EXP_COUNTER_INCREMENT(exp, update_lvb);
1306 rc = OBP(exp->exp_obd, update_lvb)(exp, lsm, lvb, valid);
1310 static inline int obd_adjust_kms(struct obd_export *exp,
1311 struct lov_stripe_md *lsm, obd_off size,
1317 OBD_CHECK_OP(exp->exp_obd, adjust_kms, -EOPNOTSUPP);
1318 EXP_COUNTER_INCREMENT(exp, adjust_kms);
1320 rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink);
1324 static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
1325 int len, void *karg, void *uarg)
1330 EXP_CHECK_OP(exp, iocontrol);
1331 EXP_COUNTER_INCREMENT(exp, iocontrol);
1333 rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
1337 static inline int obd_enqueue_rqset(struct obd_export *exp,
1338 struct obd_info *oinfo,
1339 struct ldlm_enqueue_info *einfo)
1341 struct ptlrpc_request_set *set = NULL;
1345 EXP_CHECK_OP(exp, enqueue);
1346 EXP_COUNTER_INCREMENT(exp, enqueue);
1348 set = ptlrpc_prep_set();
1352 rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set);
1354 rc = ptlrpc_set_wait(set);
1355 ptlrpc_set_destroy(set);
1359 static inline int obd_enqueue(struct obd_export *exp,
1360 struct obd_info *oinfo,
1361 struct ldlm_enqueue_info *einfo,
1362 struct ptlrpc_request_set *set)
1367 EXP_CHECK_OP(exp, enqueue);
1368 EXP_COUNTER_INCREMENT(exp, enqueue);
1370 rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set);
1374 static inline int obd_match(struct obd_export *exp, struct lov_stripe_md *ea,
1375 __u32 type, ldlm_policy_data_t *policy, __u32 mode,
1376 int *flags, void *data, struct lustre_handle *lockh,
1382 EXP_CHECK_OP(exp, match);
1383 EXP_COUNTER_INCREMENT(exp, match);
1385 rc = OBP(exp->exp_obd, match)(exp, ea, type, policy, mode, flags, data,
1390 static inline int obd_change_cbdata(struct obd_export *exp,
1391 struct lov_stripe_md *lsm,
1392 ldlm_iterator_t it, void *data)
1397 EXP_CHECK_OP(exp, change_cbdata);
1398 EXP_COUNTER_INCREMENT(exp, change_cbdata);
1400 rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data);
1404 static inline int obd_cancel(struct obd_export *exp, struct lov_stripe_md *ea,
1405 __u32 mode, struct lustre_handle *lockh, int flags,
1411 EXP_CHECK_OP(exp, cancel);
1412 EXP_COUNTER_INCREMENT(exp, cancel);
1414 rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh, flags, end);
1418 static inline int obd_cancel_unused(struct obd_export *exp,
1419 struct lov_stripe_md *ea, int flags,
1425 EXP_CHECK_OP(exp, cancel_unused);
1426 EXP_COUNTER_INCREMENT(exp, cancel_unused);
1428 rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque);
1432 static inline int obd_join_lru(struct obd_export *exp,
1433 struct lov_stripe_md *ea, int join)
1438 EXP_CHECK_OP(exp, join_lru);
1439 EXP_COUNTER_INCREMENT(exp, join_lru);
1441 rc = OBP(exp->exp_obd, join_lru)(exp, ea, join);
1445 static inline int obd_pin(struct obd_export *exp, struct ll_fid *fid,
1446 struct obd_client_handle *handle, int flag)
1451 EXP_CHECK_OP(exp, pin);
1452 EXP_COUNTER_INCREMENT(exp, pin);
1454 rc = OBP(exp->exp_obd, pin)(exp, fid, handle, flag);
1458 static inline int obd_unpin(struct obd_export *exp,
1459 struct obd_client_handle *handle, int flag)
1464 EXP_CHECK_OP(exp, unpin);
1465 EXP_COUNTER_INCREMENT(exp, unpin);
1467 rc = OBP(exp->exp_obd, unpin)(exp, handle, flag);
1472 static inline void obd_import_event(struct obd_device *obd,
1473 struct obd_import *imp,
1474 enum obd_import_event event)
1478 CERROR("NULL device\n");
1482 if (obd->obd_set_up && OBP(obd, import_event)) {
1483 OBD_COUNTER_INCREMENT(obd, import_event);
1484 OBP(obd, import_event)(obd, imp, event);
1489 static inline int obd_notify(struct obd_device *obd,
1490 struct obd_device *watched,
1491 enum obd_notify_event ev, void *data)
1496 /* the check for async_recov is a complete hack - I'm hereby
1497 overloading the meaning to also mean "this was called from
1498 mds_postsetup". I know that my mds is able to handle notifies
1499 by this point, and it needs to get them to execute mds_postrecov. */
1500 if (!obd->obd_set_up && !obd->obd_async_recov) {
1501 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
1505 if (!OBP(obd, notify))
1508 OBD_COUNTER_INCREMENT(obd, notify);
1509 RETURN(OBP(obd, notify)(obd, watched, ev, data));
1512 static inline int obd_notify_observer(struct obd_device *observer,
1513 struct obd_device *observed,
1514 enum obd_notify_event ev, void *data)
1519 struct obd_notify_upcall *onu;
1521 if (observer->obd_observer)
1522 rc1 = obd_notify(observer->obd_observer, observed, ev, data);
1526 * Also, call non-obd listener, if any
1528 onu = &observer->obd_upcall;
1529 if (onu->onu_upcall != NULL)
1530 rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner);
1537 static inline int obd_quotacheck(struct obd_export *exp,
1538 struct obd_quotactl *oqctl)
1543 EXP_CHECK_OP(exp, quotacheck);
1544 EXP_COUNTER_INCREMENT(exp, quotacheck);
1546 rc = OBP(exp->exp_obd, quotacheck)(exp, oqctl);
1550 static inline int obd_quotactl(struct obd_export *exp,
1551 struct obd_quotactl *oqctl)
1556 EXP_CHECK_OP(exp, quotactl);
1557 EXP_COUNTER_INCREMENT(exp, quotactl);
1559 rc = OBP(exp->exp_obd, quotactl)(exp, oqctl);
1563 static inline int obd_quota_adjust_qunit(struct obd_export *exp,
1564 struct quota_adjust_qunit *oqaq,
1565 struct lustre_quota_ctxt *qctxt)
1567 #if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT)
1568 struct timeval work_start;
1569 struct timeval work_end;
1575 #if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT)
1577 do_gettimeofday(&work_start);
1579 EXP_CHECK_OP(exp, quota_adjust_qunit);
1580 EXP_COUNTER_INCREMENT(exp, quota_adjust_qunit);
1582 rc = OBP(exp->exp_obd, quota_adjust_qunit)(exp, oqaq, qctxt);
1584 #if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT)
1586 do_gettimeofday(&work_end);
1587 timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
1588 lprocfs_counter_add(qctxt->lqc_stats, LQUOTA_ADJUST_QUNIT,
1595 static inline int obd_health_check(struct obd_device *obd)
1597 /* returns: 0 on healthy
1598 * >0 on unhealthy + reason code/flag
1599 * however the only suppored reason == 1 right now
1600 * We'll need to define some better reasons
1601 * or flags in the future.
1607 /* don't use EXP_CHECK_OP, because NULL method is normal here */
1608 if (obd == NULL || !OBT(obd)) {
1609 CERROR("cleaned up obd\n");
1610 RETURN(-EOPNOTSUPP);
1612 if (!obd->obd_set_up || obd->obd_stopping)
1614 if (!OBP(obd, health_check))
1617 rc = OBP(obd, health_check)(obd);
1621 static inline int obd_register_observer(struct obd_device *obd,
1622 struct obd_device *observer)
1626 if (obd->obd_observer && observer)
1628 obd->obd_observer = observer;
1632 static inline int obd_register_page_removal_cb(struct obd_device *obd,
1633 obd_page_removal_cb_t cb,
1634 obd_pin_extent_cb pin_cb)
1639 OBD_CHECK_OP(obd, register_page_removal_cb, 0);
1640 OBD_COUNTER_INCREMENT(obd, register_page_removal_cb);
1642 rc = OBP(obd, register_page_removal_cb)(obd, cb, pin_cb);
1646 static inline int obd_unregister_page_removal_cb(struct obd_device *obd,
1647 obd_page_removal_cb_t cb)
1652 OBD_CHECK_OP(obd, unregister_page_removal_cb, 0);
1653 OBD_COUNTER_INCREMENT(obd, unregister_page_removal_cb);
1655 rc = OBP(obd, unregister_page_removal_cb)(obd, cb);
1659 static inline int obd_register_lock_cancel_cb(struct obd_device *obd,
1660 obd_lock_cancel_cb cb)
1665 OBD_CHECK_OP(obd, register_lock_cancel_cb, 0);
1666 OBD_COUNTER_INCREMENT(obd, register_lock_cancel_cb);
1668 rc = OBP(obd, register_lock_cancel_cb)(obd, cb);
1672 static inline int obd_unregister_lock_cancel_cb(struct obd_device *obd,
1673 obd_lock_cancel_cb cb)
1678 OBD_CHECK_OP(obd, unregister_lock_cancel_cb, 0);
1679 OBD_COUNTER_INCREMENT(obd, unregister_lock_cancel_cb);
1681 rc = OBP(obd, unregister_lock_cancel_cb)(obd, cb);
1685 /* OBD Metadata Support */
1687 extern int obd_init_caches(void);
1688 extern void obd_cleanup_caches(void);
1690 /* support routines */
1691 extern cfs_mem_cache_t *obdo_cachep;
1693 #define OBDO_ALLOC(ptr) \
1695 OBD_SLAB_ALLOC_PTR((ptr), obdo_cachep); \
1698 #define OBDO_FREE(ptr) \
1700 OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \
1703 /* I'm as embarrassed about this as you are.
1705 * <shaver> // XXX do not look into _superhack with remaining eye
1706 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
1707 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
1710 extern void obd_sysctl_init (void);
1711 extern void obd_sysctl_clean (void);
1714 typedef __u8 class_uuid_t[16];
1715 void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out);
1718 int lustre_uuid_to_peer(char *uuid, lnet_nid_t *peer_nid, int index);
1719 int class_add_uuid(char *uuid, __u64 nid);
1720 int class_del_uuid (char *uuid);
1721 void class_init_uuidlist(void);
1722 void class_exit_uuidlist(void);
1725 void ll_generate_random_uuid(class_uuid_t uuid_out);
1727 #endif /* __LINUX_OBD_CLASS_H */