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_conn2obd(struct lustre_handle *);
56 extern struct obd_device *class_exp2obd(struct obd_export *);
57 extern int class_handle_ioctl(unsigned int cmd, unsigned long arg);
58 int lustre_get_jobid(char *jobid, size_t len);
59 void lustre_jobid_clear(const char *jobid);
60 void jobid_cache_fini(void);
61 int jobid_cache_init(void);
63 struct lu_device_type;
66 struct obd_export *class_conn2export(struct lustre_handle *);
67 struct kobject *class_setup_tunables(const char *name);
68 int class_register_type(struct obd_ops *, struct md_ops *, bool enable_proc,
69 struct lprocfs_vars *module_vars,
70 const char *nm, struct lu_device_type *ldt);
71 int class_unregister_type(const char *nm);
73 struct obd_device *class_newdev(const char *type_name, const char *name,
75 int class_register_device(struct obd_device *obd);
76 void class_unregister_device(struct obd_device *obd);
77 void class_free_dev(struct obd_device *obd);
79 struct obd_device *class_dev_by_str(const char *str);
80 int class_name2dev(const char *name);
81 struct obd_device *class_name2obd(const char *name);
82 int class_uuid2dev(struct obd_uuid *uuid);
83 struct obd_device *class_uuid2obd(struct obd_uuid *uuid);
84 void class_obd_list(void);
85 struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid,
86 const char * typ_name,
87 struct obd_uuid *grp_uuid);
88 struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid,
90 struct obd_device * class_num2obd(int num);
91 int get_devices_count(void);
93 int class_notify_sptlrpc_conf(const char *fsname, int namelen);
95 static inline char *obd_export_nid2str(struct obd_export *exp)
97 return exp->exp_connection == NULL ?
98 "<unknown>" : libcfs_nid2str(exp->exp_connection->c_peer.nid);
101 static inline char *obd_import_nid2str(struct obd_import *imp)
103 return imp->imp_connection == NULL ?
104 "<unknown>" : libcfs_nid2str(imp->imp_connection->c_peer.nid);
107 int obd_export_evict_by_nid(struct obd_device *obd, const char *nid);
108 int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid);
109 int obd_connect_flags2str(char *page, int count, __u64 flags, __u64 flags2,
112 int obd_zombie_impexp_init(void);
113 void obd_zombie_impexp_stop(void);
114 void obd_zombie_impexp_cull(void);
115 void obd_zombie_barrier(void);
116 void obd_exports_barrier(struct obd_device *obd);
117 int kuc_len(int payload_len);
118 struct kuc_hdr * kuc_ptr(void *p);
119 void *kuc_alloc(int payload_len, int transport, int type);
120 void kuc_free(void *p, int payload_len);
121 int obd_get_request_slot(struct client_obd *cli);
122 void obd_put_request_slot(struct client_obd *cli);
123 __u32 obd_get_max_rpcs_in_flight(struct client_obd *cli);
124 int obd_set_max_rpcs_in_flight(struct client_obd *cli, __u32 max);
125 __u16 obd_get_max_mod_rpcs_in_flight(struct client_obd *cli);
126 int obd_set_max_mod_rpcs_in_flight(struct client_obd *cli, __u16 max);
127 int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq);
129 __u16 obd_get_mod_rpc_slot(struct client_obd *cli, __u32 opc,
130 struct lookup_intent *it);
131 void obd_put_mod_rpc_slot(struct client_obd *cli, __u32 opc,
132 struct lookup_intent *it, __u16 tag);
136 typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
137 struct llog_rec_hdr *, void *);
139 struct obd_export *obd_stale_export_get(void);
140 void obd_stale_export_put(struct obd_export *exp);
141 void obd_stale_export_adjust(struct obd_export *exp);
144 /* For interoperability */
145 struct cfg_interop_param {
150 char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index);
151 struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
152 const char *new_name);
153 void print_lustre_cfg(struct lustre_cfg *lcfg);
154 int class_process_config(struct lustre_cfg *lcfg);
155 ssize_t class_set_global(const char *param);
156 ssize_t class_modify_config(struct lustre_cfg *lcfg, const char *prefix,
157 struct kobject *kobj);
158 int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
159 struct lustre_cfg *lcfg, void *data);
160 int class_attach(struct lustre_cfg *lcfg);
161 int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
162 int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg);
163 int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg);
165 int class_find_param(char *buf, char *key, char **valp);
166 struct cfg_interop_param *class_find_old_param(const char *param,
167 struct cfg_interop_param *ptr);
168 int class_get_next_param(char **params, char *copy);
169 int class_match_param(char *buf, const char *key, char **valp);
170 int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh);
171 int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh);
172 int class_parse_net(char *buf, u32 *net, char **endh);
173 int class_match_nid(char *buf, char *key, lnet_nid_t nid);
174 int class_match_net(char *buf, char *key, u32 net);
176 struct obd_device *class_incref(struct obd_device *obd,
177 const char *scope, const void *source);
178 void class_decref(struct obd_device *obd,
179 const char *scope, const void *source);
180 void dump_exports(struct obd_device *obd, int locks, int debug_level);
181 int class_config_llog_handler(const struct lu_env *env,
182 struct llog_handle *handle,
183 struct llog_rec_hdr *rec, void *data);
184 int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
186 #define CFG_F_START 0x01 /* Set when we start updating from a log */
187 #define CFG_F_MARKER 0x02 /* We are within a maker */
188 #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */
189 #define CFG_F_EXCLUDE 0x10 /* OST exclusion list */
191 /* Passed as data param to class_config_parse_llog */
192 struct config_llog_instance {
195 struct super_block *cfg_sb;
196 struct obd_uuid cfg_uuid;
197 llog_cb_t cfg_callback;
198 int cfg_last_idx; /* for partial llog processing */
203 int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt,
204 char *name, struct config_llog_instance *cfg);
206 #define CONFIG_SUB_SPTLRPC 0x01
207 #define CONFIG_SUB_RECOVER 0x02
208 #define CONFIG_SUB_PARAMS 0x04
209 #define CONFIG_SUB_NODEMAP 0x08
210 #define CONFIG_SUB_BARRIER 0x10
212 /* Sub clds should be attached to the config_llog_data when processing
213 * config log for client or server target. */
214 #define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \
216 #define CONFIG_SUB_SERVER (CONFIG_SUB_CLIENT | CONFIG_SUB_NODEMAP | \
219 #define PARAMS_FILENAME "params"
220 #define BARRIER_FILENAME "barrier"
221 #define LCTL_UPCALL "lctl"
223 static inline bool logname_is_barrier(const char *logname)
227 /* logname for barrier is "fsname-barrier" */
228 ptr = strstr(logname, BARRIER_FILENAME);
229 if (ptr && (ptr - logname) >= 2 &&
230 *(ptr - 1) == '-' && *(ptr + 7) == '\0')
236 /* list of active configuration logs */
237 struct config_llog_data {
238 struct ldlm_res_id cld_resid;
239 struct config_llog_instance cld_cfg;
240 struct list_head cld_list_chain;/* on config_llog_list */
241 atomic_t cld_refcount;
242 struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */
243 struct config_llog_data *cld_params; /* common parameters log */
244 struct config_llog_data *cld_recover;/* imperative recover log */
245 struct config_llog_data *cld_nodemap;/* nodemap log */
246 struct config_llog_data *cld_barrier;/* barrier log (for MDT only) */
247 struct obd_export *cld_mgcexp;
248 struct mutex cld_lock;
250 unsigned int cld_stopping:1, /* we were told to stop
252 cld_lostlock:1; /* lock not requeued */
256 struct lustre_profile {
257 struct list_head lp_list;
262 bool lp_list_deleted;
265 struct lustre_profile *class_get_profile(const char * prof);
266 void class_del_profile(const char *prof);
267 void class_put_profile(struct lustre_profile *lprof);
268 void class_del_profiles(void);
271 #if LUSTRE_TRACKS_LOCK_EXP_REFS
273 void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *);
274 void __class_export_del_lock_ref(struct obd_export *, struct ldlm_lock *);
275 extern void (*class_export_dump_hook)(struct obd_export *);
279 #define __class_export_add_lock_ref(exp, lock) do {} while(0)
280 #define __class_export_del_lock_ref(exp, lock) do {} while(0)
284 #define class_export_rpc_inc(exp) \
286 atomic_inc(&(exp)->exp_rpc_count); \
287 CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \
288 (exp), atomic_read(&(exp)->exp_rpc_count)); \
291 #define class_export_rpc_dec(exp) \
293 LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \
294 atomic_dec(&(exp)->exp_rpc_count); \
295 CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \
296 (exp), atomic_read(&(exp)->exp_rpc_count)); \
299 #define class_export_lock_get(exp, lock) \
301 atomic_inc(&(exp)->exp_locks_count); \
302 __class_export_add_lock_ref(exp, lock); \
303 CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \
304 (exp), atomic_read(&(exp)->exp_locks_count)); \
305 class_export_get(exp); \
308 #define class_export_lock_put(exp, lock) \
310 LASSERT_ATOMIC_POS(&exp->exp_locks_count); \
311 atomic_dec(&(exp)->exp_locks_count); \
312 __class_export_del_lock_ref(exp, lock); \
313 CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \
314 (exp), atomic_read(&(exp)->exp_locks_count)); \
315 class_export_put(exp); \
318 #define class_export_cb_get(exp) \
320 atomic_inc(&(exp)->exp_cb_count); \
321 CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\
322 (exp), atomic_read(&(exp)->exp_cb_count)); \
323 class_export_get(exp); \
326 #define class_export_cb_put(exp) \
328 LASSERT_ATOMIC_POS(&exp->exp_cb_count); \
329 atomic_dec(&(exp)->exp_cb_count); \
330 CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\
331 (exp), atomic_read(&(exp)->exp_cb_count)); \
332 class_export_put(exp); \
336 struct obd_export *class_export_get(struct obd_export *exp);
337 void class_export_put(struct obd_export *exp);
338 struct obd_export *class_new_export(struct obd_device *obddev,
339 struct obd_uuid *cluuid);
340 struct obd_export *class_new_export_self(struct obd_device *obd,
341 struct obd_uuid *uuid);
342 void class_unlink_export(struct obd_export *exp);
344 struct obd_import *class_import_get(struct obd_import *);
345 void class_import_put(struct obd_import *);
346 struct obd_import *class_new_import(struct obd_device *obd);
347 void class_destroy_import(struct obd_import *exp);
349 struct obd_type *class_search_type(const char *name);
350 struct obd_type *class_get_type(const char *name);
351 void class_put_type(struct obd_type *type);
352 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
353 struct obd_uuid *cluuid);
354 int class_disconnect(struct obd_export *exp);
355 void class_fail_export(struct obd_export *exp);
356 int class_connected_export(struct obd_export *exp);
357 void class_disconnect_exports(struct obd_device *obddev);
358 int class_manual_cleanup(struct obd_device *obd);
359 void class_disconnect_stale_exports(struct obd_device *,
360 int (*test_export)(struct obd_export *));
361 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
363 return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
364 (obd->obd_force ? OBD_OPT_FORCE : 0) |
365 (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) |
369 #ifdef HAVE_SERVER_SUPPORT
370 static inline struct lu_target *class_exp2tgt(struct obd_export *exp)
372 LASSERT(exp->exp_obd);
373 if (exp->exp_obd->u.obt.obt_magic != OBT_MAGIC)
375 return exp->exp_obd->u.obt.obt_lut;
378 static inline struct lr_server_data *class_server_data(struct obd_device *obd)
380 LASSERT(obd->u.obt.obt_lut);
381 return &obd->u.obt.obt_lut->lut_lsd;
389 void obdo_from_la(struct obdo *dst, const struct lu_attr *la, u64 valid);
390 void la_from_obdo(struct lu_attr *la, const struct obdo *dst, u64 valid);
392 void obdo_cpy_md(struct obdo *dst, const struct obdo *src, u64 valid);
393 void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj);
395 #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op
396 #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op
398 /* Ensure obd_setup: used for cleanup which must be called
399 while obd is stopping */
400 #define OBD_CHECK_DEV(obd) \
403 CERROR("NULL device\n"); \
408 /* ensure obd_setup and !obd_stopping */
409 #define OBD_CHECK_DEV_ACTIVE(obd) \
411 OBD_CHECK_DEV(obd); \
412 if (!(obd)->obd_set_up || (obd)->obd_stopping) { \
413 CERROR("Device %d not setup\n", \
420 static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp)
422 /* Always add in ldlm_stats */
423 tmp->nid_ldlm_stats =
424 lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC,
425 LPROCFS_STATS_FLAG_NOPERCPU);
426 if (tmp->nid_ldlm_stats == NULL)
429 lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
431 return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats",
432 tmp->nid_ldlm_stats);
435 static inline int exp_check_ops(struct obd_export *exp)
440 if (exp->exp_obd == NULL || !exp->exp_obd->obd_type) {
446 static inline int class_devno_max(void)
448 return MAX_OBD_DEVICES;
451 static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp,
452 __u32 keylen, void *key,
453 __u32 *vallen, void *val)
458 rc = exp_check_ops(exp);
462 if (!exp->exp_obd->obd_type->typ_dt_ops->o_get_info) {
463 CERROR("%s: no %s operation\n",
464 (exp)->exp_obd->obd_name, __func__);
468 rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val);
472 static inline int obd_set_info_async(const struct lu_env *env,
473 struct obd_export *exp,
474 __u32 keylen, void *key,
475 __u32 vallen, void *val,
476 struct ptlrpc_request_set *set)
481 rc = exp_check_ops(exp);
485 if (!exp->exp_obd->obd_type->typ_dt_ops->o_set_info_async) {
486 CERROR("%s: no %s operation\n",
487 (exp)->exp_obd->obd_name, __func__);
491 rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen,
497 * obd-lu integration.
499 * Functionality is being moved into new lu_device-based layering, but some
500 * pieces of configuration process are still based on obd devices.
502 * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully
503 * subsume ->o_setup() methods of obd devices they replace. The same for
504 * lu_device_operations::ldo_process_config() and ->o_process_config(). As a
505 * result, obd_setup() and obd_process_config() branch and call one XOR
508 * Yet neither lu_device_type_operations::ldto_device_fini() nor
509 * lu_device_type_operations::ldto_device_free() fully implement the
510 * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence,
511 * obd_precleanup() and obd_cleanup() call both lu_device and obd operations.
513 static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
516 struct lu_device_type *ldt = obd->obd_type->typ_lu;
522 struct lu_context session_ctx;
524 lu_context_init(&session_ctx, LCT_SESSION | LCT_SERVER_SESSION);
525 session_ctx.lc_thread = NULL;
526 lu_context_enter(&session_ctx);
528 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
530 env.le_ses = &session_ctx;
531 d = ldt->ldt_ops->ldto_device_alloc(&env, ldt, cfg);
540 lu_context_exit(&session_ctx);
541 lu_context_fini(&session_ctx);
544 if (!obd->obd_type->typ_dt_ops->o_setup) {
545 CERROR("%s: no %s operation\n", obd->obd_name,
549 rc = OBP(obd, setup)(obd, cfg);
554 static inline int obd_precleanup(struct obd_device *obd)
557 struct lu_device_type *ldt = obd->obd_type->typ_lu;
558 struct lu_device *d = obd->obd_lu_dev;
562 if (ldt != NULL && d != NULL) {
565 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
567 ldt->ldt_ops->ldto_device_fini(&env, d);
572 if (!obd->obd_type->typ_dt_ops->o_precleanup)
575 rc = OBP(obd, precleanup)(obd);
579 static inline int obd_cleanup(struct obd_device *obd)
582 struct lu_device_type *ldt = obd->obd_type->typ_lu;
583 struct lu_device *d = obd->obd_lu_dev;
586 if (ldt != NULL && d != NULL) {
589 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
591 ldt->ldt_ops->ldto_device_free(&env, d);
593 obd->obd_lu_dev = NULL;
596 if (!obd->obd_type->typ_dt_ops->o_cleanup)
599 rc = OBP(obd, cleanup)(obd);
603 static inline void obd_cleanup_client_import(struct obd_device *obd)
607 /* If we set up but never connected, the
608 client import will not have been cleaned. */
609 down_write(&obd->u.cli.cl_sem);
610 if (obd->u.cli.cl_import) {
611 struct obd_import *imp;
612 imp = obd->u.cli.cl_import;
613 CDEBUG(D_CONFIG, "%s: client import never connected\n",
615 ptlrpc_invalidate_import(imp);
616 client_destroy_import(imp);
617 obd->u.cli.cl_import = NULL;
619 up_write(&obd->u.cli.cl_sem);
624 static inline int obd_process_config(struct obd_device *obd, int datalen,
628 struct lu_device_type *ldt = obd->obd_type->typ_lu;
629 struct lu_device *d = obd->obd_lu_dev;
633 obd->obd_process_conf = 1;
634 if (ldt != NULL && d != NULL) {
637 rc = lu_env_init(&env, ldt->ldt_ctx_tags);
639 rc = d->ld_ops->ldo_process_config(&env, d, data);
643 if (!obd->obd_type->typ_dt_ops->o_process_config) {
644 CERROR("%s: no %s operation\n",
645 obd->obd_name, __func__);
648 rc = OBP(obd, process_config)(obd, datalen, data);
651 obd->obd_process_conf = 0;
656 static inline int obd_create(const struct lu_env *env, struct obd_export *exp,
662 rc = exp_check_ops(exp);
666 if (!exp->exp_obd->obd_type->typ_dt_ops->o_create) {
667 CERROR("%s: no %s operation\n",
668 (exp)->exp_obd->obd_name, __func__);
672 rc = OBP(exp->exp_obd, create)(env, exp, obdo);
676 static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp,
682 rc = exp_check_ops(exp);
686 if (!exp->exp_obd->obd_type->typ_dt_ops->o_destroy) {
687 CERROR("%s: no %s operation\n",
688 (exp)->exp_obd->obd_name, __func__);
692 rc = OBP(exp->exp_obd, destroy)(env, exp, obdo);
696 static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp,
702 rc = exp_check_ops(exp);
706 if (!exp->exp_obd->obd_type->typ_dt_ops->o_getattr) {
707 CERROR("%s: no %s operation\n",
708 (exp)->exp_obd->obd_name, __func__);
712 rc = OBP(exp->exp_obd, getattr)(env, exp, oa);
717 static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp,
723 rc = exp_check_ops(exp);
727 if (!exp->exp_obd->obd_type->typ_dt_ops->o_setattr) {
728 CERROR("%s: no %s operation\n",
729 (exp)->exp_obd->obd_name, __func__);
733 rc = OBP(exp->exp_obd, setattr)(env, exp, oa);
738 static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
741 struct obd_device *obd = imp->imp_obd;
745 OBD_CHECK_DEV_ACTIVE(obd);
746 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_add_conn) {
747 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
751 rc = OBP(obd, add_conn)(imp, uuid, priority);
755 static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
757 struct obd_device *obd = imp->imp_obd;
761 OBD_CHECK_DEV_ACTIVE(obd);
762 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_del_conn) {
763 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
767 rc = OBP(obd, del_conn)(imp, uuid);
771 static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp)
773 struct obd_uuid *uuid;
776 if (!exp->exp_obd->obd_type ||
777 !exp->exp_obd->obd_type->typ_dt_ops->o_get_uuid)
780 uuid = OBP(exp->exp_obd, get_uuid)(exp);
784 /** Create a new /a exp on device /a obd for the uuid /a cluuid
785 * @param exp New export handle
786 * @param d Connect data, supported flags are set, flags also understood
787 * by obd are returned.
789 static inline int obd_connect(const struct lu_env *env,
790 struct obd_export **exp,struct obd_device *obd,
791 struct obd_uuid *cluuid,
792 struct obd_connect_data *data,
796 __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition
800 OBD_CHECK_DEV_ACTIVE(obd);
801 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_connect) {
802 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
806 rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata);
807 /* check that only subset is granted */
808 LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) ==
809 data->ocd_connect_flags));
813 static inline int obd_reconnect(const struct lu_env *env,
814 struct obd_export *exp,
815 struct obd_device *obd,
816 struct obd_uuid *cluuid,
817 struct obd_connect_data *d,
821 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition
826 OBD_CHECK_DEV_ACTIVE(obd);
827 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_reconnect)
830 rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata);
831 /* check that only subset is granted */
832 LASSERT(ergo(d != NULL,
833 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags));
837 static inline int obd_disconnect(struct obd_export *exp)
841 rc = exp_check_ops(exp);
845 if (!exp->exp_obd->obd_type->typ_dt_ops->o_disconnect) {
846 CERROR("%s: no %s operation\n",
847 (exp)->exp_obd->obd_name, __func__);
851 rc = OBP(exp->exp_obd, disconnect)(exp);
855 static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp,
856 enum lu_cli_type type)
861 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_init)
864 rc = OBP(obd, fid_init)(obd, exp, type);
868 static inline int obd_fid_fini(struct obd_device *obd)
872 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_fini)
875 rc = OBP(obd, fid_fini)(obd);
879 static inline int obd_fid_alloc(const struct lu_env *env,
880 struct obd_export *exp,
882 struct md_op_data *op_data)
886 rc = exp_check_ops(exp);
890 if (!exp->exp_obd->obd_type->typ_dt_ops->o_fid_alloc) {
891 CERROR("%s: no %s operation\n",
892 (exp)->exp_obd->obd_name, __func__);
896 rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data);
900 static inline int obd_ping(const struct lu_env *env, struct obd_export *exp)
905 if (!exp->exp_obd->obd_type ||
906 !exp->exp_obd->obd_type->typ_dt_ops->o_ping)
909 rc = OBP(exp->exp_obd, ping)(env, exp);
913 static inline int obd_pool_new(struct obd_device *obd, char *poolname)
918 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_new) {
919 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
923 rc = OBP(obd, pool_new)(obd, poolname);
927 static inline int obd_pool_del(struct obd_device *obd, char *poolname)
931 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_del) {
932 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
936 rc = OBP(obd, pool_del)(obd, poolname);
940 static inline int obd_pool_add(struct obd_device *obd, char *poolname,
946 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_add) {
947 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
951 rc = OBP(obd, pool_add)(obd, poolname, ostname);
955 static inline int obd_pool_rem(struct obd_device *obd, char *poolname,
961 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_rem) {
962 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
966 rc = OBP(obd, pool_rem)(obd, poolname, ostname);
970 static inline int obd_init_export(struct obd_export *exp)
975 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
976 OBP((exp)->exp_obd, init_export))
977 rc = OBP(exp->exp_obd, init_export)(exp);
981 static inline int obd_destroy_export(struct obd_export *exp)
984 if (exp->exp_obd != NULL && exp->exp_obd->obd_type &&
985 OBP(exp->exp_obd, destroy_export))
986 OBP(exp->exp_obd, destroy_export)(exp);
990 /* @max_age is the oldest time in seconds that we accept using a cached data.
991 * If the cache is older than @max_age we will get a new value from the
992 * target. Use a value of 'ktime_get_seconds() + X' to guarantee freshness.
994 static inline int obd_statfs_async(struct obd_export *exp,
995 struct obd_info *oinfo,
997 struct ptlrpc_request_set *rqset)
1000 struct obd_device *obd;
1004 if (exp == NULL || exp->exp_obd == NULL)
1008 if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) {
1009 CERROR("%s: no %s operation\n", obd->obd_name, __func__);
1010 RETURN(-EOPNOTSUPP);
1013 CDEBUG(D_SUPER, "%s: osfs %p age %lld, max_age %lld\n",
1014 obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age);
1015 if (obd->obd_osfs_age < max_age) {
1016 rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset);
1019 "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n",
1020 obd->obd_name, &obd->obd_osfs,
1021 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks,
1022 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files);
1023 spin_lock(&obd->obd_osfs_lock);
1024 memcpy(oinfo->oi_osfs, &obd->obd_osfs,
1025 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,
1043 struct obd_device *obd = exp->exp_obd;
1049 OBD_CHECK_DEV_ACTIVE(obd);
1051 if (!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, "osfs %lld, max_age %lld\n",
1057 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);
1070 CDEBUG(D_SUPER, "%s: use %p cache blocks %llu/%llu"
1071 " 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, int 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, 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)
1177 if (!obd->obd_set_up) {
1178 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name);
1182 if (!OBP(obd, notify)) {
1183 CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name);
1187 rc = OBP(obd, notify)(obd, watched, ev);
1192 static inline int obd_notify_observer(struct obd_device *observer,
1193 struct obd_device *observed,
1194 enum obd_notify_event ev)
1198 struct obd_notify_upcall *onu;
1200 if (observer->obd_observer)
1201 rc = obd_notify(observer->obd_observer, observed, ev);
1204 * Also, call non-obd listener, if any
1206 onu = &observer->obd_upcall;
1207 if (onu->onu_upcall != NULL)
1208 rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner);
1210 return rc ? rc : rc2;
1213 static inline int obd_quotactl(struct obd_export *exp,
1214 struct obd_quotactl *oqctl)
1219 rc = exp_check_ops(exp);
1223 if (!exp->exp_obd->obd_type->typ_dt_ops->o_quotactl) {
1224 CERROR("%s: no %s operation\n",
1225 (exp)->exp_obd->obd_name, __func__);
1229 rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl);
1233 static inline int obd_health_check(const struct lu_env *env,
1234 struct obd_device *obd)
1236 /* returns: 0 on healthy
1237 * >0 on unhealthy + reason code/flag
1238 * however the only suppored reason == 1 right now
1239 * We'll need to define some better reasons
1240 * or flags in the future.
1247 /* NULL method is normal here */
1248 if (obd == NULL || !obd->obd_type) {
1249 CERROR("cleaned up obd\n");
1250 RETURN(-EOPNOTSUPP);
1252 if (!obd->obd_set_up || obd->obd_stopping)
1254 if (!OBP(obd, health_check))
1257 rc = OBP(obd, health_check)(env, obd);
1261 static inline int obd_register_observer(struct obd_device *obd,
1262 struct obd_device *observer)
1266 down_write(&obd->obd_observer_link_sem);
1267 if (obd->obd_observer && observer) {
1268 up_write(&obd->obd_observer_link_sem);
1271 obd->obd_observer = observer;
1272 up_write(&obd->obd_observer_link_sem);
1276 /* metadata helpers */
1282 LPROC_MD_INTENT_LOCK,
1291 LPROC_MD_INTENT_GETATTR_ASYNC,
1292 LPROC_MD_REVALIDATE_LOCK,
1296 static inline int md_get_root(struct obd_export *exp, const char *fileset,
1301 rc = exp_check_ops(exp);
1305 return MDP(exp->exp_obd, get_root)(exp, fileset, fid);
1308 static inline int md_getattr(struct obd_export *exp,
1309 struct md_op_data *op_data,
1310 struct ptlrpc_request **request)
1314 rc = exp_check_ops(exp);
1318 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1321 return MDP(exp->exp_obd, getattr)(exp, op_data, request);
1324 static inline int md_null_inode(struct obd_export *exp,
1325 const struct lu_fid *fid)
1329 rc = exp_check_ops(exp);
1333 return MDP(exp->exp_obd, null_inode)(exp, fid);
1336 static inline int md_close(struct obd_export *exp, struct md_op_data *op_data,
1337 struct md_open_data *mod,
1338 struct ptlrpc_request **request)
1342 rc = exp_check_ops(exp);
1346 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1349 return MDP(exp->exp_obd, close)(exp, op_data, mod, request);
1352 static inline int md_create(struct obd_export *exp, struct md_op_data *op_data,
1353 const void *data, size_t datalen, umode_t mode,
1354 uid_t uid, gid_t gid, cfs_cap_t cap_effective,
1355 __u64 rdev, struct ptlrpc_request **request)
1359 rc = exp_check_ops(exp);
1363 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1366 return MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode,
1367 uid, gid, cap_effective, rdev,
1371 static inline int md_enqueue(struct obd_export *exp,
1372 struct ldlm_enqueue_info *einfo,
1373 const union ldlm_policy_data *policy,
1374 struct md_op_data *op_data,
1375 struct lustre_handle *lockh,
1376 __u64 extra_lock_flags)
1380 rc = exp_check_ops(exp);
1384 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1387 return MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh,
1391 static inline int md_getattr_name(struct obd_export *exp,
1392 struct md_op_data *op_data,
1393 struct ptlrpc_request **request)
1397 rc = exp_check_ops(exp);
1401 return MDP(exp->exp_obd, getattr_name)(exp, op_data, request);
1404 static inline int md_intent_lock(struct obd_export *exp,
1405 struct md_op_data *op_data,
1406 struct lookup_intent *it,
1407 struct ptlrpc_request **reqp,
1408 ldlm_blocking_callback cb_blocking,
1409 __u64 extra_lock_flags)
1413 rc = exp_check_ops(exp);
1417 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1418 LPROC_MD_INTENT_LOCK);
1420 return MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp,
1421 cb_blocking, extra_lock_flags);
1424 static inline int md_link(struct obd_export *exp, struct md_op_data *op_data,
1425 struct ptlrpc_request **request)
1429 rc = exp_check_ops(exp);
1433 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1436 return MDP(exp->exp_obd, link)(exp, op_data, request);
1439 static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data,
1440 const char *old_name, size_t oldlen,
1441 const char *new_name, size_t newlen,
1442 struct ptlrpc_request **request)
1446 rc = exp_check_ops(exp);
1450 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1453 return MDP(exp->exp_obd, rename)(exp, op_data, old_name, oldlen,
1454 new_name, newlen, request);
1457 static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,
1458 void *ea, size_t ealen,
1459 struct ptlrpc_request **request)
1463 rc = exp_check_ops(exp);
1467 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1470 return MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request);
1473 static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid,
1474 struct ptlrpc_request **request)
1478 rc = exp_check_ops(exp);
1482 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1485 return MDP(exp->exp_obd, fsync)(exp, fid, request);
1488 /* FLR: resync mirrored files. */
1489 static inline int md_file_resync(struct obd_export *exp,
1490 struct md_op_data *data)
1494 rc = exp_check_ops(exp);
1498 return MDP(exp->exp_obd, file_resync)(exp, data);
1501 static inline int md_read_page(struct obd_export *exp,
1502 struct md_op_data *op_data,
1503 struct md_callback *cb_op,
1505 struct page **ppage)
1509 rc = exp_check_ops(exp);
1513 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1514 LPROC_MD_READ_PAGE);
1516 return MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset,
1520 static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data,
1521 struct ptlrpc_request **request)
1525 rc = exp_check_ops(exp);
1529 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1532 return MDP(exp->exp_obd, unlink)(exp, op_data, request);
1535 static inline int md_get_lustre_md(struct obd_export *exp,
1536 struct ptlrpc_request *req,
1537 struct obd_export *dt_exp,
1538 struct obd_export *md_exp,
1539 struct lustre_md *md)
1543 rc = exp_check_ops(exp);
1547 return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md);
1550 static inline int md_free_lustre_md(struct obd_export *exp,
1551 struct lustre_md *md)
1555 rc = exp_check_ops(exp);
1559 return MDP(exp->exp_obd, free_lustre_md)(exp, md);
1562 static inline int md_merge_attr(struct obd_export *exp,
1563 const struct lmv_stripe_md *lsm,
1564 struct cl_attr *attr,
1565 ldlm_blocking_callback cb)
1569 rc = exp_check_ops(exp);
1573 return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb);
1576 static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1577 u64 obd_md_valid, const char *name,
1578 const void *value, size_t value_size,
1579 unsigned int xattr_flags, u32 suppgid,
1580 struct ptlrpc_request **req)
1584 rc = exp_check_ops(exp);
1588 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1591 return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name,
1592 value, value_size, xattr_flags,
1596 static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1597 u64 obd_md_valid, const char *name,
1598 size_t buf_size, struct ptlrpc_request **req)
1602 rc = exp_check_ops(exp);
1606 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1609 return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name,
1613 static inline int md_set_open_replay_data(struct obd_export *exp,
1614 struct obd_client_handle *och,
1615 struct lookup_intent *it)
1619 rc = exp_check_ops(exp);
1623 return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it);
1626 static inline int md_clear_open_replay_data(struct obd_export *exp,
1627 struct obd_client_handle *och)
1631 rc = exp_check_ops(exp);
1635 return MDP(exp->exp_obd, clear_open_replay_data)(exp, och);
1638 static inline int md_set_lock_data(struct obd_export *exp,
1639 const struct lustre_handle *lockh,
1640 void *data, __u64 *bits)
1644 rc = exp_check_ops(exp);
1648 return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits);
1652 int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
1653 union ldlm_policy_data *policy, enum ldlm_mode mode,
1654 enum ldlm_cancel_flags cancel_flags, void *opaque)
1658 rc = exp_check_ops(exp);
1662 return MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode,
1663 cancel_flags, opaque);
1666 static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags,
1667 const struct lu_fid *fid,
1668 enum ldlm_type type,
1669 union ldlm_policy_data *policy,
1670 enum ldlm_mode mode,
1671 struct lustre_handle *lockh)
1675 rc = exp_check_ops(exp);
1679 return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type,
1680 policy, mode, lockh);
1683 static inline int md_init_ea_size(struct obd_export *exp, __u32 ea_size,
1688 rc = exp_check_ops(exp);
1692 return MDP(exp->exp_obd, init_ea_size)(exp, ea_size, def_ea_size);
1695 static inline int md_intent_getattr_async(struct obd_export *exp,
1696 struct md_enqueue_info *minfo)
1700 rc = exp_check_ops(exp);
1704 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1705 LPROC_MD_INTENT_GETATTR_ASYNC);
1707 return MDP(exp->exp_obd, intent_getattr_async)(exp, minfo);
1710 static inline int md_revalidate_lock(struct obd_export *exp,
1711 struct lookup_intent *it,
1712 struct lu_fid *fid, __u64 *bits)
1716 rc = exp_check_ops(exp);
1720 lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
1721 LPROC_MD_REVALIDATE_LOCK);
1723 return MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits);
1726 static inline int md_get_fid_from_lsm(struct obd_export *exp,
1727 const struct lmv_stripe_md *lsm,
1728 const char *name, int namelen,
1733 rc = exp_check_ops(exp);
1737 return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen,
1741 /* Unpack an MD struct from disk to in-memory format.
1742 * Returns +ve size of unpacked MD (0 for free), or -ve error.
1744 * If *plsm != NULL and lmm == NULL then *lsm will be freed.
1745 * If *plsm == NULL then it will be allocated.
1747 static inline int md_unpackmd(struct obd_export *exp,
1748 struct lmv_stripe_md **plsm,
1749 const union lmv_mds_md *lmm, size_t lmm_size)
1753 rc = exp_check_ops(exp);
1757 return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size);
1760 /* OBD Metadata Support */
1762 extern int obd_init_caches(void);
1763 extern void obd_cleanup_caches(void);
1765 /* support routines */
1766 extern struct kmem_cache *obdo_cachep;
1768 #define OBDO_ALLOC(ptr) \
1770 OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \
1773 #define OBDO_FREE(ptr) \
1775 OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \
1779 typedef int (*register_lwp_cb)(void *data);
1781 struct lwp_register_item {
1782 struct obd_export **lri_exp;
1783 register_lwp_cb lri_cb_func;
1785 struct list_head lri_list;
1787 char lri_name[MTI_NAME_MAXLEN];
1790 /* I'm as embarrassed about this as you are.
1792 * <shaver> // XXX do not look into _superhack with remaining eye
1793 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */
1794 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
1797 #ifdef HAVE_SERVER_SUPPORT
1798 int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
1799 register_lwp_cb cb_func, void *cb_data);
1800 void lustre_deregister_lwp_item(struct obd_export **exp);
1801 struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx);
1802 void lustre_notify_lwp_list(struct obd_export *exp);
1803 int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx);
1804 #endif /* HAVE_SERVER_SUPPORT */
1805 int lustre_register_fs(void);
1806 int lustre_unregister_fs(void);
1807 int lustre_check_exclusion(struct super_block *sb, char *svname);
1809 typedef __u8 class_uuid_t[16];
1810 static inline void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
1812 snprintf(out->uuid, sizeof(out->uuid), "%02x%02x%02x%02x-%02x%02x-"
1813 "%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1814 uu[14], uu[15], uu[12], uu[13], uu[10], uu[11], uu[8], uu[9],
1815 uu[6], uu[7], uu[4], uu[5], uu[2], uu[3], uu[0], uu[1]);
1819 int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
1820 int class_add_uuid(const char *uuid, __u64 nid);
1821 int class_del_uuid (const char *uuid);
1822 int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
1825 extern char obd_jobid_name[];
1828 #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t))
1832 void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs);
1833 void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs);
1835 /* root squash info */
1836 struct rw_semaphore;
1837 struct root_squash_info {
1840 struct list_head rsi_nosquash_nids;
1841 struct rw_semaphore rsi_sem;
1844 int server_name2index(const char *svname, __u32 *idx, const char **endptr);
1846 /* linux-module.c */
1847 extern struct miscdevice obd_psdev;
1848 int obd_ioctl_getdata(char **buf, int *len, void __user *arg);
1849 int class_procfs_init(void);
1850 int class_procfs_clean(void);
1851 #endif /* __LINUX_OBD_CLASS_H */