X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Fobd_class.h;h=2f7162566d0ad2d750a23134ab8c7bf861e071f8;hp=690f5c73423814f91f03c9437d870f2087c9769d;hb=3ca197b4aa3b2fc11da9a946db597e73a62fe149;hpb=7d818af6449c9005b2dd7cb213d38d6ad61bf178;ds=sidebyside diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 690f5c7..2f71625 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +26,8 @@ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -58,66 +58,58 @@ #error Unsupported operating system. #endif +#define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay + * and resends for avoid deadlocks */ +#define OBD_STATFS_FROM_CACHE 0x0002 /* the statfs callback should not update + * obd_osfs_age */ +#define OBD_STATFS_PTLRPCD 0x0004 /* requests will be sent via ptlrpcd + * instead of a specific set. This + * means that we cannot rely on the set + * interpret routine to be called. + * lov_statfs_fini() must thus be called + * by the request interpret routine */ +#define OBD_STATFS_FOR_MDT0 0x0008 /* The statfs is only for retrieving + * information from MDT0. */ +#define OBD_FL_PUNCH 0x00000001 /* To indicate it is punch operation */ + /* OBD Device Declarations */ extern struct obd_device *obd_devs[MAX_OBD_DEVICES]; -extern cfs_spinlock_t obd_dev_lock; +extern rwlock_t obd_dev_lock; /* OBD Operations Declarations */ extern struct obd_device *class_conn2obd(struct lustre_handle *); extern struct obd_device *class_exp2obd(struct obd_export *); extern int class_handle_ioctl(unsigned int cmd, unsigned long arg); +extern int lustre_get_jobid(char *jobid); struct lu_device_type; /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *); int class_register_type(struct obd_ops *, struct md_ops *, - struct lprocfs_vars *, const char *nm, - struct lu_device_type *ldt); + struct lprocfs_seq_vars *module_vars, +#ifndef HAVE_ONLY_PROCFS_SEQ + struct lprocfs_vars *, +#endif + const char *nm, + struct lu_device_type *ldt); int class_unregister_type(const char *nm); - - - -/** - allocate one minor number - */ -int obd_minor_alloc(void); -/** - release allocated minor - */ -void obd_minor_release(long minor); -/** - return 1 if minor is point to allocated device, - return 0 otherwise - */ -int obd_minor_valid(long minor); - -int obd_hashes_init(void); -void obd_hashes_fini(void); - -struct obd_device *class_newdev(const char *type_name, const char *name, - const char *uuid); +struct obd_device *class_newdev(const char *type_name, const char *name); void class_release_dev(struct obd_device *obd); int class_name2dev(const char *name); struct obd_device *class_name2obd(const char *name); int class_uuid2dev(struct obd_uuid *uuid); struct obd_device *class_uuid2obd(struct obd_uuid *uuid); - void class_obd_list(void); -void obd_devlist_first(struct obd_device **pos); -void obd_devlist_next(struct obd_device **pos); -void obd_devlist_last(struct obd_device *pos); -const char *obd_dev_status(struct obd_device *obd); - struct obd_device * class_find_client_obd(struct obd_uuid *tgt_uuid, const char * typ_name, struct obd_uuid *grp_uuid); struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid, - struct obd_device **prev); -struct obd_device * class_num2obd(__u32 num); - + int *next); +struct obd_device * class_num2obd(int num); +int get_devices_count(void); int class_notify_sptlrpc_conf(const char *fsname, int namelen); @@ -125,6 +117,7 @@ char *obd_export_nid2str(struct obd_export *exp); int obd_export_evict_by_nid(struct obd_device *obd, const char *nid); int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid); +int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep); int obd_zombie_impexp_init(void); void obd_zombie_impexp_stop(void); @@ -137,10 +130,20 @@ int kuc_ispayload(void *p); void *kuc_alloc(int payload_len, int transport, int type); void kuc_free(void *p, int payload_len); +struct llog_handle; +struct llog_rec_hdr; +typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, + struct llog_rec_hdr *, void *); /* obd_config.c */ +struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, + const char *new_name); int class_process_config(struct lustre_cfg *lcfg); +#ifndef HAVE_ONLY_PROCFS_SEQ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data); +#endif +int class_process_proc_seq_param(char *prefix, struct lprocfs_seq_vars *lvars, + struct lustre_cfg *lcfg, void *data); int class_attach(struct lustre_cfg *lcfg); int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg); int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg); @@ -150,16 +153,11 @@ struct obd_device *class_incref(struct obd_device *obd, void class_decref(struct obd_device *obd, const char *scope, const void *source); void dump_exports(struct obd_device *obd, int locks); - -/*obdecho*/ -#ifdef LPROCFS -extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars); -#else -static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) -{ - memset(lvars, 0, sizeof(*lvars)); -} -#endif +int class_config_llog_handler(const struct lu_env *env, + struct llog_handle *handle, + struct llog_rec_hdr *rec, void *data); +int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg); +int class_add_uuid(const char *uuid, __u64 nid); #define CFG_F_START 0x01 /* Set when we start updating from a log */ #define CFG_F_MARKER 0x02 /* We are within a maker */ @@ -169,32 +167,47 @@ static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars) /* Passed as data param to class_config_parse_llog */ struct config_llog_instance { - char * cfg_instance; - char * cfg_obdname; - struct super_block *cfg_sb; - struct obd_uuid cfg_uuid; - int cfg_last_idx; /* for partial llog processing */ - int cfg_flags; + char *cfg_obdname; + void *cfg_instance; + struct super_block *cfg_sb; + struct obd_uuid cfg_uuid; + llog_cb_t cfg_callback; + int cfg_last_idx; /* for partial llog processing */ + int cfg_flags; + __u32 cfg_lwp_idx; }; -int class_config_parse_llog(struct llog_ctxt *ctxt, char *name, - struct config_llog_instance *cfg); -int class_config_dump_llog(struct llog_ctxt *ctxt, char *name, - struct config_llog_instance *cfg); +int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, + char *name, struct config_llog_instance *cfg); +int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, + char *name, struct config_llog_instance *cfg); + +enum { + CONFIG_T_CONFIG = 0, + CONFIG_T_SPTLRPC = 1, + CONFIG_T_RECOVER = 2, + CONFIG_T_PARAMS = 3, + CONFIG_T_MAX = 4 +}; + +#define PARAMS_FILENAME "params" +#define LCTL_UPCALL "lctl" /* list of active configuration logs */ struct config_llog_data { - char *cld_logname; struct ldlm_res_id cld_resid; struct config_llog_instance cld_cfg; cfs_list_t cld_list_chain; - cfs_atomic_t cld_refcount; - struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */ + atomic_t cld_refcount; + struct config_llog_data *cld_sptlrpc;/* depended sptlrpc log */ + struct config_llog_data *cld_params; /* common parameters log */ + struct config_llog_data *cld_recover;/* imperative recover log */ struct obd_export *cld_mgcexp; - cfs_mutex_t cld_lock; + struct mutex cld_lock; + int cld_type; unsigned int cld_stopping:1, /* we were told to stop * watching */ - cld_lostlock:1, /* lock not requeued */ - cld_is_sptlrpc:1; + cld_lostlock:1; /* lock not requeued */ + char cld_logname[0]; }; struct lustre_profile { @@ -221,57 +234,55 @@ extern void (*class_export_dump_hook)(struct obd_export *); #endif -#define class_export_rpc_get(exp) \ +#define class_export_rpc_inc(exp) \ ({ \ - cfs_atomic_inc(&(exp)->exp_rpc_count); \ - CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \ - (exp), cfs_atomic_read(&(exp)->exp_rpc_count)); \ - class_export_get(exp); \ + atomic_inc(&(exp)->exp_rpc_count); \ + CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n", \ + (exp), atomic_read(&(exp)->exp_rpc_count)); \ }) -#define class_export_rpc_put(exp) \ +#define class_export_rpc_dec(exp) \ ({ \ - LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \ - cfs_atomic_dec(&(exp)->exp_rpc_count); \ - CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \ - (exp), cfs_atomic_read(&(exp)->exp_rpc_count)); \ - class_export_put(exp); \ + LASSERT_ATOMIC_POS(&exp->exp_rpc_count); \ + atomic_dec(&(exp)->exp_rpc_count); \ + CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n", \ + (exp), atomic_read(&(exp)->exp_rpc_count)); \ }) #define class_export_lock_get(exp, lock) \ ({ \ - cfs_atomic_inc(&(exp)->exp_locks_count); \ - __class_export_add_lock_ref(exp, lock); \ - CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \ - (exp), cfs_atomic_read(&(exp)->exp_locks_count)); \ - class_export_get(exp); \ + atomic_inc(&(exp)->exp_locks_count); \ + __class_export_add_lock_ref(exp, lock); \ + CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \ + (exp), atomic_read(&(exp)->exp_locks_count)); \ + class_export_get(exp); \ }) #define class_export_lock_put(exp, lock) \ ({ \ - LASSERT_ATOMIC_POS(&exp->exp_locks_count); \ - cfs_atomic_dec(&(exp)->exp_locks_count); \ - __class_export_del_lock_ref(exp, lock); \ - CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \ - (exp), cfs_atomic_read(&(exp)->exp_locks_count)); \ - class_export_put(exp); \ + LASSERT_ATOMIC_POS(&exp->exp_locks_count); \ + atomic_dec(&(exp)->exp_locks_count); \ + __class_export_del_lock_ref(exp, lock); \ + CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \ + (exp), atomic_read(&(exp)->exp_locks_count)); \ + class_export_put(exp); \ }) #define class_export_cb_get(exp) \ ({ \ - cfs_atomic_inc(&(exp)->exp_cb_count); \ - CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\ - (exp), cfs_atomic_read(&(exp)->exp_cb_count)); \ - class_export_get(exp); \ + atomic_inc(&(exp)->exp_cb_count); \ + CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\ + (exp), atomic_read(&(exp)->exp_cb_count)); \ + class_export_get(exp); \ }) #define class_export_cb_put(exp) \ ({ \ - LASSERT_ATOMIC_POS(&exp->exp_cb_count); \ - cfs_atomic_dec(&(exp)->exp_cb_count); \ - CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\ - (exp), cfs_atomic_read(&(exp)->exp_cb_count)); \ - class_export_put(exp); \ + LASSERT_ATOMIC_POS(&exp->exp_cb_count); \ + atomic_dec(&(exp)->exp_cb_count); \ + CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\ + (exp), atomic_read(&(exp)->exp_cb_count)); \ + class_export_put(exp); \ }) /* genops.c */ @@ -306,6 +317,7 @@ static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) 0); } +#ifdef HAVE_SERVER_SUPPORT static inline struct lu_target *class_exp2tgt(struct obd_export *exp) { LASSERT(exp->exp_obd); @@ -317,6 +329,7 @@ static inline struct lr_server_data *class_server_data(struct obd_device *obd) LASSERT(obd->u.obt.obt_lut); return &obd->u.obt.obt_lut->lut_lsd; } +#endif void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid); void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj); @@ -355,64 +368,57 @@ do { \ #ifdef LPROCFS -#define OBD_COUNTER_OFFSET(op) \ - ((offsetof(struct obd_ops, o_ ## op) - \ - offsetof(struct obd_ops, o_iocontrol)) \ - / sizeof(((struct obd_ops *)(0))->o_iocontrol)) - -#define OBD_COUNTER_INCREMENT(obdx, op) \ - if ((obdx)->obd_stats != NULL) { \ - unsigned int coffset; \ - coffset = (unsigned int)((obdx)->obd_cntr_base) + \ - OBD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (obdx)->obd_stats->ls_num); \ - lprocfs_counter_incr((obdx)->obd_stats, coffset); \ - } - -#define EXP_COUNTER_INCREMENT(export, op) \ - if ((export)->exp_obd->obd_stats != NULL) { \ - unsigned int coffset; \ - coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \ - OBD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ - lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ - if ((export)->exp_nid_stats != NULL && \ - (export)->exp_nid_stats->nid_stats != NULL) \ - lprocfs_counter_incr( \ - (export)->exp_nid_stats->nid_stats, coffset);\ - } - -#define MD_COUNTER_OFFSET(op) \ - ((offsetof(struct md_ops, m_ ## op) - \ - offsetof(struct md_ops, m_getstatus)) \ - / sizeof(((struct md_ops *)(0))->m_getstatus)) - -#define MD_COUNTER_INCREMENT(obdx, op) \ - if ((obd)->md_stats != NULL) { \ - unsigned int coffset; \ - coffset = (unsigned int)((obdx)->md_cntr_base) + \ - MD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (obdx)->md_stats->ls_num); \ - lprocfs_counter_incr((obdx)->md_stats, coffset); \ - } - -#define EXP_MD_COUNTER_INCREMENT(export, op) \ - if ((export)->exp_obd->obd_stats != NULL) { \ - unsigned int coffset; \ - coffset = (unsigned int)((export)->exp_obd->md_cntr_base) + \ - MD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (export)->exp_obd->md_stats->ls_num); \ - lprocfs_counter_incr((export)->exp_obd->md_stats, coffset); \ - if ((export)->exp_md_stats != NULL) \ - lprocfs_counter_incr( \ - (export)->exp_md_stats, coffset); \ - } +#define OBD_COUNTER_OFFSET(op) \ + ((offsetof(struct obd_ops, o_ ## op) - \ + offsetof(struct obd_ops, o_iocontrol)) \ + / sizeof(((struct obd_ops *)NULL)->o_iocontrol)) + +/* The '- 1' below is for o_owner. */ +#define NUM_OBD_STATS \ + (sizeof(struct obd_ops) / \ + sizeof(((struct obd_ops *)NULL)->o_iocontrol) - 1) + +#define OBD_COUNTER_INCREMENT(obd, op) \ + lprocfs_counter_incr((obd)->obd_stats, \ + (obd)->obd_cntr_base + OBD_COUNTER_OFFSET(op)) + +#define EXP_COUNTER_INCREMENT(exp, op) \ + do { \ + unsigned int _off; \ + _off = (exp)->exp_obd->obd_cntr_base + OBD_COUNTER_OFFSET(op); \ + lprocfs_counter_incr((exp)->exp_obd->obd_stats, _off); \ + if ((exp)->exp_obd->obd_uses_nid_stats && \ + (exp)->exp_nid_stats != NULL) \ + lprocfs_counter_incr((exp)->exp_nid_stats->nid_stats, \ + _off); \ + } while (0) + +#define _MD_COUNTER_OFFSET(m_op) \ + ((offsetof(struct md_ops, m_op) - \ + offsetof(struct md_ops, MD_STATS_FIRST_OP)) / \ + sizeof(((struct md_ops *)NULL)->MD_STATS_FIRST_OP)) + +#define MD_COUNTER_OFFSET(op) _MD_COUNTER_OFFSET(m_ ## op) + +#define NUM_MD_STATS \ + (_MD_COUNTER_OFFSET(MD_STATS_LAST_OP) - \ + _MD_COUNTER_OFFSET(MD_STATS_FIRST_OP) + 1) + +/* Note that we only increment md counters for ops whose offset is less + * than NUM_MD_STATS. This is explained in a comment in the definition + * of struct md_ops. */ +#define EXP_MD_COUNTER_INCREMENT(exp, op) \ + do { \ + if (MD_COUNTER_OFFSET(op) < NUM_MD_STATS) \ + lprocfs_counter_incr((exp)->exp_obd->obd_md_stats, \ + (exp)->exp_obd->obd_md_cntr_base + \ + MD_COUNTER_OFFSET(op)); \ + } while (0) #else #define OBD_COUNTER_OFFSET(op) #define OBD_COUNTER_INCREMENT(obd, op) #define EXP_COUNTER_INCREMENT(exp, op) -#define MD_COUNTER_INCREMENT(obd, op) #define EXP_MD_COUNTER_INCREMENT(exp, op) #endif @@ -430,16 +436,6 @@ static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp) tmp->nid_ldlm_stats); } -#define OBD_CHECK_MD_OP(obd, op, err) \ -do { \ - if (!OBT(obd) || !MDP((obd), op)) { \ - if (err) \ - CERROR("md_" #op ": dev %s/%d no operation\n", \ - obd->obd_name, obd->obd_minor); \ - RETURN(err); \ - } \ -} while (0) - #define EXP_CHECK_MD_OP(exp, op) \ do { \ if ((exp) == NULL) { \ @@ -496,7 +492,13 @@ do { \ } \ } while (0) -static inline int obd_get_info(struct obd_export *exp, __u32 keylen, +static inline int class_devno_max(void) +{ + return MAX_OBD_DEVICES; +} + +static inline int obd_get_info(const struct lu_env *env, + struct obd_export *exp, __u32 keylen, void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm) { @@ -506,11 +508,13 @@ static inline int obd_get_info(struct obd_export *exp, __u32 keylen, EXP_CHECK_DT_OP(exp, get_info); EXP_COUNTER_INCREMENT(exp, get_info); - rc = OBP(exp->exp_obd, get_info)(exp, keylen, key, vallen, val, lsm); + rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val, + lsm); RETURN(rc); } -static inline int obd_set_info_async(struct obd_export *exp, obd_count keylen, +static inline int obd_set_info_async(const struct lu_env *env, + struct obd_export *exp, obd_count keylen, void *key, obd_count vallen, void *val, struct ptlrpc_request_set *set) { @@ -520,8 +524,8 @@ static inline int obd_set_info_async(struct obd_export *exp, obd_count keylen, EXP_CHECK_DT_OP(exp, set_info_async); EXP_COUNTER_INCREMENT(exp, set_info_async); - rc = OBP(exp->exp_obd, set_info_async)(exp, keylen, key, vallen, val, - set); + rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, + val, set); RETURN(rc); } @@ -557,7 +561,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) if (ldt != NULL) { struct lu_context session_ctx; struct lu_env env; - lu_context_init(&session_ctx, LCT_SESSION); + lu_context_init(&session_ctx, LCT_SESSION | LCT_SERVER_SESSION); session_ctx.lc_thread = NULL; lu_context_enter(&session_ctx); @@ -639,6 +643,31 @@ static inline int obd_cleanup(struct obd_device *obd) RETURN(rc); } +static inline void obd_cleanup_client_import(struct obd_device *obd) +{ + ENTRY; + + /* If we set up but never connected, the + client import will not have been cleaned. */ + down_write(&obd->u.cli.cl_sem); + if (obd->u.cli.cl_import) { + struct obd_import *imp; + imp = obd->u.cli.cl_import; + CDEBUG(D_CONFIG, "%s: client import never connected\n", + obd->obd_name); + ptlrpc_invalidate_import(imp); + if (imp->imp_rq_pool) { + ptlrpc_free_rq_pool(imp->imp_rq_pool); + imp->imp_rq_pool = NULL; + } + client_destroy_import(imp); + obd->u.cli.cl_import = NULL; + } + up_write(&obd->u.cli.cl_sem); + + EXIT; +} + static inline int obd_process_config(struct obd_device *obd, int datalen, void *data) { @@ -696,21 +725,22 @@ static inline int obd_size_diskmd(struct obd_export *exp, return obd_packmd(exp, NULL, mem_src); } -/* helper functions */ -static inline int obd_alloc_diskmd(struct obd_export *exp, - struct lov_mds_md **disk_tgt) -{ - LASSERT(disk_tgt); - LASSERT(*disk_tgt == NULL); - return obd_packmd(exp, disk_tgt, NULL); -} - static inline int obd_free_diskmd(struct obd_export *exp, - struct lov_mds_md **disk_tgt) -{ - LASSERT(disk_tgt); - LASSERT(*disk_tgt); - return obd_packmd(exp, disk_tgt, NULL); + struct lov_mds_md **disk_tgt) +{ + LASSERT(disk_tgt); + LASSERT(*disk_tgt); + /* + * LU-2590, for caller's convenience, *disk_tgt could be host + * endianness, it needs swab to LE if necessary, while just + * lov_mds_md header needs it for figuring out how much memory + * needs to be freed. + */ + if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) && + (((*disk_tgt)->lmm_magic == LOV_MAGIC_V1) || + ((*disk_tgt)->lmm_magic == LOV_MAGIC_V3))) + lustre_swab_lov_mds_md(*disk_tgt); + return obd_packmd(exp, disk_tgt, NULL); } /* Unpack an MD struct from disk to in-memory format. @@ -756,18 +786,6 @@ static inline int obd_free_memmd(struct obd_export *exp, return rc; } -static inline int obd_precreate(struct obd_export *exp) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, precreate); - OBD_COUNTER_INCREMENT(exp->exp_obd, precreate); - - rc = OBP(exp->exp_obd, precreate)(exp); - RETURN(rc); -} - static inline int obd_create_async(struct obd_export *exp, struct obd_info *oinfo, struct lov_stripe_md **ea, @@ -783,8 +801,8 @@ static inline int obd_create_async(struct obd_export *exp, RETURN(rc); } -static inline int obd_create(struct obd_export *exp, struct obdo *obdo, - struct lov_stripe_md **ea, +static inline int obd_create(const struct lu_env *env, struct obd_export *exp, + struct obdo *obdo, struct lov_stripe_md **ea, struct obd_trans_info *oti) { int rc; @@ -793,12 +811,12 @@ static inline int obd_create(struct obd_export *exp, struct obdo *obdo, EXP_CHECK_DT_OP(exp, create); EXP_COUNTER_INCREMENT(exp, create); - rc = OBP(exp->exp_obd, create)(exp, obdo, ea, oti); + rc = OBP(exp->exp_obd, create)(env, exp, obdo, ea, oti); RETURN(rc); } -static inline int obd_destroy(struct obd_export *exp, struct obdo *obdo, - struct lov_stripe_md *ea, +static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, + struct obdo *obdo, struct lov_stripe_md *ea, struct obd_trans_info *oti, struct obd_export *md_exp, void *capa) { @@ -808,11 +826,12 @@ static inline int obd_destroy(struct obd_export *exp, struct obdo *obdo, EXP_CHECK_DT_OP(exp, destroy); EXP_COUNTER_INCREMENT(exp, destroy); - rc = OBP(exp->exp_obd, destroy)(exp, obdo, ea, oti, md_exp, capa); + rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp, capa); RETURN(rc); } -static inline int obd_getattr(struct obd_export *exp, struct obd_info *oinfo) +static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, + struct obd_info *oinfo) { int rc; ENTRY; @@ -820,7 +839,7 @@ static inline int obd_getattr(struct obd_export *exp, struct obd_info *oinfo) EXP_CHECK_DT_OP(exp, getattr); EXP_COUNTER_INCREMENT(exp, getattr); - rc = OBP(exp->exp_obd, getattr)(exp, oinfo); + rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo); RETURN(rc); } @@ -838,7 +857,8 @@ static inline int obd_getattr_async(struct obd_export *exp, RETURN(rc); } -static inline int obd_setattr(struct obd_export *exp, struct obd_info *oinfo, +static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, + struct obd_info *oinfo, struct obd_trans_info *oti) { int rc; @@ -847,7 +867,7 @@ static inline int obd_setattr(struct obd_export *exp, struct obd_info *oinfo, EXP_CHECK_DT_OP(exp, setattr); EXP_COUNTER_INCREMENT(exp, setattr); - rc = OBP(exp->exp_obd, setattr)(exp, oinfo, oti); + rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo, oti); RETURN(rc); } @@ -940,11 +960,11 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) static inline int obd_connect(const struct lu_env *env, struct obd_export **exp,struct obd_device *obd, struct obd_uuid *cluuid, - struct obd_connect_data *d, + struct obd_connect_data *data, void *localdata) { int rc; - __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition + __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition * check */ ENTRY; @@ -952,10 +972,10 @@ static inline int obd_connect(const struct lu_env *env, OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, connect); - rc = OBP(obd, connect)(env, exp, obd, cluuid, d, localdata); + rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); /* check that only subset is granted */ - LASSERT(ergo(d != NULL, - (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); + LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) == + data->ocd_connect_flags)); RETURN(rc); } @@ -995,28 +1015,29 @@ static inline int obd_disconnect(struct obd_export *exp) RETURN(rc); } -static inline int obd_fid_init(struct obd_export *exp) +static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, + enum lu_cli_type type) { - int rc; - ENTRY; + int rc; + ENTRY; - OBD_CHECK_DT_OP(exp->exp_obd, fid_init, 0); - EXP_COUNTER_INCREMENT(exp, fid_init); + OBD_CHECK_DT_OP(obd, fid_init, 0); + OBD_COUNTER_INCREMENT(obd, fid_init); - rc = OBP(exp->exp_obd, fid_init)(exp); - RETURN(rc); + rc = OBP(obd, fid_init)(obd, exp, type); + RETURN(rc); } -static inline int obd_fid_fini(struct obd_export *exp) +static inline int obd_fid_fini(struct obd_device *obd) { - int rc; - ENTRY; + int rc; + ENTRY; - OBD_CHECK_DT_OP(exp->exp_obd, fid_fini, 0); - EXP_COUNTER_INCREMENT(exp, fid_fini); + OBD_CHECK_DT_OP(obd, fid_fini, 0); + OBD_COUNTER_INCREMENT(obd, fid_fini); - rc = OBP(exp->exp_obd, fid_fini)(exp); - RETURN(rc); + rc = OBP(obd, fid_fini)(obd); + RETURN(rc); } static inline int obd_fid_alloc(struct obd_export *exp, @@ -1033,20 +1054,7 @@ static inline int obd_fid_alloc(struct obd_export *exp, RETURN(rc); } -static inline int obd_fid_delete(struct obd_export *exp, - const struct lu_fid *fid) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, fid_delete); - EXP_COUNTER_INCREMENT(exp, fid_delete); - - rc = OBP(exp->exp_obd, fid_delete)(exp, fid); - RETURN(rc); -} - -static inline int obd_ping(struct obd_export *exp) +static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) { int rc; ENTRY; @@ -1054,7 +1062,7 @@ static inline int obd_ping(struct obd_export *exp) OBD_CHECK_DT_OP(exp->exp_obd, ping, 0); EXP_COUNTER_INCREMENT(exp, ping); - rc = OBP(exp->exp_obd, ping)(exp); + rc = OBP(exp->exp_obd, ping)(env, exp); RETURN(rc); } @@ -1146,68 +1154,38 @@ static inline int obd_destroy_export(struct obd_export *exp) RETURN(0); } -static inline int obd_extent_calc(struct obd_export *exp, - struct lov_stripe_md *md, - int cmd, obd_off *offset) -{ - int rc; - ENTRY; - EXP_CHECK_DT_OP(exp, extent_calc); - rc = OBP(exp->exp_obd, extent_calc)(exp, md, cmd, offset); - RETURN(rc); -} - -static inline struct dentry * -obd_lvfs_fid2dentry(struct obd_export *exp, __u64 id_ino, __u32 gen, __u64 gr) -{ - LASSERT(exp->exp_obd); - - return lvfs_fid2dentry(&exp->exp_obd->obd_lvfs_ctxt, id_ino, gen, gr, - exp->exp_obd); -} - -static inline int -obd_lvfs_open_llog(struct obd_export *exp, __u64 id_ino, struct dentry *dentry) -{ - LASSERT(exp->exp_obd); - CERROR("FIXME what's the story here? This needs to be an obd fn?\n"); -#if 0 - return lvfs_open_llog(&exp->exp_obd->obd_lvfs_ctxt, id_ino, - dentry, exp->exp_obd); -#endif - return 0; -} - /* @max_age is the oldest time in jiffies that we accept using a cached data. * If the cache is older than @max_age we will get a new value from the * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ -static inline int obd_statfs_async(struct obd_device *obd, +static inline int obd_statfs_async(struct obd_export *exp, struct obd_info *oinfo, __u64 max_age, struct ptlrpc_request_set *rqset) { int rc = 0; + struct obd_device *obd; ENTRY; - if (obd == NULL) + if (exp == NULL || exp->exp_obd == NULL) RETURN(-EINVAL); + obd = exp->exp_obd; OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, statfs); CDEBUG(D_SUPER, "%s: osfs %p age "LPU64", max_age "LPU64"\n", obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age); if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { - rc = OBP(obd, statfs_async)(obd, oinfo, max_age, rqset); + rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset); } else { CDEBUG(D_SUPER,"%s: use %p cache blocks "LPU64"/"LPU64 " objects "LPU64"/"LPU64"\n", obd->obd_name, &obd->obd_osfs, obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); - cfs_spin_lock(&obd->obd_osfs_lock); - memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs)); - cfs_spin_unlock(&obd->obd_osfs_lock); + spin_lock(&obd->obd_osfs_lock); + memcpy(oinfo->oi_osfs, &obd->obd_osfs, sizeof(*oinfo->oi_osfs)); + spin_unlock(&obd->obd_osfs_lock); oinfo->oi_flags |= OBD_STATFS_FROM_CACHE; if (oinfo->oi_cb_up) oinfo->oi_cb_up(oinfo, 0); @@ -1215,7 +1193,7 @@ static inline int obd_statfs_async(struct obd_device *obd, RETURN(rc); } -static inline int obd_statfs_rqset(struct obd_device *obd, +static inline int obd_statfs_rqset(struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { @@ -1230,7 +1208,7 @@ static inline int obd_statfs_rqset(struct obd_device *obd, oinfo.oi_osfs = osfs; oinfo.oi_flags = flags; - rc = obd_statfs_async(obd, &oinfo, max_age, set); + rc = obd_statfs_async(exp, &oinfo, max_age, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); @@ -1240,10 +1218,12 @@ static inline int obd_statfs_rqset(struct obd_device *obd, /* @max_age is the oldest time in jiffies that we accept using a cached data. * If the cache is older than @max_age we will get a new value from the * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ -static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs, - __u64 max_age, __u32 flags) +static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, + struct obd_statfs *osfs, __u64 max_age, + __u32 flags) { int rc = 0; + struct obd_device *obd = exp->exp_obd; ENTRY; if (obd == NULL) @@ -1255,97 +1235,28 @@ static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs, CDEBUG(D_SUPER, "osfs "LPU64", max_age "LPU64"\n", obd->obd_osfs_age, max_age); if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { - rc = OBP(obd, statfs)(obd, osfs, max_age, flags); + rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags); if (rc == 0) { - cfs_spin_lock(&obd->obd_osfs_lock); - memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs)); - obd->obd_osfs_age = cfs_time_current_64(); - cfs_spin_unlock(&obd->obd_osfs_lock); - } - } else { - CDEBUG(D_SUPER,"%s: use %p cache blocks "LPU64"/"LPU64 - " objects "LPU64"/"LPU64"\n", - obd->obd_name, &obd->obd_osfs, - obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, - obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); - cfs_spin_lock(&obd->obd_osfs_lock); - memcpy(osfs, &obd->obd_osfs, sizeof(*osfs)); - cfs_spin_unlock(&obd->obd_osfs_lock); - } - RETURN(rc); -} - -static inline int obd_sync(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *ea, obd_size start, - obd_size end, void *capa) -{ - int rc; - ENTRY; - - OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP); - EXP_COUNTER_INCREMENT(exp, sync); - - rc = OBP(exp->exp_obd, sync)(exp, oa, ea, start, end, capa); - RETURN(rc); -} - -static inline int obd_punch_rqset(struct obd_export *exp, - struct obd_info *oinfo, - struct obd_trans_info *oti) -{ - struct ptlrpc_request_set *set = NULL; - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, punch); - EXP_COUNTER_INCREMENT(exp, punch); - - set = ptlrpc_prep_set(); - if (set == NULL) - RETURN(-ENOMEM); - - rc = OBP(exp->exp_obd, punch)(exp, oinfo, oti, set); - if (rc == 0) - rc = ptlrpc_set_wait(set); - ptlrpc_set_destroy(set); - RETURN(rc); -} - -static inline int obd_punch(struct obd_export *exp, struct obd_info *oinfo, - struct obd_trans_info *oti, - struct ptlrpc_request_set *rqset) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, punch); - EXP_COUNTER_INCREMENT(exp, punch); - - rc = OBP(exp->exp_obd, punch)(exp, oinfo, oti, rqset); - RETURN(rc); -} - -static inline int obd_brw(int cmd, struct obd_export *exp, - struct obd_info *oinfo, obd_count oa_bufs, - struct brw_page *pg, struct obd_trans_info *oti) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, brw); - EXP_COUNTER_INCREMENT(exp, brw); - - if (!(cmd & (OBD_BRW_RWMASK | OBD_BRW_CHECK))) { - CERROR("obd_brw: cmd must be OBD_BRW_READ, OBD_BRW_WRITE, " - "or OBD_BRW_CHECK\n"); - LBUG(); - } - - rc = OBP(exp->exp_obd, brw)(cmd, exp, oinfo, oa_bufs, pg, oti); - RETURN(rc); -} - -static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa, + spin_lock(&obd->obd_osfs_lock); + memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs)); + obd->obd_osfs_age = cfs_time_current_64(); + spin_unlock(&obd->obd_osfs_lock); + } + } else { + CDEBUG(D_SUPER, "%s: use %p cache blocks "LPU64"/"LPU64 + " objects "LPU64"/"LPU64"\n", + obd->obd_name, &obd->obd_osfs, + obd->obd_osfs.os_bavail, obd->obd_osfs.os_blocks, + obd->obd_osfs.os_ffree, obd->obd_osfs.os_files); + spin_lock(&obd->obd_osfs_lock); + memcpy(osfs, &obd->obd_osfs, sizeof(*osfs)); + spin_unlock(&obd->obd_osfs_lock); + } + RETURN(rc); +} + +static inline int obd_preprw(const struct lu_env *env, int cmd, + struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *remote, int *pages, struct niobuf_local *local, @@ -1358,12 +1269,13 @@ static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa, EXP_CHECK_DT_OP(exp, preprw); EXP_COUNTER_INCREMENT(exp, preprw); - rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, remote, + rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, pages, local, oti, capa); RETURN(rc); } -static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, +static inline int obd_commitrw(const struct lu_env *env, int cmd, + struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *rnb, int pages, struct niobuf_local *local, @@ -1374,39 +1286,11 @@ static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, EXP_CHECK_DT_OP(exp, commitrw); EXP_COUNTER_INCREMENT(exp, commitrw); - rc = OBP(exp->exp_obd, commitrw)(cmd, exp, oa, objcount, obj, + rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, rnb, pages, local, oti, rc); RETURN(rc); } -static inline int obd_merge_lvb(struct obd_export *exp, - struct lov_stripe_md *lsm, - struct ost_lvb *lvb, int kms_only) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, merge_lvb); - EXP_COUNTER_INCREMENT(exp, merge_lvb); - - rc = OBP(exp->exp_obd, merge_lvb)(exp, lsm, lvb, kms_only); - RETURN(rc); -} - -static inline int obd_adjust_kms(struct obd_export *exp, - struct lov_stripe_md *lsm, obd_off size, - int shrink) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, adjust_kms); - EXP_COUNTER_INCREMENT(exp, adjust_kms); - - rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink); - RETURN(rc); -} - static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { @@ -1420,43 +1304,6 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(rc); } -static inline int obd_enqueue_rqset(struct obd_export *exp, - struct obd_info *oinfo, - struct ldlm_enqueue_info *einfo) -{ - struct ptlrpc_request_set *set = NULL; - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, enqueue); - EXP_COUNTER_INCREMENT(exp, enqueue); - - set = ptlrpc_prep_set(); - if (set == NULL) - RETURN(-ENOMEM); - - rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set); - if (rc == 0) - rc = ptlrpc_set_wait(set); - ptlrpc_set_destroy(set); - RETURN(rc); -} - -static inline int obd_enqueue(struct obd_export *exp, - struct obd_info *oinfo, - struct ldlm_enqueue_info *einfo, - struct ptlrpc_request_set *set) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, enqueue); - EXP_COUNTER_INCREMENT(exp, enqueue); - - rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set); - RETURN(rc); -} - static inline int obd_change_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm, ldlm_iterator_t it, void *data) @@ -1485,35 +1332,6 @@ static inline int obd_find_cbdata(struct obd_export *exp, RETURN(rc); } -static inline int obd_cancel(struct obd_export *exp, - struct lov_stripe_md *ea, __u32 mode, - struct lustre_handle *lockh) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, cancel); - EXP_COUNTER_INCREMENT(exp, cancel); - - rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh); - RETURN(rc); -} - -static inline int obd_cancel_unused(struct obd_export *exp, - struct lov_stripe_md *ea, - ldlm_cancel_flags_t flags, - void *opaque) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, cancel_unused); - EXP_COUNTER_INCREMENT(exp, cancel_unused); - - rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque); - RETURN(rc); -} - static inline int obd_pin(struct obd_export *exp, const struct lu_fid *fid, struct obd_capa *oc, struct obd_client_handle *handle, int flag) @@ -1592,7 +1410,7 @@ static inline int obd_notify(struct obd_device *obd, } if (!OBP(obd, notify)) { - CERROR("obd %s has no notify handler\n", obd->obd_name); + CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name); RETURN(-ENOSYS); } @@ -1654,40 +1472,8 @@ static inline int obd_quotactl(struct obd_export *exp, RETURN(rc); } -static inline int obd_quota_adjust_qunit(struct obd_export *exp, - struct quota_adjust_qunit *oqaq, - struct lustre_quota_ctxt *qctxt, - struct ptlrpc_request_set *set) -{ -#if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT) - struct timeval work_start; - struct timeval work_end; - long timediff; -#endif - int rc; - ENTRY; - -#if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT) - if (qctxt) - cfs_gettimeofday(&work_start); -#endif - EXP_CHECK_DT_OP(exp, quota_adjust_qunit); - EXP_COUNTER_INCREMENT(exp, quota_adjust_qunit); - - rc = OBP(exp->exp_obd, quota_adjust_qunit)(exp, oqaq, qctxt, set); - -#if defined(LPROCFS) && defined(HAVE_QUOTA_SUPPORT) - if (qctxt) { - cfs_gettimeofday(&work_end); - timediff = cfs_timeval_sub(&work_end, &work_start, NULL); - lprocfs_counter_add(qctxt->lqc_stats, LQUOTA_ADJUST_QUNIT, - timediff); - } -#endif - RETURN(rc); -} - -static inline int obd_health_check(struct obd_device *obd) +static inline int obd_health_check(const struct lu_env *env, + struct obd_device *obd) { /* returns: 0 on healthy * >0 on unhealthy + reason code/flag @@ -1709,7 +1495,7 @@ static inline int obd_health_check(struct obd_device *obd) if (!OBP(obd, health_check)) RETURN(0); - rc = OBP(obd, health_check)(obd); + rc = OBP(obd, health_check)(env, obd); RETURN(rc); } @@ -1718,13 +1504,13 @@ static inline int obd_register_observer(struct obd_device *obd, { ENTRY; OBD_CHECK_DEV(obd); - cfs_down_write(&obd->obd_observer_link_sem); + down_write(&obd->obd_observer_link_sem); if (obd->obd_observer && observer) { - cfs_up_write(&obd->obd_observer_link_sem); + up_write(&obd->obd_observer_link_sem); RETURN(-EALREADY); } obd->obd_observer = observer; - cfs_up_write(&obd->obd_observer_link_sem); + up_write(&obd->obd_observer_link_sem); RETURN(0); } @@ -1732,10 +1518,10 @@ static inline int obd_pin_observer(struct obd_device *obd, struct obd_device **observer) { ENTRY; - cfs_down_read(&obd->obd_observer_link_sem); + down_read(&obd->obd_observer_link_sem); if (!obd->obd_observer) { *observer = NULL; - cfs_up_read(&obd->obd_observer_link_sem); + up_read(&obd->obd_observer_link_sem); RETURN(-ENOENT); } *observer = obd->obd_observer; @@ -1745,7 +1531,7 @@ static inline int obd_pin_observer(struct obd_device *obd, static inline int obd_unpin_observer(struct obd_device *obd) { ENTRY; - cfs_up_read(&obd->obd_observer_link_sem); + up_read(&obd->obd_observer_link_sem); RETURN(0); } @@ -1828,15 +1614,14 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, RETURN(rc); } -static inline int md_change_cbdata(struct obd_export *exp, - const struct lu_fid *fid, - ldlm_iterator_t it, void *data) +static inline int md_null_inode(struct obd_export *exp, + const struct lu_fid *fid) { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, change_cbdata); - EXP_MD_COUNTER_INCREMENT(exp, change_cbdata); - rc = MDP(exp->exp_obd, change_cbdata)(exp, fid, it, data); + EXP_CHECK_MD_OP(exp, null_inode); + EXP_MD_COUNTER_INCREMENT(exp, null_inode); + rc = MDP(exp->exp_obd, null_inode)(exp, fid); RETURN(rc); } @@ -1891,13 +1676,13 @@ static inline int md_done_writing(struct obd_export *exp, } static inline int md_enqueue(struct obd_export *exp, - struct ldlm_enqueue_info *einfo, - struct lookup_intent *it, - struct md_op_data *op_data, - struct lustre_handle *lockh, - void *lmm, int lmmsize, - struct ptlrpc_request **req, - int extra_lock_flags) + struct ldlm_enqueue_info *einfo, + struct lookup_intent *it, + struct md_op_data *op_data, + struct lustre_handle *lockh, + void *lmm, int lmmsize, + struct ptlrpc_request **req, + __u64 extra_lock_flags) { int rc; ENTRY; @@ -1921,18 +1706,18 @@ static inline int md_getattr_name(struct obd_export *exp, } static inline int md_intent_lock(struct obd_export *exp, - struct md_op_data *op_data, void *lmm, - int lmmsize, struct lookup_intent *it, - int flags, struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking, - int extra_lock_flags) + struct md_op_data *op_data, void *lmm, + int lmmsize, struct lookup_intent *it, + int lookup_flags, struct ptlrpc_request **reqp, + ldlm_blocking_callback cb_blocking, + __u64 extra_lock_flags) { int rc; ENTRY; EXP_CHECK_MD_OP(exp, intent_lock); EXP_MD_COUNTER_INCREMENT(exp, intent_lock); rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, - it, flags, reqp, cb_blocking, + it, lookup_flags, reqp, cb_blocking, extra_lock_flags); RETURN(rc); } @@ -1988,30 +1773,43 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, RETURN(rc); } -static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, - struct obd_capa *oc, struct ptlrpc_request **request) +static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid, + struct obd_capa *oc, struct ptlrpc_request **request) { - int rc; - ENTRY; - EXP_CHECK_MD_OP(exp, sync); - EXP_MD_COUNTER_INCREMENT(exp, sync); - rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request); - RETURN(rc); + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, fsync); + EXP_MD_COUNTER_INCREMENT(exp, fsync); + rc = MDP(exp->exp_obd, fsync)(exp, fid, oc, request); + RETURN(rc); } -static inline int md_readpage(struct obd_export *exp, const struct lu_fid *fid, - struct obd_capa *oc, __u64 offset, - struct page *page, +static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, + struct page **pages, struct ptlrpc_request **request) { int rc; ENTRY; EXP_CHECK_MD_OP(exp, readpage); EXP_MD_COUNTER_INCREMENT(exp, readpage); - rc = MDP(exp->exp_obd, readpage)(exp, fid, oc, offset, page, request); + rc = MDP(exp->exp_obd, readpage)(exp, opdata, pages, request); RETURN(rc); } +static inline int md_read_entry(struct obd_export *exp, + struct md_op_data *op_data, + struct md_callback *cb_op, + struct lu_dirent **ld, + struct page **ppage) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, read_entry); + EXP_MD_COUNTER_INCREMENT(exp, read_entry); + rc = MDP(exp->exp_obd, read_entry)(exp, op_data, cb_op, ld, ppage); + RETURN(rc); +} + static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { @@ -2044,6 +1842,27 @@ static inline int md_free_lustre_md(struct obd_export *exp, RETURN(MDP(exp->exp_obd, free_lustre_md)(exp, md)); } +static inline int md_update_lsm_md(struct obd_export *exp, + struct lmv_stripe_md *lsm, + struct mdt_body *body, + ldlm_blocking_callback cb) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, update_lsm_md); + EXP_MD_COUNTER_INCREMENT(exp, update_lsm_md); + RETURN(MDP(exp->exp_obd, update_lsm_md)(exp, lsm, body, cb)); +} + +static inline int md_merge_attr(struct obd_export *exp, + const struct lmv_stripe_md *lsm, + struct cl_attr *attr) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, merge_attr); + EXP_MD_COUNTER_INCREMENT(exp, merge_attr); + RETURN(MDP(exp->exp_obd, merge_attr)(exp, lsm, attr)); +} + static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, struct obd_capa *oc, obd_valid valid, const char *name, @@ -2075,13 +1894,13 @@ static inline int md_getxattr(struct obd_export *exp, } static inline int md_set_open_replay_data(struct obd_export *exp, - struct obd_client_handle *och, - struct ptlrpc_request *open_req) + struct obd_client_handle *och, + struct lookup_intent *it) { - ENTRY; - EXP_CHECK_MD_OP(exp, set_open_replay_data); - EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); - RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req)); + ENTRY; + EXP_CHECK_MD_OP(exp, set_open_replay_data); + EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); + RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, it)); } static inline int md_clear_open_replay_data(struct obd_export *exp, @@ -2094,7 +1913,7 @@ static inline int md_clear_open_replay_data(struct obd_export *exp, } static inline int md_set_lock_data(struct obd_export *exp, - __u64 *lockh, void *data, __u32 *bits) + __u64 *lockh, void *data, __u64 *bits) { ENTRY; EXP_CHECK_MD_OP(exp, set_lock_data); @@ -2120,7 +1939,7 @@ static inline int md_cancel_unused(struct obd_export *exp, RETURN(rc); } -static inline ldlm_mode_t md_lock_match(struct obd_export *exp, int flags, +static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, const struct lu_fid *fid, ldlm_type_t type, ldlm_policy_data_t *policy, @@ -2194,13 +2013,13 @@ static inline int md_intent_getattr_async(struct obd_export *exp, static inline int md_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, - struct lu_fid *fid) + struct lu_fid *fid, __u64 *bits) { int rc; ENTRY; EXP_CHECK_MD_OP(exp, revalidate_lock); EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); - rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid); + rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); RETURN(rc); } @@ -2211,11 +2030,11 @@ extern int obd_init_caches(void); extern void obd_cleanup_caches(void); /* support routines */ -extern cfs_mem_cache_t *obdo_cachep; +extern struct kmem_cache *obdo_cachep; #define OBDO_ALLOC(ptr) \ do { \ - OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, CFS_ALLOC_IO); \ + OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \ } while(0) #define OBDO_FREE(ptr) \ @@ -2234,12 +2053,31 @@ static inline void fid2obdo(struct lu_fid *fid, struct obdo *oa) /* something here */ } +typedef int (*register_lwp_cb)(void *data); + +struct lwp_register_item { + struct obd_export **lri_exp; + register_lwp_cb lri_cb_func; + void *lri_cb_data; + cfs_list_t lri_list; + char lri_name[MTI_NAME_MAXLEN]; +}; + /* I'm as embarrassed about this as you are. * * // XXX do not look into _superhack with remaining eye * // XXX if this were any uglier, I'd get my own show on MTV */ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); +/* obd_mount.c */ +#ifdef HAVE_SERVER_SUPPORT +int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp, + register_lwp_cb cb_func, void *cb_data); +void lustre_deregister_lwp_item(struct obd_export **exp); +struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx); +int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx); +#endif /* HAVE_SERVER_SUPPORT */ + /* sysctl.c */ extern void obd_sysctl_init (void); extern void obd_sysctl_clean (void); @@ -2252,14 +2090,17 @@ void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out); int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index); int class_add_uuid(const char *uuid, __u64 nid); int class_del_uuid (const char *uuid); +int class_check_uuid(struct obd_uuid *uuid, __u64 nid); void class_init_uuidlist(void); void class_exit_uuidlist(void); -/* mea.c */ -int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen); -int raw_name2idx(int hashtype, int count, const char *name, int namelen); - /* prng.c */ #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t)) +#ifdef __KERNEL__ +int server_name2index(const char *svname, __u32 *idx, const char **endptr); +#else +# define server_name2index(name, idx, ptr) do {} while (0) +#endif + #endif /* __LINUX_OBD_CLASS_H */