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 * typ_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 rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
1063 spin_lock(&obd->obd_osfs_lock);
1064 memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
1065 obd->obd_osfs_age = ktime_get_seconds();
1066 spin_unlock(&obd->obd_osfs_lock);
1070 "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
1071 obd->obd_name, &obd->obd_osfs,
1072 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1073 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1074 spin_lock(&obd->obd_osfs_lock);
1075 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
1076 spin_unlock(&obd->obd_osfs_lock);
1081 static inline int obd_preprw(const struct lu_env *env, int cmd,
1082 struct obd_export *exp, struct obdo *oa,
1083 int objcount, struct obd_ioobj *obj,
1084 struct niobuf_remote *remote, int *pages,
1085 struct niobuf_local *local)
1091 rc = exp_check_ops(exp);
1095 if (!exp->exp_obd->obd_type->typ_dt_ops->o_preprw) {
1096 CERROR("%s: no %s operation\n",
1097 (exp)->exp_obd->obd_name, __func__);
1101 rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote,
1107 static inline int obd_commitrw(const struct lu_env *env, int cmd,
1108 struct obd_export *exp, struct obdo *oa,
1109 int objcount, struct obd_ioobj *obj,
1110 struct niobuf_remote *rnb, int pages,
1111 struct niobuf_local *local, const int orig_rc)
1116 rc = exp_check_ops(exp);
1120 if (!exp->exp_obd->obd_type->typ_dt_ops->o_commitrw) {
1121 CERROR("%s: no %s operation\n",
1122 (exp)->exp_obd->obd_name, __func__);
1126 rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj,
1127 rnb, pages, local, orig_rc);
1132 static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
1133 int len, void *karg, void __user *uarg)
1138 rc = exp_check_ops(exp);
1142 if (!exp->exp_obd->obd_type->typ_dt_ops->o_iocontrol) {
1143 CERROR("%s: no %s operation\n",
1144 (exp)->exp_obd->obd_name, __func__);
1148 rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
1152 static inline void obd_import_event(struct obd_device *obd,
1153 struct obd_import *imp,
1154 enum obd_import_event event)
1158 CERROR("NULL device\n");
1163 if (obd->obd_set_up && OBP(obd, import_event))
1164 OBP(obd, import_event)(obd, imp, event);
1169 static inline int obd_notify(struct obd_device *obd,
1170 struct obd_device *watched,
1171 enum obd_notify_event ev)
1176 rc = obd_check_dev(obd);
1180 if (!obd->obd_set_up) {
1181 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
1185 if (!OBP(obd, notify)) {
1186 CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name);
1190 rc = OBP(obd, notify)(obd, watched, ev);
1195 static inline int obd_notify_observer(struct obd_device *observer,
1196 struct obd_device *observed,
1197 enum obd_notify_event ev)
1201 struct obd_notify_upcall *onu;
1203 if (observer->obd_observer)
1204 rc = obd_notify(observer->obd_observer, observed, ev);
1207 * Also, call non-obd listener, if any
1209 onu = &observer->obd_upcall;
1210 if (onu->onu_upcall != NULL)
1211 rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner);
1213 return rc ? rc : rc2;
1216 static inline int obd_quotactl(struct obd_export *exp,
1217 struct obd_quotactl *oqctl)
1222 rc = exp_check_ops(exp);
1226 if (!exp->exp_obd->obd_type->typ_dt_ops->o_quotactl) {
1227 CERROR("%s: no %s operation\n",
1228 (exp)->exp_obd->obd_name, __func__);
1232 rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl);
1236 static inline int obd_health_check(const struct lu_env *env,
1237 struct obd_device *obd)
1239 /* returns: 0 on healthy
1240 * >0 on unhealthy + reason code/flag
1241 * however the only suppored reason == 1 right now
1242 * We'll need to define some better reasons
1243 * or flags in the future.
1250 /* NULL method is normal here */
1251 if (obd == NULL || !obd->obd_type) {
1252 CERROR("cleaned up obd\n");
1253 RETURN(-EOPNOTSUPP);
1255 if (!obd->obd_set_up || obd->obd_stopping)
1257 if (!OBP(obd, health_check))
1260 rc = OBP(obd, health_check)(env, obd);
1264 static inline int obd_register_observer(struct obd_device *obd,
1265 struct obd_device *observer)
1270 rc = obd_check_dev(obd);
1274 down_write(&obd->obd_observer_link_sem);
1275 if (obd->obd_observer && observer) {
1276 up_write(&obd->obd_observer_link_sem);
1279 obd->obd_observer = observer;
1280 up_write(&obd->obd_observer_link_sem);
1284 /* metadata helpers */
1290 LPROC_MD_INTENT_LOCK,
1299 LPROC_MD_INTENT_GETATTR_ASYNC,
1300 LPROC_MD_REVALIDATE_LOCK,
1304 static inline int md_get_root(struct obd_export *exp, const char *fileset,
1309 rc = exp_check_ops(exp);
1313 return MDP(exp->exp_obd, get_root)(exp, fileset, fid);
1316 static inline int md_getattr(struct obd_export *exp,
1317 struct md_op_data *op_data,
1318 struct ptlrpc_request **request)
1322 rc = exp_check_ops(exp);
1326 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1329 return MDP(exp->exp_obd, getattr)(exp, op_data, request);
1332 static inline int md_null_inode(struct obd_export *exp,
1333 const struct lu_fid *fid)
1337 rc = exp_check_ops(exp);
1341 return MDP(exp->exp_obd, null_inode)(exp, fid);
1344 static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,
1345 struct md_open_data *mod,
1346 struct ptlrpc_request **request)
1350 rc = exp_check_ops(exp);
1354 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1357 return MDP(exp->exp_obd, close)(exp, op_data, mod, request);
1360 static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
1361 const void *data, size_t datalen, umode_t mode,
1362 uid_t uid, gid_t gid, cfs_cap_t cap_effective,
1363 __u64 rdev, struct ptlrpc_request **request)
1367 rc = exp_check_ops(exp);
1371 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1374 return MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode,
1375 uid, gid, cap_effective, rdev,
1379 static inline int md_enqueue(struct obd_export *exp,
1380 struct ldlm_enqueue_info *einfo,
1381 const union ldlm_policy_data *policy,
1382 struct md_op_data *op_data,
1383 struct lustre_handle *lockh,
1384 __u64 extra_lock_flags)
1388 rc = exp_check_ops(exp);
1392 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1395 return MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh,
1399 static inline int md_getattr_name(struct obd_export *exp,
1400 struct md_op_data *op_data,
1401 struct ptlrpc_request **request)
1405 rc = exp_check_ops(exp);
1409 return MDP(exp->exp_obd, getattr_name)(exp, op_data, request);
1412 static inline int md_intent_lock(struct obd_export *exp,
1413 struct md_op_data *op_data,
1414 struct lookup_intent *it,
1415 struct ptlrpc_request **reqp,
1416 ldlm_blocking_callback cb_blocking,
1417 __u64 extra_lock_flags)
1421 rc = exp_check_ops(exp);
1425 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1426 LPROC_MD_INTENT_LOCK);
1428 return MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp,
1429 cb_blocking, extra_lock_flags);
1432 static inline int md_link(struct obd_export *exp, struct md_op_data *op_data,
1433 struct ptlrpc_request **request)
1437 rc = exp_check_ops(exp);
1441 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1444 return MDP(exp->exp_obd, link)(exp, op_data, request);
1447 static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data,
1448 const char *old_name, size_t oldlen,
1449 const char *new_name, size_t newlen,
1450 struct ptlrpc_request **request)
1454 rc = exp_check_ops(exp);
1458 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1461 return MDP(exp->exp_obd, rename)(exp, op_data, old_name, oldlen,
1462 new_name, newlen, request);
1465 static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,
1466 void *ea, size_t ealen,
1467 struct ptlrpc_request **request)
1471 rc = exp_check_ops(exp);
1475 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1478 return MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request);
1481 static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid,
1482 struct ptlrpc_request **request)
1486 rc = exp_check_ops(exp);
1490 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1493 return MDP(exp->exp_obd, fsync)(exp, fid, request);
1496 /* FLR: resync mirrored files. */
1497 static inline int md_file_resync(struct obd_export *exp,
1498 struct md_op_data *data)
1502 rc = exp_check_ops(exp);
1506 return MDP(exp->exp_obd, file_resync)(exp, data);
1509 static inline int md_read_page(struct obd_export *exp,
1510 struct md_op_data *op_data,
1511 struct md_callback *cb_op,
1513 struct page **ppage)
1517 rc = exp_check_ops(exp);
1521 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1522 LPROC_MD_READ_PAGE);
1524 return MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset,
1528 static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data,
1529 struct ptlrpc_request **request)
1533 rc = exp_check_ops(exp);
1537 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1540 return MDP(exp->exp_obd, unlink)(exp, op_data, request);
1543 static inline int md_get_lustre_md(struct obd_export *exp,
1544 struct ptlrpc_request *req,
1545 struct obd_export *dt_exp,
1546 struct obd_export *md_exp,
1547 struct lustre_md *md)
1551 rc = exp_check_ops(exp);
1555 return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md);
1558 static inline int md_free_lustre_md(struct obd_export *exp,
1559 struct lustre_md *md)
1563 rc = exp_check_ops(exp);
1567 return MDP(exp->exp_obd, free_lustre_md)(exp, md);
1570 static inline int md_merge_attr(struct obd_export *exp,
1571 const struct lmv_stripe_md *lsm,
1572 struct cl_attr *attr,
1573 ldlm_blocking_callback cb)
1577 rc = exp_check_ops(exp);
1581 return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb);
1584 static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1585 u64 obd_md_valid, const char *name,
1586 const void *value, size_t value_size,
1587 unsigned int xattr_flags, u32 suppgid,
1588 struct ptlrpc_request **req)
1592 rc = exp_check_ops(exp);
1596 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1599 return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name,
1600 value, value_size, xattr_flags,
1604 static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1605 u64 obd_md_valid, const char *name,
1606 size_t buf_size, 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, getxattr)(exp, fid, obd_md_valid, name,
1621 static inline int md_set_open_replay_data(struct obd_export *exp,
1622 struct obd_client_handle *och,
1623 struct lookup_intent *it)
1627 rc = exp_check_ops(exp);
1631 return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it);
1634 static inline int md_clear_open_replay_data(struct obd_export *exp,
1635 struct obd_client_handle *och)
1639 rc = exp_check_ops(exp);
1643 return MDP(exp->exp_obd, clear_open_replay_data)(exp, och);
1646 static inline int md_set_lock_data(struct obd_export *exp,
1647 const struct lustre_handle *lockh,
1648 void *data, __u64 *bits)
1652 rc = exp_check_ops(exp);
1656 return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits);
1660 int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
1661 union ldlm_policy_data *policy, enum ldlm_mode mode,
1662 enum ldlm_cancel_flags cancel_flags, void *opaque)
1666 rc = exp_check_ops(exp);
1670 return MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode,
1671 cancel_flags, opaque);
1674 static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags,
1675 const struct lu_fid *fid,
1676 enum ldlm_type type,
1677 union ldlm_policy_data *policy,
1678 enum ldlm_mode mode,
1679 struct lustre_handle *lockh)
1683 rc = exp_check_ops(exp);
1687 return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type,
1688 policy, mode, lockh);
1691 static inline int md_init_ea_size(struct obd_export *exp, __u32 ea_size,
1696 rc = exp_check_ops(exp);
1700 return MDP(exp->exp_obd, init_ea_size)(exp, ea_size, def_ea_size);
1703 static inline int md_intent_getattr_async(struct obd_export *exp,
1704 struct md_enqueue_info *minfo)
1708 rc = exp_check_ops(exp);
1712 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1713 LPROC_MD_INTENT_GETATTR_ASYNC);
1715 return MDP(exp->exp_obd, intent_getattr_async)(exp, minfo);
1718 static inline int md_revalidate_lock(struct obd_export *exp,
1719 struct lookup_intent *it,
1720 struct lu_fid *fid, __u64 *bits)
1724 rc = exp_check_ops(exp);
1728 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1729 LPROC_MD_REVALIDATE_LOCK);
1731 return MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits);
1734 static inline int md_get_fid_from_lsm(struct obd_export *exp,
1735 const struct lmv_stripe_md *lsm,
1736 const char *name, int namelen,
1741 rc = exp_check_ops(exp);
1745 return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen,
1749 /* Unpack an MD struct from disk to in-memory format.
1750 * Returns +ve size of unpacked MD (0 for free), or -ve error.
1752 * If *plsm != NULL and lmm == NULL then *lsm will be freed.
1753 * If *plsm == NULL then it will be allocated.
1755 static inline int md_unpackmd(struct obd_export *exp,
1756 struct lmv_stripe_md **plsm,
1757 const union lmv_mds_md *lmm, size_t lmm_size)
1761 rc = exp_check_ops(exp);
1765 return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size);
1768 /* OBD Metadata Support */
1770 extern int obd_init_caches(void);
1771 extern void obd_cleanup_caches(void);
1773 typedef int (*register_lwp_cb)(void *data);
1775 struct lwp_register_item {
1776 struct obd_export **lri_exp;
1777 register_lwp_cb lri_cb_func;
1779 struct list_head lri_list;
1781 char lri_name[MTI_NAME_MAXLEN];
1784 /* I'm as embarrassed about this as you are.
1786 * <shaver> // XXX do not look into _superhack with remaining eye
1787 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
1788 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
1791 #ifdef HAVE_SERVER_SUPPORT
1792 int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
1793 register_lwp_cb cb_func, void *cb_data);
1794 void lustre_deregister_lwp_item(struct obd_export **exp);
1795 struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx);
1796 void lustre_notify_lwp_list(struct obd_export *exp);
1797 int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx);
1798 #endif /* HAVE_SERVER_SUPPORT */
1799 int lustre_register_fs(void);
1800 int lustre_unregister_fs(void);
1801 int lustre_check_exclusion(struct super_block *sb, char *svname);
1804 int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
1805 int class_add_uuid(const char *uuid, __u64 nid);
1806 int class_del_uuid (const char *uuid);
1807 int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
1810 extern char obd_jobid_name[];
1814 void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
1815 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
1817 /* root squash info */
1818 struct rw_semaphore;
1819 struct root_squash_info {
1822 struct list_head rsi_nosquash_nids;
1823 struct rw_semaphore rsi_sem;
1826 int server_name2index(const char *svname, __u32 *idx, const char **endptr);
1828 /* linux-module.c */
1829 extern struct miscdevice obd_psdev;
1830 int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
1831 int class_procfs_init(void);
1832 int class_procfs_clean(void);
1834 extern void obd_heat_add(struct obd_heat_instance *instance,
1835 unsigned int time_second, __u64 count,
1836 unsigned int weight, unsigned int period_second);
1837 extern void obd_heat_decay(struct obd_heat_instance *instance,
1838 __u64 time_second, unsigned int weight,
1839 unsigned int period_second);
1840 extern __u64 obd_heat_get(struct obd_heat_instance *instance,
1841 unsigned int time_second, unsigned int weight,
1842 unsigned int period_second);
1843 extern void obd_heat_clear(struct obd_heat_instance *instance, int count);
1844 #endif /* __LINUX_OBD_CLASS_H */