X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Fobd_class.h;h=748cc478ee88a70899393b4da86073a1a15c591d;hp=d6b84fb753c86a4c9e30b8d37343f0c86e9cf8e9;hb=4f40429775c49468d9ec1fec34d5e7500ac01116;hpb=44c4f47c4d1f185831d4629cc9ca5ae5f50a8e07 diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index d6b84fb..748cc47 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2014, Intel Corporation. + * Copyright (c) 2011, 2017, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -42,33 +38,26 @@ #include #include #include -#include +#include #include #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 +#define OBD_STATFS_FOR_MDT0 0x0004 /* The statfs is only for retrieving * information from MDT0. */ -/* OBD Device Declarations */ -extern struct obd_device *obd_devs[MAX_OBD_DEVICES]; -extern struct list_head obd_types; -extern spinlock_t obd_types_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); +int lustre_get_jobid(char *jobid); +void lustre_jobid_clear(const char *jobid); +void jobid_cache_fini(void); +int jobid_cache_init(void); struct lu_device_type; @@ -79,9 +68,13 @@ int class_register_type(struct obd_ops *, struct md_ops *, bool enable_proc, const char *nm, struct lu_device_type *ldt); int class_unregister_type(const char *nm); -struct obd_device *class_newdev(const char *type_name, const char *name); -void class_release_dev(struct obd_device *obd); +struct obd_device *class_newdev(const char *type_name, const char *name, + const char *uuid); +int class_register_device(struct obd_device *obd); +void class_unregister_device(struct obd_device *obd); +void class_free_dev(struct obd_device *obd); +struct obd_device *class_dev_by_str(const char *str); int class_name2dev(const char *name); struct obd_device *class_name2obd(const char *name); int class_uuid2dev(struct obd_uuid *uuid); @@ -101,7 +94,8 @@ 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_connect_flags2str(char *page, int count, __u64 flags, __u64 flags2, + const char *sep); int obd_zombie_impexp_init(void); void obd_zombie_impexp_stop(void); @@ -110,7 +104,6 @@ void obd_zombie_barrier(void); void obd_exports_barrier(struct obd_device *obd); int kuc_len(int payload_len); struct kuc_hdr * kuc_ptr(void *p); -int kuc_ispayload(void *p); void *kuc_alloc(int payload_len, int transport, int type); void kuc_free(void *p, int payload_len); int obd_get_request_slot(struct client_obd *cli); @@ -130,9 +123,22 @@ struct llog_handle; struct llog_rec_hdr; typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *, struct llog_rec_hdr *, void *); + +struct obd_export *obd_stale_export_get(void); +void obd_stale_export_put(struct obd_export *exp); +void obd_stale_export_adjust(struct obd_export *exp); + /* obd_config.c */ +/* For interoperability */ +struct cfg_interop_param { + char *old_param; + char *new_param; +}; + +char *lustre_cfg_string(struct lustre_cfg *lcfg, u32 index); struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, const char *new_name); +void print_lustre_cfg(struct lustre_cfg *lcfg); int class_process_config(struct lustre_cfg *lcfg); int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, struct lustre_cfg *lcfg, void *data); @@ -140,16 +146,27 @@ 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); int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg); + +int class_find_param(char *buf, char *key, char **valp); +struct cfg_interop_param *class_find_old_param(const char *param, + struct cfg_interop_param *ptr); +int class_get_next_param(char **params, char *copy); +int class_match_param(char *buf, const char *key, char **valp); +int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh); +int class_parse_nid_quiet(char *buf, lnet_nid_t *nid, char **endh); +int class_parse_net(char *buf, u32 *net, char **endh); +int class_match_nid(char *buf, char *key, lnet_nid_t nid); +int class_match_net(char *buf, char *key, u32 net); + struct obd_device *class_incref(struct obd_device *obd, const char *scope, const void *source); void class_decref(struct obd_device *obd, const char *scope, const void *source); -void dump_exports(struct obd_device *obd, int locks); +void dump_exports(struct obd_device *obd, int locks, int debug_level); 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 */ @@ -162,44 +179,64 @@ struct config_llog_instance { char *cfg_obdname; void *cfg_instance; struct super_block *cfg_sb; - struct obd_uuid cfg_uuid; + 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; + __u32 cfg_sub_clds; }; 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" +#define CONFIG_SUB_SPTLRPC 0x01 +#define CONFIG_SUB_RECOVER 0x02 +#define CONFIG_SUB_PARAMS 0x04 +#define CONFIG_SUB_NODEMAP 0x08 +#define CONFIG_SUB_BARRIER 0x10 + +/* Sub clds should be attached to the config_llog_data when processing + * config log for client or server target. */ +#define CONFIG_SUB_CLIENT (CONFIG_SUB_SPTLRPC | CONFIG_SUB_RECOVER | \ + CONFIG_SUB_PARAMS) +#define CONFIG_SUB_SERVER (CONFIG_SUB_CLIENT | CONFIG_SUB_NODEMAP | \ + CONFIG_SUB_BARRIER) + +#define PARAMS_FILENAME "params" +#define BARRIER_FILENAME "barrier" +#define LCTL_UPCALL "lctl" + +static inline bool logname_is_barrier(const char *logname) +{ + char *ptr; + + /* logname for barrier is "fsname-barrier" */ + ptr = strstr(logname, BARRIER_FILENAME); + if (ptr && (ptr - logname) >= 2 && + *(ptr - 1) == '-' && *(ptr + 7) == '\0') + return true; + + return false; +} /* list of active configuration logs */ struct config_llog_data { - struct ldlm_res_id cld_resid; - struct config_llog_instance cld_cfg; - struct list_head cld_list_chain; + struct ldlm_res_id cld_resid; + struct config_llog_instance cld_cfg; + struct list_head cld_list_chain;/* on config_llog_list */ 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_params; /* common parameters log */ struct config_llog_data *cld_recover;/* imperative recover log */ - struct obd_export *cld_mgcexp; + struct config_llog_data *cld_nodemap;/* nodemap log */ + struct config_llog_data *cld_barrier;/* barrier log (for MDT only) */ + struct obd_export *cld_mgcexp; struct mutex cld_lock; - int cld_type; - unsigned int cld_stopping:1, /* we were told to stop - * watching */ - cld_lostlock:1; /* lock not requeued */ - char cld_logname[0]; + int cld_type; + unsigned int cld_stopping:1, /* we were told to stop + * watching */ + cld_lostlock:1; /* lock not requeued */ + char cld_logname[0]; }; struct lustre_profile { @@ -207,12 +244,16 @@ struct lustre_profile { char *lp_profile; char *lp_dt; char *lp_md; + int lp_refs; + bool lp_list_deleted; }; struct lustre_profile *class_get_profile(const char * prof); void class_del_profile(const char *prof); +void class_put_profile(struct lustre_profile *lprof); void class_del_profiles(void); + #if LUSTRE_TRACKS_LOCK_EXP_REFS void __class_export_add_lock_ref(struct obd_export *, struct ldlm_lock *); @@ -282,6 +323,8 @@ struct obd_export *class_export_get(struct obd_export *exp); void class_export_put(struct obd_export *exp); struct obd_export *class_new_export(struct obd_device *obddev, struct obd_uuid *cluuid); +struct obd_export *class_new_export_self(struct obd_device *obd, + struct obd_uuid *uuid); void class_unlink_export(struct obd_export *exp); struct obd_import *class_import_get(struct obd_import *); @@ -335,10 +378,8 @@ void la_from_obdo(struct lu_attr *la, const struct obdo *dst, u64 valid); void obdo_cpy_md(struct obdo *dst, const struct obdo *src, u64 valid); void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj); -#define OBT(dev) (dev)->obd_type #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op -#define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op /* Ensure obd_setup: used for cleanup which must be called while obd is stopping */ @@ -419,77 +460,33 @@ do { \ static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp) { - /* Always add in ldlm_stats */ - tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC - ,LPROCFS_STATS_FLAG_NOPERCPU); - if (tmp->nid_ldlm_stats == NULL) - return -ENOMEM; + /* Always add in ldlm_stats */ + tmp->nid_ldlm_stats = + lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC, + LPROCFS_STATS_FLAG_NOPERCPU); + if (tmp->nid_ldlm_stats == NULL) + return -ENOMEM; - lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); + lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats); - return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", - tmp->nid_ldlm_stats); + return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats", + tmp->nid_ldlm_stats); } -#define EXP_CHECK_MD_OP(exp, op) \ -do { \ - if ((exp) == NULL) { \ - CERROR("obd_" #op ": NULL export\n"); \ - RETURN(-ENODEV); \ - } \ - if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - RETURN(-EOPNOTSUPP); \ - } \ - if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ - CERROR("obd_" #op ": dev %s/%d no operation\n", \ - (exp)->exp_obd->obd_name, \ - (exp)->exp_obd->obd_minor); \ - RETURN(-EOPNOTSUPP); \ - } \ -} while (0) - - -#define OBD_CHECK_DT_OP(obd, op, err) \ -do { \ - if (!OBT(obd) || !OBP((obd), op)) { \ - if (err) \ - CERROR("obd_" #op ": dev %d no operation\n", \ - obd->obd_minor); \ - RETURN(err); \ - } \ -} while (0) - -#define EXP_CHECK_DT_OP(exp, op) \ -do { \ - if ((exp) == NULL) { \ - CERROR("obd_" #op ": NULL export\n"); \ - RETURN(-ENODEV); \ - } \ - if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - RETURN(-EOPNOTSUPP); \ - } \ - if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \ - CERROR("obd_" #op ": dev %d no operation\n", \ - (exp)->exp_obd->obd_minor); \ - RETURN(-EOPNOTSUPP); \ - } \ -} while (0) - -#define CTXT_CHECK_OP(ctxt, op, err) \ -do { \ - if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ - if (err) \ - CERROR("lop_" #op ": dev %d no operation\n", \ - ctxt->loc_obd->obd_minor); \ - RETURN(err); \ - } \ -} while (0) +static inline int exp_check_ops(struct obd_export *exp) +{ + if (exp == NULL) { + RETURN(-ENODEV); + } + if (exp->exp_obd == NULL || !exp->exp_obd->obd_type) { + RETURN(-EOPNOTSUPP); + } + RETURN(0); +} static inline int class_devno_max(void) { - return MAX_OBD_DEVICES; + return MAX_OBD_DEVICES; } static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp, @@ -499,7 +496,15 @@ static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, get_info); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_get_info) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, get_info); rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val); @@ -515,7 +520,15 @@ static inline int obd_set_info_async(const struct lu_env *env, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, set_info_async); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_set_info_async) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, set_info_async); rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, @@ -540,18 +553,14 @@ static inline int obd_set_info_async(const struct lu_env *env, * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence, * obd_precleanup() and obd_cleanup() call both lu_device and obd operations. */ - -#define DECLARE_LU_VARS(ldt, d) \ - struct lu_device_type *ldt; \ - struct lu_device *d - static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) { int rc; - DECLARE_LU_VARS(ldt, d); + struct lu_device_type *ldt = obd->obd_type->typ_lu; + struct lu_device *d; + ENTRY; - ldt = obd->obd_type->typ_lu; if (ldt != NULL) { struct lu_context session_ctx; struct lu_env env; @@ -575,51 +584,51 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) lu_context_fini(&session_ctx); } else { - OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP); + if (!obd->obd_type->typ_dt_ops->o_setup) { + CERROR("%s: no %s operation\n", obd->obd_name, + __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } RETURN(rc); } -static inline int obd_precleanup(struct obd_device *obd, - enum obd_cleanup_stage cleanup_stage) +static inline int obd_precleanup(struct obd_device *obd) { - int rc; - DECLARE_LU_VARS(ldt, d); - ENTRY; + int rc; + struct lu_device_type *ldt = obd->obd_type->typ_lu; + struct lu_device *d = obd->obd_lu_dev; - OBD_CHECK_DEV(obd); - ldt = obd->obd_type->typ_lu; - d = obd->obd_lu_dev; - if (ldt != NULL && d != NULL) { - if (cleanup_stage == OBD_CLEANUP_EXPORTS) { - struct lu_env env; - - rc = lu_env_init(&env, ldt->ldt_ctx_tags); - if (rc == 0) { - ldt->ldt_ops->ldto_device_fini(&env, d); - lu_env_fini(&env); - } - } - } - OBD_CHECK_DT_OP(obd, precleanup, 0); - OBD_COUNTER_INCREMENT(obd, precleanup); + ENTRY; - rc = OBP(obd, precleanup)(obd, cleanup_stage); - RETURN(rc); + if (ldt != NULL && d != NULL) { + struct lu_env env; + + rc = lu_env_init(&env, ldt->ldt_ctx_tags); + if (rc == 0) { + ldt->ldt_ops->ldto_device_fini(&env, d); + lu_env_fini(&env); + } + } + + if (!obd->obd_type->typ_dt_ops->o_precleanup) + RETURN(0); + + OBD_COUNTER_INCREMENT(obd, precleanup); + + rc = OBP(obd, precleanup)(obd); + RETURN(rc); } static inline int obd_cleanup(struct obd_device *obd) { int rc; - DECLARE_LU_VARS(ldt, d); - ENTRY; - - OBD_CHECK_DEV(obd); + struct lu_device_type *ldt = obd->obd_type->typ_lu; + struct lu_device *d = obd->obd_lu_dev; - ldt = obd->obd_type->typ_lu; - d = obd->obd_lu_dev; + ENTRY; if (ldt != NULL && d != NULL) { struct lu_env env; @@ -630,7 +639,9 @@ static inline int obd_cleanup(struct obd_device *obd) obd->obd_lu_dev = NULL; } } - OBD_CHECK_DT_OP(obd, cleanup, 0); + if (!obd->obd_type->typ_dt_ops->o_cleanup) + RETURN(0); + OBD_COUNTER_INCREMENT(obd, cleanup); rc = OBP(obd, cleanup)(obd); @@ -658,18 +669,16 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) EXIT; } -static inline int -obd_process_config(struct obd_device *obd, int datalen, void *data) +static inline int obd_process_config(struct obd_device *obd, int datalen, + void *data) { int rc; - DECLARE_LU_VARS(ldt, d); - ENTRY; + struct lu_device_type *ldt = obd->obd_type->typ_lu; + struct lu_device *d = obd->obd_lu_dev; - OBD_CHECK_DEV(obd); + ENTRY; obd->obd_process_conf = 1; - ldt = obd->obd_type->typ_lu; - d = obd->obd_lu_dev; if (ldt != NULL && d != NULL) { struct lu_env env; @@ -679,7 +688,11 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) lu_env_fini(&env); } } else { - OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); + if (!obd->obd_type->typ_dt_ops->o_process_config) { + CERROR("%s: no %s operation\n", + obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } rc = OBP(obd, process_config)(obd, datalen, data); } OBD_COUNTER_INCREMENT(obd, process_config); @@ -694,7 +707,15 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, create); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_create) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, create); rc = OBP(exp->exp_obd, create)(env, exp, obdo); @@ -707,7 +728,15 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, destroy); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_destroy) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, destroy); rc = OBP(exp->exp_obd, destroy)(env, exp, obdo); @@ -720,7 +749,15 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, getattr); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_getattr) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, getattr); rc = OBP(exp->exp_obd, getattr)(env, exp, oa); @@ -733,7 +770,15 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, setattr); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_setattr) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, setattr); rc = OBP(exp->exp_obd, setattr)(env, exp, oa); @@ -748,7 +793,10 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_add_conn) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, add_conn); rc = OBP(obd, add_conn)(imp, uuid, priority); @@ -762,7 +810,10 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_del_conn) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, del_conn); rc = OBP(obd, del_conn)(imp, uuid); @@ -774,7 +825,10 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) struct obd_uuid *uuid; ENTRY; - OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL); + if (!exp->exp_obd->obd_type || + !exp->exp_obd->obd_type->typ_dt_ops->o_get_uuid) + RETURN(NULL); + EXP_COUNTER_INCREMENT(exp, get_uuid); uuid = OBP(exp->exp_obd, get_uuid)(exp); @@ -798,7 +852,10 @@ static inline int obd_connect(const struct lu_env *env, ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_connect) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, connect); rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); @@ -822,7 +879,9 @@ static inline int obd_reconnect(const struct lu_env *env, ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_DT_OP(obd, reconnect, 0); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_reconnect) + RETURN(0); + OBD_COUNTER_INCREMENT(obd, reconnect); rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata); @@ -836,8 +895,15 @@ static inline int obd_disconnect(struct obd_export *exp) { int rc; ENTRY; - - EXP_CHECK_DT_OP(exp, disconnect); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_disconnect) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); @@ -850,7 +916,8 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_DT_OP(obd, fid_init, 0); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_init) + RETURN(0); OBD_COUNTER_INCREMENT(obd, fid_init); rc = OBP(obd, fid_init)(obd, exp, type); @@ -861,8 +928,8 @@ static inline int obd_fid_fini(struct obd_device *obd) { int rc; ENTRY; - - OBD_CHECK_DT_OP(obd, fid_fini, 0); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_fid_fini) + RETURN(0); OBD_COUNTER_INCREMENT(obd, fid_fini); rc = OBP(obd, fid_fini)(obd); @@ -876,8 +943,15 @@ static inline int obd_fid_alloc(const struct lu_env *env, { int rc; ENTRY; - - EXP_CHECK_DT_OP(exp, fid_alloc); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_fid_alloc) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, fid_alloc); rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data); @@ -889,7 +963,10 @@ static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) int rc; ENTRY; - OBD_CHECK_DT_OP(exp->exp_obd, ping, 0); + if (!exp->exp_obd->obd_type || + !exp->exp_obd->obd_type->typ_dt_ops->o_ping) + RETURN(0); + EXP_COUNTER_INCREMENT(exp, ping); rc = OBP(exp->exp_obd, ping)(env, exp); @@ -901,7 +978,10 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) int rc; ENTRY; - OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_new) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, pool_new); rc = OBP(obd, pool_new)(obd, poolname); @@ -912,140 +992,129 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) { int rc; ENTRY; - - OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_del) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, pool_del); rc = OBP(obd, pool_del)(obd, poolname); RETURN(rc); } -static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) +static inline int obd_pool_add(struct obd_device *obd, char *poolname, + char *ostname) { int rc; ENTRY; - OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_add) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, pool_add); rc = OBP(obd, pool_add)(obd, poolname, ostname); RETURN(rc); } -static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname) +static inline int obd_pool_rem(struct obd_device *obd, char *poolname, + char *ostname) { - int rc; - ENTRY; + int rc; - OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP); - OBD_COUNTER_INCREMENT(obd, pool_rem); + ENTRY; + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_pool_rem) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } + OBD_COUNTER_INCREMENT(obd, pool_rem); - rc = OBP(obd, pool_rem)(obd, poolname, ostname); - RETURN(rc); + rc = OBP(obd, pool_rem)(obd, poolname, ostname); + RETURN(rc); } static inline void obd_getref(struct obd_device *obd) { - ENTRY; - if (OBT(obd) && OBP(obd, getref)) { - OBD_COUNTER_INCREMENT(obd, getref); - OBP(obd, getref)(obd); - } - EXIT; + ENTRY; + if (obd->obd_type && OBP(obd, getref)) { + OBD_COUNTER_INCREMENT(obd, getref); + OBP(obd, getref)(obd); + } + EXIT; } static inline void obd_putref(struct obd_device *obd) { - ENTRY; - if (OBT(obd) && OBP(obd, putref)) { - OBD_COUNTER_INCREMENT(obd, putref); - OBP(obd, putref)(obd); - } - EXIT; + ENTRY; + if (obd->obd_type && OBP(obd, putref)) { + OBD_COUNTER_INCREMENT(obd, putref); + OBP(obd, putref)(obd); + } + EXIT; } static inline int obd_init_export(struct obd_export *exp) { - int rc = 0; + int rc = 0; - ENTRY; - if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && - OBP((exp)->exp_obd, init_export)) - rc = OBP(exp->exp_obd, init_export)(exp); - RETURN(rc); + ENTRY; + if (exp->exp_obd != NULL && exp->exp_obd->obd_type && + OBP((exp)->exp_obd, init_export)) + rc = OBP(exp->exp_obd, init_export)(exp); + RETURN(rc); } static inline int obd_destroy_export(struct obd_export *exp) { - ENTRY; - if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && - OBP((exp)->exp_obd, destroy_export)) - OBP(exp->exp_obd, destroy_export)(exp); - RETURN(0); + ENTRY; + if (exp->exp_obd != NULL && exp->exp_obd->obd_type && + OBP(exp->exp_obd, destroy_export)) + OBP(exp->exp_obd, destroy_export)(exp); + 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_export *exp, - struct obd_info *oinfo, - __u64 max_age, - struct ptlrpc_request_set *rqset) + struct obd_info *oinfo, + time64_t max_age, + struct ptlrpc_request_set *rqset) { - int rc = 0; - struct obd_device *obd; - ENTRY; - - 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)(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); - 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); - } - RETURN(rc); -} - -static inline int obd_statfs_rqset(struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, - __u32 flags) -{ - struct ptlrpc_request_set *set = NULL; - struct obd_info oinfo = { - .oi_osfs = osfs, - .oi_flags = flags, - }; int rc = 0; + struct obd_device *obd; ENTRY; - set = ptlrpc_prep_set(); - if (set == NULL) - RETURN(-ENOMEM); - - rc = obd_statfs_async(exp, &oinfo, max_age, set); - if (rc == 0) - rc = ptlrpc_set_wait(set); + if (exp == NULL || exp->exp_obd == NULL) + RETURN(-EINVAL); - ptlrpc_set_destroy(set); + obd = exp->exp_obd; + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } + OBD_COUNTER_INCREMENT(obd, statfs); + CDEBUG(D_SUPER, "%s: osfs %p age %lld, max_age %lld\n", + obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age); + if (obd->obd_osfs_age < max_age) { + rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset); + } else { + CDEBUG(D_SUPER, + "%s: use %p cache blocks %llu/%llu objects %llu/%llu\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(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); + } RETURN(rc); } @@ -1053,7 +1122,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp, * 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(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, + struct obd_statfs *osfs, time64_t max_age, __u32 flags) { int rc = 0; @@ -1063,22 +1132,27 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, if (obd == NULL) RETURN(-EINVAL); - OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); + OBD_CHECK_DEV_ACTIVE(obd); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + RETURN(-EOPNOTSUPP); + } OBD_COUNTER_INCREMENT(obd, statfs); - CDEBUG(D_SUPER, "osfs "LPU64", max_age "LPU64"\n", + CDEBUG(D_SUPER, "osfs %lld, max_age %lld\n", obd->obd_osfs_age, max_age); - if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { + if (obd->obd_osfs_age < max_age) { rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags); if (rc == 0) { spin_lock(&obd->obd_osfs_lock); memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs)); - obd->obd_osfs_age = cfs_time_current_64(); + obd->obd_osfs_age = ktime_get_seconds(); spin_unlock(&obd->obd_osfs_lock); } } else { - CDEBUG(D_SUPER, "%s: use %p cache blocks "LPU64"/"LPU64 - " objects "LPU64"/"LPU64"\n", + CDEBUG(D_SUPER, "%s: use %p cache blocks %llu/%llu" + " objects %llu/%llu\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); @@ -1098,7 +1172,16 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, preprw); + + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_preprw) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, preprw); rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, pages, local); @@ -1114,7 +1197,15 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, { ENTRY; - EXP_CHECK_DT_OP(exp, commitrw); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_commitrw) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, commitrw); rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, rnb, pages, local, rc); @@ -1128,7 +1219,15 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, iocontrol); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_iocontrol) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); @@ -1153,54 +1252,48 @@ static inline void obd_import_event(struct obd_device *obd, } static inline int obd_notify(struct obd_device *obd, - struct obd_device *watched, - enum obd_notify_event ev, - void *data) + struct obd_device *watched, + enum obd_notify_event ev) { - int rc; - ENTRY; - OBD_CHECK_DEV(obd); + int rc; + ENTRY; + OBD_CHECK_DEV(obd); if (!obd->obd_set_up) { - CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); - RETURN(-EINVAL); - } + CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); + RETURN(-EINVAL); + } - if (!OBP(obd, notify)) { - CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name); - RETURN(-ENOSYS); - } + if (!OBP(obd, notify)) { + CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name); + RETURN(-ENOSYS); + } - OBD_COUNTER_INCREMENT(obd, notify); - rc = OBP(obd, notify)(obd, watched, ev, data); - RETURN(rc); + OBD_COUNTER_INCREMENT(obd, notify); + rc = OBP(obd, notify)(obd, watched, ev); + + RETURN(rc); } static inline int obd_notify_observer(struct obd_device *observer, - struct obd_device *observed, - enum obd_notify_event ev, - void *data) + struct obd_device *observed, + enum obd_notify_event ev) { - int rc1; - int rc2; + int rc = 0; + int rc2 = 0; + struct obd_notify_upcall *onu; - struct obd_notify_upcall *onu; + if (observer->obd_observer) + rc = obd_notify(observer->obd_observer, observed, ev); - if (observer->obd_observer) - rc1 = obd_notify(observer->obd_observer, observed, ev, data); - else - rc1 = 0; - /* - * Also, call non-obd listener, if any - */ - onu = &observer->obd_upcall; - if (onu->onu_upcall != NULL) - rc2 = onu->onu_upcall(observer, observed, ev, - onu->onu_owner, NULL); - else - rc2 = 0; + /* + * Also, call non-obd listener, if any + */ + onu = &observer->obd_upcall; + if (onu->onu_upcall != NULL) + rc2 = onu->onu_upcall(observer, observed, ev, onu->onu_owner); - return rc1 ? rc1 : rc2; + return rc ? rc : rc2; } static inline int obd_quotactl(struct obd_export *exp, @@ -1209,7 +1302,15 @@ static inline int obd_quotactl(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_DT_OP(exp, quotactl); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + if (!exp->exp_obd->obd_type->typ_dt_ops->o_quotactl) { + CERROR("%s: no %s operation\n", + (exp)->exp_obd->obd_name, __func__); + RETURN(-ENOTSUPP); + } EXP_COUNTER_INCREMENT(exp, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); @@ -1217,30 +1318,31 @@ static inline int obd_quotactl(struct obd_export *exp, } 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 - * however the only suppored reason == 1 right now - * We'll need to define some better reasons - * or flags in the future. - * <0 on error - */ - int rc; - ENTRY; + struct obd_device *obd) +{ + /* returns: 0 on healthy + * >0 on unhealthy + reason code/flag + * however the only suppored reason == 1 right now + * We'll need to define some better reasons + * or flags in the future. + * <0 on error + */ + int rc; - /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ - if (obd == NULL || !OBT(obd)) { - CERROR("cleaned up obd\n"); - RETURN(-EOPNOTSUPP); - } - if (!obd->obd_set_up || obd->obd_stopping) - RETURN(0); - if (!OBP(obd, health_check)) - RETURN(0); + ENTRY; - rc = OBP(obd, health_check)(env, obd); - RETURN(rc); + /* NULL method is normal here */ + if (obd == NULL || !obd->obd_type) { + CERROR("cleaned up obd\n"); + RETURN(-EOPNOTSUPP); + } + if (!obd->obd_set_up || obd->obd_stopping) + RETURN(0); + if (!OBP(obd, health_check)) + RETURN(0); + + rc = OBP(obd, health_check)(env, obd); + RETURN(rc); } static inline int obd_register_observer(struct obd_device *obd, @@ -1259,27 +1361,34 @@ static inline int obd_register_observer(struct obd_device *obd, } /* metadata helpers */ -static inline int md_getstatus(struct obd_export *exp, struct lu_fid *fid) +static inline int md_get_root(struct obd_export *exp, const char *fileset, + struct lu_fid *fid) { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, getstatus); - EXP_MD_COUNTER_INCREMENT(exp, getstatus); - rc = MDP(exp->exp_obd, getstatus)(exp, fid); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, get_root); + rc = MDP(exp->exp_obd, get_root)(exp, fileset, fid); RETURN(rc); } -static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, - struct ptlrpc_request **request) +static inline int md_getattr(struct obd_export *exp, + struct md_op_data *op_data, + struct ptlrpc_request **request) { - int rc; - ENTRY; - EXP_CHECK_MD_OP(exp, getattr); - EXP_MD_COUNTER_INCREMENT(exp, getattr); - rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); - RETURN(rc); + int rc; + + ENTRY; + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, getattr); + rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); + RETURN(rc); } static inline int md_null_inode(struct obd_export *exp, @@ -1287,31 +1396,23 @@ static inline int md_null_inode(struct obd_export *exp, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, null_inode); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, null_inode); rc = MDP(exp->exp_obd, null_inode)(exp, fid); RETURN(rc); } -static inline int md_find_cbdata(struct obd_export *exp, - const struct lu_fid *fid, - ldlm_iterator_t it, void *data) -{ - int rc; - ENTRY; - EXP_CHECK_MD_OP(exp, find_cbdata); - EXP_MD_COUNTER_INCREMENT(exp, find_cbdata); - rc = MDP(exp->exp_obd, find_cbdata)(exp, fid, it, data); - RETURN(rc); -} - static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, struct md_open_data *mod, struct ptlrpc_request **request) { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, close); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, close); rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); RETURN(rc); @@ -1324,7 +1425,9 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, create); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, create); rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, uid, gid, cap_effective, rdev, request); @@ -1334,16 +1437,17 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, static inline int md_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, const union ldlm_policy_data *policy, - struct lookup_intent *it, struct md_op_data *op_data, struct lustre_handle *lockh, __u64 extra_lock_flags) { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, enqueue); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, enqueue); - rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, it, op_data, lockh, + rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh, extra_lock_flags); RETURN(rc); } @@ -1354,7 +1458,9 @@ static inline int md_getattr_name(struct obd_export *exp, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, getattr_name); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, getattr_name); rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); RETURN(rc); @@ -1369,7 +1475,9 @@ static inline int md_intent_lock(struct obd_export *exp, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, intent_lock); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, intent_lock); rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp, cb_blocking, extra_lock_flags); @@ -1381,7 +1489,9 @@ static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, link); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, link); rc = MDP(exp->exp_obd, link)(exp, op_data, request); RETURN(rc); @@ -1393,7 +1503,10 @@ static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, rename); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, rename); rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, newlen, request); @@ -1406,7 +1519,10 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, setattr); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, setattr); rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request); RETURN(rc); @@ -1418,13 +1534,33 @@ static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid, int rc; ENTRY; - EXP_CHECK_MD_OP(exp, fsync); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, fsync); rc = MDP(exp->exp_obd, fsync)(exp, fid, request); RETURN(rc); } +/* FLR: resync mirrored files. */ +static inline int md_file_resync(struct obd_export *exp, + struct md_op_data *data) +{ + int rc; + + ENTRY; + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + + EXP_MD_COUNTER_INCREMENT(exp, file_resync); + rc = MDP(exp->exp_obd, file_resync)(exp, data); + + RETURN(rc); +} + static inline int md_read_page(struct obd_export *exp, struct md_op_data *op_data, struct md_callback *cb_op, @@ -1433,7 +1569,10 @@ static inline int md_read_page(struct obd_export *exp, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, read_page); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, read_page); rc = MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset, ppage); @@ -1445,7 +1584,10 @@ static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, unlink); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, unlink); rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); RETURN(rc); @@ -1457,8 +1599,12 @@ static inline int md_get_lustre_md(struct obd_export *exp, struct obd_export *md_exp, struct lustre_md *md) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, get_lustre_md); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md)); } @@ -1466,8 +1612,11 @@ static inline int md_get_lustre_md(struct obd_export *exp, static inline int md_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, free_lustre_md); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); RETURN(MDP(exp->exp_obd, free_lustre_md)(exp, md)); } @@ -1477,8 +1626,11 @@ static inline int md_merge_attr(struct obd_export *exp, struct cl_attr *attr, ldlm_blocking_callback cb) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, merge_attr); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, merge_attr); RETURN(MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb)); } @@ -1489,8 +1641,12 @@ static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, int output_size, int flags, __u32 suppgid, struct ptlrpc_request **request) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, setxattr); + + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, setxattr); RETURN(MDP(exp->exp_obd, setxattr)(exp, fid, valid, name, input, input_size, output_size, flags, @@ -1503,8 +1659,11 @@ static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid, int output_size, int flags, struct ptlrpc_request **request) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, getxattr); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, getxattr); RETURN(MDP(exp->exp_obd, getxattr)(exp, fid, valid, name, input, input_size, output_size, flags, @@ -1515,8 +1674,11 @@ static inline int md_set_open_replay_data(struct obd_export *exp, struct obd_client_handle *och, struct lookup_intent *it) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, set_open_replay_data); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, it)); } @@ -1524,83 +1686,86 @@ static inline int md_set_open_replay_data(struct obd_export *exp, static inline int md_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, clear_open_replay_data); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); RETURN(MDP(exp->exp_obd, clear_open_replay_data)(exp, och)); } static inline int md_set_lock_data(struct obd_export *exp, - __u64 *lockh, void *data, __u64 *bits) + const struct lustre_handle *lockh, + void *data, __u64 *bits) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, set_lock_data); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); RETURN(MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits)); } -static inline int md_cancel_unused(struct obd_export *exp, - const struct lu_fid *fid, - ldlm_policy_data_t *policy, - ldlm_mode_t mode, - ldlm_cancel_flags_t flags, - void *opaque) +static inline +int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, + union ldlm_policy_data *policy, enum ldlm_mode mode, + enum ldlm_cancel_flags cancel_flags, void *opaque) { - int rc; - ENTRY; + int rc; + ENTRY; - EXP_CHECK_MD_OP(exp, cancel_unused); - EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); - rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, - flags, opaque); - RETURN(rc); + rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, + cancel_flags, opaque); + RETURN(rc); } -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, - ldlm_mode_t mode, - struct lustre_handle *lockh) +static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, + const struct lu_fid *fid, + enum ldlm_type type, + union ldlm_policy_data *policy, + enum ldlm_mode mode, + struct lustre_handle *lockh) { - ENTRY; - EXP_CHECK_MD_OP(exp, lock_match); - EXP_MD_COUNTER_INCREMENT(exp, lock_match); - RETURN(MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, - policy, mode, lockh)); + int rc; + ENTRY; + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, lock_match); + RETURN(MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, + policy, mode, lockh)); } static inline int md_init_ea_size(struct obd_export *exp, __u32 ea_size, __u32 def_ea_size) { + int rc; ENTRY; - EXP_CHECK_MD_OP(exp, init_ea_size); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); RETURN(MDP(exp->exp_obd, init_ea_size)(exp, ea_size, def_ea_size)); } -static inline int md_get_remote_perm(struct obd_export *exp, - const struct lu_fid *fid, u32 suppgid, - struct ptlrpc_request **request) -{ - ENTRY; - EXP_CHECK_MD_OP(exp, get_remote_perm); - EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm); - - RETURN(MDP(exp->exp_obd, get_remote_perm)(exp, fid, suppgid, request)); -} - static inline int md_intent_getattr_async(struct obd_export *exp, - struct md_enqueue_info *minfo, - struct ldlm_enqueue_info *einfo) + struct md_enqueue_info *minfo) { - int rc; - ENTRY; - EXP_CHECK_MD_OP(exp, intent_getattr_async); - EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); - rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo); - RETURN(rc); + int rc; + ENTRY; + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); + EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); + rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo); + RETURN(rc); } static inline int md_revalidate_lock(struct obd_export *exp, @@ -1609,7 +1774,9 @@ static inline int md_revalidate_lock(struct obd_export *exp, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, revalidate_lock); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); RETURN(rc); @@ -1622,7 +1789,9 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, get_fid_from_lsm); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, get_fid_from_lsm); rc = MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, fid); RETURN(rc); @@ -1641,7 +1810,9 @@ static inline int md_unpackmd(struct obd_export *exp, { int rc; ENTRY; - EXP_CHECK_MD_OP(exp, unpackmd); + rc = exp_check_ops(exp); + if (rc) + RETURN(rc); EXP_MD_COUNTER_INCREMENT(exp, unpackmd); rc = MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size); RETURN(rc); @@ -1672,7 +1843,8 @@ struct lwp_register_item { struct obd_export **lri_exp; register_lwp_cb lri_cb_func; void *lri_cb_data; - struct list_head lri_list; + struct list_head lri_list; + atomic_t lri_ref; char lri_name[MTI_NAME_MAXLEN]; }; @@ -1688,6 +1860,7 @@ 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); +void lustre_notify_lwp_list(struct obd_export *exp); int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx); #endif /* HAVE_SERVER_SUPPORT */ int lustre_register_fs(void); @@ -1695,20 +1868,26 @@ int lustre_unregister_fs(void); int lustre_check_exclusion(struct super_block *sb, char *svname); /* sysctl.c */ -extern void obd_sysctl_init (void); -extern void obd_sysctl_clean (void); +extern int obd_sysctl_init(void); +extern void obd_sysctl_clean(void); -/* uuid.c */ typedef __u8 class_uuid_t[16]; -void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out); +static inline void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out) +{ + snprintf(out->uuid, sizeof(out->uuid), "%02x%02x%02x%02x-%02x%02x-" + "%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uu[14], uu[15], uu[12], uu[13], uu[10], uu[11], uu[8], uu[9], + uu[6], uu[7], uu[4], uu[5], uu[2], uu[3], uu[0], uu[1]); +} /* lustre_peer.c */ 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); + +/* class_obd.c */ +extern char obd_jobid_node[]; /* prng.c */ #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t)) @@ -1731,6 +1910,7 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr); /* linux-module.c */ extern struct miscdevice obd_psdev; +int obd_ioctl_getdata(char **buf, int *len, void __user *arg); int class_procfs_init(void); int class_procfs_clean(void);