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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
35 #include <linux/kobject.h>
36 #include <obd_support.h>
37 #include <lustre_import.h>
38 #include <lustre_net.h>
40 #include <lustre_lib.h>
41 #include <uapi/linux/lustre/lustre_idl.h>
42 #include <lprocfs_status.h>
44 #define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay
45 * and resends for avoid deadlocks */
46 #define OBD_STATFS_FROM_CACHE 0x0002 /* the statfs callback should not update
48 #define OBD_STATFS_FOR_MDT0 0x0004 /* The statfs is only for retrieving
49 * information from MDT0. */
50 #define OBD_STATFS_SUM 0x0008 /* get aggregated statfs from MDT */
52 extern rwlock_t obd_dev_lock;
54 /* OBD Operations Declarations */
55 extern struct obd_device *class_exp2obd(struct obd_export *);
56 extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
57 int lustre_get_jobid(char *jobid, size_t len);
58 void lustre_jobid_clear(const char *jobid);
59 void jobid_cache_fini(void);
60 int jobid_cache_init(void);
61 char *jobid_current(void);
62 int jobid_set_current(char *jobid);
64 struct lu_device_type;
67 struct obd_export *class_conn2export(struct lustre_handle *);
68 #ifdef HAVE_SERVER_SUPPORT
69 struct obd_type *class_add_symlinks(const char *name, bool enable_proc);
71 int class_register_type(struct obd_ops *, struct md_ops *, bool enable_proc,
72 struct lprocfs_vars *module_vars,
73 const char *nm, struct lu_device_type *ldt);
74 int class_unregister_type(const char *nm);
76 struct obd_device *class_newdev(const char *type_name, const char *name,
78 int class_register_device(struct obd_device *obd);
79 void class_unregister_device(struct obd_device *obd);
80 void class_free_dev(struct obd_device *obd);
82 struct obd_device *class_dev_by_str(const char *str);
83 int class_name2dev(const char *name);
84 struct obd_device *class_name2obd(const char *name);
85 int class_uuid2dev(struct obd_uuid *uuid);
86 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
87 void class_obd_list(void);
88 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
89 const char *type_name,
90 struct obd_uuid *grp_uuid);
91 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
93 struct obd_device * class_num2obd(int num);
94 int get_devices_count(void);
96 int class_notify_sptlrpc_conf(const char *fsname, int namelen);
98 static inline char *obd_export_nid2str(struct obd_export *exp)
100 return exp->exp_connection == NULL ?
101 "<unknown>" : libcfs_nid2str(exp->exp_connection->c_peer.nid);
104 static inline char *obd_import_nid2str(struct obd_import *imp)
106 return imp->imp_connection == NULL ?
107 "<unknown>" : libcfs_nid2str(imp->imp_connection->c_peer.nid);
110 int obd_export_evict_by_nid(struct obd_device *obd, const char *nid);
111 int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid);
112 int obd_connect_flags2str(char *page, int count, __u64 flags, __u64 flags2,
115 int obd_zombie_impexp_init(void);
116 void obd_zombie_impexp_stop(void);
117 void obd_zombie_impexp_cull(void);
118 void obd_zombie_barrier(void);
119 void obd_exports_barrier(struct obd_device *obd);
120 int kuc_len(int payload_len);
121 struct kuc_hdr * kuc_ptr(void *p);
122 void *kuc_alloc(int payload_len, int transport, int type);
123 void kuc_free(void *p, int payload_len);
124 int obd_get_request_slot(struct client_obd *cli);
125 void obd_put_request_slot(struct client_obd *cli);
126 __u32 obd_get_max_rpcs_in_flight(struct client_obd *cli);
127 int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max);
128 __u16 obd_get_max_mod_rpcs_in_flight(struct client_obd *cli);
129 int obd_set_max_mod_rpcs_in_flight(struct client_obd *cli, __u16 max);
130 int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq);
132 __u16 obd_get_mod_rpc_slot(struct client_obd *cli, __u32 opc,
133 struct lookup_intent *it);
134 void obd_put_mod_rpc_slot(struct client_obd *cli, __u32 opc,
135 struct lookup_intent *it, __u16 tag);
139 typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
140 struct llog_rec_hdr *, void *);
142 struct obd_export *obd_stale_export_get(void);
143 void obd_stale_export_put(struct obd_export *exp);
144 void obd_stale_export_adjust(struct obd_export *exp);
147 /* For interoperability */
148 struct cfg_interop_param {
153 char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index);
154 struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
155 const char *new_name);
156 void print_lustre_cfg(struct lustre_cfg *lcfg);
157 int class_process_config(struct lustre_cfg *lcfg);
158 ssize_t class_set_global(const char *param);
159 ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
160 struct kobject *kobj);
161 int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
162 struct lustre_cfg *lcfg, void *data);
163 int class_attach(struct lustre_cfg *lcfg);
164 int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
165 int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
166 int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
168 int class_find_param(char *buf, char *key, char **valp);
169 struct cfg_interop_param *class_find_old_param(const char *param,
170 struct cfg_interop_param *ptr);
171 int class_get_next_param(char **params, char *copy);
172 int class_match_param(char *buf, const char *key, char **valp);
173 int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh);
174 int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh);
175 int class_parse_net(char *buf, u32 *net, char **endh);
176 int class_match_nid(char *buf, char *key, lnet_nid_t nid);
177 int class_match_net(char *buf, char *key, u32 net);
179 struct obd_device *class_incref(struct obd_device *obd,
180 const char *scope, const void *source);
181 void class_decref(struct obd_device *obd,
182 const char *scope, const void *source);
183 void dump_exports(struct obd_device *obd, int locks, int debug_level);
184 int class_config_llog_handler(const struct lu_env *env,
185 struct llog_handle *handle,
186 struct llog_rec_hdr *rec, void *data);
187 int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
189 #define CFG_F_START 0x01 /* Set when we start updating from a log */
190 #define CFG_F_MARKER 0x02 /* We are within a maker */
191 #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */
192 #define CFG_F_EXCLUDE 0x10 /* OST exclusion list */
194 /* Passed as data param to class_config_parse_llog */
195 struct config_llog_instance {
196 unsigned long cfg_instance;
197 struct super_block *cfg_sb;
198 struct obd_uuid cfg_uuid;
199 llog_cb_t cfg_callback;
200 int cfg_last_idx; /* for partial llog processing */
205 int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
206 char *name, struct config_llog_instance *cfg);
209 * Generate a unique configuration instance for this mount
211 * Temporary hack to bypass ASLR in 4.15+ kernels, a better fix soon.
212 * For now, use the same value as before - the superblock pointer value.
214 * Using the client UUID would be an option, but it needs more testing.
216 static inline unsigned long ll_get_cfg_instance(struct super_block *sb)
218 return (unsigned long)sb;
221 #define CONFIG_SUB_SPTLRPC 0x01
222 #define CONFIG_SUB_RECOVER 0x02
223 #define CONFIG_SUB_PARAMS 0x04
224 #define CONFIG_SUB_NODEMAP 0x08
225 #define CONFIG_SUB_BARRIER 0x10
227 /* Sub clds should be attached to the config_llog_data when processing
228 * config log for client or server target. */
229 #define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \
231 #define CONFIG_SUB_SERVER (CONFIG_SUB_CLIENT | CONFIG_SUB_NODEMAP | \
234 #define PARAMS_FILENAME "params"
235 #define BARRIER_FILENAME "barrier"
236 #define LCTL_UPCALL "lctl"
238 static inline bool logname_is_barrier(const char *logname)
242 /* logname for barrier is "fsname-barrier" */
243 ptr = strstr(logname, BARRIER_FILENAME);
244 if (ptr && (ptr - logname) >= 2 &&
245 *(ptr - 1) == '-' && *(ptr + 7) == '\0')
251 /* list of active configuration logs */
252 struct config_llog_data {
253 struct ldlm_res_id cld_resid;
254 struct config_llog_instance cld_cfg;
255 struct list_head cld_list_chain;/* on config_llog_list */
256 atomic_t cld_refcount;
257 struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */
258 struct config_llog_data *cld_params; /* common parameters log */
259 struct config_llog_data *cld_recover;/* imperative recover log */
260 struct config_llog_data *cld_nodemap;/* nodemap log */
261 struct config_llog_data *cld_barrier;/* barrier log (for MDT only) */
262 struct obd_export *cld_mgcexp;
263 struct mutex cld_lock;
265 unsigned int cld_stopping:1, /* we were told to stop
267 cld_lostlock:1; /* lock not requeued */
271 struct lustre_profile {
272 struct list_head lp_list;
277 bool lp_list_deleted;
280 struct lustre_profile *class_get_profile(const char * prof);
281 void class_del_profile(const char *prof);
282 void class_put_profile(struct lustre_profile *lprof);
283 void class_del_profiles(void);
286 #if LUSTRE_TRACKS_LOCK_EXP_REFS
288 void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *);
289 void __class_export_del_lock_ref(struct obd_export *, struct ldlm_lock *);
290 extern void (*class_export_dump_hook)(struct obd_export *);
294 #define __class_export_add_lock_ref(exp, lock) do {} while(0)
295 #define __class_export_del_lock_ref(exp, lock) do {} while(0)
299 #define class_export_rpc_inc(exp) \
301 atomic_inc(&(exp)->exp_rpc_count); \
302 CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \
303 (exp), atomic_read(&(exp)->exp_rpc_count)); \
306 #define class_export_rpc_dec(exp) \
308 LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \
309 atomic_dec(&(exp)->exp_rpc_count); \
310 CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \
311 (exp), atomic_read(&(exp)->exp_rpc_count)); \
314 #define class_export_lock_get(exp, lock) \
316 atomic_inc(&(exp)->exp_locks_count); \
317 __class_export_add_lock_ref(exp, lock); \
318 CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \
319 (exp), atomic_read(&(exp)->exp_locks_count)); \
320 class_export_get(exp); \
323 #define class_export_lock_put(exp, lock) \
325 LASSERT_ATOMIC_POS(&exp->exp_locks_count); \
326 atomic_dec(&(exp)->exp_locks_count); \
327 __class_export_del_lock_ref(exp, lock); \
328 CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \
329 (exp), atomic_read(&(exp)->exp_locks_count)); \
330 class_export_put(exp); \
333 #define class_export_cb_get(exp) \
335 atomic_inc(&(exp)->exp_cb_count); \
336 CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\
337 (exp), atomic_read(&(exp)->exp_cb_count)); \
338 class_export_get(exp); \
341 #define class_export_cb_put(exp) \
343 LASSERT_ATOMIC_POS(&exp->exp_cb_count); \
344 atomic_dec(&(exp)->exp_cb_count); \
345 CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\
346 (exp), atomic_read(&(exp)->exp_cb_count)); \
347 class_export_put(exp); \
351 struct obd_export *class_export_get(struct obd_export *exp);
352 void class_export_put(struct obd_export *exp);
353 struct obd_export *class_new_export(struct obd_device *obddev,
354 struct obd_uuid *cluuid);
355 struct obd_export *class_new_export_self(struct obd_device *obd,
356 struct obd_uuid *uuid);
357 void class_unlink_export(struct obd_export *exp);
359 struct obd_import *class_import_get(struct obd_import *);
360 void class_import_put(struct obd_import *);
361 struct obd_import *class_new_import(struct obd_device *obd);
362 void class_destroy_import(struct obd_import *exp);
364 struct obd_type *class_search_type(const char *name);
365 struct obd_type *class_get_type(const char *name);
366 void class_put_type(struct obd_type *type);
367 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
368 struct obd_uuid *cluuid);
369 int class_disconnect(struct obd_export *exp);
370 void class_fail_export(struct obd_export *exp);
371 int class_connected_export(struct obd_export *exp);
372 void class_disconnect_exports(struct obd_device *obddev);
373 int class_manual_cleanup(struct obd_device *obd);
374 void class_disconnect_stale_exports(struct obd_device *,
375 int (*test_export)(struct obd_export *));
377 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
379 return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
380 (obd->obd_force ? OBD_OPT_FORCE : 0) |
381 (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) |
385 #ifdef HAVE_SERVER_SUPPORT
386 static inline struct lu_target *class_exp2tgt(struct obd_export *exp)
388 LASSERT(exp->exp_obd);
389 if (exp->exp_obd->u.obt.obt_magic != OBT_MAGIC)
391 return exp->exp_obd->u.obt.obt_lut;
394 static inline struct lr_server_data *class_server_data(struct obd_device *obd)
396 LASSERT(obd->u.obt.obt_lut);
397 return &obd->u.obt.obt_lut->lut_lsd;
405 void obdo_from_la(struct obdo *dst, const struct lu_attr *la, u64 valid);
406 void la_from_obdo(struct lu_attr *la, const struct obdo *dst, u64 valid);
408 void obdo_cpy_md(struct obdo *dst, const struct obdo *src, u64 valid);
409 void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj);
411 #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op
412 #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op
414 static inline int obd_check_dev(struct obd_device *obd)
417 CERROR("NULL device\n");
423 /* ensure obd_setup and !obd_stopping */
424 #define OBD_CHECK_DEV_ACTIVE(obd) \
426 rc = obd_check_dev(obd); \
430 if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
431 CERROR("Device %d not setup\n", \
438 static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp)
440 /* Always add in ldlm_stats */
441 tmp->nid_ldlm_stats =
442 lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC,
443 LPROCFS_STATS_FLAG_NOPERCPU);
444 if (tmp->nid_ldlm_stats == NULL)
447 lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
449 return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats",
450 tmp->nid_ldlm_stats);
453 static inline int exp_check_ops(struct obd_export *exp)
458 if (exp->exp_obd == NULL || !exp->exp_obd->obd_type) {
464 static inline int class_devno_max(void)
466 return MAX_OBD_DEVICES;
469 static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp,
470 __u32 keylen, void *key,
471 __u32 *vallen, void *val)
476 rc = exp_check_ops(exp);
480 if (!exp->exp_obd->obd_type->typ_dt_ops->o_get_info) {
481 CERROR("%s: no %s operation\n",
482 (exp)->exp_obd->obd_name, __func__);
486 rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val);
490 static inline int obd_set_info_async(const struct lu_env *env,
491 struct obd_export *exp,
492 __u32 keylen, void *key,
493 __u32 vallen, void *val,
494 struct ptlrpc_request_set *set)
499 rc = exp_check_ops(exp);
503 if (!exp->exp_obd->obd_type->typ_dt_ops->o_set_info_async) {
504 CERROR("%s: no %s operation\n",
505 (exp)->exp_obd->obd_name, __func__);
509 rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen,
515 * obd-lu integration.
517 * Functionality is being moved into new lu_device-based layering, but some
518 * pieces of configuration process are still based on obd devices.
520 * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully
521 * subsume ->o_setup() methods of obd devices they replace. The same for
522 * lu_device_operations::ldo_process_config() and ->o_process_config(). As a
523 * result, obd_setup() and obd_process_config() branch and call one XOR
526 * Yet neither lu_device_type_operations::ldto_device_fini() nor
527 * lu_device_type_operations::ldto_device_free() fully implement the
528 * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence,
529 * obd_precleanup() and obd_cleanup() call both lu_device and obd operations.
531 static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
534 struct lu_device_type *ldt = obd->obd_type->typ_lu;
540 struct lu_context session_ctx;
542 lu_context_init(&session_ctx, LCT_SESSION | LCT_SERVER_SESSION);
543 session_ctx.lc_thread = NULL;
544 lu_context_enter(&session_ctx);
546 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
548 env.le_ses = &session_ctx;
549 d = ldt->ldt_ops->ldto_device_alloc(&env, ldt, cfg);
558 lu_context_exit(&session_ctx);
559 lu_context_fini(&session_ctx);
562 if (!obd->obd_type->typ_dt_ops->o_setup) {
563 CERROR("%s: no %s operation\n", obd->obd_name,
567 rc = OBP(obd, setup)(obd, cfg);
572 static inline int obd_precleanup(struct obd_device *obd)
575 struct lu_device_type *ldt = obd->obd_type->typ_lu;
576 struct lu_device *d = obd->obd_lu_dev;
580 if (ldt != NULL && d != NULL) {
581 struct lu_env *env = lu_env_find();
586 rc = lu_env_init(env, ldt->ldt_ctx_tags);
590 ldt->ldt_ops->ldto_device_fini(env, d);
597 if (!obd->obd_type->typ_dt_ops->o_precleanup)
600 rc = OBP(obd, precleanup)(obd);
604 static inline int obd_cleanup(struct obd_device *obd)
607 struct lu_device_type *ldt = obd->obd_type->typ_lu;
608 struct lu_device *d = obd->obd_lu_dev;
611 if (ldt != NULL && d != NULL) {
614 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
616 ldt->ldt_ops->ldto_device_free(&env, d);
618 obd->obd_lu_dev = NULL;
621 if (!obd->obd_type->typ_dt_ops->o_cleanup)
624 rc = OBP(obd, cleanup)(obd);
628 static inline void obd_cleanup_client_import(struct obd_device *obd)
632 /* If we set up but never connected, the
633 client import will not have been cleaned. */
634 down_write(&obd->u.cli.cl_sem);
635 if (obd->u.cli.cl_import) {
636 struct obd_import *imp;
637 imp = obd->u.cli.cl_import;
638 CDEBUG(D_CONFIG, "%s: client import never connected\n",
640 ptlrpc_invalidate_import(imp);
641 client_destroy_import(imp);
642 obd->u.cli.cl_import = NULL;
644 up_write(&obd->u.cli.cl_sem);
649 static inline int obd_process_config(struct obd_device *obd, int datalen,
653 struct lu_device_type *ldt = obd->obd_type->typ_lu;
654 struct lu_device *d = obd->obd_lu_dev;
658 obd->obd_process_conf = 1;
659 if (ldt != NULL && d != NULL) {
662 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
664 rc = d->ld_ops->ldo_process_config(&env, d, data);
668 if (!obd->obd_type->typ_dt_ops->o_process_config) {
669 CERROR("%s: no %s operation\n",
670 obd->obd_name, __func__);
673 rc = OBP(obd, process_config)(obd, datalen, data);
676 obd->obd_process_conf = 0;
681 static inline int obd_create(const struct lu_env *env, struct obd_export *exp,
687 rc = exp_check_ops(exp);
691 if (!exp->exp_obd->obd_type->typ_dt_ops->o_create) {
692 CERROR("%s: no %s operation\n",
693 (exp)->exp_obd->obd_name, __func__);
697 rc = OBP(exp->exp_obd, create)(env, exp, obdo);
701 static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp,
707 rc = exp_check_ops(exp);
711 if (!exp->exp_obd->obd_type->typ_dt_ops->o_destroy) {
712 CERROR("%s: no %s operation\n",
713 (exp)->exp_obd->obd_name, __func__);
717 rc = OBP(exp->exp_obd, destroy)(env, exp, obdo);
721 static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp,
727 rc = exp_check_ops(exp);
731 if (!exp->exp_obd->obd_type->typ_dt_ops->o_getattr) {
732 CERROR("%s: no %s operation\n",
733 (exp)->exp_obd->obd_name, __func__);
737 rc = OBP(exp->exp_obd, getattr)(env, exp, oa);
742 static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp,
748 rc = exp_check_ops(exp);
752 if (!exp->exp_obd->obd_type->typ_dt_ops->o_setattr) {
753 CERROR("%s: no %s operation\n",
754 (exp)->exp_obd->obd_name, __func__);
758 rc = OBP(exp->exp_obd, setattr)(env, exp, oa);
763 static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
766 struct obd_device *obd = imp->imp_obd;
770 OBD_CHECK_DEV_ACTIVE(obd);
771 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_add_conn) {
772 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
776 rc = OBP(obd, add_conn)(imp, uuid, priority);
780 static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
782 struct obd_device *obd = imp->imp_obd;
786 OBD_CHECK_DEV_ACTIVE(obd);
787 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_del_conn) {
788 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
792 rc = OBP(obd, del_conn)(imp, uuid);
796 static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp)
798 struct obd_uuid *uuid;
801 if (!exp->exp_obd->obd_type ||
802 !exp->exp_obd->obd_type->typ_dt_ops->o_get_uuid)
805 uuid = OBP(exp->exp_obd, get_uuid)(exp);
809 /** Create a new /a exp on device /a obd for the uuid /a cluuid
810 * @param exp New export handle
811 * @param d Connect data, supported flags are set, flags also understood
812 * by obd are returned.
814 static inline int obd_connect(const struct lu_env *env,
815 struct obd_export **exp,struct obd_device *obd,
816 struct obd_uuid *cluuid,
817 struct obd_connect_data *data,
821 __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition
825 OBD_CHECK_DEV_ACTIVE(obd);
826 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_connect) {
827 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
831 rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata);
832 /* check that only subset is granted */
833 LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) ==
834 data->ocd_connect_flags));
838 static inline int obd_reconnect(const struct lu_env *env,
839 struct obd_export *exp,
840 struct obd_device *obd,
841 struct obd_uuid *cluuid,
842 struct obd_connect_data *d,
846 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition
851 OBD_CHECK_DEV_ACTIVE(obd);
852 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_reconnect)
855 rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata);
856 /* check that only subset is granted */
857 LASSERT(ergo(d != NULL,
858 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
862 static inline int obd_disconnect(struct obd_export *exp)
866 rc = exp_check_ops(exp);
870 if (!exp->exp_obd->obd_type->typ_dt_ops->o_disconnect) {
871 CERROR("%s: no %s operation\n",
872 (exp)->exp_obd->obd_name, __func__);
876 rc = OBP(exp->exp_obd, disconnect)(exp);
880 static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp,
881 enum lu_cli_type type)
886 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_init)
889 rc = OBP(obd, fid_init)(obd, exp, type);
893 static inline int obd_fid_fini(struct obd_device *obd)
897 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_fini)
900 rc = OBP(obd, fid_fini)(obd);
904 static inline int obd_fid_alloc(const struct lu_env *env,
905 struct obd_export *exp,
907 struct md_op_data *op_data)
911 rc = exp_check_ops(exp);
915 if (!exp->exp_obd->obd_type->typ_dt_ops->o_fid_alloc) {
916 CERROR("%s: no %s operation\n",
917 (exp)->exp_obd->obd_name, __func__);
921 rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data);
925 static inline int obd_pool_new(struct obd_device *obd, char *poolname)
930 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_new) {
931 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
935 rc = OBP(obd, pool_new)(obd, poolname);
939 static inline int obd_pool_del(struct obd_device *obd, char *poolname)
943 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_del) {
944 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
948 rc = OBP(obd, pool_del)(obd, poolname);
952 static inline int obd_pool_add(struct obd_device *obd, char *poolname,
958 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_add) {
959 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
963 rc = OBP(obd, pool_add)(obd, poolname, ostname);
967 static inline int obd_pool_rem(struct obd_device *obd, char *poolname,
973 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_rem) {
974 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
978 rc = OBP(obd, pool_rem)(obd, poolname, ostname);
982 static inline int obd_init_export(struct obd_export *exp)
987 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
988 OBP((exp)->exp_obd, init_export))
989 rc = OBP(exp->exp_obd, init_export)(exp);
993 static inline int obd_destroy_export(struct obd_export *exp)
996 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
997 OBP(exp->exp_obd, destroy_export))
998 OBP(exp->exp_obd, destroy_export)(exp);
1002 /* @max_age is the oldest time in seconds that we accept using a cached data.
1003 * If the cache is older than @max_age we will get a new value from the
1004 * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
1006 static inline int obd_statfs_async(struct obd_export *exp,
1007 struct obd_info *oinfo,
1009 struct ptlrpc_request_set *rqset)
1011 struct obd_device *obd;
1016 if (exp == NULL || exp->exp_obd == NULL)
1020 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) {
1022 CERROR("%s: no statfs operation: rc = %d\n", obd->obd_name, rc);
1026 CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
1027 obd->obd_name, obd->obd_osfs_age, max_age);
1028 rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
1033 /* @max_age is the oldest time in seconds that we accept using a cached data.
1034 * If the cache is older than @max_age we will get a new value from the
1035 * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
1037 static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
1038 struct obd_statfs *osfs, time64_t max_age,
1041 struct obd_device *obd = exp->exp_obd;
1045 if (unlikely(obd == NULL))
1048 OBD_CHECK_DEV_ACTIVE(obd);
1050 if (unlikely(!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs)) {
1051 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
1052 RETURN(-EOPNOTSUPP);
1055 CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
1056 obd->obd_name, obd->obd_osfs_age, max_age);
1057 /* ignore cache if aggregated isn't expected */
1058 if (obd->obd_osfs_age < max_age ||
1059 ((obd->obd_osfs.os_state & OS_STATE_SUM) &&
1060 !(flags & OBD_STATFS_SUM))) {
1061 bool update_age = false;
1062 /* the RPC will block anyway, so avoid sending many at once */
1063 rc = mutex_lock_interruptible(&obd->obd_dev_mutex);
1066 if (obd->obd_osfs_age < max_age ||
1067 ((obd->obd_osfs.os_state & OS_STATE_SUM) &&
1068 !(flags & OBD_STATFS_SUM))) {
1069 rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
1073 "%s: new %p cache blocks %llu/%llu objects %llu/%llu\n",
1074 obd->obd_name, &obd->obd_osfs,
1075 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1076 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1079 spin_lock(&obd->obd_osfs_lock);
1080 memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
1082 obd->obd_osfs_age = ktime_get_seconds();
1083 spin_unlock(&obd->obd_osfs_lock);
1085 mutex_unlock(&obd->obd_dev_mutex);
1088 "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
1089 obd->obd_name, &obd->obd_osfs,
1090 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1091 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1092 spin_lock(&obd->obd_osfs_lock);
1093 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
1094 spin_unlock(&obd->obd_osfs_lock);
1099 static inline int obd_preprw(const struct lu_env *env, int cmd,
1100 struct obd_export *exp, struct obdo *oa,
1101 int objcount, struct obd_ioobj *obj,
1102 struct niobuf_remote *remote, int *pages,
1103 struct niobuf_local *local)
1109 rc = exp_check_ops(exp);
1113 if (!exp->exp_obd->obd_type->typ_dt_ops->o_preprw) {
1114 CERROR("%s: no %s operation\n",
1115 (exp)->exp_obd->obd_name, __func__);
1119 rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote,
1125 static inline int obd_commitrw(const struct lu_env *env, int cmd,
1126 struct obd_export *exp, struct obdo *oa,
1127 int objcount, struct obd_ioobj *obj,
1128 struct niobuf_remote *rnb, int pages,
1129 struct niobuf_local *local, const int orig_rc)
1134 rc = exp_check_ops(exp);
1138 if (!exp->exp_obd->obd_type->typ_dt_ops->o_commitrw) {
1139 CERROR("%s: no %s operation\n",
1140 (exp)->exp_obd->obd_name, __func__);
1144 rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj,
1145 rnb, pages, local, orig_rc);
1150 static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
1151 int len, void *karg, void __user *uarg)
1156 rc = exp_check_ops(exp);
1160 if (!exp->exp_obd->obd_type->typ_dt_ops->o_iocontrol) {
1161 CERROR("%s: no %s operation\n",
1162 (exp)->exp_obd->obd_name, __func__);
1166 rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
1170 static inline void obd_import_event(struct obd_device *obd,
1171 struct obd_import *imp,
1172 enum obd_import_event event)
1176 CERROR("NULL device\n");
1181 if (obd->obd_set_up && OBP(obd, import_event))
1182 OBP(obd, import_event)(obd, imp, event);
1187 static inline int obd_notify(struct obd_device *obd,
1188 struct obd_device *watched,
1189 enum obd_notify_event ev)
1194 rc = obd_check_dev(obd);
1198 if (!obd->obd_set_up) {
1199 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
1203 if (!OBP(obd, notify)) {
1204 CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name);
1208 rc = OBP(obd, notify)(obd, watched, ev);
1213 static inline int obd_notify_observer(struct obd_device *observer,
1214 struct obd_device *observed,
1215 enum obd_notify_event ev)
1219 struct obd_notify_upcall *onu;
1221 if (observer->obd_observer)
1222 rc = obd_notify(observer->obd_observer, observed, ev);
1225 * Also, call non-obd listener, if any
1227 onu = &observer->obd_upcall;
1228 if (onu->onu_upcall != NULL)
1229 rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner);
1231 return rc ? rc : rc2;
1234 static inline int obd_quotactl(struct obd_export *exp,
1235 struct obd_quotactl *oqctl)
1240 rc = exp_check_ops(exp);
1244 if (!exp->exp_obd->obd_type->typ_dt_ops->o_quotactl) {
1245 CERROR("%s: no %s operation\n",
1246 (exp)->exp_obd->obd_name, __func__);
1250 rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl);
1254 static inline int obd_health_check(const struct lu_env *env,
1255 struct obd_device *obd)
1257 /* returns: 0 on healthy
1258 * >0 on unhealthy + reason code/flag
1259 * however the only suppored reason == 1 right now
1260 * We'll need to define some better reasons
1261 * or flags in the future.
1268 /* NULL method is normal here */
1269 if (obd == NULL || !obd->obd_type) {
1270 CERROR("cleaned up obd\n");
1271 RETURN(-EOPNOTSUPP);
1273 if (!obd->obd_set_up || obd->obd_stopping)
1275 if (!OBP(obd, health_check))
1278 rc = OBP(obd, health_check)(env, obd);
1282 static inline int obd_register_observer(struct obd_device *obd,
1283 struct obd_device *observer)
1288 rc = obd_check_dev(obd);
1292 down_write(&obd->obd_observer_link_sem);
1293 if (obd->obd_observer && observer) {
1294 up_write(&obd->obd_observer_link_sem);
1297 obd->obd_observer = observer;
1298 up_write(&obd->obd_observer_link_sem);
1302 /* metadata helpers */
1308 LPROC_MD_INTENT_LOCK,
1317 LPROC_MD_INTENT_GETATTR_ASYNC,
1318 LPROC_MD_REVALIDATE_LOCK,
1322 static inline int md_get_root(struct obd_export *exp, const char *fileset,
1327 rc = exp_check_ops(exp);
1331 return MDP(exp->exp_obd, get_root)(exp, fileset, fid);
1334 static inline int md_getattr(struct obd_export *exp,
1335 struct md_op_data *op_data,
1336 struct ptlrpc_request **request)
1340 rc = exp_check_ops(exp);
1344 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1347 return MDP(exp->exp_obd, getattr)(exp, op_data, request);
1350 static inline int md_null_inode(struct obd_export *exp,
1351 const struct lu_fid *fid)
1355 rc = exp_check_ops(exp);
1359 return MDP(exp->exp_obd, null_inode)(exp, fid);
1362 static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,
1363 struct md_open_data *mod,
1364 struct ptlrpc_request **request)
1368 rc = exp_check_ops(exp);
1372 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1375 return MDP(exp->exp_obd, close)(exp, op_data, mod, request);
1378 static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
1379 const void *data, size_t datalen, umode_t mode,
1380 uid_t uid, gid_t gid, cfs_cap_t cap_effective,
1381 __u64 rdev, struct ptlrpc_request **request)
1385 rc = exp_check_ops(exp);
1389 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1392 return MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode,
1393 uid, gid, cap_effective, rdev,
1397 static inline int md_enqueue(struct obd_export *exp,
1398 struct ldlm_enqueue_info *einfo,
1399 const union ldlm_policy_data *policy,
1400 struct md_op_data *op_data,
1401 struct lustre_handle *lockh,
1402 __u64 extra_lock_flags)
1406 rc = exp_check_ops(exp);
1410 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1413 return MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh,
1417 static inline int md_getattr_name(struct obd_export *exp,
1418 struct md_op_data *op_data,
1419 struct ptlrpc_request **request)
1423 rc = exp_check_ops(exp);
1427 return MDP(exp->exp_obd, getattr_name)(exp, op_data, request);
1430 static inline int md_intent_lock(struct obd_export *exp,
1431 struct md_op_data *op_data,
1432 struct lookup_intent *it,
1433 struct ptlrpc_request **reqp,
1434 ldlm_blocking_callback cb_blocking,
1435 __u64 extra_lock_flags)
1439 rc = exp_check_ops(exp);
1443 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1444 LPROC_MD_INTENT_LOCK);
1446 return MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp,
1447 cb_blocking, extra_lock_flags);
1450 static inline int md_link(struct obd_export *exp, struct md_op_data *op_data,
1451 struct ptlrpc_request **request)
1455 rc = exp_check_ops(exp);
1459 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1462 return MDP(exp->exp_obd, link)(exp, op_data, request);
1465 static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data,
1466 const char *old_name, size_t oldlen,
1467 const char *new_name, size_t newlen,
1468 struct ptlrpc_request **request)
1472 rc = exp_check_ops(exp);
1476 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1479 return MDP(exp->exp_obd, rename)(exp, op_data, old_name, oldlen,
1480 new_name, newlen, request);
1483 static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,
1484 void *ea, size_t ealen,
1485 struct ptlrpc_request **request)
1489 rc = exp_check_ops(exp);
1493 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1496 return MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request);
1499 static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid,
1500 struct ptlrpc_request **request)
1504 rc = exp_check_ops(exp);
1508 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1511 return MDP(exp->exp_obd, fsync)(exp, fid, request);
1514 /* FLR: resync mirrored files. */
1515 static inline int md_file_resync(struct obd_export *exp,
1516 struct md_op_data *data)
1520 rc = exp_check_ops(exp);
1524 return MDP(exp->exp_obd, file_resync)(exp, data);
1527 static inline int md_read_page(struct obd_export *exp,
1528 struct md_op_data *op_data,
1529 struct md_callback *cb_op,
1531 struct page **ppage)
1535 rc = exp_check_ops(exp);
1539 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1540 LPROC_MD_READ_PAGE);
1542 return MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset,
1546 static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data,
1547 struct ptlrpc_request **request)
1551 rc = exp_check_ops(exp);
1555 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1558 return MDP(exp->exp_obd, unlink)(exp, op_data, request);
1561 static inline int md_get_lustre_md(struct obd_export *exp,
1562 struct ptlrpc_request *req,
1563 struct obd_export *dt_exp,
1564 struct obd_export *md_exp,
1565 struct lustre_md *md)
1569 rc = exp_check_ops(exp);
1573 return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md);
1576 static inline int md_free_lustre_md(struct obd_export *exp,
1577 struct lustre_md *md)
1581 rc = exp_check_ops(exp);
1585 return MDP(exp->exp_obd, free_lustre_md)(exp, md);
1588 static inline int md_merge_attr(struct obd_export *exp,
1589 const struct lmv_stripe_md *lsm,
1590 struct cl_attr *attr,
1591 ldlm_blocking_callback cb)
1595 rc = exp_check_ops(exp);
1599 return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb);
1602 static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1603 u64 obd_md_valid, const char *name,
1604 const void *value, size_t value_size,
1605 unsigned int xattr_flags, u32 suppgid,
1606 struct ptlrpc_request **req)
1610 rc = exp_check_ops(exp);
1614 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1617 return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name,
1618 value, value_size, xattr_flags,
1622 static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1623 u64 obd_md_valid, const char *name,
1624 size_t buf_size, struct ptlrpc_request **req)
1628 rc = exp_check_ops(exp);
1632 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1635 return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name,
1639 static inline int md_set_open_replay_data(struct obd_export *exp,
1640 struct obd_client_handle *och,
1641 struct lookup_intent *it)
1645 rc = exp_check_ops(exp);
1649 return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it);
1652 static inline int md_clear_open_replay_data(struct obd_export *exp,
1653 struct obd_client_handle *och)
1657 rc = exp_check_ops(exp);
1661 return MDP(exp->exp_obd, clear_open_replay_data)(exp, och);
1664 static inline int md_set_lock_data(struct obd_export *exp,
1665 const struct lustre_handle *lockh,
1666 void *data, __u64 *bits)
1670 rc = exp_check_ops(exp);
1674 return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits);
1678 int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
1679 union ldlm_policy_data *policy, enum ldlm_mode mode,
1680 enum ldlm_cancel_flags cancel_flags, void *opaque)
1684 rc = exp_check_ops(exp);
1688 return MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode,
1689 cancel_flags, opaque);
1692 static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags,
1693 const struct lu_fid *fid,
1694 enum ldlm_type type,
1695 union ldlm_policy_data *policy,
1696 enum ldlm_mode mode,
1697 struct lustre_handle *lockh)
1701 rc = exp_check_ops(exp);
1705 return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type,
1706 policy, mode, lockh);
1709 static inline int md_init_ea_size(struct obd_export *exp, __u32 ea_size,
1714 rc = exp_check_ops(exp);
1718 return MDP(exp->exp_obd, init_ea_size)(exp, ea_size, def_ea_size);
1721 static inline int md_intent_getattr_async(struct obd_export *exp,
1722 struct md_enqueue_info *minfo)
1726 rc = exp_check_ops(exp);
1730 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1731 LPROC_MD_INTENT_GETATTR_ASYNC);
1733 return MDP(exp->exp_obd, intent_getattr_async)(exp, minfo);
1736 static inline int md_revalidate_lock(struct obd_export *exp,
1737 struct lookup_intent *it,
1738 struct lu_fid *fid, __u64 *bits)
1742 rc = exp_check_ops(exp);
1746 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1747 LPROC_MD_REVALIDATE_LOCK);
1749 return MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits);
1752 static inline int md_get_fid_from_lsm(struct obd_export *exp,
1753 const struct lmv_stripe_md *lsm,
1754 const char *name, int namelen,
1759 rc = exp_check_ops(exp);
1763 return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen,
1767 /* Unpack an MD struct from disk to in-memory format.
1768 * Returns +ve size of unpacked MD (0 for free), or -ve error.
1770 * If *plsm != NULL and lmm == NULL then *lsm will be freed.
1771 * If *plsm == NULL then it will be allocated.
1773 static inline int md_unpackmd(struct obd_export *exp,
1774 struct lmv_stripe_md **plsm,
1775 const union lmv_mds_md *lmm, size_t lmm_size)
1779 rc = exp_check_ops(exp);
1783 return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size);
1786 /* OBD Metadata Support */
1788 extern int obd_init_caches(void);
1789 extern void obd_cleanup_caches(void);
1791 typedef int (*register_lwp_cb)(void *data);
1793 struct lwp_register_item {
1794 struct obd_export **lri_exp;
1795 register_lwp_cb lri_cb_func;
1797 struct list_head lri_list;
1799 char lri_name[MTI_NAME_MAXLEN];
1802 /* I'm as embarrassed about this as you are.
1804 * <shaver> // XXX do not look into _superhack with remaining eye
1805 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
1806 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
1809 #ifdef HAVE_SERVER_SUPPORT
1810 int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
1811 register_lwp_cb cb_func, void *cb_data);
1812 void lustre_deregister_lwp_item(struct obd_export **exp);
1813 struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx);
1814 void lustre_notify_lwp_list(struct obd_export *exp);
1815 int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx);
1816 #endif /* HAVE_SERVER_SUPPORT */
1817 int lustre_register_fs(void);
1818 int lustre_unregister_fs(void);
1819 int lustre_check_exclusion(struct super_block *sb, char *svname);
1822 int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
1823 int class_add_uuid(const char *uuid, __u64 nid);
1824 int class_del_uuid (const char *uuid);
1825 int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
1828 extern char obd_jobid_name[];
1832 void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
1833 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
1835 /* root squash info */
1836 struct rw_semaphore;
1837 struct root_squash_info {
1840 struct list_head rsi_nosquash_nids;
1841 struct rw_semaphore rsi_sem;
1844 int server_name2index(const char *svname, __u32 *idx, const char **endptr);
1846 /* linux-module.c */
1847 extern struct miscdevice obd_psdev;
1848 int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
1849 int class_procfs_init(void);
1850 int class_procfs_clean(void);
1852 extern void obd_heat_add(struct obd_heat_instance *instance,
1853 unsigned int time_second, __u64 count,
1854 unsigned int weight, unsigned int period_second);
1855 extern void obd_heat_decay(struct obd_heat_instance *instance,
1856 __u64 time_second, unsigned int weight,
1857 unsigned int period_second);
1858 extern __u64 obd_heat_get(struct obd_heat_instance *instance,
1859 unsigned int time_second, unsigned int weight,
1860 unsigned int period_second);
1861 extern void obd_heat_clear(struct obd_heat_instance *instance, int count);
1862 #endif /* __LINUX_OBD_CLASS_H */