4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
40 # include <liblustre.h>
43 #include <obd_support.h>
44 #include <lustre_import.h>
45 #include <lustre_net.h>
47 #include <lustre_lib.h>
48 #include <lustre/lustre_idl.h>
49 #include <lprocfs_status.h>
51 #if defined(__linux__)
52 #include <linux/obd_class.h>
53 #elif defined(__APPLE__)
54 #include <darwin/obd_class.h>
55 #elif defined(__WINNT__)
56 #include <winnt/obd_class.h>
58 #error Unsupported operating system.
61 #define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay
62 * and resends for avoid deadlocks */
63 #define OBD_STATFS_FROM_CACHE 0x0002 /* the statfs callback should not update
65 #define OBD_STATFS_PTLRPCD 0x0004 /* requests will be sent via ptlrpcd
66 * instead of a specific set. This
67 * means that we cannot rely on the set
68 * interpret routine to be called.
69 * lov_statfs_fini() must thus be called
70 * by the request interpret routine */
71 #define OBD_STATFS_FOR_MDT0 0x0008 /* The statfs is only for retrieving
72 * information from MDT0. */
73 #define OBD_FL_PUNCH 0x00000001 /* To indicate it is punch operation */
75 /* OBD Device Declarations */
76 extern struct obd_device *obd_devs[MAX_OBD_DEVICES];
77 extern rwlock_t obd_dev_lock;
79 /* OBD Operations Declarations */
80 extern struct obd_device *class_conn2obd(struct lustre_handle *);
81 extern struct obd_device *class_exp2obd(struct obd_export *);
82 extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
83 extern int lustre_get_jobid(char *jobid);
85 struct lu_device_type;
88 struct obd_export *class_conn2export(struct lustre_handle *);
89 int class_register_type(struct obd_ops *, struct md_ops *,
90 struct lprocfs_vars *, const char *nm,
91 struct lu_device_type *ldt);
92 int class_unregister_type(const char *nm);
94 struct obd_device *class_newdev(const char *type_name, const char *name);
95 void class_release_dev(struct obd_device *obd);
97 int class_name2dev(const char *name);
98 struct obd_device *class_name2obd(const char *name);
99 int class_uuid2dev(struct obd_uuid *uuid);
100 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
101 void class_obd_list(void);
102 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
103 const char * typ_name,
104 struct obd_uuid *grp_uuid);
105 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
107 struct obd_device * class_num2obd(int num);
108 int get_devices_count(void);
110 int class_notify_sptlrpc_conf(const char *fsname, int namelen);
112 char *obd_export_nid2str(struct obd_export *exp);
114 int obd_export_evict_by_nid(struct obd_device *obd, const char *nid);
115 int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid);
116 int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep);
118 int obd_zombie_impexp_init(void);
119 void obd_zombie_impexp_stop(void);
120 void obd_zombie_impexp_cull(void);
121 void obd_zombie_barrier(void);
122 void obd_exports_barrier(struct obd_device *obd);
123 int kuc_len(int payload_len);
124 struct kuc_hdr * kuc_ptr(void *p);
125 int kuc_ispayload(void *p);
126 void *kuc_alloc(int payload_len, int transport, int type);
127 void kuc_free(void *p, int payload_len);
131 typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
132 struct llog_rec_hdr *, void *);
134 struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
135 const char *new_name);
136 int class_process_config(struct lustre_cfg *lcfg);
137 int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
138 struct lustre_cfg *lcfg, void *data);
139 int class_attach(struct lustre_cfg *lcfg);
140 int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
141 int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
142 int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
143 struct obd_device *class_incref(struct obd_device *obd,
144 const char *scope, const void *source);
145 void class_decref(struct obd_device *obd,
146 const char *scope, const void *source);
147 void dump_exports(struct obd_device *obd, int locks);
148 int class_config_llog_handler(const struct lu_env *env,
149 struct llog_handle *handle,
150 struct llog_rec_hdr *rec, void *data);
151 int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
152 int class_add_uuid(const char *uuid, __u64 nid);
156 extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);
158 static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
160 memset(lvars, 0, sizeof(*lvars));
164 #define CFG_F_START 0x01 /* Set when we start updating from a log */
165 #define CFG_F_MARKER 0x02 /* We are within a maker */
166 #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */
167 #define CFG_F_COMPAT146 0x08 /* Allow old-style logs */
168 #define CFG_F_EXCLUDE 0x10 /* OST exclusion list */
170 /* Passed as data param to class_config_parse_llog */
171 struct config_llog_instance {
174 struct super_block *cfg_sb;
175 struct obd_uuid cfg_uuid;
176 llog_cb_t cfg_callback;
177 int cfg_last_idx; /* for partial llog processing */
180 int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
181 char *name, struct config_llog_instance *cfg);
182 int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
183 char *name, struct config_llog_instance *cfg);
187 CONFIG_T_SPTLRPC = 1,
188 CONFIG_T_RECOVER = 2,
192 /* list of active configuration logs */
193 struct config_llog_data {
194 struct ldlm_res_id cld_resid;
195 struct config_llog_instance cld_cfg;
196 cfs_list_t cld_list_chain;
197 cfs_atomic_t cld_refcount;
198 struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */
199 struct config_llog_data *cld_recover; /* imperative recover log */
200 struct obd_export *cld_mgcexp;
201 struct mutex cld_lock;
203 unsigned int cld_stopping:1, /* we were told to stop
205 cld_lostlock:1; /* lock not requeued */
209 struct lustre_profile {
216 struct lustre_profile *class_get_profile(const char * prof);
217 void class_del_profile(const char *prof);
218 void class_del_profiles(void);
220 #if LUSTRE_TRACKS_LOCK_EXP_REFS
222 void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *);
223 void __class_export_del_lock_ref(struct obd_export *, struct ldlm_lock *);
224 extern void (*class_export_dump_hook)(struct obd_export *);
228 #define __class_export_add_lock_ref(exp, lock) do {} while(0)
229 #define __class_export_del_lock_ref(exp, lock) do {} while(0)
233 #define class_export_rpc_get(exp) \
235 cfs_atomic_inc(&(exp)->exp_rpc_count); \
236 CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \
237 (exp), cfs_atomic_read(&(exp)->exp_rpc_count)); \
238 class_export_get(exp); \
241 #define class_export_rpc_put(exp) \
243 LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \
244 cfs_atomic_dec(&(exp)->exp_rpc_count); \
245 CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \
246 (exp), cfs_atomic_read(&(exp)->exp_rpc_count)); \
247 class_export_put(exp); \
250 #define class_export_lock_get(exp, lock) \
252 cfs_atomic_inc(&(exp)->exp_locks_count); \
253 __class_export_add_lock_ref(exp, lock); \
254 CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \
255 (exp), cfs_atomic_read(&(exp)->exp_locks_count)); \
256 class_export_get(exp); \
259 #define class_export_lock_put(exp, lock) \
261 LASSERT_ATOMIC_POS(&exp->exp_locks_count); \
262 cfs_atomic_dec(&(exp)->exp_locks_count); \
263 __class_export_del_lock_ref(exp, lock); \
264 CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \
265 (exp), cfs_atomic_read(&(exp)->exp_locks_count)); \
266 class_export_put(exp); \
269 #define class_export_cb_get(exp) \
271 cfs_atomic_inc(&(exp)->exp_cb_count); \
272 CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\
273 (exp), cfs_atomic_read(&(exp)->exp_cb_count)); \
274 class_export_get(exp); \
277 #define class_export_cb_put(exp) \
279 LASSERT_ATOMIC_POS(&exp->exp_cb_count); \
280 cfs_atomic_dec(&(exp)->exp_cb_count); \
281 CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\
282 (exp), cfs_atomic_read(&(exp)->exp_cb_count)); \
283 class_export_put(exp); \
287 struct obd_export *class_export_get(struct obd_export *exp);
288 void class_export_put(struct obd_export *exp);
289 struct obd_export *class_new_export(struct obd_device *obddev,
290 struct obd_uuid *cluuid);
291 void class_unlink_export(struct obd_export *exp);
293 struct obd_import *class_import_get(struct obd_import *);
294 void class_import_put(struct obd_import *);
295 struct obd_import *class_new_import(struct obd_device *obd);
296 void class_destroy_import(struct obd_import *exp);
298 struct obd_type *class_search_type(const char *name);
299 struct obd_type *class_get_type(const char *name);
300 void class_put_type(struct obd_type *type);
301 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
302 struct obd_uuid *cluuid);
303 int class_disconnect(struct obd_export *exp);
304 void class_fail_export(struct obd_export *exp);
305 int class_connected_export(struct obd_export *exp);
306 void class_disconnect_exports(struct obd_device *obddev);
307 int class_manual_cleanup(struct obd_device *obd);
308 void class_disconnect_stale_exports(struct obd_device *,
309 int (*test_export)(struct obd_export *));
310 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
312 return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
313 (obd->obd_force ? OBD_OPT_FORCE : 0) |
314 (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) |
318 #ifdef HAVE_SERVER_SUPPORT
319 static inline struct lu_target *class_exp2tgt(struct obd_export *exp)
321 LASSERT(exp->exp_obd);
322 return exp->exp_obd->u.obt.obt_lut;
325 static inline struct lr_server_data *class_server_data(struct obd_device *obd)
327 LASSERT(obd->u.obt.obt_lut);
328 return &obd->u.obt.obt_lut->lut_lsd;
332 void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid);
333 void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj);
334 void obdo_from_iattr(struct obdo *oa, struct iattr *attr,
335 unsigned int ia_valid);
336 void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid);
337 void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, obd_flag valid);
338 void obdo_from_md(struct obdo *oa, struct md_op_data *op_data,
341 #define OBT(dev) (dev)->obd_type
342 #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op
343 #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op
344 #define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op
346 /* Ensure obd_setup: used for cleanup which must be called
347 while obd is stopping */
348 #define OBD_CHECK_DEV(obd) \
351 CERROR("NULL device\n"); \
356 /* ensure obd_setup and !obd_stopping */
357 #define OBD_CHECK_DEV_ACTIVE(obd) \
359 OBD_CHECK_DEV(obd); \
360 if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
361 CERROR("Device %d not setup\n", \
369 #define OBD_COUNTER_OFFSET(op) \
370 ((offsetof(struct obd_ops, o_ ## op) - \
371 offsetof(struct obd_ops, o_iocontrol)) \
372 / sizeof(((struct obd_ops *)(0))->o_iocontrol))
374 #define OBD_COUNTER_INCREMENT(obdx, op) \
375 if ((obdx)->obd_stats != NULL) { \
376 unsigned int coffset; \
377 coffset = (unsigned int)((obdx)->obd_cntr_base) + \
378 OBD_COUNTER_OFFSET(op); \
379 LASSERT(coffset < (obdx)->obd_stats->ls_num); \
380 lprocfs_counter_incr((obdx)->obd_stats, coffset); \
383 #define EXP_COUNTER_INCREMENT(export, op) \
384 if ((export)->exp_obd->obd_stats != NULL) { \
385 unsigned int coffset; \
386 coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \
387 OBD_COUNTER_OFFSET(op); \
388 LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \
389 lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \
390 if ((export)->exp_nid_stats != NULL && \
391 (export)->exp_nid_stats->nid_stats != NULL) \
392 lprocfs_counter_incr( \
393 (export)->exp_nid_stats->nid_stats, coffset);\
396 #define MD_COUNTER_OFFSET(op) \
397 ((offsetof(struct md_ops, m_ ## op) - \
398 offsetof(struct md_ops, m_getstatus)) \
399 / sizeof(((struct md_ops *)(0))->m_getstatus))
401 #define MD_COUNTER_INCREMENT(obdx, op) \
402 if ((obd)->md_stats != NULL) { \
403 unsigned int coffset; \
404 coffset = (unsigned int)((obdx)->md_cntr_base) + \
405 MD_COUNTER_OFFSET(op); \
406 LASSERT(coffset < (obdx)->md_stats->ls_num); \
407 lprocfs_counter_incr((obdx)->md_stats, coffset); \
410 #define EXP_MD_COUNTER_INCREMENT(export, op) \
411 if ((export)->exp_obd->obd_stats != NULL) { \
412 unsigned int coffset; \
413 coffset = (unsigned int)((export)->exp_obd->md_cntr_base) + \
414 MD_COUNTER_OFFSET(op); \
415 LASSERT(coffset < (export)->exp_obd->md_stats->ls_num); \
416 lprocfs_counter_incr((export)->exp_obd->md_stats, coffset); \
417 if ((export)->exp_md_stats != NULL) \
418 lprocfs_counter_incr( \
419 (export)->exp_md_stats, coffset); \
423 #define OBD_COUNTER_OFFSET(op)
424 #define OBD_COUNTER_INCREMENT(obd, op)
425 #define EXP_COUNTER_INCREMENT(exp, op)
426 #define MD_COUNTER_INCREMENT(obd, op)
427 #define EXP_MD_COUNTER_INCREMENT(exp, op)
430 static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp)
432 /* Always add in ldlm_stats */
433 tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC
434 ,LPROCFS_STATS_FLAG_NOPERCPU);
435 if (tmp->nid_ldlm_stats == NULL)
438 lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
440 return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats",
441 tmp->nid_ldlm_stats);
444 #define OBD_CHECK_MD_OP(obd, op, err) \
446 if (!OBT(obd) || !MDP((obd), op)) { \
448 CERROR("md_" #op ": dev %s/%d no operation\n", \
449 obd->obd_name, obd->obd_minor); \
454 #define EXP_CHECK_MD_OP(exp, op) \
456 if ((exp) == NULL) { \
457 CERROR("obd_" #op ": NULL export\n"); \
460 if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \
461 CERROR("obd_" #op ": cleaned up obd\n"); \
462 RETURN(-EOPNOTSUPP); \
464 if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \
465 CERROR("obd_" #op ": dev %s/%d no operation\n", \
466 (exp)->exp_obd->obd_name, \
467 (exp)->exp_obd->obd_minor); \
468 RETURN(-EOPNOTSUPP); \
473 #define OBD_CHECK_DT_OP(obd, op, err) \
475 if (!OBT(obd) || !OBP((obd), op)) { \
477 CERROR("obd_" #op ": dev %d no operation\n", \
483 #define EXP_CHECK_DT_OP(exp, op) \
485 if ((exp) == NULL) { \
486 CERROR("obd_" #op ": NULL export\n"); \
489 if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \
490 CERROR("obd_" #op ": cleaned up obd\n"); \
491 RETURN(-EOPNOTSUPP); \
493 if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \
494 CERROR("obd_" #op ": dev %d no operation\n", \
495 (exp)->exp_obd->obd_minor); \
496 RETURN(-EOPNOTSUPP); \
500 #define CTXT_CHECK_OP(ctxt, op, err) \
502 if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \
504 CERROR("lop_" #op ": dev %d no operation\n", \
505 ctxt->loc_obd->obd_minor); \
510 static inline int class_devno_max(void)
512 return MAX_OBD_DEVICES;
515 static inline int obd_get_info(const struct lu_env *env,
516 struct obd_export *exp, __u32 keylen,
517 void *key, __u32 *vallen, void *val,
518 struct lov_stripe_md *lsm)
523 EXP_CHECK_DT_OP(exp, get_info);
524 EXP_COUNTER_INCREMENT(exp, get_info);
526 rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val,
531 static inline int obd_set_info_async(const struct lu_env *env,
532 struct obd_export *exp, obd_count keylen,
533 void *key, obd_count vallen, void *val,
534 struct ptlrpc_request_set *set)
539 EXP_CHECK_DT_OP(exp, set_info_async);
540 EXP_COUNTER_INCREMENT(exp, set_info_async);
542 rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen,
548 * obd-lu integration.
550 * Functionality is being moved into new lu_device-based layering, but some
551 * pieces of configuration process are still based on obd devices.
553 * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully
554 * subsume ->o_setup() methods of obd devices they replace. The same for
555 * lu_device_operations::ldo_process_config() and ->o_process_config(). As a
556 * result, obd_setup() and obd_process_config() branch and call one XOR
559 * Yet neither lu_device_type_operations::ldto_device_fini() nor
560 * lu_device_type_operations::ldto_device_free() fully implement the
561 * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence,
562 * obd_precleanup() and obd_cleanup() call both lu_device and obd operations.
565 #define DECLARE_LU_VARS(ldt, d) \
566 struct lu_device_type *ldt; \
569 static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
572 DECLARE_LU_VARS(ldt, d);
575 ldt = obd->obd_type->typ_lu;
577 struct lu_context session_ctx;
579 lu_context_init(&session_ctx, LCT_SESSION);
580 session_ctx.lc_thread = NULL;
581 lu_context_enter(&session_ctx);
583 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
585 env.le_ses = &session_ctx;
586 d = ldt->ldt_ops->ldto_device_alloc(&env, ldt, cfg);
595 lu_context_exit(&session_ctx);
596 lu_context_fini(&session_ctx);
599 OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP);
600 OBD_COUNTER_INCREMENT(obd, setup);
601 rc = OBP(obd, setup)(obd, cfg);
606 static inline int obd_precleanup(struct obd_device *obd,
607 enum obd_cleanup_stage cleanup_stage)
610 DECLARE_LU_VARS(ldt, d);
614 ldt = obd->obd_type->typ_lu;
616 if (ldt != NULL && d != NULL) {
617 if (cleanup_stage == OBD_CLEANUP_EXPORTS) {
620 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
622 ldt->ldt_ops->ldto_device_fini(&env, d);
627 OBD_CHECK_DT_OP(obd, precleanup, 0);
628 OBD_COUNTER_INCREMENT(obd, precleanup);
630 rc = OBP(obd, precleanup)(obd, cleanup_stage);
634 static inline int obd_cleanup(struct obd_device *obd)
637 DECLARE_LU_VARS(ldt, d);
642 ldt = obd->obd_type->typ_lu;
644 if (ldt != NULL && d != NULL) {
647 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
649 ldt->ldt_ops->ldto_device_free(&env, d);
651 obd->obd_lu_dev = NULL;
654 OBD_CHECK_DT_OP(obd, cleanup, 0);
655 OBD_COUNTER_INCREMENT(obd, cleanup);
657 rc = OBP(obd, cleanup)(obd);
661 static inline void obd_cleanup_client_import(struct obd_device *obd)
665 /* If we set up but never connected, the
666 client import will not have been cleaned. */
667 down_write(&obd->u.cli.cl_sem);
668 if (obd->u.cli.cl_import) {
669 struct obd_import *imp;
670 imp = obd->u.cli.cl_import;
671 CDEBUG(D_CONFIG, "%s: client import never connected\n",
673 ptlrpc_invalidate_import(imp);
674 if (imp->imp_rq_pool) {
675 ptlrpc_free_rq_pool(imp->imp_rq_pool);
676 imp->imp_rq_pool = NULL;
678 client_destroy_import(imp);
679 obd->u.cli.cl_import = NULL;
681 up_write(&obd->u.cli.cl_sem);
687 obd_process_config(struct obd_device *obd, int datalen, void *data)
690 DECLARE_LU_VARS(ldt, d);
695 obd->obd_process_conf = 1;
696 ldt = obd->obd_type->typ_lu;
698 if (ldt != NULL && d != NULL) {
701 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
703 rc = d->ld_ops->ldo_process_config(&env, d, data);
707 OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP);
708 rc = OBP(obd, process_config)(obd, datalen, data);
710 OBD_COUNTER_INCREMENT(obd, process_config);
711 obd->obd_process_conf = 0;
716 /* Pack an in-memory MD struct for storage on disk.
717 * Returns +ve size of packed MD (0 for free), or -ve error.
719 * If @disk_tgt == NULL, MD size is returned (max size if @mem_src == NULL).
720 * If @*disk_tgt != NULL and @mem_src == NULL, @*disk_tgt will be freed.
721 * If @*disk_tgt == NULL, it will be allocated
723 static inline int obd_packmd(struct obd_export *exp,
724 struct lov_mds_md **disk_tgt,
725 struct lov_stripe_md *mem_src)
730 EXP_CHECK_DT_OP(exp, packmd);
731 EXP_COUNTER_INCREMENT(exp, packmd);
733 rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src);
737 static inline int obd_size_diskmd(struct obd_export *exp,
738 struct lov_stripe_md *mem_src)
740 return obd_packmd(exp, NULL, mem_src);
743 /* helper functions */
744 static inline int obd_alloc_diskmd(struct obd_export *exp,
745 struct lov_mds_md **disk_tgt)
748 LASSERT(*disk_tgt == NULL);
749 return obd_packmd(exp, disk_tgt, NULL);
752 static inline int obd_free_diskmd(struct obd_export *exp,
753 struct lov_mds_md **disk_tgt)
757 return obd_packmd(exp, disk_tgt, NULL);
760 /* Unpack an MD struct from disk to in-memory format.
761 * Returns +ve size of unpacked MD (0 for free), or -ve error.
763 * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL).
764 * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed.
765 * If @*mem_tgt == NULL, it will be allocated
767 static inline int obd_unpackmd(struct obd_export *exp,
768 struct lov_stripe_md **mem_tgt,
769 struct lov_mds_md *disk_src,
775 EXP_CHECK_DT_OP(exp, unpackmd);
776 EXP_COUNTER_INCREMENT(exp, unpackmd);
778 rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len);
782 /* helper functions */
783 static inline int obd_alloc_memmd(struct obd_export *exp,
784 struct lov_stripe_md **mem_tgt)
787 LASSERT(*mem_tgt == NULL);
788 return obd_unpackmd(exp, mem_tgt, NULL, 0);
791 static inline int obd_free_memmd(struct obd_export *exp,
792 struct lov_stripe_md **mem_tgt)
798 rc = obd_unpackmd(exp, mem_tgt, NULL, 0);
803 static inline int obd_precreate(struct obd_export *exp)
808 EXP_CHECK_DT_OP(exp, precreate);
809 OBD_COUNTER_INCREMENT(exp->exp_obd, precreate);
811 rc = OBP(exp->exp_obd, precreate)(exp);
815 static inline int obd_create_async(struct obd_export *exp,
816 struct obd_info *oinfo,
817 struct lov_stripe_md **ea,
818 struct obd_trans_info *oti)
823 EXP_CHECK_DT_OP(exp, create_async);
824 EXP_COUNTER_INCREMENT(exp, create_async);
826 rc = OBP(exp->exp_obd, create_async)(exp, oinfo, ea, oti);
830 static inline int obd_create(const struct lu_env *env, struct obd_export *exp,
831 struct obdo *obdo, struct lov_stripe_md **ea,
832 struct obd_trans_info *oti)
837 EXP_CHECK_DT_OP(exp, create);
838 EXP_COUNTER_INCREMENT(exp, create);
840 rc = OBP(exp->exp_obd, create)(env, exp, obdo, ea, oti);
844 static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp,
845 struct obdo *obdo, struct lov_stripe_md *ea,
846 struct obd_trans_info *oti,
847 struct obd_export *md_exp, void *capa)
852 EXP_CHECK_DT_OP(exp, destroy);
853 EXP_COUNTER_INCREMENT(exp, destroy);
855 rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp, capa);
859 static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp,
860 struct obd_info *oinfo)
865 EXP_CHECK_DT_OP(exp, getattr);
866 EXP_COUNTER_INCREMENT(exp, getattr);
868 rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo);
872 static inline int obd_getattr_async(struct obd_export *exp,
873 struct obd_info *oinfo,
874 struct ptlrpc_request_set *set)
879 EXP_CHECK_DT_OP(exp, getattr_async);
880 EXP_COUNTER_INCREMENT(exp, getattr_async);
882 rc = OBP(exp->exp_obd, getattr_async)(exp, oinfo, set);
886 static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp,
887 struct obd_info *oinfo,
888 struct obd_trans_info *oti)
893 EXP_CHECK_DT_OP(exp, setattr);
894 EXP_COUNTER_INCREMENT(exp, setattr);
896 rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo, oti);
900 /* This performs all the requests set init/wait/destroy actions. */
901 static inline int obd_setattr_rqset(struct obd_export *exp,
902 struct obd_info *oinfo,
903 struct obd_trans_info *oti)
905 struct ptlrpc_request_set *set = NULL;
909 EXP_CHECK_DT_OP(exp, setattr_async);
910 EXP_COUNTER_INCREMENT(exp, setattr_async);
912 set = ptlrpc_prep_set();
916 rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set);
918 rc = ptlrpc_set_wait(set);
919 ptlrpc_set_destroy(set);
923 /* This adds all the requests into @set if @set != NULL, otherwise
924 all requests are sent asynchronously without waiting for response. */
925 static inline int obd_setattr_async(struct obd_export *exp,
926 struct obd_info *oinfo,
927 struct obd_trans_info *oti,
928 struct ptlrpc_request_set *set)
933 EXP_CHECK_DT_OP(exp, setattr_async);
934 EXP_COUNTER_INCREMENT(exp, setattr_async);
936 rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set);
940 static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
943 struct obd_device *obd = imp->imp_obd;
947 OBD_CHECK_DEV_ACTIVE(obd);
948 OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP);
949 OBD_COUNTER_INCREMENT(obd, add_conn);
951 rc = OBP(obd, add_conn)(imp, uuid, priority);
955 static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
957 struct obd_device *obd = imp->imp_obd;
961 OBD_CHECK_DEV_ACTIVE(obd);
962 OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP);
963 OBD_COUNTER_INCREMENT(obd, del_conn);
965 rc = OBP(obd, del_conn)(imp, uuid);
969 static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp)
971 struct obd_uuid *uuid;
974 OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL);
975 EXP_COUNTER_INCREMENT(exp, get_uuid);
977 uuid = OBP(exp->exp_obd, get_uuid)(exp);
981 /** Create a new /a exp on device /a obd for the uuid /a cluuid
982 * @param exp New export handle
983 * @param d Connect data, supported flags are set, flags also understood
984 * by obd are returned.
986 static inline int obd_connect(const struct lu_env *env,
987 struct obd_export **exp,struct obd_device *obd,
988 struct obd_uuid *cluuid,
989 struct obd_connect_data *data,
993 __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition
997 OBD_CHECK_DEV_ACTIVE(obd);
998 OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP);
999 OBD_COUNTER_INCREMENT(obd, connect);
1001 rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata);
1002 /* check that only subset is granted */
1003 LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) ==
1004 data->ocd_connect_flags));
1008 static inline int obd_reconnect(const struct lu_env *env,
1009 struct obd_export *exp,
1010 struct obd_device *obd,
1011 struct obd_uuid *cluuid,
1012 struct obd_connect_data *d,
1016 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition
1021 OBD_CHECK_DEV_ACTIVE(obd);
1022 OBD_CHECK_DT_OP(obd, reconnect, 0);
1023 OBD_COUNTER_INCREMENT(obd, reconnect);
1025 rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata);
1026 /* check that only subset is granted */
1027 LASSERT(ergo(d != NULL,
1028 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
1032 static inline int obd_disconnect(struct obd_export *exp)
1037 EXP_CHECK_DT_OP(exp, disconnect);
1038 EXP_COUNTER_INCREMENT(exp, disconnect);
1040 rc = OBP(exp->exp_obd, disconnect)(exp);
1044 static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp,
1045 enum lu_cli_type type)
1050 OBD_CHECK_DT_OP(obd, fid_init, 0);
1051 OBD_COUNTER_INCREMENT(obd, fid_init);
1053 rc = OBP(obd, fid_init)(obd, exp, type);
1057 static inline int obd_fid_fini(struct obd_device *obd)
1062 OBD_CHECK_DT_OP(obd, fid_fini, 0);
1063 OBD_COUNTER_INCREMENT(obd, fid_fini);
1065 rc = OBP(obd, fid_fini)(obd);
1069 static inline int obd_fid_alloc(struct obd_export *exp,
1071 struct md_op_data *op_data)
1076 EXP_CHECK_DT_OP(exp, fid_alloc);
1077 EXP_COUNTER_INCREMENT(exp, fid_alloc);
1079 rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, op_data);
1083 static inline int obd_ping(const struct lu_env *env, struct obd_export *exp)
1088 OBD_CHECK_DT_OP(exp->exp_obd, ping, 0);
1089 EXP_COUNTER_INCREMENT(exp, ping);
1091 rc = OBP(exp->exp_obd, ping)(env, exp);
1095 static inline int obd_pool_new(struct obd_device *obd, char *poolname)
1100 OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP);
1101 OBD_COUNTER_INCREMENT(obd, pool_new);
1103 rc = OBP(obd, pool_new)(obd, poolname);
1107 static inline int obd_pool_del(struct obd_device *obd, char *poolname)
1112 OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP);
1113 OBD_COUNTER_INCREMENT(obd, pool_del);
1115 rc = OBP(obd, pool_del)(obd, poolname);
1119 static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname)
1124 OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP);
1125 OBD_COUNTER_INCREMENT(obd, pool_add);
1127 rc = OBP(obd, pool_add)(obd, poolname, ostname);
1131 static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname)
1136 OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP);
1137 OBD_COUNTER_INCREMENT(obd, pool_rem);
1139 rc = OBP(obd, pool_rem)(obd, poolname, ostname);
1143 static inline void obd_getref(struct obd_device *obd)
1146 if (OBT(obd) && OBP(obd, getref)) {
1147 OBD_COUNTER_INCREMENT(obd, getref);
1148 OBP(obd, getref)(obd);
1153 static inline void obd_putref(struct obd_device *obd)
1156 if (OBT(obd) && OBP(obd, putref)) {
1157 OBD_COUNTER_INCREMENT(obd, putref);
1158 OBP(obd, putref)(obd);
1163 static inline int obd_init_export(struct obd_export *exp)
1168 if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
1169 OBP((exp)->exp_obd, init_export))
1170 rc = OBP(exp->exp_obd, init_export)(exp);
1174 static inline int obd_destroy_export(struct obd_export *exp)
1177 if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) &&
1178 OBP((exp)->exp_obd, destroy_export))
1179 OBP(exp->exp_obd, destroy_export)(exp);
1183 static inline int obd_extent_calc(struct obd_export *exp,
1184 struct lov_stripe_md *md,
1185 int cmd, obd_off *offset)
1189 EXP_CHECK_DT_OP(exp, extent_calc);
1190 rc = OBP(exp->exp_obd, extent_calc)(exp, md, cmd, offset);
1194 static inline struct dentry *
1195 obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr)
1197 LASSERT(exp->exp_obd);
1199 return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr,
1204 obd_lvfs_open_llog(struct obd_export *exp, __u64 id_ino, struct dentry *dentry)
1206 LASSERT(exp->exp_obd);
1207 CERROR("FIXME what's the story here? This needs to be an obd fn?\n");
1209 return lvfs_open_llog(&exp->exp_obd->obd_lvfs_ctxt, id_ino,
1210 dentry, exp->exp_obd);
1215 /* @max_age is the oldest time in jiffies that we accept using a cached data.
1216 * If the cache is older than @max_age we will get a new value from the
1217 * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */
1218 static inline int obd_statfs_async(struct obd_export *exp,
1219 struct obd_info *oinfo,
1221 struct ptlrpc_request_set *rqset)
1224 struct obd_device *obd;
1227 if (exp == NULL || exp->exp_obd == NULL)
1231 OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP);
1232 OBD_COUNTER_INCREMENT(obd, statfs);
1234 CDEBUG(D_SUPER, "%s: osfs %p age "LPU64", max_age "LPU64"\n",
1235 obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
1236 if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
1237 rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
1239 CDEBUG(D_SUPER,"%s: use %p cache blocks "LPU64"/"LPU64
1240 " objects "LPU64"/"LPU64"\n",
1241 obd->obd_name, &obd->obd_osfs,
1242 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1243 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1244 spin_lock(&obd->obd_osfs_lock);
1245 memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs));
1246 spin_unlock(&obd->obd_osfs_lock);
1247 oinfo->oi_flags |= OBD_STATFS_FROM_CACHE;
1248 if (oinfo->oi_cb_up)
1249 oinfo->oi_cb_up(oinfo, 0);
1254 static inline int obd_statfs_rqset(struct obd_export *exp,
1255 struct obd_statfs *osfs, __u64 max_age,
1258 struct ptlrpc_request_set *set = NULL;
1259 struct obd_info oinfo = { { { 0 } } };
1263 set = ptlrpc_prep_set();
1267 oinfo.oi_osfs = osfs;
1268 oinfo.oi_flags = flags;
1269 rc = obd_statfs_async(exp, &oinfo, max_age, set);
1271 rc = ptlrpc_set_wait(set);
1272 ptlrpc_set_destroy(set);
1276 /* @max_age is the oldest time in jiffies that we accept using a cached data.
1277 * If the cache is older than @max_age we will get a new value from the
1278 * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */
1279 static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
1280 struct obd_statfs *osfs, __u64 max_age,
1284 struct obd_device *obd = exp->exp_obd;
1290 OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP);
1291 OBD_COUNTER_INCREMENT(obd, statfs);
1293 CDEBUG(D_SUPER, "osfs "LPU64", max_age "LPU64"\n",
1294 obd->obd_osfs_age, max_age);
1295 if (cfs_time_before_64(obd->obd_osfs_age, max_age)) {
1296 rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
1298 spin_lock(&obd->obd_osfs_lock);
1299 memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
1300 obd->obd_osfs_age = cfs_time_current_64();
1301 spin_unlock(&obd->obd_osfs_lock);
1304 CDEBUG(D_SUPER, "%s: use %p cache blocks "LPU64"/"LPU64
1305 " objects "LPU64"/"LPU64"\n",
1306 obd->obd_name, &obd->obd_osfs,
1307 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1308 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1309 spin_lock(&obd->obd_osfs_lock);
1310 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
1311 spin_unlock(&obd->obd_osfs_lock);
1316 static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo,
1317 obd_size start, obd_size end)
1319 struct ptlrpc_request_set *set = NULL;
1323 OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP);
1324 EXP_COUNTER_INCREMENT(exp, sync);
1326 set = ptlrpc_prep_set();
1330 rc = OBP(exp->exp_obd, sync)(NULL, exp, oinfo, start, end, set);
1332 rc = ptlrpc_set_wait(set);
1333 ptlrpc_set_destroy(set);
1337 static inline int obd_sync(const struct lu_env *env, struct obd_export *exp,
1338 struct obd_info *oinfo, obd_size start, obd_size end,
1339 struct ptlrpc_request_set *set)
1344 OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP);
1345 EXP_COUNTER_INCREMENT(exp, sync);
1347 rc = OBP(exp->exp_obd, sync)(env, exp, oinfo, start, end, set);
1351 static inline int obd_punch_rqset(struct obd_export *exp,
1352 struct obd_info *oinfo,
1353 struct obd_trans_info *oti)
1355 struct ptlrpc_request_set *set = NULL;
1359 EXP_CHECK_DT_OP(exp, punch);
1360 EXP_COUNTER_INCREMENT(exp, punch);
1362 set = ptlrpc_prep_set();
1366 rc = OBP(exp->exp_obd, punch)(NULL, exp, oinfo, oti, set);
1368 rc = ptlrpc_set_wait(set);
1369 ptlrpc_set_destroy(set);
1373 static inline int obd_punch(const struct lu_env *env, struct obd_export *exp,
1374 struct obd_info *oinfo, struct obd_trans_info *oti,
1375 struct ptlrpc_request_set *rqset)
1380 EXP_CHECK_DT_OP(exp, punch);
1381 EXP_COUNTER_INCREMENT(exp, punch);
1383 rc = OBP(exp->exp_obd, punch)(env, exp, oinfo, oti, rqset);
1387 static inline int obd_brw(int cmd, struct obd_export *exp,
1388 struct obd_info *oinfo, obd_count oa_bufs,
1389 struct brw_page *pg, struct obd_trans_info *oti)
1394 EXP_CHECK_DT_OP(exp, brw);
1395 EXP_COUNTER_INCREMENT(exp, brw);
1397 if (!(cmd & (OBD_BRW_RWMASK | OBD_BRW_CHECK))) {
1398 CERROR("obd_brw: cmd must be OBD_BRW_READ, OBD_BRW_WRITE, "
1399 "or OBD_BRW_CHECK\n");
1403 rc = OBP(exp->exp_obd, brw)(cmd, exp, oinfo, oa_bufs, pg, oti);
1407 static inline int obd_preprw(const struct lu_env *env, int cmd,
1408 struct obd_export *exp, struct obdo *oa,
1409 int objcount, struct obd_ioobj *obj,
1410 struct niobuf_remote *remote, int *pages,
1411 struct niobuf_local *local,
1412 struct obd_trans_info *oti,
1413 struct lustre_capa *capa)
1418 EXP_CHECK_DT_OP(exp, preprw);
1419 EXP_COUNTER_INCREMENT(exp, preprw);
1421 rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote,
1422 pages, local, oti, capa);
1426 static inline int obd_commitrw(const struct lu_env *env, int cmd,
1427 struct obd_export *exp, struct obdo *oa,
1428 int objcount, struct obd_ioobj *obj,
1429 struct niobuf_remote *rnb, int pages,
1430 struct niobuf_local *local,
1431 struct obd_trans_info *oti, int rc)
1435 EXP_CHECK_DT_OP(exp, commitrw);
1436 EXP_COUNTER_INCREMENT(exp, commitrw);
1438 rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj,
1439 rnb, pages, local, oti, rc);
1443 static inline int obd_merge_lvb(struct obd_export *exp,
1444 struct lov_stripe_md *lsm,
1445 struct ost_lvb *lvb, int kms_only)
1450 EXP_CHECK_DT_OP(exp, merge_lvb);
1451 EXP_COUNTER_INCREMENT(exp, merge_lvb);
1453 rc = OBP(exp->exp_obd, merge_lvb)(exp, lsm, lvb, kms_only);
1457 static inline int obd_adjust_kms(struct obd_export *exp,
1458 struct lov_stripe_md *lsm, obd_off size,
1464 EXP_CHECK_DT_OP(exp, adjust_kms);
1465 EXP_COUNTER_INCREMENT(exp, adjust_kms);
1467 rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink);
1471 static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
1472 int len, void *karg, void *uarg)
1477 EXP_CHECK_DT_OP(exp, iocontrol);
1478 EXP_COUNTER_INCREMENT(exp, iocontrol);
1480 rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
1484 static inline int obd_enqueue_rqset(struct obd_export *exp,
1485 struct obd_info *oinfo,
1486 struct ldlm_enqueue_info *einfo)
1488 struct ptlrpc_request_set *set = NULL;
1492 EXP_CHECK_DT_OP(exp, enqueue);
1493 EXP_COUNTER_INCREMENT(exp, enqueue);
1495 set = ptlrpc_prep_set();
1499 rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set);
1501 rc = ptlrpc_set_wait(set);
1502 ptlrpc_set_destroy(set);
1506 static inline int obd_enqueue(struct obd_export *exp,
1507 struct obd_info *oinfo,
1508 struct ldlm_enqueue_info *einfo,
1509 struct ptlrpc_request_set *set)
1514 EXP_CHECK_DT_OP(exp, enqueue);
1515 EXP_COUNTER_INCREMENT(exp, enqueue);
1517 rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set);
1521 static inline int obd_change_cbdata(struct obd_export *exp,
1522 struct lov_stripe_md *lsm,
1523 ldlm_iterator_t it, void *data)
1528 EXP_CHECK_DT_OP(exp, change_cbdata);
1529 EXP_COUNTER_INCREMENT(exp, change_cbdata);
1531 rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data);
1535 static inline int obd_find_cbdata(struct obd_export *exp,
1536 struct lov_stripe_md *lsm,
1537 ldlm_iterator_t it, void *data)
1542 EXP_CHECK_DT_OP(exp, find_cbdata);
1543 EXP_COUNTER_INCREMENT(exp, find_cbdata);
1545 rc = OBP(exp->exp_obd, find_cbdata)(exp, lsm, it, data);
1549 static inline int obd_cancel(struct obd_export *exp,
1550 struct lov_stripe_md *ea, __u32 mode,
1551 struct lustre_handle *lockh)
1556 EXP_CHECK_DT_OP(exp, cancel);
1557 EXP_COUNTER_INCREMENT(exp, cancel);
1559 rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh);
1563 static inline int obd_cancel_unused(struct obd_export *exp,
1564 struct lov_stripe_md *ea,
1565 ldlm_cancel_flags_t flags,
1571 EXP_CHECK_DT_OP(exp, cancel_unused);
1572 EXP_COUNTER_INCREMENT(exp, cancel_unused);
1574 rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque);
1578 static inline int obd_pin(struct obd_export *exp, const struct lu_fid *fid,
1579 struct obd_capa *oc, struct obd_client_handle *handle,
1585 EXP_CHECK_DT_OP(exp, pin);
1586 EXP_COUNTER_INCREMENT(exp, pin);
1588 rc = OBP(exp->exp_obd, pin)(exp, fid, oc, handle, flag);
1592 static inline int obd_unpin(struct obd_export *exp,
1593 struct obd_client_handle *handle, int flag)
1598 EXP_CHECK_DT_OP(exp, unpin);
1599 EXP_COUNTER_INCREMENT(exp, unpin);
1601 rc = OBP(exp->exp_obd, unpin)(exp, handle, flag);
1606 static inline void obd_import_event(struct obd_device *obd,
1607 struct obd_import *imp,
1608 enum obd_import_event event)
1612 CERROR("NULL device\n");
1616 if (obd->obd_set_up && OBP(obd, import_event)) {
1617 OBD_COUNTER_INCREMENT(obd, import_event);
1618 OBP(obd, import_event)(obd, imp, event);
1623 static inline int obd_llog_connect(struct obd_export *exp,
1624 struct llogd_conn_body *body)
1629 OBD_CHECK_DT_OP(exp->exp_obd, llog_connect, 0);
1630 EXP_COUNTER_INCREMENT(exp, llog_connect);
1632 rc = OBP(exp->exp_obd, llog_connect)(exp, body);
1637 static inline int obd_notify(struct obd_device *obd,
1638 struct obd_device *watched,
1639 enum obd_notify_event ev,
1646 /* the check for async_recov is a complete hack - I'm hereby
1647 overloading the meaning to also mean "this was called from
1648 mds_postsetup". I know that my mds is able to handle notifies
1649 by this point, and it needs to get them to execute mds_postrecov. */
1650 if (!obd->obd_set_up && !obd->obd_async_recov) {
1651 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
1655 if (!OBP(obd, notify)) {
1656 CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name);
1660 OBD_COUNTER_INCREMENT(obd, notify);
1661 rc = OBP(obd, notify)(obd, watched, ev, data);
1665 static inline int obd_notify_observer(struct obd_device *observer,
1666 struct obd_device *observed,
1667 enum obd_notify_event ev,
1673 struct obd_notify_upcall *onu;
1675 if (observer->obd_observer)
1676 rc1 = obd_notify(observer->obd_observer, observed, ev, data);
1680 * Also, call non-obd listener, if any
1682 onu = &observer->obd_upcall;
1683 if (onu->onu_upcall != NULL)
1684 rc2 = onu->onu_upcall(observer, observed, ev,
1685 onu->onu_owner, NULL);
1689 return rc1 ? rc1 : rc2;
1692 static inline int obd_quotacheck(struct obd_export *exp,
1693 struct obd_quotactl *oqctl)
1698 EXP_CHECK_DT_OP(exp, quotacheck);
1699 EXP_COUNTER_INCREMENT(exp, quotacheck);
1701 rc = OBP(exp->exp_obd, quotacheck)(exp->exp_obd, exp, oqctl);
1705 static inline int obd_quotactl(struct obd_export *exp,
1706 struct obd_quotactl *oqctl)
1711 EXP_CHECK_DT_OP(exp, quotactl);
1712 EXP_COUNTER_INCREMENT(exp, quotactl);
1714 rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl);
1718 static inline int obd_health_check(const struct lu_env *env,
1719 struct obd_device *obd)
1721 /* returns: 0 on healthy
1722 * >0 on unhealthy + reason code/flag
1723 * however the only suppored reason == 1 right now
1724 * We'll need to define some better reasons
1725 * or flags in the future.
1731 /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */
1732 if (obd == NULL || !OBT(obd)) {
1733 CERROR("cleaned up obd\n");
1734 RETURN(-EOPNOTSUPP);
1736 if (!obd->obd_set_up || obd->obd_stopping)
1738 if (!OBP(obd, health_check))
1741 rc = OBP(obd, health_check)(env, obd);
1745 static inline int obd_register_observer(struct obd_device *obd,
1746 struct obd_device *observer)
1750 down_write(&obd->obd_observer_link_sem);
1751 if (obd->obd_observer && observer) {
1752 up_write(&obd->obd_observer_link_sem);
1755 obd->obd_observer = observer;
1756 up_write(&obd->obd_observer_link_sem);
1760 static inline int obd_pin_observer(struct obd_device *obd,
1761 struct obd_device **observer)
1764 down_read(&obd->obd_observer_link_sem);
1765 if (!obd->obd_observer) {
1767 up_read(&obd->obd_observer_link_sem);
1770 *observer = obd->obd_observer;
1774 static inline int obd_unpin_observer(struct obd_device *obd)
1777 up_read(&obd->obd_observer_link_sem);
1782 static inline int obd_register_page_removal_cb(struct obd_export *exp,
1783 obd_page_removal_cb_t cb,
1784 obd_pin_extent_cb pin_cb)
1789 OBD_CHECK_DT_OP(exp->exp_obd, register_page_removal_cb, 0);
1790 OBD_COUNTER_INCREMENT(exp->exp_obd, register_page_removal_cb);
1792 rc = OBP(exp->exp_obd, register_page_removal_cb)(exp, cb, pin_cb);
1796 static inline int obd_unregister_page_removal_cb(struct obd_export *exp,
1797 obd_page_removal_cb_t cb)
1802 OBD_CHECK_DT_OP(exp->exp_obd, unregister_page_removal_cb, 0);
1803 OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_page_removal_cb);
1805 rc = OBP(exp->exp_obd, unregister_page_removal_cb)(exp, cb);
1809 static inline int obd_register_lock_cancel_cb(struct obd_export *exp,
1810 obd_lock_cancel_cb cb)
1815 OBD_CHECK_DT_OP(exp->exp_obd, register_lock_cancel_cb, 0);
1816 OBD_COUNTER_INCREMENT(exp->exp_obd, register_lock_cancel_cb);
1818 rc = OBP(exp->exp_obd, register_lock_cancel_cb)(exp, cb);
1822 static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp,
1823 obd_lock_cancel_cb cb)
1828 OBD_CHECK_DT_OP(exp->exp_obd, unregister_lock_cancel_cb, 0);
1829 OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_lock_cancel_cb);
1831 rc = OBP(exp->exp_obd, unregister_lock_cancel_cb)(exp, cb);
1836 /* metadata helpers */
1837 static inline int md_getstatus(struct obd_export *exp,
1838 struct lu_fid *fid, struct obd_capa **pc)
1843 EXP_CHECK_MD_OP(exp, getstatus);
1844 EXP_MD_COUNTER_INCREMENT(exp, getstatus);
1845 rc = MDP(exp->exp_obd, getstatus)(exp, fid, pc);
1849 static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data,
1850 struct ptlrpc_request **request)
1854 EXP_CHECK_MD_OP(exp, getattr);
1855 EXP_MD_COUNTER_INCREMENT(exp, getattr);
1856 rc = MDP(exp->exp_obd, getattr)(exp, op_data, request);
1860 static inline int md_change_cbdata(struct obd_export *exp,
1861 const struct lu_fid *fid,
1862 ldlm_iterator_t it, void *data)
1866 EXP_CHECK_MD_OP(exp, change_cbdata);
1867 EXP_MD_COUNTER_INCREMENT(exp, change_cbdata);
1868 rc = MDP(exp->exp_obd, change_cbdata)(exp, fid, it, data);
1872 static inline int md_find_cbdata(struct obd_export *exp,
1873 const struct lu_fid *fid,
1874 ldlm_iterator_t it, void *data)
1878 EXP_CHECK_MD_OP(exp, find_cbdata);
1879 EXP_MD_COUNTER_INCREMENT(exp, find_cbdata);
1880 rc = MDP(exp->exp_obd, find_cbdata)(exp, fid, it, data);
1884 static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,
1885 struct md_open_data *mod,
1886 struct ptlrpc_request **request)
1890 EXP_CHECK_MD_OP(exp, close);
1891 EXP_MD_COUNTER_INCREMENT(exp, close);
1892 rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request);
1896 static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
1897 const void *data, int datalen, int mode, __u32 uid,
1898 __u32 gid, cfs_cap_t cap_effective, __u64 rdev,
1899 struct ptlrpc_request **request)
1903 EXP_CHECK_MD_OP(exp, create);
1904 EXP_MD_COUNTER_INCREMENT(exp, create);
1905 rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode,
1906 uid, gid, cap_effective, rdev, request);
1910 static inline int md_done_writing(struct obd_export *exp,
1911 struct md_op_data *op_data,
1912 struct md_open_data *mod)
1916 EXP_CHECK_MD_OP(exp, done_writing);
1917 EXP_MD_COUNTER_INCREMENT(exp, done_writing);
1918 rc = MDP(exp->exp_obd, done_writing)(exp, op_data, mod);
1922 static inline int md_enqueue(struct obd_export *exp,
1923 struct ldlm_enqueue_info *einfo,
1924 struct lookup_intent *it,
1925 struct md_op_data *op_data,
1926 struct lustre_handle *lockh,
1927 void *lmm, int lmmsize,
1928 struct ptlrpc_request **req,
1929 int extra_lock_flags)
1933 EXP_CHECK_MD_OP(exp, enqueue);
1934 EXP_MD_COUNTER_INCREMENT(exp, enqueue);
1935 rc = MDP(exp->exp_obd, enqueue)(exp, einfo, it, op_data, lockh,
1936 lmm, lmmsize, req, extra_lock_flags);
1940 static inline int md_getattr_name(struct obd_export *exp,
1941 struct md_op_data *op_data,
1942 struct ptlrpc_request **request)
1946 EXP_CHECK_MD_OP(exp, getattr_name);
1947 EXP_MD_COUNTER_INCREMENT(exp, getattr_name);
1948 rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request);
1952 static inline int md_intent_lock(struct obd_export *exp,
1953 struct md_op_data *op_data, void *lmm,
1954 int lmmsize, struct lookup_intent *it,
1955 int lookup_flags, struct ptlrpc_request **reqp,
1956 ldlm_blocking_callback cb_blocking,
1957 __u64 extra_lock_flags)
1961 EXP_CHECK_MD_OP(exp, intent_lock);
1962 EXP_MD_COUNTER_INCREMENT(exp, intent_lock);
1963 rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize,
1964 it, lookup_flags, reqp, cb_blocking,
1969 static inline int md_link(struct obd_export *exp, struct md_op_data *op_data,
1970 struct ptlrpc_request **request)
1974 EXP_CHECK_MD_OP(exp, link);
1975 EXP_MD_COUNTER_INCREMENT(exp, link);
1976 rc = MDP(exp->exp_obd, link)(exp, op_data, request);
1980 static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data,
1981 const char *old, int oldlen, const char *new,
1982 int newlen, struct ptlrpc_request **request)
1986 EXP_CHECK_MD_OP(exp, rename);
1987 EXP_MD_COUNTER_INCREMENT(exp, rename);
1988 rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new,
1993 static inline int md_is_subdir(struct obd_export *exp,
1994 const struct lu_fid *pfid,
1995 const struct lu_fid *cfid,
1996 struct ptlrpc_request **request)
2000 EXP_CHECK_MD_OP(exp, is_subdir);
2001 EXP_MD_COUNTER_INCREMENT(exp, is_subdir);
2002 rc = MDP(exp->exp_obd, is_subdir)(exp, pfid, cfid, request);
2006 static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,
2007 void *ea, int ealen, void *ea2, int ea2len,
2008 struct ptlrpc_request **request,
2009 struct md_open_data **mod)
2013 EXP_CHECK_MD_OP(exp, setattr);
2014 EXP_MD_COUNTER_INCREMENT(exp, setattr);
2015 rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen,
2016 ea2, ea2len, request, mod);
2020 static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid,
2021 struct obd_capa *oc, struct ptlrpc_request **request)
2025 EXP_CHECK_MD_OP(exp, sync);
2026 EXP_MD_COUNTER_INCREMENT(exp, sync);
2027 rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request);
2031 static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata,
2032 struct page **pages,
2033 struct ptlrpc_request **request)
2037 EXP_CHECK_MD_OP(exp, readpage);
2038 EXP_MD_COUNTER_INCREMENT(exp, readpage);
2039 rc = MDP(exp->exp_obd, readpage)(exp, opdata, pages, request);
2043 static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data,
2044 struct ptlrpc_request **request)
2048 EXP_CHECK_MD_OP(exp, unlink);
2049 EXP_MD_COUNTER_INCREMENT(exp, unlink);
2050 rc = MDP(exp->exp_obd, unlink)(exp, op_data, request);
2054 static inline int md_get_lustre_md(struct obd_export *exp,
2055 struct ptlrpc_request *req,
2056 struct obd_export *dt_exp,
2057 struct obd_export *md_exp,
2058 struct lustre_md *md)
2061 EXP_CHECK_MD_OP(exp, get_lustre_md);
2062 EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md);
2063 RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md));
2066 static inline int md_free_lustre_md(struct obd_export *exp,
2067 struct lustre_md *md)
2070 EXP_CHECK_MD_OP(exp, free_lustre_md);
2071 EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md);
2072 RETURN(MDP(exp->exp_obd, free_lustre_md)(exp, md));
2075 static inline int md_setxattr(struct obd_export *exp,
2076 const struct lu_fid *fid, struct obd_capa *oc,
2077 obd_valid valid, const char *name,
2078 const char *input, int input_size,
2079 int output_size, int flags, __u32 suppgid,
2080 struct ptlrpc_request **request)
2083 EXP_CHECK_MD_OP(exp, setxattr);
2084 EXP_MD_COUNTER_INCREMENT(exp, setxattr);
2085 RETURN(MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input,
2086 input_size, output_size, flags,
2090 static inline int md_getxattr(struct obd_export *exp,
2091 const struct lu_fid *fid, struct obd_capa *oc,
2092 obd_valid valid, const char *name,
2093 const char *input, int input_size,
2094 int output_size, int flags,
2095 struct ptlrpc_request **request)
2098 EXP_CHECK_MD_OP(exp, getxattr);
2099 EXP_MD_COUNTER_INCREMENT(exp, getxattr);
2100 RETURN(MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input,
2101 input_size, output_size, flags,
2105 static inline int md_set_open_replay_data(struct obd_export *exp,
2106 struct obd_client_handle *och,
2107 struct ptlrpc_request *open_req)
2110 EXP_CHECK_MD_OP(exp, set_open_replay_data);
2111 EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data);
2112 RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req));
2115 static inline int md_clear_open_replay_data(struct obd_export *exp,
2116 struct obd_client_handle *och)
2119 EXP_CHECK_MD_OP(exp, clear_open_replay_data);
2120 EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data);
2121 RETURN(MDP(exp->exp_obd, clear_open_replay_data)(exp, och));
2124 static inline int md_set_lock_data(struct obd_export *exp,
2125 __u64 *lockh, void *data, __u64 *bits)
2128 EXP_CHECK_MD_OP(exp, set_lock_data);
2129 EXP_MD_COUNTER_INCREMENT(exp, set_lock_data);
2130 RETURN(MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits));
2133 static inline int md_cancel_unused(struct obd_export *exp,
2134 const struct lu_fid *fid,
2135 ldlm_policy_data_t *policy,
2137 ldlm_cancel_flags_t flags,
2143 EXP_CHECK_MD_OP(exp, cancel_unused);
2144 EXP_MD_COUNTER_INCREMENT(exp, cancel_unused);
2146 rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode,
2151 static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags,
2152 const struct lu_fid *fid,
2154 ldlm_policy_data_t *policy,
2156 struct lustre_handle *lockh)
2159 EXP_CHECK_MD_OP(exp, lock_match);
2160 EXP_MD_COUNTER_INCREMENT(exp, lock_match);
2161 RETURN(MDP(exp->exp_obd, lock_match)(exp, flags, fid, type,
2162 policy, mode, lockh));
2165 static inline int md_init_ea_size(struct obd_export *exp, int easize,
2166 int def_asize, int cookiesize)
2169 EXP_CHECK_MD_OP(exp, init_ea_size);
2170 EXP_MD_COUNTER_INCREMENT(exp, init_ea_size);
2171 RETURN(MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize,
2175 static inline int md_get_remote_perm(struct obd_export *exp,
2176 const struct lu_fid *fid,
2177 struct obd_capa *oc, __u32 suppgid,
2178 struct ptlrpc_request **request)
2181 EXP_CHECK_MD_OP(exp, get_remote_perm);
2182 EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm);
2183 RETURN(MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid,
2187 static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa,
2192 EXP_CHECK_MD_OP(exp, renew_capa);
2193 EXP_MD_COUNTER_INCREMENT(exp, renew_capa);
2194 rc = MDP(exp->exp_obd, renew_capa)(exp, ocapa, cb);
2198 static inline int md_unpack_capa(struct obd_export *exp,
2199 struct ptlrpc_request *req,
2200 const struct req_msg_field *field,
2201 struct obd_capa **oc)
2205 EXP_CHECK_MD_OP(exp, unpack_capa);
2206 EXP_MD_COUNTER_INCREMENT(exp, unpack_capa);
2207 rc = MDP(exp->exp_obd, unpack_capa)(exp, req, field, oc);
2211 static inline int md_intent_getattr_async(struct obd_export *exp,
2212 struct md_enqueue_info *minfo,
2213 struct ldlm_enqueue_info *einfo)
2217 EXP_CHECK_MD_OP(exp, intent_getattr_async);
2218 EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async);
2219 rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo);
2223 static inline int md_revalidate_lock(struct obd_export *exp,
2224 struct lookup_intent *it,
2225 struct lu_fid *fid, __u64 *bits)
2229 EXP_CHECK_MD_OP(exp, revalidate_lock);
2230 EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock);
2231 rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits);
2236 /* OBD Metadata Support */
2238 extern int obd_init_caches(void);
2239 extern void obd_cleanup_caches(void);
2241 /* support routines */
2242 extern cfs_mem_cache_t *obdo_cachep;
2244 #define OBDO_ALLOC(ptr) \
2246 OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, CFS_ALLOC_IO); \
2249 #define OBDO_FREE(ptr) \
2251 OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \
2255 static inline void obdo2fid(struct obdo *oa, struct lu_fid *fid)
2257 /* something here */
2260 static inline void fid2obdo(struct lu_fid *fid, struct obdo *oa)
2262 /* something here */
2265 typedef int (*register_lwp_cb)(void *data);
2267 struct lwp_register_item {
2268 struct obd_export **lri_exp;
2269 register_lwp_cb lri_cb_func;
2271 cfs_list_t lri_list;
2272 char lri_name[MTI_NAME_MAXLEN];
2275 /* I'm as embarrassed about this as you are.
2277 * <shaver> // XXX do not look into _superhack with remaining eye
2278 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
2279 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
2282 int server_name2fsname(char *svname, char *fsname, char **endptr);
2283 int lustre_register_lwp_item(char *lwpname, struct obd_export **exp,
2284 register_lwp_cb cb_func, void *cb_data);
2285 void lustre_deregister_lwp_item(struct obd_export **exp);
2286 int tgt_name2lwpname(char *tgt_name, char *lwp_name);
2289 extern void obd_sysctl_init (void);
2290 extern void obd_sysctl_clean (void);
2293 typedef __u8 class_uuid_t[16];
2294 void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out);
2297 int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
2298 int class_add_uuid(const char *uuid, __u64 nid);
2299 int class_del_uuid (const char *uuid);
2300 int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
2301 void class_init_uuidlist(void);
2302 void class_exit_uuidlist(void);
2305 int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen);
2306 int raw_name2idx(int hashtype, int count, const char *name, int namelen);
2309 #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t))
2311 #endif /* __LINUX_OBD_CLASS_H */