1/* 2 * GPL HEADER START 3 * 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 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. 9 * 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). 15 * 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.sun.com/software/products/lustre/docs/GPLv2.pdf 19 * 20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 21 * CA 95054 USA or visit www.sun.com if you need additional information or 22 * have any questions. 23 * 24 * GPL HEADER END 25 */ 26/* 27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 28 * Use is subject to license terms. 29 * 30 * Copyright (c) 2011, 2012, Intel Corporation. 31 */ 32/* 33 * This file is part of Lustre, http://www.lustre.org/ 34 * Lustre is a trademark of Sun Microsystems, Inc. 35 */ 36#ifndef __CLASS_OBD_H 37#define __CLASS_OBD_H 38 39 40#include "obd_support.h" 41#include "lustre_import.h" 42#include "lustre_net.h" 43#include "obd.h" 44#include "lustre_lib.h" 45#include "lustre/lustre_idl.h" 46#include "lprocfs_status.h" 47 48#define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay 49 * and resends for avoid deadlocks */ 50#define OBD_STATFS_FROM_CACHE 0x0002 /* the statfs callback should not update 51 * obd_osfs_age */ 52#define OBD_STATFS_PTLRPCD 0x0004 /* requests will be sent via ptlrpcd 53 * instead of a specific set. This 54 * means that we cannot rely on the set 55 * interpret routine to be called. 56 * lov_statfs_fini() must thus be called 57 * by the request interpret routine */ 58#define OBD_STATFS_FOR_MDT0 0x0008 /* The statfs is only for retrieving 59 * information from MDT0. */ 60#define OBD_FL_PUNCH 0x00000001 /* To indicate it is punch operation */ 61 62/* OBD Device Declarations */ 63extern struct obd_device *obd_devs[MAX_OBD_DEVICES]; 64extern rwlock_t obd_dev_lock; 65 66/* OBD Operations Declarations */ 67extern struct obd_device *class_conn2obd(struct lustre_handle *); 68extern struct obd_device *class_exp2obd(struct obd_export *); 69extern int class_handle_ioctl(unsigned int cmd, unsigned long arg); 70extern int lustre_get_jobid(char *jobid); 71 72struct lu_device_type; 73 74/* genops.c */ 75struct obd_export *class_conn2export(struct lustre_handle *); 76int class_register_type(struct obd_ops *, struct md_ops *, 77 struct lprocfs_vars *, const char *nm, 78 struct lu_device_type *ldt); 79int class_unregister_type(const char *nm); 80 81struct obd_device *class_newdev(const char *type_name, const char *name); 82void class_release_dev(struct obd_device *obd); 83 84int class_name2dev(const char *name); 85struct obd_device *class_name2obd(const char *name); 86int class_uuid2dev(struct obd_uuid *uuid); 87struct obd_device *class_uuid2obd(struct obd_uuid *uuid); 88void class_obd_list(void); 89struct obd_device *class_find_client_obd(struct obd_uuid *tgt_uuid, 90 const char *typ_name, 91 struct obd_uuid *grp_uuid); 92struct obd_device *class_devices_in_group(struct obd_uuid *grp_uuid, 93 int *next); 94struct obd_device *class_num2obd(int num); 95int get_devices_count(void); 96 97int class_notify_sptlrpc_conf(const char *fsname, int namelen); 98 99char *obd_export_nid2str(struct obd_export *exp); 100 101int obd_export_evict_by_nid(struct obd_device *obd, const char *nid); 102int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid); 103int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep); 104 105int obd_zombie_impexp_init(void); 106void obd_zombie_impexp_stop(void); 107void obd_zombie_impexp_cull(void); 108void obd_zombie_barrier(void); 109void obd_exports_barrier(struct obd_device *obd); 110int kuc_len(int payload_len); 111struct kuc_hdr *kuc_ptr(void *p); 112int kuc_ispayload(void *p); 113void *kuc_alloc(int payload_len, int transport, int type); 114void kuc_free(void *p, int payload_len); 115 116struct llog_handle; 117struct llog_rec_hdr; 118typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, 119 struct llog_rec_hdr *, void *); 120/* obd_config.c */ 121struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, 122 const char *new_name); 123int class_process_config(struct lustre_cfg *lcfg); 124int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, 125 struct lustre_cfg *lcfg, void *data); 126int class_attach(struct lustre_cfg *lcfg); 127int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg); 128int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg); 129int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg); 130struct obd_device *class_incref(struct obd_device *obd, 131 const char *scope, const void *source); 132void class_decref(struct obd_device *obd, 133 const char *scope, const void *source); 134void dump_exports(struct obd_device *obd, int locks); 135int class_config_llog_handler(const struct lu_env *env, 136 struct llog_handle *handle, 137 struct llog_rec_hdr *rec, void *data); 138int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg); 139int class_add_uuid(const char *uuid, __u64 nid); 140 141/*obdecho*/ 142#if defined (CONFIG_PROC_FS) 143extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars); 144#else 145static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) 146{ 147 memset(lvars, 0, sizeof(*lvars)); 148} 149#endif 150 151#define CFG_F_START 0x01 /* Set when we start updating from a log */ 152#define CFG_F_MARKER 0x02 /* We are within a maker */ 153#define CFG_F_SKIP 0x04 /* We should ignore this cfg command */ 154#define CFG_F_COMPAT146 0x08 /* Allow old-style logs */ 155#define CFG_F_EXCLUDE 0x10 /* OST exclusion list */ 156 157/* Passed as data param to class_config_parse_llog */ 158struct config_llog_instance { 159 char *cfg_obdname; 160 void *cfg_instance; 161 struct super_block *cfg_sb; 162 struct obd_uuid cfg_uuid; 163 llog_cb_t cfg_callback; 164 int cfg_last_idx; /* for partial llog processing */ 165 int cfg_flags; 166}; 167int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, 168 char *name, struct config_llog_instance *cfg); 169int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, 170 char *name, struct config_llog_instance *cfg); 171 172enum { 173 CONFIG_T_CONFIG = 0, 174 CONFIG_T_SPTLRPC = 1, 175 CONFIG_T_RECOVER = 2, 176 CONFIG_T_PARAMS = 3, 177 CONFIG_T_MAX = 4 178}; 179 180#define PARAMS_FILENAME "params" 181#define LCTL_UPCALL "lctl" 182 183/* list of active configuration logs */ 184struct config_llog_data { 185 struct ldlm_res_id cld_resid; 186 struct config_llog_instance cld_cfg; 187 struct list_head cld_list_chain; 188 atomic_t cld_refcount; 189 struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */ 190 struct config_llog_data *cld_params; /* common parameters log */ 191 struct config_llog_data *cld_recover;/* imperative recover log */ 192 struct obd_export *cld_mgcexp; 193 struct mutex cld_lock; 194 int cld_type; 195 unsigned int cld_stopping:1, /* we were told to stop 196 * watching */ 197 cld_lostlock:1; /* lock not requeued */ 198 char cld_logname[0]; 199}; 200 201struct lustre_profile { 202 struct list_head lp_list; 203 char *lp_profile; 204 char *lp_dt; 205 char *lp_md; 206}; 207 208struct lustre_profile *class_get_profile(const char *prof); 209void class_del_profile(const char *prof); 210void class_del_profiles(void); 211 212#if LUSTRE_TRACKS_LOCK_EXP_REFS 213 214void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *); 215void __class_export_del_lock_ref(struct obd_export *, struct ldlm_lock *); 216extern void (*class_export_dump_hook)(struct obd_export *); 217 218#else 219 220#define __class_export_add_lock_ref(exp, lock) do {} while (0) 221#define __class_export_del_lock_ref(exp, lock) do {} while (0) 222 223#endif 224 225#define class_export_rpc_inc(exp) \ 226({ \ 227 atomic_inc(&(exp)->exp_rpc_count); \ 228 CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \ 229 (exp), atomic_read(&(exp)->exp_rpc_count)); \ 230}) 231 232#define class_export_rpc_dec(exp) \ 233({ \ 234 LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \ 235 atomic_dec(&(exp)->exp_rpc_count); \ 236 CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \ 237 (exp), atomic_read(&(exp)->exp_rpc_count)); \ 238}) 239 240#define class_export_lock_get(exp, lock) \ 241({ \ 242 atomic_inc(&(exp)->exp_locks_count); \ 243 __class_export_add_lock_ref(exp, lock); \ 244 CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \ 245 (exp), atomic_read(&(exp)->exp_locks_count)); \ 246 class_export_get(exp); \ 247}) 248 249#define class_export_lock_put(exp, lock) \ 250({ \ 251 LASSERT_ATOMIC_POS(&exp->exp_locks_count); \ 252 atomic_dec(&(exp)->exp_locks_count); \ 253 __class_export_del_lock_ref(exp, lock); \ 254 CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \ 255 (exp), atomic_read(&(exp)->exp_locks_count)); \ 256 class_export_put(exp); \ 257}) 258 259#define class_export_cb_get(exp) \ 260({ \ 261 atomic_inc(&(exp)->exp_cb_count); \ 262 CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\ 263 (exp), atomic_read(&(exp)->exp_cb_count)); \ 264 class_export_get(exp); \ 265}) 266 267#define class_export_cb_put(exp) \ 268({ \ 269 LASSERT_ATOMIC_POS(&exp->exp_cb_count); \ 270 atomic_dec(&(exp)->exp_cb_count); \ 271 CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\ 272 (exp), atomic_read(&(exp)->exp_cb_count)); \ 273 class_export_put(exp); \ 274}) 275 276/* genops.c */ 277struct obd_export *class_export_get(struct obd_export *exp); 278void class_export_put(struct obd_export *exp); 279struct obd_export *class_new_export(struct obd_device *obddev, 280 struct obd_uuid *cluuid); 281void class_unlink_export(struct obd_export *exp); 282 283struct obd_import *class_import_get(struct obd_import *); 284void class_import_put(struct obd_import *); 285struct obd_import *class_new_import(struct obd_device *obd); 286void class_destroy_import(struct obd_import *exp); 287 288struct obd_type *class_search_type(const char *name); 289struct obd_type *class_get_type(const char *name); 290void class_put_type(struct obd_type *type); 291int class_connect(struct lustre_handle *conn, struct obd_device *obd, 292 struct obd_uuid *cluuid); 293int class_disconnect(struct obd_export *exp); 294void class_fail_export(struct obd_export *exp); 295int class_connected_export(struct obd_export *exp); 296void class_disconnect_exports(struct obd_device *obddev); 297int class_manual_cleanup(struct obd_device *obd); 298void class_disconnect_stale_exports(struct obd_device *, 299 int (*test_export)(struct obd_export *)); 300static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) 301{ 302 return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) | 303 (obd->obd_force ? OBD_OPT_FORCE : 0) | 304 (obd->obd_abort_recovery ? OBD_OPT_ABORT_RECOV : 0) | 305 0); 306} 307 308struct inode; 309struct lu_attr; 310struct obdo; 311void obdo_from_la(struct obdo *dst, struct lu_attr *la, __u64 valid); 312void la_from_obdo(struct lu_attr *la, struct obdo *dst, u32 valid); 313void obdo_refresh_inode(struct inode *dst, struct obdo *src, u32 valid); 314void obdo_to_inode(struct inode *dst, struct obdo *src, u32 valid); 315 316void obdo_cpy_md(struct obdo *dst, struct obdo *src, u32 valid); 317void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj); 318void obdo_from_iattr(struct obdo *oa, struct iattr *attr, 319 unsigned int ia_valid); 320void iattr_from_obdo(struct iattr *attr, struct obdo *oa, u32 valid); 321void md_from_obdo(struct md_op_data *op_data, struct obdo *oa, u32 valid); 322void obdo_from_md(struct obdo *oa, struct md_op_data *op_data, 323 unsigned int valid); 324 325void obdo_cpu_to_le(struct obdo *dobdo, struct obdo *sobdo); 326void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo); 327 328#define OBT(dev) (dev)->obd_type 329#define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op 330#define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op 331#define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op 332 333/* Ensure obd_setup: used for cleanup which must be called 334 while obd is stopping */ 335#define OBD_CHECK_DEV(obd) \ 336do { \ 337 if (!(obd)) { \ 338 CERROR("NULL device\n"); \ 339 return -ENODEV; \ 340 } \ 341} while (0) 342 343/* ensure obd_setup and !obd_stopping */ 344#define OBD_CHECK_DEV_ACTIVE(obd) \ 345do { \ 346 OBD_CHECK_DEV(obd); \ 347 if (!(obd)->obd_set_up || (obd)->obd_stopping) { \ 348 CERROR("Device %d not setup\n", \ 349 (obd)->obd_minor); \ 350 return -ENODEV; \ 351 } \ 352} while (0) 353 354 355#if defined (CONFIG_PROC_FS) 356#define OBD_COUNTER_OFFSET(op) \ 357 ((offsetof(struct obd_ops, o_ ## op) - \ 358 offsetof(struct obd_ops, o_iocontrol)) \ 359 / sizeof(((struct obd_ops *)(0))->o_iocontrol)) 360 361#define OBD_COUNTER_INCREMENT(obdx, op) \ 362 if ((obdx)->obd_stats != NULL) { \ 363 unsigned int coffset; \ 364 coffset = (unsigned int)((obdx)->obd_cntr_base) + \ 365 OBD_COUNTER_OFFSET(op); \ 366 LASSERT(coffset < (obdx)->obd_stats->ls_num); \ 367 lprocfs_counter_incr((obdx)->obd_stats, coffset); \ 368 } 369 370#define EXP_COUNTER_INCREMENT(export, op) \ 371 if ((export)->exp_obd->obd_stats != NULL) { \ 372 unsigned int coffset; \ 373 coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \ 374 OBD_COUNTER_OFFSET(op); \ 375 LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ 376 lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ 377 if ((export)->exp_nid_stats != NULL && \ 378 (export)->exp_nid_stats->nid_stats != NULL) \ 379 lprocfs_counter_incr( \ 380 (export)->exp_nid_stats->nid_stats, coffset);\ 381 } 382 383#define MD_COUNTER_OFFSET(op) \ 384 ((offsetof(struct md_ops, m_ ## op) - \ 385 offsetof(struct md_ops, m_getstatus)) \ 386 / sizeof(((struct md_ops *)(0))->m_getstatus)) 387 388#define MD_COUNTER_INCREMENT(obdx, op) \ 389 if ((obd)->md_stats != NULL) { \ 390 unsigned int coffset; \ 391 coffset = (unsigned int)((obdx)->md_cntr_base) + \ 392 MD_COUNTER_OFFSET(op); \ 393 LASSERT(coffset < (obdx)->md_stats->ls_num); \ 394 lprocfs_counter_incr((obdx)->md_stats, coffset); \ 395 } 396 397#define EXP_MD_COUNTER_INCREMENT(export, op) \ 398 if ((export)->exp_obd->obd_stats != NULL) { \ 399 unsigned int coffset; \ 400 coffset = (unsigned int)((export)->exp_obd->md_cntr_base) + \ 401 MD_COUNTER_OFFSET(op); \ 402 LASSERT(coffset < (export)->exp_obd->md_stats->ls_num); \ 403 lprocfs_counter_incr((export)->exp_obd->md_stats, coffset); \ 404 if ((export)->exp_md_stats != NULL) \ 405 lprocfs_counter_incr( \ 406 (export)->exp_md_stats, coffset); \ 407 } 408 409#else 410#define OBD_COUNTER_OFFSET(op) 411#define OBD_COUNTER_INCREMENT(obd, op) 412#define EXP_COUNTER_INCREMENT(exp, op) 413#define MD_COUNTER_INCREMENT(obd, op) 414#define EXP_MD_COUNTER_INCREMENT(exp, op) 415#endif 416 417static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp) 418{ 419 /* Always add in ldlm_stats */ 420 tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC 421 ,LPROCFS_STATS_FLAG_NOPERCPU); 422 if (tmp->nid_ldlm_stats == NULL) 423 return -ENOMEM; 424 425 lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); 426 427 return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", 428 tmp->nid_ldlm_stats); 429} 430 431#define OBD_CHECK_MD_OP(obd, op, err) \ 432do { \ 433 if (!OBT(obd) || !MDP((obd), op)) { \ 434 if (err) \ 435 CERROR("md_" #op ": dev %s/%d no operation\n", \ 436 obd->obd_name, obd->obd_minor); \ 437 return err; \ 438 } \ 439} while (0) 440 441#define EXP_CHECK_MD_OP(exp, op) \ 442do { \ 443 if ((exp) == NULL) { \ 444 CERROR("obd_" #op ": NULL export\n"); \ 445 return -ENODEV; \ 446 } \ 447 if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ 448 CERROR("obd_" #op ": cleaned up obd\n"); \ 449 return -EOPNOTSUPP; \ 450 } \ 451 if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ 452 CERROR("obd_" #op ": dev %s/%d no operation\n", \ 453 (exp)->exp_obd->obd_name, \ 454 (exp)->exp_obd->obd_minor); \ 455 return -EOPNOTSUPP; \ 456 } \ 457} while (0) 458 459 460#define OBD_CHECK_DT_OP(obd, op, err) \ 461do { \ 462 if (!OBT(obd) || !OBP((obd), op)) { \ 463 if (err) \ 464 CERROR("obd_" #op ": dev %d no operation\n", \ 465 obd->obd_minor); \ 466 return err; \ 467 } \ 468} while (0) 469 470#define EXP_CHECK_DT_OP(exp, op) \ 471do { \ 472 if ((exp) == NULL) { \ 473 CERROR("obd_" #op ": NULL export\n"); \ 474 return -ENODEV; \ 475 } \ 476 if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ 477 CERROR("obd_" #op ": cleaned up obd\n"); \ 478 return -EOPNOTSUPP; \ 479 } \ 480 if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \ 481 CERROR("obd_" #op ": dev %d no operation\n", \ 482 (exp)->exp_obd->obd_minor); \ 483 return -EOPNOTSUPP; \ 484 } \ 485} while (0) 486 487#define CTXT_CHECK_OP(ctxt, op, err) \ 488do { \ 489 if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ 490 if (err) \ 491 CERROR("lop_" #op ": dev %d no operation\n", \ 492 ctxt->loc_obd->obd_minor); \ 493 return err; \ 494 } \ 495} while (0) 496 497static inline int class_devno_max(void) 498{ 499 return MAX_OBD_DEVICES; 500} 501 502static inline int obd_get_info(const struct lu_env *env, 503 struct obd_export *exp, __u32 keylen, 504 void *key, __u32 *vallen, void *val, 505 struct lov_stripe_md *lsm) 506{ 507 int rc; 508 509 EXP_CHECK_DT_OP(exp, get_info); 510 EXP_COUNTER_INCREMENT(exp, get_info); 511 512 rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val, 513 lsm); 514 return rc; 515} 516 517static inline int obd_set_info_async(const struct lu_env *env, 518 struct obd_export *exp, u32 keylen, 519 void *key, u32 vallen, void *val, 520 struct ptlrpc_request_set *set) 521{ 522 int rc; 523 524 EXP_CHECK_DT_OP(exp, set_info_async); 525 EXP_COUNTER_INCREMENT(exp, set_info_async); 526 527 rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, 528 val, set); 529 return rc; 530} 531 532/* 533 * obd-lu integration. 534 * 535 * Functionality is being moved into new lu_device-based layering, but some 536 * pieces of configuration process are still based on obd devices. 537 * 538 * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully 539 * subsume ->o_setup() methods of obd devices they replace. The same for 540 * lu_device_operations::ldo_process_config() and ->o_process_config(). As a 541 * result, obd_setup() and obd_process_config() branch and call one XOR 542 * another. 543 * 544 * Yet neither lu_device_type_operations::ldto_device_fini() nor 545 * lu_device_type_operations::ldto_device_free() fully implement the 546 * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence, 547 * obd_precleanup() and obd_cleanup() call both lu_device and obd operations. 548 */ 549 550#define DECLARE_LU_VARS(ldt, d) \ 551 struct lu_device_type *ldt; \ 552 struct lu_device *d 553 554static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) 555{ 556 int rc; 557 DECLARE_LU_VARS(ldt, d); 558 559 ldt = obd->obd_type->typ_lu; 560 if (ldt != NULL) { 561 struct lu_context session_ctx; 562 struct lu_env env; 563 lu_context_init(&session_ctx, LCT_SESSION); 564 session_ctx.lc_thread = NULL; 565 lu_context_enter(&session_ctx); 566 567 rc = lu_env_init(&env, ldt->ldt_ctx_tags); 568 if (rc == 0) { 569 env.le_ses = &session_ctx; 570 d = ldt->ldt_ops->ldto_device_alloc(&env, ldt, cfg); 571 lu_env_fini(&env); 572 if (!IS_ERR(d)) { 573 obd->obd_lu_dev = d; 574 d->ld_obd = obd; 575 rc = 0; 576 } else 577 rc = PTR_ERR(d); 578 } 579 lu_context_exit(&session_ctx); 580 lu_context_fini(&session_ctx); 581 582 } else { 583 OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP); 584 OBD_COUNTER_INCREMENT(obd, setup); 585 rc = OBP(obd, setup)(obd, cfg); 586 } 587 return rc; 588} 589 590static inline int obd_precleanup(struct obd_device *obd, 591 enum obd_cleanup_stage cleanup_stage) 592{ 593 int rc; 594 DECLARE_LU_VARS(ldt, d); 595 596 OBD_CHECK_DEV(obd); 597 ldt = obd->obd_type->typ_lu; 598 d = obd->obd_lu_dev; 599 if (ldt != NULL && d != NULL) { 600 if (cleanup_stage == OBD_CLEANUP_EXPORTS) { 601 struct lu_env env; 602 603 rc = lu_env_init(&env, ldt->ldt_ctx_tags); 604 if (rc == 0) { 605 ldt->ldt_ops->ldto_device_fini(&env, d); 606 lu_env_fini(&env); 607 } 608 } 609 } 610 OBD_CHECK_DT_OP(obd, precleanup, 0); 611 OBD_COUNTER_INCREMENT(obd, precleanup); 612 613 rc = OBP(obd, precleanup)(obd, cleanup_stage); 614 return rc; 615} 616 617static inline int obd_cleanup(struct obd_device *obd) 618{ 619 int rc; 620 DECLARE_LU_VARS(ldt, d); 621 622 OBD_CHECK_DEV(obd); 623 624 ldt = obd->obd_type->typ_lu; 625 d = obd->obd_lu_dev; 626 if (ldt != NULL && d != NULL) { 627 struct lu_env env; 628 629 rc = lu_env_init(&env, ldt->ldt_ctx_tags); 630 if (rc == 0) { 631 ldt->ldt_ops->ldto_device_free(&env, d); 632 lu_env_fini(&env); 633 obd->obd_lu_dev = NULL; 634 } 635 } 636 OBD_CHECK_DT_OP(obd, cleanup, 0); 637 OBD_COUNTER_INCREMENT(obd, cleanup); 638 639 rc = OBP(obd, cleanup)(obd); 640 return rc; 641} 642 643static inline void obd_cleanup_client_import(struct obd_device *obd) 644{ 645 /* If we set up but never connected, the 646 client import will not have been cleaned. */ 647 down_write(&obd->u.cli.cl_sem); 648 if (obd->u.cli.cl_import) { 649 struct obd_import *imp; 650 imp = obd->u.cli.cl_import; 651 CDEBUG(D_CONFIG, "%s: client import never connected\n", 652 obd->obd_name); 653 ptlrpc_invalidate_import(imp); 654 if (imp->imp_rq_pool) { 655 ptlrpc_free_rq_pool(imp->imp_rq_pool); 656 imp->imp_rq_pool = NULL; 657 } 658 client_destroy_import(imp); 659 obd->u.cli.cl_import = NULL; 660 } 661 up_write(&obd->u.cli.cl_sem); 662} 663 664static inline int 665obd_process_config(struct obd_device *obd, int datalen, void *data) 666{ 667 int rc; 668 DECLARE_LU_VARS(ldt, d); 669 670 OBD_CHECK_DEV(obd); 671 672 obd->obd_process_conf = 1; 673 ldt = obd->obd_type->typ_lu; 674 d = obd->obd_lu_dev; 675 if (ldt != NULL && d != NULL) { 676 struct lu_env env; 677 678 rc = lu_env_init(&env, ldt->ldt_ctx_tags); 679 if (rc == 0) { 680 rc = d->ld_ops->ldo_process_config(&env, d, data); 681 lu_env_fini(&env); 682 } 683 } else { 684 OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); 685 rc = OBP(obd, process_config)(obd, datalen, data); 686 } 687 OBD_COUNTER_INCREMENT(obd, process_config); 688 obd->obd_process_conf = 0; 689 690 return rc; 691} 692 693/* Pack an in-memory MD struct for storage on disk. 694 * Returns +ve size of packed MD (0 for free), or -ve error. 695 * 696 * If @disk_tgt == NULL, MD size is returned (max size if @mem_src == NULL). 697 * If @*disk_tgt != NULL and @mem_src == NULL, @*disk_tgt will be freed. 698 * If @*disk_tgt == NULL, it will be allocated 699 */ 700static inline int obd_packmd(struct obd_export *exp, 701 struct lov_mds_md **disk_tgt, 702 struct lov_stripe_md *mem_src) 703{ 704 int rc; 705 706 EXP_CHECK_DT_OP(exp, packmd); 707 EXP_COUNTER_INCREMENT(exp, packmd); 708 709 rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src); 710 return rc; 711} 712 713static inline int obd_size_diskmd(struct obd_export *exp, 714 struct lov_stripe_md *mem_src) 715{ 716 return obd_packmd(exp, NULL, mem_src); 717} 718 719static inline int obd_free_diskmd(struct obd_export *exp, 720 struct lov_mds_md **disk_tgt) 721{ 722 LASSERT(disk_tgt); 723 LASSERT(*disk_tgt); 724 /* 725 * LU-2590, for caller's convenience, *disk_tgt could be host 726 * endianness, it needs swab to LE if necessary, while just 727 * lov_mds_md header needs it for figuring out how much memory 728 * needs to be freed. 729 */ 730 if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) && 731 (((*disk_tgt)->lmm_magic == LOV_MAGIC_V1) || 732 ((*disk_tgt)->lmm_magic == LOV_MAGIC_V3))) 733 lustre_swab_lov_mds_md(*disk_tgt); 734 return obd_packmd(exp, disk_tgt, NULL); 735} 736 737/* Unpack an MD struct from disk to in-memory format. 738 * Returns +ve size of unpacked MD (0 for free), or -ve error. 739 * 740 * If @mem_tgt == NULL, MD size is returned (max size if @disk_src == NULL). 741 * If @*mem_tgt != NULL and @disk_src == NULL, @*mem_tgt will be freed. 742 * If @*mem_tgt == NULL, it will be allocated 743 */ 744static inline int obd_unpackmd(struct obd_export *exp, 745 struct lov_stripe_md **mem_tgt, 746 struct lov_mds_md *disk_src, 747 int disk_len) 748{ 749 int rc; 750 751 EXP_CHECK_DT_OP(exp, unpackmd); 752 EXP_COUNTER_INCREMENT(exp, unpackmd); 753 754 rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len); 755 return rc; 756} 757 758/* helper functions */ 759static inline int obd_alloc_memmd(struct obd_export *exp, 760 struct lov_stripe_md **mem_tgt) 761{ 762 LASSERT(mem_tgt); 763 LASSERT(*mem_tgt == NULL); 764 return obd_unpackmd(exp, mem_tgt, NULL, 0); 765} 766 767static inline int obd_free_memmd(struct obd_export *exp, 768 struct lov_stripe_md **mem_tgt) 769{ 770 int rc; 771 772 LASSERT(mem_tgt); 773 LASSERT(*mem_tgt); 774 rc = obd_unpackmd(exp, mem_tgt, NULL, 0); 775 *mem_tgt = NULL; 776 return rc; 777} 778 779static inline int obd_create(const struct lu_env *env, struct obd_export *exp, 780 struct obdo *obdo, struct lov_stripe_md **ea, 781 struct obd_trans_info *oti) 782{ 783 int rc; 784 785 EXP_CHECK_DT_OP(exp, create); 786 EXP_COUNTER_INCREMENT(exp, create); 787 788 rc = OBP(exp->exp_obd, create)(env, exp, obdo, ea, oti); 789 return rc; 790} 791 792static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, 793 struct obdo *obdo, struct lov_stripe_md *ea, 794 struct obd_trans_info *oti, 795 struct obd_export *md_exp, void *capa) 796{ 797 int rc; 798 799 EXP_CHECK_DT_OP(exp, destroy); 800 EXP_COUNTER_INCREMENT(exp, destroy); 801 802 rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp, capa); 803 return rc; 804} 805 806static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, 807 struct obd_info *oinfo) 808{ 809 int rc; 810 811 EXP_CHECK_DT_OP(exp, getattr); 812 EXP_COUNTER_INCREMENT(exp, getattr); 813 814 rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo); 815 return rc; 816} 817 818static inline int obd_getattr_async(struct obd_export *exp, 819 struct obd_info *oinfo, 820 struct ptlrpc_request_set *set) 821{ 822 int rc; 823 824 EXP_CHECK_DT_OP(exp, getattr_async); 825 EXP_COUNTER_INCREMENT(exp, getattr_async); 826 827 rc = OBP(exp->exp_obd, getattr_async)(exp, oinfo, set); 828 return rc; 829} 830 831static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, 832 struct obd_info *oinfo, 833 struct obd_trans_info *oti) 834{ 835 int rc; 836 837 EXP_CHECK_DT_OP(exp, setattr); 838 EXP_COUNTER_INCREMENT(exp, setattr); 839 840 rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo, oti); 841 return rc; 842} 843 844/* This performs all the requests set init/wait/destroy actions. */ 845static inline int obd_setattr_rqset(struct obd_export *exp, 846 struct obd_info *oinfo, 847 struct obd_trans_info *oti) 848{ 849 struct ptlrpc_request_set *set = NULL; 850 int rc; 851 852 EXP_CHECK_DT_OP(exp, setattr_async); 853 EXP_COUNTER_INCREMENT(exp, setattr_async); 854 855 set = ptlrpc_prep_set(); 856 if (set == NULL) 857 return -ENOMEM; 858 859 rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); 860 if (rc == 0) 861 rc = ptlrpc_set_wait(set); 862 ptlrpc_set_destroy(set); 863 return rc; 864} 865 866/* This adds all the requests into @set if @set != NULL, otherwise 867 all requests are sent asynchronously without waiting for response. */ 868static inline int obd_setattr_async(struct obd_export *exp, 869 struct obd_info *oinfo, 870 struct obd_trans_info *oti, 871 struct ptlrpc_request_set *set) 872{ 873 int rc; 874 875 EXP_CHECK_DT_OP(exp, setattr_async); 876 EXP_COUNTER_INCREMENT(exp, setattr_async); 877 878 rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); 879 return rc; 880} 881 882static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, 883 int priority) 884{ 885 struct obd_device *obd = imp->imp_obd; 886 int rc; 887 888 OBD_CHECK_DEV_ACTIVE(obd); 889 OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); 890 OBD_COUNTER_INCREMENT(obd, add_conn); 891 892 rc = OBP(obd, add_conn)(imp, uuid, priority); 893 return rc; 894} 895 896static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) 897{ 898 struct obd_device *obd = imp->imp_obd; 899 int rc; 900 901 OBD_CHECK_DEV_ACTIVE(obd); 902 OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); 903 OBD_COUNTER_INCREMENT(obd, del_conn); 904 905 rc = OBP(obd, del_conn)(imp, uuid); 906 return rc; 907} 908 909static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) 910{ 911 struct obd_uuid *uuid; 912 913 OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL); 914 EXP_COUNTER_INCREMENT(exp, get_uuid); 915 916 uuid = OBP(exp->exp_obd, get_uuid)(exp); 917 return uuid; 918} 919 920/** Create a new /a exp on device /a obd for the uuid /a cluuid 921 * @param exp New export handle 922 * @param d Connect data, supported flags are set, flags also understood 923 * by obd are returned. 924 */ 925static inline int obd_connect(const struct lu_env *env, 926 struct obd_export **exp, struct obd_device *obd, 927 struct obd_uuid *cluuid, 928 struct obd_connect_data *data, 929 void *localdata) 930{ 931 int rc; 932 __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition 933 * check */ 934 935 OBD_CHECK_DEV_ACTIVE(obd); 936 OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); 937 OBD_COUNTER_INCREMENT(obd, connect); 938 939 rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); 940 /* check that only subset is granted */ 941 LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) == 942 data->ocd_connect_flags)); 943 return rc; 944} 945 946static inline int obd_reconnect(const struct lu_env *env, 947 struct obd_export *exp, 948 struct obd_device *obd, 949 struct obd_uuid *cluuid, 950 struct obd_connect_data *d, 951 void *localdata) 952{ 953 int rc; 954 __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition 955 * check */ 956 957 OBD_CHECK_DEV_ACTIVE(obd); 958 OBD_CHECK_DT_OP(obd, reconnect, 0); 959 OBD_COUNTER_INCREMENT(obd, reconnect); 960 961 rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata); 962 /* check that only subset is granted */ 963 LASSERT(ergo(d != NULL, 964 (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); 965 return rc; 966} 967 968static inline int obd_disconnect(struct obd_export *exp) 969{ 970 int rc; 971 972 EXP_CHECK_DT_OP(exp, disconnect); 973 EXP_COUNTER_INCREMENT(exp, disconnect); 974 975 rc = OBP(exp->exp_obd, disconnect)(exp); 976 return rc; 977} 978 979static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, 980 enum lu_cli_type type) 981{ 982 int rc; 983 984 OBD_CHECK_DT_OP(obd, fid_init, 0); 985 OBD_COUNTER_INCREMENT(obd, fid_init); 986 987 rc = OBP(obd, fid_init)(obd, exp, type); 988 return rc; 989} 990 991static inline int obd_fid_fini(struct obd_device *obd) 992{ 993 int rc; 994 995 OBD_CHECK_DT_OP(obd, fid_fini, 0); 996 OBD_COUNTER_INCREMENT(obd, fid_fini); 997 998 rc = OBP(obd, fid_fini)(obd); 999 return rc; 1000} 1001 1002static inline int obd_fid_alloc(struct obd_export *exp, 1003 struct lu_fid *fid, 1004 struct md_op_data *op_data) 1005{ 1006 int rc; 1007 1008 EXP_CHECK_DT_OP(exp, fid_alloc); 1009 EXP_COUNTER_INCREMENT(exp, fid_alloc); 1010 1011 rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, op_data); 1012 return rc; 1013} 1014 1015static inline int obd_pool_new(struct obd_device *obd, char *poolname) 1016{ 1017 int rc; 1018 1019 OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP); 1020 OBD_COUNTER_INCREMENT(obd, pool_new); 1021 1022 rc = OBP(obd, pool_new)(obd, poolname); 1023 return rc; 1024} 1025 1026static inline int obd_pool_del(struct obd_device *obd, char *poolname) 1027{ 1028 int rc; 1029 1030 OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP); 1031 OBD_COUNTER_INCREMENT(obd, pool_del); 1032 1033 rc = OBP(obd, pool_del)(obd, poolname); 1034 return rc; 1035} 1036 1037static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) 1038{ 1039 int rc; 1040 1041 OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP); 1042 OBD_COUNTER_INCREMENT(obd, pool_add); 1043 1044 rc = OBP(obd, pool_add)(obd, poolname, ostname); 1045 return rc; 1046} 1047 1048static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname) 1049{ 1050 int rc; 1051 1052 OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP); 1053 OBD_COUNTER_INCREMENT(obd, pool_rem); 1054 1055 rc = OBP(obd, pool_rem)(obd, poolname, ostname); 1056 return rc; 1057} 1058 1059static inline void obd_getref(struct obd_device *obd) 1060{ 1061 if (OBT(obd) && OBP(obd, getref)) { 1062 OBD_COUNTER_INCREMENT(obd, getref); 1063 OBP(obd, getref)(obd); 1064 } 1065} 1066 1067static inline void obd_putref(struct obd_device *obd) 1068{ 1069 if (OBT(obd) && OBP(obd, putref)) { 1070 OBD_COUNTER_INCREMENT(obd, putref); 1071 OBP(obd, putref)(obd); 1072 } 1073} 1074 1075static inline int obd_init_export(struct obd_export *exp) 1076{ 1077 int rc = 0; 1078 1079 if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && 1080 OBP((exp)->exp_obd, init_export)) 1081 rc = OBP(exp->exp_obd, init_export)(exp); 1082 return rc; 1083} 1084 1085static inline int obd_destroy_export(struct obd_export *exp) 1086{ 1087 if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && 1088 OBP((exp)->exp_obd, destroy_export)) 1089 OBP(exp->exp_obd, destroy_export)(exp); 1090 return 0; 1091} 1092 1093/* @max_age is the oldest time in jiffies that we accept using a cached data. 1094 * If the cache is older than @max_age we will get a new value from the 1095 * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ 1096static inline int obd_statfs_async(struct obd_export *exp, 1097 struct obd_info *oinfo, 1098 __u64 max_age, 1099 struct ptlrpc_request_set *rqset) 1100{ 1101 int rc = 0; 1102 struct obd_device *obd; 1103 1104 if (exp == NULL || exp->exp_obd == NULL) 1105 return -EINVAL; 1106 1107 obd = exp->exp_obd; 1108 OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); 1109 OBD_COUNTER_INCREMENT(obd, statfs); 1110 1111 CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n", 1112 obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age); 1113 if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { 1114 rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset); 1115 } else { 1116 CDEBUG(D_SUPER, 1117 "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n", 1118 obd->obd_name, &obd->obd_osfs, 1119 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, 1120 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); 1121 spin_lock(&obd->obd_osfs_lock); 1122 memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs)); 1123 spin_unlock(&obd->obd_osfs_lock); 1124 oinfo->oi_flags |= OBD_STATFS_FROM_CACHE; 1125 if (oinfo->oi_cb_up) 1126 oinfo->oi_cb_up(oinfo, 0); 1127 } 1128 return rc; 1129} 1130 1131static inline int obd_statfs_rqset(struct obd_export *exp, 1132 struct obd_statfs *osfs, __u64 max_age, 1133 __u32 flags) 1134{ 1135 struct ptlrpc_request_set *set = NULL; 1136 struct obd_info oinfo = { { { 0 } } }; 1137 int rc = 0; 1138 1139 set = ptlrpc_prep_set(); 1140 if (set == NULL) 1141 return -ENOMEM; 1142 1143 oinfo.oi_osfs = osfs; 1144 oinfo.oi_flags = flags; 1145 rc = obd_statfs_async(exp, &oinfo, max_age, set); 1146 if (rc == 0) 1147 rc = ptlrpc_set_wait(set); 1148 ptlrpc_set_destroy(set); 1149 return rc; 1150} 1151 1152/* @max_age is the oldest time in jiffies that we accept using a cached data. 1153 * If the cache is older than @max_age we will get a new value from the 1154 * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ 1155static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, 1156 struct obd_statfs *osfs, __u64 max_age, 1157 __u32 flags) 1158{ 1159 int rc = 0; 1160 struct obd_device *obd = exp->exp_obd; 1161 1162 if (obd == NULL) 1163 return -EINVAL; 1164 1165 OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); 1166 OBD_COUNTER_INCREMENT(obd, statfs); 1167 1168 CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n", 1169 obd->obd_osfs_age, max_age); 1170 if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { 1171 rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags); 1172 if (rc == 0) { 1173 spin_lock(&obd->obd_osfs_lock); 1174 memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs)); 1175 obd->obd_osfs_age = cfs_time_current_64(); 1176 spin_unlock(&obd->obd_osfs_lock); 1177 } 1178 } else { 1179 CDEBUG(D_SUPER, "%s: use %p cache blocks %llu/%llu objects %llu/%llu\n", 1180 obd->obd_name, &obd->obd_osfs, 1181 obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, 1182 obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); 1183 spin_lock(&obd->obd_osfs_lock); 1184 memcpy(osfs, &obd->obd_osfs, sizeof(*osfs)); 1185 spin_unlock(&obd->obd_osfs_lock); 1186 } 1187 return rc; 1188} 1189 1190static inline int obd_preprw(const struct lu_env *env, int cmd, 1191 struct obd_export *exp, struct obdo *oa, 1192 int objcount, struct obd_ioobj *obj, 1193 struct niobuf_remote *remote, int *pages, 1194 struct niobuf_local *local, 1195 struct obd_trans_info *oti, 1196 struct lustre_capa *capa) 1197{ 1198 int rc; 1199 1200 EXP_CHECK_DT_OP(exp, preprw); 1201 EXP_COUNTER_INCREMENT(exp, preprw); 1202 1203 rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, 1204 pages, local, oti, capa); 1205 return rc; 1206} 1207 1208static inline int obd_commitrw(const struct lu_env *env, int cmd, 1209 struct obd_export *exp, struct obdo *oa, 1210 int objcount, struct obd_ioobj *obj, 1211 struct niobuf_remote *rnb, int pages, 1212 struct niobuf_local *local, 1213 struct obd_trans_info *oti, int rc) 1214{ 1215 EXP_CHECK_DT_OP(exp, commitrw); 1216 EXP_COUNTER_INCREMENT(exp, commitrw); 1217 1218 rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, 1219 rnb, pages, local, oti, rc); 1220 return rc; 1221} 1222 1223static inline int obd_adjust_kms(struct obd_export *exp, 1224 struct lov_stripe_md *lsm, u64 size, 1225 int shrink) 1226{ 1227 int rc; 1228 1229 EXP_CHECK_DT_OP(exp, adjust_kms); 1230 EXP_COUNTER_INCREMENT(exp, adjust_kms); 1231 1232 rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink); 1233 return rc; 1234} 1235 1236static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, 1237 int len, void *karg, void *uarg) 1238{ 1239 int rc; 1240 1241 EXP_CHECK_DT_OP(exp, iocontrol); 1242 EXP_COUNTER_INCREMENT(exp, iocontrol); 1243 1244 rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); 1245 return rc; 1246} 1247 1248static inline int obd_find_cbdata(struct obd_export *exp, 1249 struct lov_stripe_md *lsm, 1250 ldlm_iterator_t it, void *data) 1251{ 1252 int rc; 1253 1254 EXP_CHECK_DT_OP(exp, find_cbdata); 1255 EXP_COUNTER_INCREMENT(exp, find_cbdata); 1256 1257 rc = OBP(exp->exp_obd, find_cbdata)(exp, lsm, it, data); 1258 return rc; 1259} 1260 1261static inline void obd_import_event(struct obd_device *obd, 1262 struct obd_import *imp, 1263 enum obd_import_event event) 1264{ 1265 if (!obd) { 1266 CERROR("NULL device\n"); 1267 return; 1268 } 1269 if (obd->obd_set_up && OBP(obd, import_event)) { 1270 OBD_COUNTER_INCREMENT(obd, import_event); 1271 OBP(obd, import_event)(obd, imp, event); 1272 } 1273} 1274 1275static inline int obd_notify(struct obd_device *obd, 1276 struct obd_device *watched, 1277 enum obd_notify_event ev, 1278 void *data) 1279{ 1280 int rc; 1281 1282 OBD_CHECK_DEV(obd); 1283 1284 /* the check for async_recov is a complete hack - I'm hereby 1285 overloading the meaning to also mean "this was called from 1286 mds_postsetup". I know that my mds is able to handle notifies 1287 by this point, and it needs to get them to execute mds_postrecov. */ 1288 if (!obd->obd_set_up && !obd->obd_async_recov) { 1289 CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); 1290 return -EINVAL; 1291 } 1292 1293 if (!OBP(obd, notify)) { 1294 CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name); 1295 return -ENOSYS; 1296 } 1297 1298 OBD_COUNTER_INCREMENT(obd, notify); 1299 rc = OBP(obd, notify)(obd, watched, ev, data); 1300 return rc; 1301} 1302 1303static inline int obd_notify_observer(struct obd_device *observer, 1304 struct obd_device *observed, 1305 enum obd_notify_event ev, 1306 void *data) 1307{ 1308 int rc1; 1309 int rc2; 1310 1311 struct obd_notify_upcall *onu; 1312 1313 if (observer->obd_observer) 1314 rc1 = obd_notify(observer->obd_observer, observed, ev, data); 1315 else 1316 rc1 = 0; 1317 /* 1318 * Also, call non-obd listener, if any 1319 */ 1320 onu = &observer->obd_upcall; 1321 if (onu->onu_upcall != NULL) 1322 rc2 = onu->onu_upcall(observer, observed, ev, 1323 onu->onu_owner, NULL); 1324 else 1325 rc2 = 0; 1326 1327 return rc1 ? rc1 : rc2; 1328} 1329 1330static inline int obd_quotacheck(struct obd_export *exp, 1331 struct obd_quotactl *oqctl) 1332{ 1333 int rc; 1334 1335 EXP_CHECK_DT_OP(exp, quotacheck); 1336 EXP_COUNTER_INCREMENT(exp, quotacheck); 1337 1338 rc = OBP(exp->exp_obd, quotacheck)(exp->exp_obd, exp, oqctl); 1339 return rc; 1340} 1341 1342static inline int obd_quotactl(struct obd_export *exp, 1343 struct obd_quotactl *oqctl) 1344{ 1345 int rc; 1346 1347 EXP_CHECK_DT_OP(exp, quotactl); 1348 EXP_COUNTER_INCREMENT(exp, quotactl); 1349 1350 rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); 1351 return rc; 1352} 1353 1354static inline int obd_health_check(const struct lu_env *env, 1355 struct obd_device *obd) 1356{ 1357 /* returns: 0 on healthy 1358 * >0 on unhealthy + reason code/flag 1359 * however the only supported reason == 1 right now 1360 * We'll need to define some better reasons 1361 * or flags in the future. 1362 * <0 on error 1363 */ 1364 int rc; 1365 1366 /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ 1367 if (obd == NULL || !OBT(obd)) { 1368 CERROR("cleaned up obd\n"); 1369 return -EOPNOTSUPP; 1370 } 1371 if (!obd->obd_set_up || obd->obd_stopping) 1372 return 0; 1373 if (!OBP(obd, health_check)) 1374 return 0; 1375 1376 rc = OBP(obd, health_check)(env, obd); 1377 return rc; 1378} 1379 1380static inline int obd_register_observer(struct obd_device *obd, 1381 struct obd_device *observer) 1382{ 1383 OBD_CHECK_DEV(obd); 1384 down_write(&obd->obd_observer_link_sem); 1385 if (obd->obd_observer && observer) { 1386 up_write(&obd->obd_observer_link_sem); 1387 return -EALREADY; 1388 } 1389 obd->obd_observer = observer; 1390 up_write(&obd->obd_observer_link_sem); 1391 return 0; 1392} 1393 1394#if 0 1395static inline int obd_register_page_removal_cb(struct obd_export *exp, 1396 obd_page_removal_cb_t cb, 1397 obd_pin_extent_cb pin_cb) 1398{ 1399 int rc; 1400 1401 OBD_CHECK_DT_OP(exp->exp_obd, register_page_removal_cb, 0); 1402 OBD_COUNTER_INCREMENT(exp->exp_obd, register_page_removal_cb); 1403 1404 rc = OBP(exp->exp_obd, register_page_removal_cb)(exp, cb, pin_cb); 1405 return rc; 1406} 1407 1408static inline int obd_unregister_page_removal_cb(struct obd_export *exp, 1409 obd_page_removal_cb_t cb) 1410{ 1411 int rc; 1412 1413 OBD_CHECK_DT_OP(exp->exp_obd, unregister_page_removal_cb, 0); 1414 OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_page_removal_cb); 1415 1416 rc = OBP(exp->exp_obd, unregister_page_removal_cb)(exp, cb); 1417 return rc; 1418} 1419 1420static inline int obd_register_lock_cancel_cb(struct obd_export *exp, 1421 obd_lock_cancel_cb cb) 1422{ 1423 int rc; 1424 1425 OBD_CHECK_DT_OP(exp->exp_obd, register_lock_cancel_cb, 0); 1426 OBD_COUNTER_INCREMENT(exp->exp_obd, register_lock_cancel_cb); 1427 1428 rc = OBP(exp->exp_obd, register_lock_cancel_cb)(exp, cb); 1429 return rc; 1430} 1431 1432static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp, 1433 obd_lock_cancel_cb cb) 1434{ 1435 int rc; 1436 1437 OBD_CHECK_DT_OP(exp->exp_obd, unregister_lock_cancel_cb, 0); 1438 OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_lock_cancel_cb); 1439 1440 rc = OBP(exp->exp_obd, unregister_lock_cancel_cb)(exp, cb); 1441 return rc; 1442} 1443#endif 1444 1445/* metadata helpers */ 1446static inline int md_getstatus(struct obd_export *exp, 1447 struct lu_fid *fid, struct obd_capa **pc) 1448{ 1449 int rc; 1450 1451 EXP_CHECK_MD_OP(exp, getstatus); 1452 EXP_MD_COUNTER_INCREMENT(exp, getstatus); 1453 rc = MDP(exp->exp_obd, getstatus)(exp, fid, pc); 1454 return rc; 1455} 1456 1457static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, 1458 struct ptlrpc_request **request) 1459{ 1460 int rc; 1461 1462 EXP_CHECK_MD_OP(exp, getattr); 1463 EXP_MD_COUNTER_INCREMENT(exp, getattr); 1464 rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); 1465 return rc; 1466} 1467 1468static inline int md_null_inode(struct obd_export *exp, 1469 const struct lu_fid *fid) 1470{ 1471 int rc; 1472 1473 EXP_CHECK_MD_OP(exp, null_inode); 1474 EXP_MD_COUNTER_INCREMENT(exp, null_inode); 1475 rc = MDP(exp->exp_obd, null_inode)(exp, fid); 1476 return rc; 1477} 1478 1479static inline int md_find_cbdata(struct obd_export *exp, 1480 const struct lu_fid *fid, 1481 ldlm_iterator_t it, void *data) 1482{ 1483 int rc; 1484 1485 EXP_CHECK_MD_OP(exp, find_cbdata); 1486 EXP_MD_COUNTER_INCREMENT(exp, find_cbdata); 1487 rc = MDP(exp->exp_obd, find_cbdata)(exp, fid, it, data); 1488 return rc; 1489} 1490 1491static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, 1492 struct md_open_data *mod, 1493 struct ptlrpc_request **request) 1494{ 1495 int rc; 1496 1497 EXP_CHECK_MD_OP(exp, close); 1498 EXP_MD_COUNTER_INCREMENT(exp, close); 1499 rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); 1500 return rc; 1501} 1502 1503static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, 1504 const void *data, int datalen, int mode, __u32 uid, 1505 __u32 gid, cfs_cap_t cap_effective, __u64 rdev, 1506 struct ptlrpc_request **request) 1507{ 1508 int rc; 1509 1510 EXP_CHECK_MD_OP(exp, create); 1511 EXP_MD_COUNTER_INCREMENT(exp, create); 1512 rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, 1513 uid, gid, cap_effective, rdev, request); 1514 return rc; 1515} 1516 1517static inline int md_done_writing(struct obd_export *exp, 1518 struct md_op_data *op_data, 1519 struct md_open_data *mod) 1520{ 1521 int rc; 1522 1523 EXP_CHECK_MD_OP(exp, done_writing); 1524 EXP_MD_COUNTER_INCREMENT(exp, done_writing); 1525 rc = MDP(exp->exp_obd, done_writing)(exp, op_data, mod); 1526 return rc; 1527} 1528 1529static inline int md_enqueue(struct obd_export *exp, 1530 struct ldlm_enqueue_info *einfo, 1531 struct lookup_intent *it, 1532 struct md_op_data *op_data, 1533 struct lustre_handle *lockh, 1534 void *lmm, int lmmsize, 1535 struct ptlrpc_request **req, 1536 __u64 extra_lock_flags) 1537{ 1538 int rc; 1539 1540 EXP_CHECK_MD_OP(exp, enqueue); 1541 EXP_MD_COUNTER_INCREMENT(exp, enqueue); 1542 rc = MDP(exp->exp_obd, enqueue)(exp, einfo, it, op_data, lockh, 1543 lmm, lmmsize, req, extra_lock_flags); 1544 return rc; 1545} 1546 1547static inline int md_getattr_name(struct obd_export *exp, 1548 struct md_op_data *op_data, 1549 struct ptlrpc_request **request) 1550{ 1551 int rc; 1552 1553 EXP_CHECK_MD_OP(exp, getattr_name); 1554 EXP_MD_COUNTER_INCREMENT(exp, getattr_name); 1555 rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); 1556 return rc; 1557} 1558 1559static inline int md_intent_lock(struct obd_export *exp, 1560 struct md_op_data *op_data, void *lmm, 1561 int lmmsize, struct lookup_intent *it, 1562 int lookup_flags, struct ptlrpc_request **reqp, 1563 ldlm_blocking_callback cb_blocking, 1564 __u64 extra_lock_flags) 1565{ 1566 int rc; 1567 1568 EXP_CHECK_MD_OP(exp, intent_lock); 1569 EXP_MD_COUNTER_INCREMENT(exp, intent_lock); 1570 rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, 1571 it, lookup_flags, reqp, cb_blocking, 1572 extra_lock_flags); 1573 return rc; 1574} 1575 1576static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, 1577 struct ptlrpc_request **request) 1578{ 1579 int rc; 1580 1581 EXP_CHECK_MD_OP(exp, link); 1582 EXP_MD_COUNTER_INCREMENT(exp, link); 1583 rc = MDP(exp->exp_obd, link)(exp, op_data, request); 1584 return rc; 1585} 1586 1587static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, 1588 const char *old, int oldlen, const char *new, 1589 int newlen, struct ptlrpc_request **request) 1590{ 1591 int rc; 1592 1593 EXP_CHECK_MD_OP(exp, rename); 1594 EXP_MD_COUNTER_INCREMENT(exp, rename); 1595 rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, 1596 newlen, request); 1597 return rc; 1598} 1599 1600static inline int md_is_subdir(struct obd_export *exp, 1601 const struct lu_fid *pfid, 1602 const struct lu_fid *cfid, 1603 struct ptlrpc_request **request) 1604{ 1605 int rc; 1606 1607 EXP_CHECK_MD_OP(exp, is_subdir); 1608 EXP_MD_COUNTER_INCREMENT(exp, is_subdir); 1609 rc = MDP(exp->exp_obd, is_subdir)(exp, pfid, cfid, request); 1610 return rc; 1611} 1612 1613static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, 1614 void *ea, int ealen, void *ea2, int ea2len, 1615 struct ptlrpc_request **request, 1616 struct md_open_data **mod) 1617{ 1618 int rc; 1619 1620 EXP_CHECK_MD_OP(exp, setattr); 1621 EXP_MD_COUNTER_INCREMENT(exp, setattr); 1622 rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, 1623 ea2, ea2len, request, mod); 1624 return rc; 1625} 1626 1627static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, 1628 struct obd_capa *oc, struct ptlrpc_request **request) 1629{ 1630 int rc; 1631 1632 EXP_CHECK_MD_OP(exp, sync); 1633 EXP_MD_COUNTER_INCREMENT(exp, sync); 1634 rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request); 1635 return rc; 1636} 1637 1638static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, 1639 struct page **pages, 1640 struct ptlrpc_request **request) 1641{ 1642 int rc; 1643 1644 EXP_CHECK_MD_OP(exp, readpage); 1645 EXP_MD_COUNTER_INCREMENT(exp, readpage); 1646 rc = MDP(exp->exp_obd, readpage)(exp, opdata, pages, request); 1647 return rc; 1648} 1649 1650static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, 1651 struct ptlrpc_request **request) 1652{ 1653 int rc; 1654 1655 EXP_CHECK_MD_OP(exp, unlink); 1656 EXP_MD_COUNTER_INCREMENT(exp, unlink); 1657 rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); 1658 return rc; 1659} 1660 1661static inline int md_get_lustre_md(struct obd_export *exp, 1662 struct ptlrpc_request *req, 1663 struct obd_export *dt_exp, 1664 struct obd_export *md_exp, 1665 struct lustre_md *md) 1666{ 1667 EXP_CHECK_MD_OP(exp, get_lustre_md); 1668 EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); 1669 return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); 1670} 1671 1672static inline int md_free_lustre_md(struct obd_export *exp, 1673 struct lustre_md *md) 1674{ 1675 EXP_CHECK_MD_OP(exp, free_lustre_md); 1676 EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); 1677 return MDP(exp->exp_obd, free_lustre_md)(exp, md); 1678} 1679 1680static inline int md_setxattr(struct obd_export *exp, 1681 const struct lu_fid *fid, struct obd_capa *oc, 1682 u64 valid, const char *name, 1683 const char *input, int input_size, 1684 int output_size, int flags, __u32 suppgid, 1685 struct ptlrpc_request **request) 1686{ 1687 EXP_CHECK_MD_OP(exp, setxattr); 1688 EXP_MD_COUNTER_INCREMENT(exp, setxattr); 1689 return MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input, 1690 input_size, output_size, flags, 1691 suppgid, request); 1692} 1693 1694static inline int md_getxattr(struct obd_export *exp, 1695 const struct lu_fid *fid, struct obd_capa *oc, 1696 u64 valid, const char *name, 1697 const char *input, int input_size, 1698 int output_size, int flags, 1699 struct ptlrpc_request **request) 1700{ 1701 EXP_CHECK_MD_OP(exp, getxattr); 1702 EXP_MD_COUNTER_INCREMENT(exp, getxattr); 1703 return MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input, 1704 input_size, output_size, flags, 1705 request); 1706} 1707 1708static inline int md_set_open_replay_data(struct obd_export *exp, 1709 struct obd_client_handle *och, 1710 struct lookup_intent *it) 1711{ 1712 EXP_CHECK_MD_OP(exp, set_open_replay_data); 1713 EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); 1714 return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it); 1715} 1716 1717static inline int md_clear_open_replay_data(struct obd_export *exp, 1718 struct obd_client_handle *och) 1719{ 1720 EXP_CHECK_MD_OP(exp, clear_open_replay_data); 1721 EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); 1722 return MDP(exp->exp_obd, clear_open_replay_data)(exp, och); 1723} 1724 1725static inline int md_set_lock_data(struct obd_export *exp, 1726 __u64 *lockh, void *data, __u64 *bits) 1727{ 1728 EXP_CHECK_MD_OP(exp, set_lock_data); 1729 EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); 1730 return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits); 1731} 1732 1733static inline int md_cancel_unused(struct obd_export *exp, 1734 const struct lu_fid *fid, 1735 ldlm_policy_data_t *policy, 1736 ldlm_mode_t mode, 1737 ldlm_cancel_flags_t flags, 1738 void *opaque) 1739{ 1740 int rc; 1741 1742 EXP_CHECK_MD_OP(exp, cancel_unused); 1743 EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); 1744 1745 rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, 1746 flags, opaque); 1747 return rc; 1748} 1749 1750static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, 1751 const struct lu_fid *fid, 1752 ldlm_type_t type, 1753 ldlm_policy_data_t *policy, 1754 ldlm_mode_t mode, 1755 struct lustre_handle *lockh) 1756{ 1757 EXP_CHECK_MD_OP(exp, lock_match); 1758 EXP_MD_COUNTER_INCREMENT(exp, lock_match); 1759 return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, 1760 policy, mode, lockh); 1761} 1762 1763static inline int md_init_ea_size(struct obd_export *exp, int easize, 1764 int def_asize, int cookiesize, 1765 int def_cookiesize) 1766{ 1767 EXP_CHECK_MD_OP(exp, init_ea_size); 1768 EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); 1769 return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, 1770 cookiesize, def_cookiesize); 1771} 1772 1773static inline int md_get_remote_perm(struct obd_export *exp, 1774 const struct lu_fid *fid, 1775 struct obd_capa *oc, __u32 suppgid, 1776 struct ptlrpc_request **request) 1777{ 1778 EXP_CHECK_MD_OP(exp, get_remote_perm); 1779 EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm); 1780 return MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid, 1781 request); 1782} 1783 1784static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa, 1785 renew_capa_cb_t cb) 1786{ 1787 int rc; 1788 1789 EXP_CHECK_MD_OP(exp, renew_capa); 1790 EXP_MD_COUNTER_INCREMENT(exp, renew_capa); 1791 rc = MDP(exp->exp_obd, renew_capa)(exp, ocapa, cb); 1792 return rc; 1793} 1794 1795static inline int md_unpack_capa(struct obd_export *exp, 1796 struct ptlrpc_request *req, 1797 const struct req_msg_field *field, 1798 struct obd_capa **oc) 1799{ 1800 int rc; 1801 1802 EXP_CHECK_MD_OP(exp, unpack_capa); 1803 EXP_MD_COUNTER_INCREMENT(exp, unpack_capa); 1804 rc = MDP(exp->exp_obd, unpack_capa)(exp, req, field, oc); 1805 return rc; 1806} 1807 1808static inline int md_intent_getattr_async(struct obd_export *exp, 1809 struct md_enqueue_info *minfo, 1810 struct ldlm_enqueue_info *einfo) 1811{ 1812 int rc; 1813 1814 EXP_CHECK_MD_OP(exp, intent_getattr_async); 1815 EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); 1816 rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo); 1817 return rc; 1818} 1819 1820static inline int md_revalidate_lock(struct obd_export *exp, 1821 struct lookup_intent *it, 1822 struct lu_fid *fid, __u64 *bits) 1823{ 1824 int rc; 1825 1826 EXP_CHECK_MD_OP(exp, revalidate_lock); 1827 EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); 1828 rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); 1829 return rc; 1830} 1831 1832 1833/* OBD Metadata Support */ 1834 1835extern int obd_init_caches(void); 1836extern void obd_cleanup_caches(void); 1837 1838/* support routines */ 1839extern struct kmem_cache *obdo_cachep; 1840 1841#define OBDO_ALLOC(ptr) \ 1842do { \ 1843 OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \ 1844} while (0) 1845 1846#define OBDO_FREE(ptr) \ 1847do { \ 1848 OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \ 1849} while (0) 1850 1851 1852static inline void obdo2fid(struct obdo *oa, struct lu_fid *fid) 1853{ 1854 /* something here */ 1855} 1856 1857static inline void fid2obdo(struct lu_fid *fid, struct obdo *oa) 1858{ 1859 /* something here */ 1860} 1861 1862typedef int (*register_lwp_cb)(void *data); 1863 1864struct lwp_register_item { 1865 struct obd_export **lri_exp; 1866 register_lwp_cb lri_cb_func; 1867 void *lri_cb_data; 1868 struct list_head lri_list; 1869 char lri_name[MTI_NAME_MAXLEN]; 1870}; 1871 1872/* I'm as embarrassed about this as you are. 1873 * 1874 * <shaver> // XXX do not look into _superhack with remaining eye 1875 * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */ 1876extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); 1877 1878/* obd_mount.c */ 1879 1880/* sysctl.c */ 1881extern void obd_sysctl_init (void); 1882extern void obd_sysctl_clean (void); 1883 1884/* uuid.c */ 1885typedef __u8 class_uuid_t[16]; 1886void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out); 1887 1888/* lustre_peer.c */ 1889int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index); 1890int class_add_uuid(const char *uuid, __u64 nid); 1891int class_del_uuid (const char *uuid); 1892int class_check_uuid(struct obd_uuid *uuid, __u64 nid); 1893void class_init_uuidlist(void); 1894void class_exit_uuidlist(void); 1895 1896/* class_obd.c */ 1897extern char obd_jobid_node[]; 1898 1899/* prng.c */ 1900#define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t)) 1901 1902#endif /* __LINUX_OBD_CLASS_H */ 1903