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 void obd_put_mod_rpc_slot(struct client_obd *cli, __u32 opc, __u16 tag);
137 typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
138 struct llog_rec_hdr *, void *);
140 struct obd_export *obd_stale_export_get(void);
141 void obd_stale_export_put(struct obd_export *exp);
142 void obd_stale_export_adjust(struct obd_export *exp);
145 /* For interoperability */
146 struct cfg_interop_param {
151 char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index);
152 struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
153 const char *new_name);
154 void print_lustre_cfg(struct lustre_cfg *lcfg);
155 int class_process_config(struct lustre_cfg *lcfg);
156 ssize_t class_set_global(const char *param);
157 ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
158 struct kobject *kobj);
159 int class_attach(struct lustre_cfg *lcfg);
160 int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
161 int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
162 int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
164 int class_find_param(char *buf, char *key, char **valp);
165 struct cfg_interop_param *class_find_old_param(const char *param,
166 struct cfg_interop_param *ptr);
167 int class_get_next_param(char **params, char *copy);
168 int class_match_param(char *buf, const char *key, char **valp);
169 int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh);
170 int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh);
171 int class_parse_net(char *buf, u32 *net, char **endh);
172 int class_match_nid(char *buf, char *key, lnet_nid_t nid);
173 int class_match_net(char *buf, char *key, u32 net);
175 struct obd_device *class_incref(struct obd_device *obd,
176 const char *scope, const void *source);
177 void class_decref(struct obd_device *obd,
178 const char *scope, const void *source);
179 void dump_exports(struct obd_device *obd, int locks, int debug_level);
180 int class_config_llog_handler(const struct lu_env *env,
181 struct llog_handle *handle,
182 struct llog_rec_hdr *rec, void *data);
183 int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
185 #define CFG_F_START 0x01 /* Set when we start updating from a log */
186 #define CFG_F_MARKER 0x02 /* We are within a maker */
187 #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */
188 #define CFG_F_EXCLUDE 0x10 /* OST exclusion list */
190 /* Passed as data param to class_config_parse_llog */
191 struct config_llog_instance {
192 unsigned long cfg_instance;
193 struct super_block *cfg_sb;
194 struct obd_uuid cfg_uuid;
195 llog_cb_t cfg_callback;
196 int cfg_last_idx; /* for partial llog processing */
201 int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
202 char *name, struct config_llog_instance *cfg);
205 * Generate a unique configuration instance for this mount
207 * Temporary hack to bypass ASLR in 4.15+ kernels, a better fix soon.
208 * For now, use the same value as before - the superblock pointer value.
210 * Using the client UUID would be an option, but it needs more testing.
212 static inline unsigned long ll_get_cfg_instance(struct super_block *sb)
214 return (unsigned long)sb;
217 #define CONFIG_SUB_SPTLRPC 0x01
218 #define CONFIG_SUB_RECOVER 0x02
219 #define CONFIG_SUB_PARAMS 0x04
220 #define CONFIG_SUB_NODEMAP 0x08
221 #define CONFIG_SUB_BARRIER 0x10
223 /* Sub clds should be attached to the config_llog_data when processing
224 * config log for client or server target. */
225 #define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \
227 #define CONFIG_SUB_SERVER (CONFIG_SUB_CLIENT | CONFIG_SUB_NODEMAP | \
230 #define PARAMS_FILENAME "params"
231 #define BARRIER_FILENAME "barrier"
232 #define LCTL_UPCALL "lctl"
234 static inline bool logname_is_barrier(const char *logname)
238 /* logname for barrier is "fsname-barrier" */
239 ptr = strstr(logname, BARRIER_FILENAME);
240 if (ptr && (ptr - logname) >= 2 &&
241 *(ptr - 1) == '-' && *(ptr + 7) == '\0')
247 /* list of active configuration logs */
248 struct config_llog_data {
249 struct ldlm_res_id cld_resid;
250 struct lustre_handle cld_lockh;
251 struct config_llog_instance cld_cfg;
252 struct list_head cld_list_chain;/* on config_llog_list */
253 atomic_t cld_refcount;
254 struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */
255 struct config_llog_data *cld_params; /* common parameters log */
256 struct config_llog_data *cld_recover;/* imperative recover log */
257 struct config_llog_data *cld_nodemap;/* nodemap log */
258 struct config_llog_data *cld_barrier;/* barrier log (for MDT only) */
259 struct obd_export *cld_mgcexp;
260 struct mutex cld_lock;
262 unsigned int cld_stopping:1, /* we were told to stop
264 cld_lostlock:1; /* lock not requeued */
268 struct lustre_profile {
269 struct list_head lp_list;
274 bool lp_list_deleted;
277 struct lustre_profile *class_get_profile(const char * prof);
278 void class_del_profile(const char *prof);
279 void class_put_profile(struct lustre_profile *lprof);
280 void class_del_profiles(void);
283 #if LUSTRE_TRACKS_LOCK_EXP_REFS
285 void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *);
286 void __class_export_del_lock_ref(struct obd_export *, struct ldlm_lock *);
287 extern void (*class_export_dump_hook)(struct obd_export *);
291 #define __class_export_add_lock_ref(exp, lock) do {} while(0)
292 #define __class_export_del_lock_ref(exp, lock) do {} while(0)
296 #define class_export_rpc_inc(exp) \
298 atomic_inc(&(exp)->exp_rpc_count); \
299 CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \
300 (exp), atomic_read(&(exp)->exp_rpc_count)); \
303 #define class_export_rpc_dec(exp) \
305 LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \
306 atomic_dec(&(exp)->exp_rpc_count); \
307 CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \
308 (exp), atomic_read(&(exp)->exp_rpc_count)); \
311 #define class_export_lock_get(exp, lock) \
313 atomic_inc(&(exp)->exp_locks_count); \
314 __class_export_add_lock_ref(exp, lock); \
315 CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \
316 (exp), atomic_read(&(exp)->exp_locks_count)); \
317 class_export_get(exp); \
320 #define class_export_lock_put(exp, lock) \
322 LASSERT_ATOMIC_POS(&exp->exp_locks_count); \
323 atomic_dec(&(exp)->exp_locks_count); \
324 __class_export_del_lock_ref(exp, lock); \
325 CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \
326 (exp), atomic_read(&(exp)->exp_locks_count)); \
327 class_export_put(exp); \
330 #define class_export_cb_get(exp) \
332 atomic_inc(&(exp)->exp_cb_count); \
333 CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\
334 (exp), atomic_read(&(exp)->exp_cb_count)); \
335 class_export_get(exp); \
338 #define class_export_cb_put(exp) \
340 LASSERT_ATOMIC_POS(&exp->exp_cb_count); \
341 atomic_dec(&(exp)->exp_cb_count); \
342 CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\
343 (exp), atomic_read(&(exp)->exp_cb_count)); \
344 class_export_put(exp); \
348 struct obd_export *class_export_get(struct obd_export *exp);
349 void class_export_put(struct obd_export *exp);
350 struct obd_export *class_new_export(struct obd_device *obddev,
351 struct obd_uuid *cluuid);
352 struct obd_export *class_new_export_self(struct obd_device *obd,
353 struct obd_uuid *uuid);
354 void class_unlink_export(struct obd_export *exp);
356 struct obd_import *class_import_get(struct obd_import *);
357 void class_import_put(struct obd_import *);
358 struct obd_import *class_new_import(struct obd_device *obd);
359 void class_destroy_import(struct obd_import *exp);
361 #ifdef HAVE_SERVER_SUPPORT
362 struct obd_type *class_search_type(const char *name);
363 struct obd_type *class_get_type(const char *name);
365 void class_put_type(struct obd_type *type);
366 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
367 struct obd_uuid *cluuid);
368 int class_disconnect(struct obd_export *exp);
369 void class_fail_export(struct obd_export *exp);
370 int class_connected_export(struct obd_export *exp);
371 void class_disconnect_exports(struct obd_device *obddev);
372 int class_manual_cleanup(struct obd_device *obd);
373 void class_disconnect_stale_exports(struct obd_device *,
374 int (*test_export)(struct obd_export *));
376 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
378 return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
379 (obd->obd_force ? OBD_OPT_FORCE : 0) |
380 (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) |
384 #ifdef HAVE_SERVER_SUPPORT
385 static inline struct lu_target *class_exp2tgt(struct obd_export *exp)
387 LASSERT(exp->exp_obd);
388 if (exp->exp_obd->u.obt.obt_magic != OBT_MAGIC)
390 return exp->exp_obd->u.obt.obt_lut;
393 static inline struct lr_server_data *class_server_data(struct obd_device *obd)
395 LASSERT(obd->u.obt.obt_lut);
396 return &obd->u.obt.obt_lut->lut_lsd;
404 void obdo_from_la(struct obdo *dst, const struct lu_attr *la, u64 valid);
405 void la_from_obdo(struct lu_attr *la, const struct obdo *dst, u64 valid);
407 void obdo_cpy_md(struct obdo *dst, const struct obdo *src, u64 valid);
408 void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj);
410 #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op
411 #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op
413 static inline int obd_check_dev(struct obd_device *obd)
416 CERROR("NULL device\n");
422 /* ensure obd_setup and !obd_stopping */
423 #define OBD_CHECK_DEV_ACTIVE(obd) \
425 rc = obd_check_dev(obd); \
429 if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
430 CERROR("Device %d not setup\n", \
437 static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp)
439 /* Always add in ldlm_stats */
440 tmp->nid_ldlm_stats =
441 lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC,
442 LPROCFS_STATS_FLAG_NOPERCPU);
443 if (tmp->nid_ldlm_stats == NULL)
446 lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
448 return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats",
449 tmp->nid_ldlm_stats);
452 static inline int exp_check_ops(struct obd_export *exp)
457 if (exp->exp_obd == NULL || !exp->exp_obd->obd_type) {
463 static inline int class_devno_max(void)
465 return MAX_OBD_DEVICES;
468 static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp,
469 __u32 keylen, void *key,
470 __u32 *vallen, void *val)
475 rc = exp_check_ops(exp);
479 if (!exp->exp_obd->obd_type->typ_dt_ops->o_get_info) {
480 CERROR("%s: no %s operation\n",
481 (exp)->exp_obd->obd_name, __func__);
485 rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val);
489 static inline int obd_set_info_async(const struct lu_env *env,
490 struct obd_export *exp,
491 __u32 keylen, void *key,
492 __u32 vallen, void *val,
493 struct ptlrpc_request_set *set)
498 rc = exp_check_ops(exp);
502 if (!exp->exp_obd->obd_type->typ_dt_ops->o_set_info_async) {
503 CERROR("%s: no %s operation\n",
504 (exp)->exp_obd->obd_name, __func__);
508 rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen,
514 * obd-lu integration.
516 * Functionality is being moved into new lu_device-based layering, but some
517 * pieces of configuration process are still based on obd devices.
519 * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully
520 * subsume ->o_setup() methods of obd devices they replace. The same for
521 * lu_device_operations::ldo_process_config() and ->o_process_config(). As a
522 * result, obd_setup() and obd_process_config() branch and call one XOR
525 * Yet neither lu_device_type_operations::ldto_device_fini() nor
526 * lu_device_type_operations::ldto_device_free() fully implement the
527 * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence,
528 * obd_precleanup() and obd_cleanup() call both lu_device and obd operations.
530 static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
533 struct lu_device_type *ldt = obd->obd_type->typ_lu;
539 struct lu_context session_ctx;
541 lu_context_init(&session_ctx, LCT_SESSION | LCT_SERVER_SESSION);
542 session_ctx.lc_thread = NULL;
543 lu_context_enter(&session_ctx);
545 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
547 env.le_ses = &session_ctx;
548 d = ldt->ldt_ops->ldto_device_alloc(&env, ldt, cfg);
557 lu_context_exit(&session_ctx);
558 lu_context_fini(&session_ctx);
561 if (!obd->obd_type->typ_dt_ops->o_setup) {
562 CERROR("%s: no %s operation\n", obd->obd_name,
566 rc = OBP(obd, setup)(obd, cfg);
571 static inline int obd_precleanup(struct obd_device *obd)
574 struct lu_device_type *ldt = obd->obd_type->typ_lu;
575 struct lu_device *d = obd->obd_lu_dev;
579 if (ldt != NULL && d != NULL) {
580 struct lu_env *env = lu_env_find();
585 rc = lu_env_init(env, ldt->ldt_ctx_tags);
589 ldt->ldt_ops->ldto_device_fini(env, d);
596 if (!obd->obd_type->typ_dt_ops->o_precleanup)
599 rc = OBP(obd, precleanup)(obd);
603 static inline int obd_cleanup(struct obd_device *obd)
606 struct lu_device_type *ldt = obd->obd_type->typ_lu;
607 struct lu_device *d = obd->obd_lu_dev;
610 if (ldt != NULL && d != NULL) {
613 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
615 ldt->ldt_ops->ldto_device_free(&env, d);
617 obd->obd_lu_dev = NULL;
620 if (!obd->obd_type->typ_dt_ops->o_cleanup)
623 rc = OBP(obd, cleanup)(obd);
627 static inline void obd_cleanup_client_import(struct obd_device *obd)
631 /* If we set up but never connected, the
632 client import will not have been cleaned. */
633 down_write(&obd->u.cli.cl_sem);
634 if (obd->u.cli.cl_import) {
635 struct obd_import *imp;
636 imp = obd->u.cli.cl_import;
637 CDEBUG(D_CONFIG, "%s: client import never connected\n",
639 ptlrpc_invalidate_import(imp);
640 client_destroy_import(imp);
641 obd->u.cli.cl_import = NULL;
643 up_write(&obd->u.cli.cl_sem);
648 static inline int obd_process_config(struct obd_device *obd, int datalen,
652 struct lu_device_type *ldt = obd->obd_type->typ_lu;
653 struct lu_device *d = obd->obd_lu_dev;
657 obd->obd_process_conf = 1;
658 if (ldt != NULL && d != NULL) {
661 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
663 rc = d->ld_ops->ldo_process_config(&env, d, data);
667 if (!obd->obd_type->typ_dt_ops->o_process_config) {
668 CERROR("%s: no %s operation\n",
669 obd->obd_name, __func__);
672 rc = OBP(obd, process_config)(obd, datalen, data);
675 obd->obd_process_conf = 0;
680 static inline int obd_create(const struct lu_env *env, struct obd_export *exp,
686 rc = exp_check_ops(exp);
690 if (!exp->exp_obd->obd_type->typ_dt_ops->o_create) {
691 CERROR("%s: no %s operation\n",
692 (exp)->exp_obd->obd_name, __func__);
696 rc = OBP(exp->exp_obd, create)(env, exp, obdo);
700 static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp,
706 rc = exp_check_ops(exp);
710 if (!exp->exp_obd->obd_type->typ_dt_ops->o_destroy) {
711 CERROR("%s: no %s operation\n",
712 (exp)->exp_obd->obd_name, __func__);
716 rc = OBP(exp->exp_obd, destroy)(env, exp, obdo);
720 static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp,
726 rc = exp_check_ops(exp);
730 if (!exp->exp_obd->obd_type->typ_dt_ops->o_getattr) {
731 CERROR("%s: no %s operation\n",
732 (exp)->exp_obd->obd_name, __func__);
736 rc = OBP(exp->exp_obd, getattr)(env, exp, oa);
741 static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp,
747 rc = exp_check_ops(exp);
751 if (!exp->exp_obd->obd_type->typ_dt_ops->o_setattr) {
752 CERROR("%s: no %s operation\n",
753 (exp)->exp_obd->obd_name, __func__);
757 rc = OBP(exp->exp_obd, setattr)(env, exp, oa);
762 static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
765 struct obd_device *obd = imp->imp_obd;
769 OBD_CHECK_DEV_ACTIVE(obd);
770 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_add_conn) {
771 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
775 rc = OBP(obd, add_conn)(imp, uuid, priority);
779 static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
781 struct obd_device *obd = imp->imp_obd;
785 OBD_CHECK_DEV_ACTIVE(obd);
786 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_del_conn) {
787 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
791 rc = OBP(obd, del_conn)(imp, uuid);
795 static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp)
797 struct obd_uuid *uuid;
800 if (!exp->exp_obd->obd_type ||
801 !exp->exp_obd->obd_type->typ_dt_ops->o_get_uuid)
804 uuid = OBP(exp->exp_obd, get_uuid)(exp);
808 /** Create a new /a exp on device /a obd for the uuid /a cluuid
809 * @param exp New export handle
810 * @param d Connect data, supported flags are set, flags also understood
811 * by obd are returned.
813 static inline int obd_connect(const struct lu_env *env,
814 struct obd_export **exp,struct obd_device *obd,
815 struct obd_uuid *cluuid,
816 struct obd_connect_data *data,
820 __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition
824 OBD_CHECK_DEV_ACTIVE(obd);
825 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_connect) {
826 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
830 rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata);
831 /* check that only subset is granted */
832 LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) ==
833 data->ocd_connect_flags));
837 static inline int obd_reconnect(const struct lu_env *env,
838 struct obd_export *exp,
839 struct obd_device *obd,
840 struct obd_uuid *cluuid,
841 struct obd_connect_data *d,
845 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition
850 OBD_CHECK_DEV_ACTIVE(obd);
851 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_reconnect)
854 rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata);
855 /* check that only subset is granted */
856 LASSERT(ergo(d != NULL,
857 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
861 static inline int obd_disconnect(struct obd_export *exp)
865 rc = exp_check_ops(exp);
869 if (!exp->exp_obd->obd_type->typ_dt_ops->o_disconnect) {
870 CERROR("%s: no %s operation\n",
871 (exp)->exp_obd->obd_name, __func__);
875 rc = OBP(exp->exp_obd, disconnect)(exp);
879 static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp,
880 enum lu_cli_type type)
885 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_init)
888 rc = OBP(obd, fid_init)(obd, exp, type);
892 static inline int obd_fid_fini(struct obd_device *obd)
896 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_fini)
899 rc = OBP(obd, fid_fini)(obd);
903 static inline int obd_fid_alloc(const struct lu_env *env,
904 struct obd_export *exp,
906 struct md_op_data *op_data)
910 rc = exp_check_ops(exp);
914 if (!exp->exp_obd->obd_type->typ_dt_ops->o_fid_alloc) {
915 CERROR("%s: no %s operation\n",
916 (exp)->exp_obd->obd_name, __func__);
920 rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data);
924 static inline int obd_pool_new(struct obd_device *obd, char *poolname)
929 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_new) {
930 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
934 rc = OBP(obd, pool_new)(obd, poolname);
938 static inline int obd_pool_del(struct obd_device *obd, char *poolname)
942 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_del) {
943 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
947 rc = OBP(obd, pool_del)(obd, poolname);
951 static inline int obd_pool_add(struct obd_device *obd, char *poolname,
957 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_add) {
958 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
962 rc = OBP(obd, pool_add)(obd, poolname, ostname);
966 static inline int obd_pool_rem(struct obd_device *obd, char *poolname,
972 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_rem) {
973 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
977 rc = OBP(obd, pool_rem)(obd, poolname, ostname);
981 static inline int obd_init_export(struct obd_export *exp)
986 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
987 OBP((exp)->exp_obd, init_export))
988 rc = OBP(exp->exp_obd, init_export)(exp);
992 static inline int obd_destroy_export(struct obd_export *exp)
995 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
996 OBP(exp->exp_obd, destroy_export))
997 OBP(exp->exp_obd, destroy_export)(exp);
1001 /* @max_age is the oldest time in seconds that we accept using a cached data.
1002 * If the cache is older than @max_age we will get a new value from the
1003 * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
1005 static inline int obd_statfs_async(struct obd_export *exp,
1006 struct obd_info *oinfo,
1008 struct ptlrpc_request_set *rqset)
1010 struct obd_device *obd;
1015 if (exp == NULL || exp->exp_obd == NULL)
1019 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) {
1021 CERROR("%s: no statfs operation: rc = %d\n", obd->obd_name, rc);
1025 CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
1026 obd->obd_name, obd->obd_osfs_age, max_age);
1027 rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
1032 /* @max_age is the oldest time in seconds that we accept using a cached data.
1033 * If the cache is older than @max_age we will get a new value from the
1034 * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
1036 static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
1037 struct obd_statfs *osfs, time64_t max_age,
1040 struct obd_device *obd = exp->exp_obd;
1044 if (unlikely(obd == NULL))
1047 OBD_CHECK_DEV_ACTIVE(obd);
1049 if (unlikely(!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs)) {
1050 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
1051 RETURN(-EOPNOTSUPP);
1054 CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
1055 obd->obd_name, obd->obd_osfs_age, max_age);
1056 /* ignore cache if aggregated isn't expected */
1057 if (obd->obd_osfs_age < max_age ||
1058 ((obd->obd_osfs.os_state & OS_STATE_SUM) &&
1059 !(flags & OBD_STATFS_SUM))) {
1060 bool update_age = false;
1061 /* the RPC will block anyway, so avoid sending many at once */
1062 rc = mutex_lock_interruptible(&obd->obd_dev_mutex);
1065 if (obd->obd_osfs_age < max_age ||
1066 ((obd->obd_osfs.os_state & OS_STATE_SUM) &&
1067 !(flags & OBD_STATFS_SUM))) {
1068 rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
1072 "%s: new %p cache blocks %llu/%llu objects %llu/%llu\n",
1073 obd->obd_name, &obd->obd_osfs,
1074 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1075 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1078 spin_lock(&obd->obd_osfs_lock);
1079 memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
1081 obd->obd_osfs_age = ktime_get_seconds();
1082 spin_unlock(&obd->obd_osfs_lock);
1084 mutex_unlock(&obd->obd_dev_mutex);
1087 "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
1088 obd->obd_name, &obd->obd_osfs,
1089 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1090 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1091 spin_lock(&obd->obd_osfs_lock);
1092 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
1093 spin_unlock(&obd->obd_osfs_lock);
1098 static inline int obd_preprw(const struct lu_env *env, int cmd,
1099 struct obd_export *exp, struct obdo *oa,
1100 int objcount, struct obd_ioobj *obj,
1101 struct niobuf_remote *remote, int *pages,
1102 struct niobuf_local *local)
1108 rc = exp_check_ops(exp);
1112 if (!exp->exp_obd->obd_type->typ_dt_ops->o_preprw) {
1113 CERROR("%s: no %s operation\n",
1114 (exp)->exp_obd->obd_name, __func__);
1118 rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote,
1124 static inline int obd_commitrw(const struct lu_env *env, int cmd,
1125 struct obd_export *exp, struct obdo *oa,
1126 int objcount, struct obd_ioobj *obj,
1127 struct niobuf_remote *rnb, int pages,
1128 struct niobuf_local *local, const int orig_rc)
1133 rc = exp_check_ops(exp);
1137 if (!exp->exp_obd->obd_type->typ_dt_ops->o_commitrw) {
1138 CERROR("%s: no %s operation\n",
1139 (exp)->exp_obd->obd_name, __func__);
1143 rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj,
1144 rnb, pages, local, orig_rc);
1149 static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
1150 int len, void *karg, void __user *uarg)
1155 rc = exp_check_ops(exp);
1159 if (!exp->exp_obd->obd_type->typ_dt_ops->o_iocontrol) {
1160 CERROR("%s: no %s operation\n",
1161 (exp)->exp_obd->obd_name, __func__);
1165 rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
1169 static inline void obd_import_event(struct obd_device *obd,
1170 struct obd_import *imp,
1171 enum obd_import_event event)
1175 CERROR("NULL device\n");
1180 if (obd->obd_set_up && OBP(obd, import_event))
1181 OBP(obd, import_event)(obd, imp, event);
1186 static inline int obd_notify(struct obd_device *obd,
1187 struct obd_device *watched,
1188 enum obd_notify_event ev)
1193 rc = obd_check_dev(obd);
1197 if (!obd->obd_set_up) {
1198 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
1202 if (!OBP(obd, notify)) {
1203 CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name);
1207 rc = OBP(obd, notify)(obd, watched, ev);
1212 static inline int obd_notify_observer(struct obd_device *observer,
1213 struct obd_device *observed,
1214 enum obd_notify_event ev)
1218 struct obd_notify_upcall *onu;
1220 if (observer->obd_observer)
1221 rc = obd_notify(observer->obd_observer, observed, ev);
1224 * Also, call non-obd listener, if any
1226 onu = &observer->obd_upcall;
1227 if (onu->onu_upcall != NULL)
1228 rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner);
1230 return rc ? rc : rc2;
1233 static inline int obd_quotactl(struct obd_export *exp,
1234 struct obd_quotactl *oqctl)
1239 rc = exp_check_ops(exp);
1243 if (!exp->exp_obd->obd_type->typ_dt_ops->o_quotactl) {
1244 CERROR("%s: no %s operation\n",
1245 (exp)->exp_obd->obd_name, __func__);
1249 rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl);
1253 static inline int obd_health_check(const struct lu_env *env,
1254 struct obd_device *obd)
1256 /* returns: 0 on healthy
1257 * >0 on unhealthy + reason code/flag
1258 * however the only suppored reason == 1 right now
1259 * We'll need to define some better reasons
1260 * or flags in the future.
1267 /* NULL method is normal here */
1268 if (obd == NULL || !obd->obd_type) {
1269 CERROR("cleaned up obd\n");
1270 RETURN(-EOPNOTSUPP);
1272 if (!obd->obd_set_up || obd->obd_stopping)
1274 if (!OBP(obd, health_check))
1277 rc = OBP(obd, health_check)(env, obd);
1281 static inline int obd_register_observer(struct obd_device *obd,
1282 struct obd_device *observer)
1287 rc = obd_check_dev(obd);
1291 down_write(&obd->obd_observer_link_sem);
1292 if (obd->obd_observer && observer) {
1293 up_write(&obd->obd_observer_link_sem);
1296 obd->obd_observer = observer;
1297 up_write(&obd->obd_observer_link_sem);
1301 /* metadata helpers */
1307 LPROC_MD_INTENT_LOCK,
1316 LPROC_MD_INTENT_GETATTR_ASYNC,
1317 LPROC_MD_REVALIDATE_LOCK,
1321 static inline int md_get_root(struct obd_export *exp, const char *fileset,
1326 rc = exp_check_ops(exp);
1330 return MDP(exp->exp_obd, get_root)(exp, fileset, fid);
1333 static inline int md_getattr(struct obd_export *exp,
1334 struct md_op_data *op_data,
1335 struct ptlrpc_request **request)
1339 rc = exp_check_ops(exp);
1343 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1346 return MDP(exp->exp_obd, getattr)(exp, op_data, request);
1349 static inline int md_null_inode(struct obd_export *exp,
1350 const struct lu_fid *fid)
1354 rc = exp_check_ops(exp);
1358 return MDP(exp->exp_obd, null_inode)(exp, fid);
1361 static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,
1362 struct md_open_data *mod,
1363 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, close)(exp, op_data, mod, request);
1377 static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
1378 const void *data, size_t datalen, umode_t mode,
1379 uid_t uid, gid_t gid, cfs_cap_t cap_effective,
1380 __u64 rdev, struct ptlrpc_request **request)
1384 rc = exp_check_ops(exp);
1388 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1391 return MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode,
1392 uid, gid, cap_effective, rdev,
1396 static inline int md_enqueue(struct obd_export *exp,
1397 struct ldlm_enqueue_info *einfo,
1398 const union ldlm_policy_data *policy,
1399 struct md_op_data *op_data,
1400 struct lustre_handle *lockh,
1401 __u64 extra_lock_flags)
1405 rc = exp_check_ops(exp);
1409 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1412 return MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh,
1416 static inline int md_getattr_name(struct obd_export *exp,
1417 struct md_op_data *op_data,
1418 struct ptlrpc_request **request)
1422 rc = exp_check_ops(exp);
1426 return MDP(exp->exp_obd, getattr_name)(exp, op_data, request);
1429 static inline int md_intent_lock(struct obd_export *exp,
1430 struct md_op_data *op_data,
1431 struct lookup_intent *it,
1432 struct ptlrpc_request **reqp,
1433 ldlm_blocking_callback cb_blocking,
1434 __u64 extra_lock_flags)
1438 rc = exp_check_ops(exp);
1442 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1443 LPROC_MD_INTENT_LOCK);
1445 return MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp,
1446 cb_blocking, extra_lock_flags);
1449 static inline int md_link(struct obd_export *exp, struct md_op_data *op_data,
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, link)(exp, op_data, request);
1464 static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data,
1465 const char *old_name, size_t oldlen,
1466 const char *new_name, size_t newlen,
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, rename)(exp, op_data, old_name, oldlen,
1479 new_name, newlen, request);
1482 static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,
1483 void *ea, size_t ealen,
1484 struct ptlrpc_request **request)
1488 rc = exp_check_ops(exp);
1492 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1495 return MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request);
1498 static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid,
1499 struct ptlrpc_request **request)
1503 rc = exp_check_ops(exp);
1507 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1510 return MDP(exp->exp_obd, fsync)(exp, fid, request);
1513 /* FLR: resync mirrored files. */
1514 static inline int md_file_resync(struct obd_export *exp,
1515 struct md_op_data *data)
1519 rc = exp_check_ops(exp);
1523 return MDP(exp->exp_obd, file_resync)(exp, data);
1526 static inline int md_read_page(struct obd_export *exp,
1527 struct md_op_data *op_data,
1528 struct md_callback *cb_op,
1530 struct page **ppage)
1534 rc = exp_check_ops(exp);
1538 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1539 LPROC_MD_READ_PAGE);
1541 return MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset,
1545 static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data,
1546 struct ptlrpc_request **request)
1550 rc = exp_check_ops(exp);
1554 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1557 return MDP(exp->exp_obd, unlink)(exp, op_data, request);
1560 static inline int md_get_lustre_md(struct obd_export *exp,
1561 struct ptlrpc_request *req,
1562 struct obd_export *dt_exp,
1563 struct obd_export *md_exp,
1564 struct lustre_md *md)
1568 rc = exp_check_ops(exp);
1572 return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md);
1575 static inline int md_free_lustre_md(struct obd_export *exp,
1576 struct lustre_md *md)
1580 rc = exp_check_ops(exp);
1584 return MDP(exp->exp_obd, free_lustre_md)(exp, md);
1587 static inline int md_merge_attr(struct obd_export *exp,
1588 const struct lmv_stripe_md *lsm,
1589 struct cl_attr *attr,
1590 ldlm_blocking_callback cb)
1594 rc = exp_check_ops(exp);
1598 return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb);
1601 static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1602 u64 obd_md_valid, const char *name,
1603 const void *value, size_t value_size,
1604 unsigned int xattr_flags, u32 suppgid,
1605 struct ptlrpc_request **req)
1609 rc = exp_check_ops(exp);
1613 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1616 return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name,
1617 value, value_size, xattr_flags,
1621 static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1622 u64 obd_md_valid, const char *name,
1623 size_t buf_size, struct ptlrpc_request **req)
1627 rc = exp_check_ops(exp);
1631 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1634 return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name,
1638 static inline int md_set_open_replay_data(struct obd_export *exp,
1639 struct obd_client_handle *och,
1640 struct lookup_intent *it)
1644 rc = exp_check_ops(exp);
1648 return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it);
1651 static inline int md_clear_open_replay_data(struct obd_export *exp,
1652 struct obd_client_handle *och)
1656 rc = exp_check_ops(exp);
1660 return MDP(exp->exp_obd, clear_open_replay_data)(exp, och);
1663 static inline int md_set_lock_data(struct obd_export *exp,
1664 const struct lustre_handle *lockh,
1665 void *data, __u64 *bits)
1669 rc = exp_check_ops(exp);
1673 return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits);
1677 int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
1678 union ldlm_policy_data *policy, enum ldlm_mode mode,
1679 enum ldlm_cancel_flags cancel_flags, void *opaque)
1683 rc = exp_check_ops(exp);
1687 return MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode,
1688 cancel_flags, opaque);
1691 static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags,
1692 const struct lu_fid *fid,
1693 enum ldlm_type type,
1694 union ldlm_policy_data *policy,
1695 enum ldlm_mode mode,
1696 struct lustre_handle *lockh)
1700 rc = exp_check_ops(exp);
1704 return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type,
1705 policy, mode, lockh);
1708 static inline int md_init_ea_size(struct obd_export *exp, __u32 ea_size,
1713 rc = exp_check_ops(exp);
1717 return MDP(exp->exp_obd, init_ea_size)(exp, ea_size, def_ea_size);
1720 static inline int md_intent_getattr_async(struct obd_export *exp,
1721 struct md_enqueue_info *minfo)
1725 rc = exp_check_ops(exp);
1729 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1730 LPROC_MD_INTENT_GETATTR_ASYNC);
1732 return MDP(exp->exp_obd, intent_getattr_async)(exp, minfo);
1735 static inline int md_revalidate_lock(struct obd_export *exp,
1736 struct lookup_intent *it,
1737 struct lu_fid *fid, __u64 *bits)
1741 rc = exp_check_ops(exp);
1745 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1746 LPROC_MD_REVALIDATE_LOCK);
1748 return MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits);
1751 static inline int md_get_fid_from_lsm(struct obd_export *exp,
1752 const struct lmv_stripe_md *lsm,
1753 const char *name, int namelen,
1758 rc = exp_check_ops(exp);
1762 return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen,
1766 /* Unpack an MD struct from disk to in-memory format.
1767 * Returns +ve size of unpacked MD (0 for free), or -ve error.
1769 * If *plsm != NULL and lmm == NULL then *lsm will be freed.
1770 * If *plsm == NULL then it will be allocated.
1772 static inline int md_unpackmd(struct obd_export *exp,
1773 struct lmv_stripe_md **plsm,
1774 const union lmv_mds_md *lmm, size_t lmm_size)
1778 rc = exp_check_ops(exp);
1782 return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size);
1785 static inline int md_rmfid(struct obd_export *exp, struct fid_array *fa,
1786 int *rcs, struct ptlrpc_request_set *set)
1790 rc = exp_check_ops(exp);
1794 return MDP(exp->exp_obd, rmfid)(exp, fa, rcs, set);
1797 /* OBD Metadata Support */
1799 extern int obd_init_caches(void);
1800 extern void obd_cleanup_caches(void);
1802 typedef int (*register_lwp_cb)(void *data);
1804 struct lwp_register_item {
1805 struct obd_export **lri_exp;
1806 register_lwp_cb lri_cb_func;
1808 struct list_head lri_list;
1810 char lri_name[MTI_NAME_MAXLEN];
1813 /* I'm as embarrassed about this as you are.
1815 * <shaver> // XXX do not look into _superhack with remaining eye
1816 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
1817 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
1820 #ifdef HAVE_SERVER_SUPPORT
1821 int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
1822 register_lwp_cb cb_func, void *cb_data);
1823 void lustre_deregister_lwp_item(struct obd_export **exp);
1824 struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx);
1825 void lustre_notify_lwp_list(struct obd_export *exp);
1826 int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx);
1827 #endif /* HAVE_SERVER_SUPPORT */
1828 int lustre_register_fs(void);
1829 int lustre_unregister_fs(void);
1830 int lustre_check_exclusion(struct super_block *sb, char *svname);
1833 int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
1834 int class_add_uuid(const char *uuid, __u64 nid);
1835 int class_del_uuid (const char *uuid);
1836 int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
1839 extern char obd_jobid_name[];
1843 void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
1844 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
1846 /* root squash info */
1847 struct root_squash_info {
1850 struct list_head rsi_nosquash_nids;
1851 spinlock_t rsi_lock;
1854 int server_name2index(const char *svname, __u32 *idx, const char **endptr);
1856 /* linux-module.c */
1857 extern struct miscdevice obd_psdev;
1858 int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
1859 int class_procfs_init(void);
1860 int class_procfs_clean(void);
1862 extern void obd_heat_add(struct obd_heat_instance *instance,
1863 unsigned int time_second, __u64 count,
1864 unsigned int weight, unsigned int period_second);
1865 extern void obd_heat_decay(struct obd_heat_instance *instance,
1866 __u64 time_second, unsigned int weight,
1867 unsigned int period_second);
1868 extern __u64 obd_heat_get(struct obd_heat_instance *instance,
1869 unsigned int time_second, unsigned int weight,
1870 unsigned int period_second);
1871 extern void obd_heat_clear(struct obd_heat_instance *instance, int count);
1872 #endif /* __LINUX_OBD_CLASS_H */