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);
62 struct lu_device_type;
65 struct obd_export *class_conn2export(struct lustre_handle *);
66 struct kobject *class_setup_tunables(const char *name);
67 int class_register_type(struct obd_ops *, struct md_ops *, bool enable_proc,
68 struct lprocfs_vars *module_vars,
69 const char *nm, struct lu_device_type *ldt);
70 int class_unregister_type(const char *nm);
72 struct obd_device *class_newdev(const char *type_name, const char *name,
74 int class_register_device(struct obd_device *obd);
75 void class_unregister_device(struct obd_device *obd);
76 void class_free_dev(struct obd_device *obd);
78 struct obd_device *class_dev_by_str(const char *str);
79 int class_name2dev(const char *name);
80 struct obd_device *class_name2obd(const char *name);
81 int class_uuid2dev(struct obd_uuid *uuid);
82 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
83 void class_obd_list(void);
84 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
85 const char * typ_name,
86 struct obd_uuid *grp_uuid);
87 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
89 struct obd_device * class_num2obd(int num);
90 int get_devices_count(void);
92 int class_notify_sptlrpc_conf(const char *fsname, int namelen);
94 static inline char *obd_export_nid2str(struct obd_export *exp)
96 return exp->exp_connection == NULL ?
97 "<unknown>" : libcfs_nid2str(exp->exp_connection->c_peer.nid);
100 static inline char *obd_import_nid2str(struct obd_import *imp)
102 return imp->imp_connection == NULL ?
103 "<unknown>" : libcfs_nid2str(imp->imp_connection->c_peer.nid);
106 int obd_export_evict_by_nid(struct obd_device *obd, const char *nid);
107 int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid);
108 int obd_connect_flags2str(char *page, int count, __u64 flags, __u64 flags2,
111 int obd_zombie_impexp_init(void);
112 void obd_zombie_impexp_stop(void);
113 void obd_zombie_impexp_cull(void);
114 void obd_zombie_barrier(void);
115 void obd_exports_barrier(struct obd_device *obd);
116 int kuc_len(int payload_len);
117 struct kuc_hdr * kuc_ptr(void *p);
118 void *kuc_alloc(int payload_len, int transport, int type);
119 void kuc_free(void *p, int payload_len);
120 int obd_get_request_slot(struct client_obd *cli);
121 void obd_put_request_slot(struct client_obd *cli);
122 __u32 obd_get_max_rpcs_in_flight(struct client_obd *cli);
123 int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max);
124 __u16 obd_get_max_mod_rpcs_in_flight(struct client_obd *cli);
125 int obd_set_max_mod_rpcs_in_flight(struct client_obd *cli, __u16 max);
126 int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq);
128 __u16 obd_get_mod_rpc_slot(struct client_obd *cli, __u32 opc,
129 struct lookup_intent *it);
130 void obd_put_mod_rpc_slot(struct client_obd *cli, __u32 opc,
131 struct lookup_intent *it, __u16 tag);
135 typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
136 struct llog_rec_hdr *, void *);
138 struct obd_export *obd_stale_export_get(void);
139 void obd_stale_export_put(struct obd_export *exp);
140 void obd_stale_export_adjust(struct obd_export *exp);
143 /* For interoperability */
144 struct cfg_interop_param {
149 char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index);
150 struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
151 const char *new_name);
152 void print_lustre_cfg(struct lustre_cfg *lcfg);
153 int class_process_config(struct lustre_cfg *lcfg);
154 ssize_t class_set_global(const char *param);
155 ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
156 struct kobject *kobj);
157 int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
158 struct lustre_cfg *lcfg, void *data);
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 {
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);
204 #define CONFIG_SUB_SPTLRPC 0x01
205 #define CONFIG_SUB_RECOVER 0x02
206 #define CONFIG_SUB_PARAMS 0x04
207 #define CONFIG_SUB_NODEMAP 0x08
208 #define CONFIG_SUB_BARRIER 0x10
210 /* Sub clds should be attached to the config_llog_data when processing
211 * config log for client or server target. */
212 #define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \
214 #define CONFIG_SUB_SERVER (CONFIG_SUB_CLIENT | CONFIG_SUB_NODEMAP | \
217 #define PARAMS_FILENAME "params"
218 #define BARRIER_FILENAME "barrier"
219 #define LCTL_UPCALL "lctl"
221 static inline bool logname_is_barrier(const char *logname)
225 /* logname for barrier is "fsname-barrier" */
226 ptr = strstr(logname, BARRIER_FILENAME);
227 if (ptr && (ptr - logname) >= 2 &&
228 *(ptr - 1) == '-' && *(ptr + 7) == '\0')
234 /* list of active configuration logs */
235 struct config_llog_data {
236 struct ldlm_res_id cld_resid;
237 struct config_llog_instance cld_cfg;
238 struct list_head cld_list_chain;/* on config_llog_list */
239 atomic_t cld_refcount;
240 struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */
241 struct config_llog_data *cld_params; /* common parameters log */
242 struct config_llog_data *cld_recover;/* imperative recover log */
243 struct config_llog_data *cld_nodemap;/* nodemap log */
244 struct config_llog_data *cld_barrier;/* barrier log (for MDT only) */
245 struct obd_export *cld_mgcexp;
246 struct mutex cld_lock;
248 unsigned int cld_stopping:1, /* we were told to stop
250 cld_lostlock:1; /* lock not requeued */
254 struct lustre_profile {
255 struct list_head lp_list;
260 bool lp_list_deleted;
263 struct lustre_profile *class_get_profile(const char * prof);
264 void class_del_profile(const char *prof);
265 void class_put_profile(struct lustre_profile *lprof);
266 void class_del_profiles(void);
269 #if LUSTRE_TRACKS_LOCK_EXP_REFS
271 void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *);
272 void __class_export_del_lock_ref(struct obd_export *, struct ldlm_lock *);
273 extern void (*class_export_dump_hook)(struct obd_export *);
277 #define __class_export_add_lock_ref(exp, lock) do {} while(0)
278 #define __class_export_del_lock_ref(exp, lock) do {} while(0)
282 #define class_export_rpc_inc(exp) \
284 atomic_inc(&(exp)->exp_rpc_count); \
285 CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \
286 (exp), atomic_read(&(exp)->exp_rpc_count)); \
289 #define class_export_rpc_dec(exp) \
291 LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \
292 atomic_dec(&(exp)->exp_rpc_count); \
293 CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \
294 (exp), atomic_read(&(exp)->exp_rpc_count)); \
297 #define class_export_lock_get(exp, lock) \
299 atomic_inc(&(exp)->exp_locks_count); \
300 __class_export_add_lock_ref(exp, lock); \
301 CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \
302 (exp), atomic_read(&(exp)->exp_locks_count)); \
303 class_export_get(exp); \
306 #define class_export_lock_put(exp, lock) \
308 LASSERT_ATOMIC_POS(&exp->exp_locks_count); \
309 atomic_dec(&(exp)->exp_locks_count); \
310 __class_export_del_lock_ref(exp, lock); \
311 CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \
312 (exp), atomic_read(&(exp)->exp_locks_count)); \
313 class_export_put(exp); \
316 #define class_export_cb_get(exp) \
318 atomic_inc(&(exp)->exp_cb_count); \
319 CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\
320 (exp), atomic_read(&(exp)->exp_cb_count)); \
321 class_export_get(exp); \
324 #define class_export_cb_put(exp) \
326 LASSERT_ATOMIC_POS(&exp->exp_cb_count); \
327 atomic_dec(&(exp)->exp_cb_count); \
328 CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\
329 (exp), atomic_read(&(exp)->exp_cb_count)); \
330 class_export_put(exp); \
334 struct obd_export *class_export_get(struct obd_export *exp);
335 void class_export_put(struct obd_export *exp);
336 struct obd_export *class_new_export(struct obd_device *obddev,
337 struct obd_uuid *cluuid);
338 struct obd_export *class_new_export_self(struct obd_device *obd,
339 struct obd_uuid *uuid);
340 void class_unlink_export(struct obd_export *exp);
342 struct obd_import *class_import_get(struct obd_import *);
343 void class_import_put(struct obd_import *);
344 struct obd_import *class_new_import(struct obd_device *obd);
345 void class_destroy_import(struct obd_import *exp);
347 struct obd_type *class_search_type(const char *name);
348 struct obd_type *class_get_type(const char *name);
349 void class_put_type(struct obd_type *type);
350 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
351 struct obd_uuid *cluuid);
352 int class_disconnect(struct obd_export *exp);
353 void class_fail_export(struct obd_export *exp);
354 int class_connected_export(struct obd_export *exp);
355 void class_disconnect_exports(struct obd_device *obddev);
356 int class_manual_cleanup(struct obd_device *obd);
357 void class_disconnect_stale_exports(struct obd_device *,
358 int (*test_export)(struct obd_export *));
360 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
362 return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
363 (obd->obd_force ? OBD_OPT_FORCE : 0) |
364 (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) |
368 #ifdef HAVE_SERVER_SUPPORT
369 static inline struct lu_target *class_exp2tgt(struct obd_export *exp)
371 LASSERT(exp->exp_obd);
372 if (exp->exp_obd->u.obt.obt_magic != OBT_MAGIC)
374 return exp->exp_obd->u.obt.obt_lut;
377 static inline struct lr_server_data *class_server_data(struct obd_device *obd)
379 LASSERT(obd->u.obt.obt_lut);
380 return &obd->u.obt.obt_lut->lut_lsd;
388 void obdo_from_la(struct obdo *dst, const struct lu_attr *la, u64 valid);
389 void la_from_obdo(struct lu_attr *la, const struct obdo *dst, u64 valid);
391 void obdo_cpy_md(struct obdo *dst, const struct obdo *src, u64 valid);
392 void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj);
394 #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op
395 #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op
397 static inline int obd_check_dev(struct obd_device *obd)
400 CERROR("NULL device\n");
406 /* ensure obd_setup and !obd_stopping */
407 #define OBD_CHECK_DEV_ACTIVE(obd) \
409 rc = obd_check_dev(obd); \
413 if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
414 CERROR("Device %d not setup\n", \
421 static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp)
423 /* Always add in ldlm_stats */
424 tmp->nid_ldlm_stats =
425 lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC,
426 LPROCFS_STATS_FLAG_NOPERCPU);
427 if (tmp->nid_ldlm_stats == NULL)
430 lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
432 return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats",
433 tmp->nid_ldlm_stats);
436 static inline int exp_check_ops(struct obd_export *exp)
441 if (exp->exp_obd == NULL || !exp->exp_obd->obd_type) {
447 static inline int class_devno_max(void)
449 return MAX_OBD_DEVICES;
452 static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp,
453 __u32 keylen, void *key,
454 __u32 *vallen, void *val)
459 rc = exp_check_ops(exp);
463 if (!exp->exp_obd->obd_type->typ_dt_ops->o_get_info) {
464 CERROR("%s: no %s operation\n",
465 (exp)->exp_obd->obd_name, __func__);
469 rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val);
473 static inline int obd_set_info_async(const struct lu_env *env,
474 struct obd_export *exp,
475 __u32 keylen, void *key,
476 __u32 vallen, void *val,
477 struct ptlrpc_request_set *set)
482 rc = exp_check_ops(exp);
486 if (!exp->exp_obd->obd_type->typ_dt_ops->o_set_info_async) {
487 CERROR("%s: no %s operation\n",
488 (exp)->exp_obd->obd_name, __func__);
492 rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen,
498 * obd-lu integration.
500 * Functionality is being moved into new lu_device-based layering, but some
501 * pieces of configuration process are still based on obd devices.
503 * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully
504 * subsume ->o_setup() methods of obd devices they replace. The same for
505 * lu_device_operations::ldo_process_config() and ->o_process_config(). As a
506 * result, obd_setup() and obd_process_config() branch and call one XOR
509 * Yet neither lu_device_type_operations::ldto_device_fini() nor
510 * lu_device_type_operations::ldto_device_free() fully implement the
511 * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence,
512 * obd_precleanup() and obd_cleanup() call both lu_device and obd operations.
514 static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
517 struct lu_device_type *ldt = obd->obd_type->typ_lu;
523 struct lu_context session_ctx;
525 lu_context_init(&session_ctx, LCT_SESSION | LCT_SERVER_SESSION);
526 session_ctx.lc_thread = NULL;
527 lu_context_enter(&session_ctx);
529 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
531 env.le_ses = &session_ctx;
532 d = ldt->ldt_ops->ldto_device_alloc(&env, ldt, cfg);
541 lu_context_exit(&session_ctx);
542 lu_context_fini(&session_ctx);
545 if (!obd->obd_type->typ_dt_ops->o_setup) {
546 CERROR("%s: no %s operation\n", obd->obd_name,
550 rc = OBP(obd, setup)(obd, cfg);
555 static inline int obd_precleanup(struct obd_device *obd)
558 struct lu_device_type *ldt = obd->obd_type->typ_lu;
559 struct lu_device *d = obd->obd_lu_dev;
563 if (ldt != NULL && d != NULL) {
566 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
568 ldt->ldt_ops->ldto_device_fini(&env, d);
573 if (!obd->obd_type->typ_dt_ops->o_precleanup)
576 rc = OBP(obd, precleanup)(obd);
580 static inline int obd_cleanup(struct obd_device *obd)
583 struct lu_device_type *ldt = obd->obd_type->typ_lu;
584 struct lu_device *d = obd->obd_lu_dev;
587 if (ldt != NULL && d != NULL) {
590 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
592 ldt->ldt_ops->ldto_device_free(&env, d);
594 obd->obd_lu_dev = NULL;
597 if (!obd->obd_type->typ_dt_ops->o_cleanup)
600 rc = OBP(obd, cleanup)(obd);
604 static inline void obd_cleanup_client_import(struct obd_device *obd)
608 /* If we set up but never connected, the
609 client import will not have been cleaned. */
610 down_write(&obd->u.cli.cl_sem);
611 if (obd->u.cli.cl_import) {
612 struct obd_import *imp;
613 imp = obd->u.cli.cl_import;
614 CDEBUG(D_CONFIG, "%s: client import never connected\n",
616 ptlrpc_invalidate_import(imp);
617 client_destroy_import(imp);
618 obd->u.cli.cl_import = NULL;
620 up_write(&obd->u.cli.cl_sem);
625 static inline int obd_process_config(struct obd_device *obd, int datalen,
629 struct lu_device_type *ldt = obd->obd_type->typ_lu;
630 struct lu_device *d = obd->obd_lu_dev;
634 obd->obd_process_conf = 1;
635 if (ldt != NULL && d != NULL) {
638 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
640 rc = d->ld_ops->ldo_process_config(&env, d, data);
644 if (!obd->obd_type->typ_dt_ops->o_process_config) {
645 CERROR("%s: no %s operation\n",
646 obd->obd_name, __func__);
649 rc = OBP(obd, process_config)(obd, datalen, data);
652 obd->obd_process_conf = 0;
657 static inline int obd_create(const struct lu_env *env, struct obd_export *exp,
663 rc = exp_check_ops(exp);
667 if (!exp->exp_obd->obd_type->typ_dt_ops->o_create) {
668 CERROR("%s: no %s operation\n",
669 (exp)->exp_obd->obd_name, __func__);
673 rc = OBP(exp->exp_obd, create)(env, exp, obdo);
677 static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp,
683 rc = exp_check_ops(exp);
687 if (!exp->exp_obd->obd_type->typ_dt_ops->o_destroy) {
688 CERROR("%s: no %s operation\n",
689 (exp)->exp_obd->obd_name, __func__);
693 rc = OBP(exp->exp_obd, destroy)(env, exp, obdo);
697 static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp,
703 rc = exp_check_ops(exp);
707 if (!exp->exp_obd->obd_type->typ_dt_ops->o_getattr) {
708 CERROR("%s: no %s operation\n",
709 (exp)->exp_obd->obd_name, __func__);
713 rc = OBP(exp->exp_obd, getattr)(env, exp, oa);
718 static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp,
724 rc = exp_check_ops(exp);
728 if (!exp->exp_obd->obd_type->typ_dt_ops->o_setattr) {
729 CERROR("%s: no %s operation\n",
730 (exp)->exp_obd->obd_name, __func__);
734 rc = OBP(exp->exp_obd, setattr)(env, exp, oa);
739 static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
742 struct obd_device *obd = imp->imp_obd;
746 OBD_CHECK_DEV_ACTIVE(obd);
747 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_add_conn) {
748 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
752 rc = OBP(obd, add_conn)(imp, uuid, priority);
756 static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
758 struct obd_device *obd = imp->imp_obd;
762 OBD_CHECK_DEV_ACTIVE(obd);
763 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_del_conn) {
764 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
768 rc = OBP(obd, del_conn)(imp, uuid);
772 static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp)
774 struct obd_uuid *uuid;
777 if (!exp->exp_obd->obd_type ||
778 !exp->exp_obd->obd_type->typ_dt_ops->o_get_uuid)
781 uuid = OBP(exp->exp_obd, get_uuid)(exp);
785 /** Create a new /a exp on device /a obd for the uuid /a cluuid
786 * @param exp New export handle
787 * @param d Connect data, supported flags are set, flags also understood
788 * by obd are returned.
790 static inline int obd_connect(const struct lu_env *env,
791 struct obd_export **exp,struct obd_device *obd,
792 struct obd_uuid *cluuid,
793 struct obd_connect_data *data,
797 __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition
801 OBD_CHECK_DEV_ACTIVE(obd);
802 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_connect) {
803 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
807 rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata);
808 /* check that only subset is granted */
809 LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) ==
810 data->ocd_connect_flags));
814 static inline int obd_reconnect(const struct lu_env *env,
815 struct obd_export *exp,
816 struct obd_device *obd,
817 struct obd_uuid *cluuid,
818 struct obd_connect_data *d,
822 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition
827 OBD_CHECK_DEV_ACTIVE(obd);
828 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_reconnect)
831 rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata);
832 /* check that only subset is granted */
833 LASSERT(ergo(d != NULL,
834 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
838 static inline int obd_disconnect(struct obd_export *exp)
842 rc = exp_check_ops(exp);
846 if (!exp->exp_obd->obd_type->typ_dt_ops->o_disconnect) {
847 CERROR("%s: no %s operation\n",
848 (exp)->exp_obd->obd_name, __func__);
852 rc = OBP(exp->exp_obd, disconnect)(exp);
856 static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp,
857 enum lu_cli_type type)
862 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_init)
865 rc = OBP(obd, fid_init)(obd, exp, type);
869 static inline int obd_fid_fini(struct obd_device *obd)
873 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_fini)
876 rc = OBP(obd, fid_fini)(obd);
880 static inline int obd_fid_alloc(const struct lu_env *env,
881 struct obd_export *exp,
883 struct md_op_data *op_data)
887 rc = exp_check_ops(exp);
891 if (!exp->exp_obd->obd_type->typ_dt_ops->o_fid_alloc) {
892 CERROR("%s: no %s operation\n",
893 (exp)->exp_obd->obd_name, __func__);
897 rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data);
901 static inline int obd_ping(const struct lu_env *env, struct obd_export *exp)
906 if (!exp->exp_obd->obd_type ||
907 !exp->exp_obd->obd_type->typ_dt_ops->o_ping)
910 rc = OBP(exp->exp_obd, ping)(env, exp);
914 static inline int obd_pool_new(struct obd_device *obd, char *poolname)
919 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_new) {
920 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
924 rc = OBP(obd, pool_new)(obd, poolname);
928 static inline int obd_pool_del(struct obd_device *obd, char *poolname)
932 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_del) {
933 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
937 rc = OBP(obd, pool_del)(obd, poolname);
941 static inline int obd_pool_add(struct obd_device *obd, char *poolname,
947 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_add) {
948 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
952 rc = OBP(obd, pool_add)(obd, poolname, ostname);
956 static inline int obd_pool_rem(struct obd_device *obd, char *poolname,
962 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_rem) {
963 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
967 rc = OBP(obd, pool_rem)(obd, poolname, ostname);
971 static inline int obd_init_export(struct obd_export *exp)
976 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
977 OBP((exp)->exp_obd, init_export))
978 rc = OBP(exp->exp_obd, init_export)(exp);
982 static inline int obd_destroy_export(struct obd_export *exp)
985 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
986 OBP(exp->exp_obd, destroy_export))
987 OBP(exp->exp_obd, destroy_export)(exp);
991 /* @max_age is the oldest time in seconds that we accept using a cached data.
992 * If the cache is older than @max_age we will get a new value from the
993 * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
995 static inline int obd_statfs_async(struct obd_export *exp,
996 struct obd_info *oinfo,
998 struct ptlrpc_request_set *rqset)
1000 struct obd_device *obd;
1005 if (exp == NULL || exp->exp_obd == NULL)
1009 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) {
1010 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
1011 RETURN(-EOPNOTSUPP);
1014 CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
1015 obd->obd_name, obd->obd_osfs_age, max_age);
1016 if (obd->obd_osfs_age < max_age) {
1017 rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
1020 "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
1021 obd->obd_name, &obd->obd_osfs,
1022 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1023 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1024 spin_lock(&obd->obd_osfs_lock);
1025 memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs));
1026 spin_unlock(&obd->obd_osfs_lock);
1027 oinfo->oi_flags |= OBD_STATFS_FROM_CACHE;
1028 if (oinfo->oi_cb_up)
1029 oinfo->oi_cb_up(oinfo, 0);
1034 /* @max_age is the oldest time in seconds that we accept using a cached data.
1035 * If the cache is older than @max_age we will get a new value from the
1036 * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
1038 static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
1039 struct obd_statfs *osfs, time64_t max_age,
1042 struct obd_device *obd = exp->exp_obd;
1046 if (unlikely(obd == NULL))
1049 OBD_CHECK_DEV_ACTIVE(obd);
1051 if (unlikely(!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs)) {
1052 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
1053 RETURN(-EOPNOTSUPP);
1056 CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n",
1057 obd->obd_name, obd->obd_osfs_age, max_age);
1058 /* ignore cache if aggregated isn't expected */
1059 if (obd->obd_osfs_age < max_age ||
1060 ((obd->obd_osfs.os_state & OS_STATE_SUM) &&
1061 !(flags & OBD_STATFS_SUM))) {
1062 rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags);
1064 spin_lock(&obd->obd_osfs_lock);
1065 memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs));
1066 obd->obd_osfs_age = ktime_get_seconds();
1067 spin_unlock(&obd->obd_osfs_lock);
1071 "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
1072 obd->obd_name, &obd->obd_osfs,
1073 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1074 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1075 spin_lock(&obd->obd_osfs_lock);
1076 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs));
1077 spin_unlock(&obd->obd_osfs_lock);
1082 static inline int obd_preprw(const struct lu_env *env, int cmd,
1083 struct obd_export *exp, struct obdo *oa,
1084 int objcount, struct obd_ioobj *obj,
1085 struct niobuf_remote *remote, int *pages,
1086 struct niobuf_local *local)
1092 rc = exp_check_ops(exp);
1096 if (!exp->exp_obd->obd_type->typ_dt_ops->o_preprw) {
1097 CERROR("%s: no %s operation\n",
1098 (exp)->exp_obd->obd_name, __func__);
1102 rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote,
1108 static inline int obd_commitrw(const struct lu_env *env, int cmd,
1109 struct obd_export *exp, struct obdo *oa,
1110 int objcount, struct obd_ioobj *obj,
1111 struct niobuf_remote *rnb, int pages,
1112 struct niobuf_local *local, const int orig_rc)
1117 rc = exp_check_ops(exp);
1121 if (!exp->exp_obd->obd_type->typ_dt_ops->o_commitrw) {
1122 CERROR("%s: no %s operation\n",
1123 (exp)->exp_obd->obd_name, __func__);
1127 rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj,
1128 rnb, pages, local, orig_rc);
1133 static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp,
1134 int len, void *karg, void __user *uarg)
1139 rc = exp_check_ops(exp);
1143 if (!exp->exp_obd->obd_type->typ_dt_ops->o_iocontrol) {
1144 CERROR("%s: no %s operation\n",
1145 (exp)->exp_obd->obd_name, __func__);
1149 rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
1153 static inline void obd_import_event(struct obd_device *obd,
1154 struct obd_import *imp,
1155 enum obd_import_event event)
1159 CERROR("NULL device\n");
1164 if (obd->obd_set_up && OBP(obd, import_event))
1165 OBP(obd, import_event)(obd, imp, event);
1170 static inline int obd_notify(struct obd_device *obd,
1171 struct obd_device *watched,
1172 enum obd_notify_event ev)
1177 rc = obd_check_dev(obd);
1181 if (!obd->obd_set_up) {
1182 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
1186 if (!OBP(obd, notify)) {
1187 CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name);
1191 rc = OBP(obd, notify)(obd, watched, ev);
1196 static inline int obd_notify_observer(struct obd_device *observer,
1197 struct obd_device *observed,
1198 enum obd_notify_event ev)
1202 struct obd_notify_upcall *onu;
1204 if (observer->obd_observer)
1205 rc = obd_notify(observer->obd_observer, observed, ev);
1208 * Also, call non-obd listener, if any
1210 onu = &observer->obd_upcall;
1211 if (onu->onu_upcall != NULL)
1212 rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner);
1214 return rc ? rc : rc2;
1217 static inline int obd_quotactl(struct obd_export *exp,
1218 struct obd_quotactl *oqctl)
1223 rc = exp_check_ops(exp);
1227 if (!exp->exp_obd->obd_type->typ_dt_ops->o_quotactl) {
1228 CERROR("%s: no %s operation\n",
1229 (exp)->exp_obd->obd_name, __func__);
1233 rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl);
1237 static inline int obd_health_check(const struct lu_env *env,
1238 struct obd_device *obd)
1240 /* returns: 0 on healthy
1241 * >0 on unhealthy + reason code/flag
1242 * however the only suppored reason == 1 right now
1243 * We'll need to define some better reasons
1244 * or flags in the future.
1251 /* NULL method is normal here */
1252 if (obd == NULL || !obd->obd_type) {
1253 CERROR("cleaned up obd\n");
1254 RETURN(-EOPNOTSUPP);
1256 if (!obd->obd_set_up || obd->obd_stopping)
1258 if (!OBP(obd, health_check))
1261 rc = OBP(obd, health_check)(env, obd);
1265 static inline int obd_register_observer(struct obd_device *obd,
1266 struct obd_device *observer)
1271 rc = obd_check_dev(obd);
1275 down_write(&obd->obd_observer_link_sem);
1276 if (obd->obd_observer && observer) {
1277 up_write(&obd->obd_observer_link_sem);
1280 obd->obd_observer = observer;
1281 up_write(&obd->obd_observer_link_sem);
1285 /* metadata helpers */
1291 LPROC_MD_INTENT_LOCK,
1300 LPROC_MD_INTENT_GETATTR_ASYNC,
1301 LPROC_MD_REVALIDATE_LOCK,
1305 static inline int md_get_root(struct obd_export *exp, const char *fileset,
1310 rc = exp_check_ops(exp);
1314 return MDP(exp->exp_obd, get_root)(exp, fileset, fid);
1317 static inline int md_getattr(struct obd_export *exp,
1318 struct md_op_data *op_data,
1319 struct ptlrpc_request **request)
1323 rc = exp_check_ops(exp);
1327 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1330 return MDP(exp->exp_obd, getattr)(exp, op_data, request);
1333 static inline int md_null_inode(struct obd_export *exp,
1334 const struct lu_fid *fid)
1338 rc = exp_check_ops(exp);
1342 return MDP(exp->exp_obd, null_inode)(exp, fid);
1345 static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,
1346 struct md_open_data *mod,
1347 struct ptlrpc_request **request)
1351 rc = exp_check_ops(exp);
1355 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1358 return MDP(exp->exp_obd, close)(exp, op_data, mod, request);
1361 static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
1362 const void *data, size_t datalen, umode_t mode,
1363 uid_t uid, gid_t gid, cfs_cap_t cap_effective,
1364 __u64 rdev, 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, create)(exp, op_data, data, datalen, mode,
1376 uid, gid, cap_effective, rdev,
1380 static inline int md_enqueue(struct obd_export *exp,
1381 struct ldlm_enqueue_info *einfo,
1382 const union ldlm_policy_data *policy,
1383 struct md_op_data *op_data,
1384 struct lustre_handle *lockh,
1385 __u64 extra_lock_flags)
1389 rc = exp_check_ops(exp);
1393 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1396 return MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh,
1400 static inline int md_getattr_name(struct obd_export *exp,
1401 struct md_op_data *op_data,
1402 struct ptlrpc_request **request)
1406 rc = exp_check_ops(exp);
1410 return MDP(exp->exp_obd, getattr_name)(exp, op_data, request);
1413 static inline int md_intent_lock(struct obd_export *exp,
1414 struct md_op_data *op_data,
1415 struct lookup_intent *it,
1416 struct ptlrpc_request **reqp,
1417 ldlm_blocking_callback cb_blocking,
1418 __u64 extra_lock_flags)
1422 rc = exp_check_ops(exp);
1426 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1427 LPROC_MD_INTENT_LOCK);
1429 return MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp,
1430 cb_blocking, extra_lock_flags);
1433 static inline int md_link(struct obd_export *exp, struct md_op_data *op_data,
1434 struct ptlrpc_request **request)
1438 rc = exp_check_ops(exp);
1442 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1445 return MDP(exp->exp_obd, link)(exp, op_data, request);
1448 static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data,
1449 const char *old_name, size_t oldlen,
1450 const char *new_name, size_t newlen,
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, rename)(exp, op_data, old_name, oldlen,
1463 new_name, newlen, request);
1466 static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,
1467 void *ea, size_t ealen,
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, setattr)(exp, op_data, ea, ealen, request);
1482 static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid,
1483 struct ptlrpc_request **request)
1487 rc = exp_check_ops(exp);
1491 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1494 return MDP(exp->exp_obd, fsync)(exp, fid, request);
1497 /* FLR: resync mirrored files. */
1498 static inline int md_file_resync(struct obd_export *exp,
1499 struct md_op_data *data)
1503 rc = exp_check_ops(exp);
1507 return MDP(exp->exp_obd, file_resync)(exp, data);
1510 static inline int md_read_page(struct obd_export *exp,
1511 struct md_op_data *op_data,
1512 struct md_callback *cb_op,
1514 struct page **ppage)
1518 rc = exp_check_ops(exp);
1522 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1523 LPROC_MD_READ_PAGE);
1525 return MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset,
1529 static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data,
1530 struct ptlrpc_request **request)
1534 rc = exp_check_ops(exp);
1538 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1541 return MDP(exp->exp_obd, unlink)(exp, op_data, request);
1544 static inline int md_get_lustre_md(struct obd_export *exp,
1545 struct ptlrpc_request *req,
1546 struct obd_export *dt_exp,
1547 struct obd_export *md_exp,
1548 struct lustre_md *md)
1552 rc = exp_check_ops(exp);
1556 return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md);
1559 static inline int md_free_lustre_md(struct obd_export *exp,
1560 struct lustre_md *md)
1564 rc = exp_check_ops(exp);
1568 return MDP(exp->exp_obd, free_lustre_md)(exp, md);
1571 static inline int md_merge_attr(struct obd_export *exp,
1572 const struct lmv_stripe_md *lsm,
1573 struct cl_attr *attr,
1574 ldlm_blocking_callback cb)
1578 rc = exp_check_ops(exp);
1582 return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb);
1585 static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1586 u64 obd_md_valid, const char *name,
1587 const void *value, size_t value_size,
1588 unsigned int xattr_flags, u32 suppgid,
1589 struct ptlrpc_request **req)
1593 rc = exp_check_ops(exp);
1597 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1600 return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name,
1601 value, value_size, xattr_flags,
1605 static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1606 u64 obd_md_valid, const char *name,
1607 size_t buf_size, struct ptlrpc_request **req)
1611 rc = exp_check_ops(exp);
1615 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1618 return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name,
1622 static inline int md_set_open_replay_data(struct obd_export *exp,
1623 struct obd_client_handle *och,
1624 struct lookup_intent *it)
1628 rc = exp_check_ops(exp);
1632 return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it);
1635 static inline int md_clear_open_replay_data(struct obd_export *exp,
1636 struct obd_client_handle *och)
1640 rc = exp_check_ops(exp);
1644 return MDP(exp->exp_obd, clear_open_replay_data)(exp, och);
1647 static inline int md_set_lock_data(struct obd_export *exp,
1648 const struct lustre_handle *lockh,
1649 void *data, __u64 *bits)
1653 rc = exp_check_ops(exp);
1657 return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits);
1661 int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
1662 union ldlm_policy_data *policy, enum ldlm_mode mode,
1663 enum ldlm_cancel_flags cancel_flags, void *opaque)
1667 rc = exp_check_ops(exp);
1671 return MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode,
1672 cancel_flags, opaque);
1675 static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags,
1676 const struct lu_fid *fid,
1677 enum ldlm_type type,
1678 union ldlm_policy_data *policy,
1679 enum ldlm_mode mode,
1680 struct lustre_handle *lockh)
1684 rc = exp_check_ops(exp);
1688 return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type,
1689 policy, mode, lockh);
1692 static inline int md_init_ea_size(struct obd_export *exp, __u32 ea_size,
1697 rc = exp_check_ops(exp);
1701 return MDP(exp->exp_obd, init_ea_size)(exp, ea_size, def_ea_size);
1704 static inline int md_intent_getattr_async(struct obd_export *exp,
1705 struct md_enqueue_info *minfo)
1709 rc = exp_check_ops(exp);
1713 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1714 LPROC_MD_INTENT_GETATTR_ASYNC);
1716 return MDP(exp->exp_obd, intent_getattr_async)(exp, minfo);
1719 static inline int md_revalidate_lock(struct obd_export *exp,
1720 struct lookup_intent *it,
1721 struct lu_fid *fid, __u64 *bits)
1725 rc = exp_check_ops(exp);
1729 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1730 LPROC_MD_REVALIDATE_LOCK);
1732 return MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits);
1735 static inline int md_get_fid_from_lsm(struct obd_export *exp,
1736 const struct lmv_stripe_md *lsm,
1737 const char *name, int namelen,
1742 rc = exp_check_ops(exp);
1746 return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen,
1750 /* Unpack an MD struct from disk to in-memory format.
1751 * Returns +ve size of unpacked MD (0 for free), or -ve error.
1753 * If *plsm != NULL and lmm == NULL then *lsm will be freed.
1754 * If *plsm == NULL then it will be allocated.
1756 static inline int md_unpackmd(struct obd_export *exp,
1757 struct lmv_stripe_md **plsm,
1758 const union lmv_mds_md *lmm, size_t lmm_size)
1762 rc = exp_check_ops(exp);
1766 return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size);
1769 /* OBD Metadata Support */
1771 extern int obd_init_caches(void);
1772 extern void obd_cleanup_caches(void);
1774 typedef int (*register_lwp_cb)(void *data);
1776 struct lwp_register_item {
1777 struct obd_export **lri_exp;
1778 register_lwp_cb lri_cb_func;
1780 struct list_head lri_list;
1782 char lri_name[MTI_NAME_MAXLEN];
1785 /* I'm as embarrassed about this as you are.
1787 * <shaver> // XXX do not look into _superhack with remaining eye
1788 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
1789 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
1792 #ifdef HAVE_SERVER_SUPPORT
1793 int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
1794 register_lwp_cb cb_func, void *cb_data);
1795 void lustre_deregister_lwp_item(struct obd_export **exp);
1796 struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx);
1797 void lustre_notify_lwp_list(struct obd_export *exp);
1798 int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx);
1799 #endif /* HAVE_SERVER_SUPPORT */
1800 int lustre_register_fs(void);
1801 int lustre_unregister_fs(void);
1802 int lustre_check_exclusion(struct super_block *sb, char *svname);
1804 typedef __u8 class_uuid_t[16];
1805 static inline void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
1807 snprintf(out->uuid, sizeof(out->uuid), "%02x%02x%02x%02x-%02x%02x-"
1808 "%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1809 uu[14], uu[15], uu[12], uu[13], uu[10], uu[11], uu[8], uu[9],
1810 uu[6], uu[7], uu[4], uu[5], uu[2], uu[3], uu[0], uu[1]);
1814 int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
1815 int class_add_uuid(const char *uuid, __u64 nid);
1816 int class_del_uuid (const char *uuid);
1817 int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
1820 extern char obd_jobid_name[];
1823 #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t))
1827 void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
1828 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
1830 /* root squash info */
1831 struct rw_semaphore;
1832 struct root_squash_info {
1835 struct list_head rsi_nosquash_nids;
1836 struct rw_semaphore rsi_sem;
1839 int server_name2index(const char *svname, __u32 *idx, const char **endptr);
1841 /* linux-module.c */
1842 extern struct miscdevice obd_psdev;
1843 int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
1844 int class_procfs_init(void);
1845 int class_procfs_clean(void);
1846 #endif /* __LINUX_OBD_CLASS_H */