X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Fobd_class.h;h=86822487cace93aef486cd5387c3a609dde7e1b4;hp=2c52b368ce8e181d16d2cd65491c140d34b0ef62;hb=ca9300e53dc2b7bcaaa5482bb4234cce7d9a344e;hpb=ae1be8a06214468502fb312c1f974943ca8b3aab diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 2c52b36..8682248 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -47,11 +47,11 @@ * obd_osfs_age */ #define OBD_STATFS_FOR_MDT0 0x0004 /* The statfs is only for retrieving * information from MDT0. */ +#define OBD_STATFS_SUM 0x0008 /* get aggregated statfs from MDT */ 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); int lustre_get_jobid(char *jobid, size_t len); @@ -185,12 +185,10 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg); #define CFG_F_START 0x01 /* Set when we start updating from a log */ #define CFG_F_MARKER 0x02 /* We are within a maker */ #define CFG_F_SKIP 0x04 /* We should ignore this cfg command */ -#define CFG_F_COMPAT146 0x08 /* Allow old-style logs */ #define CFG_F_EXCLUDE 0x10 /* OST exclusion list */ /* Passed as data param to class_config_parse_llog */ struct config_llog_instance { - char *cfg_obdname; void *cfg_instance; struct super_block *cfg_sb; struct obd_uuid cfg_uuid; @@ -358,6 +356,7 @@ void class_disconnect_exports(struct obd_device *obddev); int class_manual_cleanup(struct obd_device *obd); void class_disconnect_stale_exports(struct obd_device *, int (*test_export)(struct obd_export *)); + static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) { return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) | @@ -395,20 +394,22 @@ void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj); #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op -/* Ensure obd_setup: used for cleanup which must be called - while obd is stopping */ -#define OBD_CHECK_DEV(obd) \ -do { \ - if (!(obd)) { \ - CERROR("NULL device\n"); \ - RETURN(-ENODEV); \ - } \ -} while (0) +static inline int obd_check_dev(struct obd_device *obd) +{ + if (!obd) { + CERROR("NULL device\n"); + return -ENODEV; + } + return 0; +} /* ensure obd_setup and !obd_stopping */ #define OBD_CHECK_DEV_ACTIVE(obd) \ do { \ - OBD_CHECK_DEV(obd); \ + rc = obd_check_dev(obd); \ + if (rc) \ + return rc; \ + \ if (!(obd)->obd_set_up || (obd)->obd_stopping) { \ CERROR("Device %d not setup\n", \ (obd)->obd_minor); \ @@ -417,61 +418,6 @@ do { \ } while (0) -#ifdef CONFIG_PROC_FS -#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 EXP_MD_COUNTER_INCREMENT(exp, op) -#endif - static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp) { /* Always add in ldlm_stats */ @@ -519,7 +465,6 @@ static inline int obd_get_info(const struct lu_env *env, struct obd_export *exp, (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); RETURN(rc); @@ -543,7 +488,6 @@ static inline int obd_set_info_async(const struct lu_env *env, (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, val, set); @@ -603,7 +547,6 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) __func__); RETURN(-EOPNOTSUPP); } - OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } RETURN(rc); @@ -630,8 +573,6 @@ static inline int obd_precleanup(struct obd_device *obd) if (!obd->obd_type->typ_dt_ops->o_precleanup) RETURN(0); - OBD_COUNTER_INCREMENT(obd, precleanup); - rc = OBP(obd, precleanup)(obd); RETURN(rc); } @@ -656,8 +597,6 @@ static inline int obd_cleanup(struct obd_device *obd) if (!obd->obd_type->typ_dt_ops->o_cleanup) RETURN(0); - OBD_COUNTER_INCREMENT(obd, cleanup); - rc = OBP(obd, cleanup)(obd); RETURN(rc); } @@ -709,7 +648,7 @@ static inline int obd_process_config(struct obd_device *obd, int datalen, } rc = OBP(obd, process_config)(obd, datalen, data); } - OBD_COUNTER_INCREMENT(obd, process_config); + obd->obd_process_conf = 0; RETURN(rc); @@ -730,7 +669,6 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, (exp)->exp_obd->obd_name, __func__); RETURN(-ENOTSUPP); } - EXP_COUNTER_INCREMENT(exp, create); rc = OBP(exp->exp_obd, create)(env, exp, obdo); RETURN(rc); @@ -751,7 +689,6 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, (exp)->exp_obd->obd_name, __func__); RETURN(-ENOTSUPP); } - EXP_COUNTER_INCREMENT(exp, destroy); rc = OBP(exp->exp_obd, destroy)(env, exp, obdo); RETURN(rc); @@ -772,7 +709,7 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, (exp)->exp_obd->obd_name, __func__); RETURN(-ENOTSUPP); } - EXP_COUNTER_INCREMENT(exp, getattr); + rc = OBP(exp->exp_obd, getattr)(env, exp, oa); RETURN(rc); @@ -793,7 +730,7 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, (exp)->exp_obd->obd_name, __func__); RETURN(-ENOTSUPP); } - EXP_COUNTER_INCREMENT(exp, setattr); + rc = OBP(exp->exp_obd, setattr)(env, exp, oa); RETURN(rc); @@ -811,7 +748,6 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, 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); RETURN(rc); @@ -828,7 +764,6 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) 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); RETURN(rc); @@ -843,8 +778,6 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) !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); RETURN(uuid); } @@ -870,7 +803,6 @@ static inline int obd_connect(const struct lu_env *env, 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); /* check that only subset is granted */ @@ -896,8 +828,6 @@ static inline int obd_reconnect(const struct lu_env *env, 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); /* check that only subset is granted */ LASSERT(ergo(d != NULL, @@ -918,7 +848,6 @@ static inline int obd_disconnect(struct obd_export *exp) (exp)->exp_obd->obd_name, __func__); RETURN(-ENOTSUPP); } - EXP_COUNTER_INCREMENT(exp, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); RETURN(rc); @@ -932,7 +861,6 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, 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); RETURN(rc); @@ -944,7 +872,6 @@ static inline int obd_fid_fini(struct obd_device *obd) ENTRY; 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); RETURN(rc); @@ -966,7 +893,6 @@ static inline int obd_fid_alloc(const struct lu_env *env, (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); RETURN(rc); @@ -981,8 +907,6 @@ static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) !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); RETURN(rc); } @@ -996,7 +920,6 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) 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); RETURN(rc); @@ -1010,7 +933,6 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) 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); @@ -1026,7 +948,6 @@ static inline int obd_pool_add(struct obd_device *obd, char *poolname, 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); @@ -1042,32 +963,11 @@ static inline int obd_pool_rem(struct obd_device *obd, char *poolname, 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); } -static inline void obd_getref(struct obd_device *obd) -{ - 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 (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; @@ -1097,8 +997,8 @@ static inline int obd_statfs_async(struct obd_export *exp, time64_t max_age, struct ptlrpc_request_set *rqset) { - int rc = 0; struct obd_device *obd; + int rc = 0; ENTRY; @@ -1110,10 +1010,9 @@ static inline int obd_statfs_async(struct obd_export *exp, 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); + CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n", + obd->obd_name, obd->obd_osfs_age, max_age); if (obd->obd_osfs_age < max_age) { rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset); } else { @@ -1123,8 +1022,7 @@ static inline int obd_statfs_async(struct obd_export *exp, 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)); + 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) @@ -1139,36 +1037,38 @@ static inline int obd_statfs_async(struct obd_export *exp, */ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, time64_t max_age, - __u32 flags) + __u32 flags) { - int rc = 0; - struct obd_device *obd = exp->exp_obd; - ENTRY; + struct obd_device *obd = exp->exp_obd; + int rc = 0; - if (obd == NULL) - RETURN(-EINVAL); + ENTRY; + if (unlikely(obd == NULL)) + RETURN(-EINVAL); OBD_CHECK_DEV_ACTIVE(obd); - if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) { + if (unlikely(!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 %lld, max_age %lld\n", - 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) { + CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n", + obd->obd_name, obd->obd_osfs_age, max_age); + /* ignore cache if aggregated isn't expected */ + if (obd->obd_osfs_age < max_age || + ((obd->obd_osfs.os_state & OS_STATE_SUM) && + !(flags & OBD_STATFS_SUM))) { + 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 = ktime_get_seconds(); spin_unlock(&obd->obd_osfs_lock); } } else { - CDEBUG(D_SUPER, "%s: use %p cache blocks %llu/%llu" - " objects %llu/%llu\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); @@ -1198,7 +1098,7 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, (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); @@ -1209,8 +1109,9 @@ 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, int rc) + struct niobuf_local *local, const int orig_rc) { + int rc; ENTRY; rc = exp_check_ops(exp); @@ -1222,9 +1123,9 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, (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); + rnb, pages, local, orig_rc); RETURN(rc); } @@ -1244,7 +1145,6 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, (exp)->exp_obd->obd_name, __func__); RETURN(-ENOTSUPP); } - EXP_COUNTER_INCREMENT(exp, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); RETURN(rc); @@ -1260,10 +1160,10 @@ static inline void obd_import_event(struct obd_device *obd, EXIT; return; } - if (obd->obd_set_up && OBP(obd, import_event)) { - OBD_COUNTER_INCREMENT(obd, import_event); + + if (obd->obd_set_up && OBP(obd, import_event)) OBP(obd, import_event)(obd, imp, event); - } + EXIT; } @@ -1273,7 +1173,10 @@ static inline int obd_notify(struct obd_device *obd, { int rc; ENTRY; - OBD_CHECK_DEV(obd); + + rc = obd_check_dev(obd); + if (rc) + return rc; if (!obd->obd_set_up) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); @@ -1285,7 +1188,6 @@ static inline int obd_notify(struct obd_device *obd, RETURN(-ENOSYS); } - OBD_COUNTER_INCREMENT(obd, notify); rc = OBP(obd, notify)(obd, watched, ev); RETURN(rc); @@ -1327,7 +1229,6 @@ static inline int obd_quotactl(struct obd_export *exp, (exp)->exp_obd->obd_name, __func__); RETURN(-ENOTSUPP); } - EXP_COUNTER_INCREMENT(exp, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); RETURN(rc); @@ -1364,8 +1265,13 @@ static inline int obd_health_check(const struct lu_env *env, static inline int obd_register_observer(struct obd_device *obd, struct obd_device *observer) { + int rc; ENTRY; - OBD_CHECK_DEV(obd); + + rc = obd_check_dev(obd); + if (rc) + return rc; + down_write(&obd->obd_observer_link_sem); if (obd->obd_observer && observer) { up_write(&obd->obd_observer_link_sem); @@ -1377,19 +1283,35 @@ static inline int obd_register_observer(struct obd_device *obd, } /* metadata helpers */ +enum mps_stat_idx { + LPROC_MD_CLOSE, + LPROC_MD_CREATE, + LPROC_MD_ENQUEUE, + LPROC_MD_GETATTR, + LPROC_MD_INTENT_LOCK, + LPROC_MD_LINK, + LPROC_MD_RENAME, + LPROC_MD_SETATTR, + LPROC_MD_FSYNC, + LPROC_MD_READ_PAGE, + LPROC_MD_UNLINK, + LPROC_MD_SETXATTR, + LPROC_MD_GETXATTR, + LPROC_MD_INTENT_GETATTR_ASYNC, + LPROC_MD_REVALIDATE_LOCK, + LPROC_MD_LAST_OPC, +}; + static inline int md_get_root(struct obd_export *exp, const char *fileset, struct lu_fid *fid) { int rc; - ENTRY; 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; - RETURN(rc); + return MDP(exp->exp_obd, get_root)(exp, fileset, fid); } static inline int md_getattr(struct obd_export *exp, @@ -1398,40 +1320,42 @@ static inline int md_getattr(struct obd_export *exp, { 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); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_GETATTR); + + return MDP(exp->exp_obd, getattr)(exp, op_data, request); } static inline int md_null_inode(struct obd_export *exp, const struct lu_fid *fid) { - int rc; - ENTRY; + int rc; + 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); + return rc; + + return MDP(exp->exp_obd, null_inode)(exp, fid); } 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; + int rc; + 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); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_CLOSE); + + return MDP(exp->exp_obd, close)(exp, op_data, mod, request); } static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, @@ -1439,15 +1363,18 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, uid_t uid, gid_t gid, cfs_cap_t cap_effective, __u64 rdev, struct ptlrpc_request **request) { - int rc; - ENTRY; + int rc; + 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); - RETURN(rc); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_CREATE); + + return MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, + uid, gid, cap_effective, rdev, + request); } static inline int md_enqueue(struct obd_export *exp, @@ -1458,28 +1385,29 @@ static inline int md_enqueue(struct obd_export *exp, __u64 extra_lock_flags) { int rc; - ENTRY; + rc = exp_check_ops(exp); if (rc) - RETURN(rc); - EXP_MD_COUNTER_INCREMENT(exp, enqueue); - rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh, - extra_lock_flags); - RETURN(rc); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_ENQUEUE); + + return MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh, + extra_lock_flags); } static inline int md_getattr_name(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { - int rc; - ENTRY; + int rc; + 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); + return rc; + + return MDP(exp->exp_obd, getattr_name)(exp, op_data, request); } static inline int md_intent_lock(struct obd_export *exp, @@ -1490,43 +1418,49 @@ static inline int md_intent_lock(struct obd_export *exp, __u64 extra_lock_flags) { int rc; - ENTRY; + 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); - RETURN(rc); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_INTENT_LOCK); + + return MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp, + cb_blocking, extra_lock_flags); } static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { - int rc; - ENTRY; + int rc; + 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); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_LINK); + + return MDP(exp->exp_obd, link)(exp, op_data, request); } static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, - const char *old, size_t oldlen, const char *new, - size_t newlen, struct ptlrpc_request **request) + const char *old_name, size_t oldlen, + const char *new_name, size_t newlen, + struct ptlrpc_request **request) { - int rc; - ENTRY; + int rc; + rc = exp_check_ops(exp); if (rc) - RETURN(rc); + return rc; - EXP_MD_COUNTER_INCREMENT(exp, rename); - rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, - newlen, request); - RETURN(rc); + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_RENAME); + + return MDP(exp->exp_obd, rename)(exp, op_data, old_name, oldlen, + new_name, newlen, request); } static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1534,14 +1468,15 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + rc = exp_check_ops(exp); if (rc) - RETURN(rc); + return rc; - EXP_MD_COUNTER_INCREMENT(exp, setattr); - rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request); - RETURN(rc); + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_SETATTR); + + return MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request); } static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid, @@ -1549,15 +1484,14 @@ static inline int md_fsync(struct obd_export *exp, const struct lu_fid *fid, { int rc; - ENTRY; rc = exp_check_ops(exp); if (rc) - RETURN(rc); + return rc; - EXP_MD_COUNTER_INCREMENT(exp, fsync); - rc = MDP(exp->exp_obd, fsync)(exp, fid, request); + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_FSYNC); - RETURN(rc); + return MDP(exp->exp_obd, fsync)(exp, fid, request); } /* FLR: resync mirrored files. */ @@ -1566,15 +1500,11 @@ static inline int md_file_resync(struct obd_export *exp, { 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; - RETURN(rc); + return MDP(exp->exp_obd, file_resync)(exp, data); } static inline int md_read_page(struct obd_export *exp, @@ -1584,29 +1514,31 @@ static inline int md_read_page(struct obd_export *exp, struct page **ppage) { int rc; - ENTRY; + rc = exp_check_ops(exp); if (rc) - RETURN(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); - RETURN(rc); + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_READ_PAGE); + + return MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset, + ppage); } static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { - int rc; - ENTRY; + int rc; + rc = exp_check_ops(exp); if (rc) - RETURN(rc); + return rc; - EXP_MD_COUNTER_INCREMENT(exp, unlink); - rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); - RETURN(rc); + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_UNLINK); + + return MDP(exp->exp_obd, unlink)(exp, op_data, request); } static inline int md_get_lustre_md(struct obd_export *exp, @@ -1616,25 +1548,24 @@ static inline int md_get_lustre_md(struct obd_export *exp, struct lustre_md *md) { int rc; - ENTRY; + rc = exp_check_ops(exp); if (rc) - RETURN(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)); + return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); } static inline int md_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { int rc; - ENTRY; + 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)); + return rc; + + return MDP(exp->exp_obd, free_lustre_md)(exp, md); } static inline int md_merge_attr(struct obd_export *exp, @@ -1643,12 +1574,12 @@ static inline int md_merge_attr(struct obd_export *exp, ldlm_blocking_callback cb) { int rc; - ENTRY; + 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)); + return rc; + + return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb); } static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1658,15 +1589,17 @@ static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, struct ptlrpc_request **req) { int rc; - ENTRY; rc = exp_check_ops(exp); if (rc) - RETURN(rc); - EXP_MD_COUNTER_INCREMENT(exp, setxattr); - RETURN(MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name, + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_SETXATTR); + + return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name, value, value_size, xattr_flags, - suppgid, req)); + suppgid, req); } static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1674,13 +1607,16 @@ static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid, size_t buf_size, struct ptlrpc_request **req) { int rc; - ENTRY; + rc = exp_check_ops(exp); if (rc) - RETURN(rc); - EXP_MD_COUNTER_INCREMENT(exp, getxattr); - RETURN(MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name, - buf_size, req)); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_GETXATTR); + + return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name, + buf_size, req); } static inline int md_set_open_replay_data(struct obd_export *exp, @@ -1688,24 +1624,24 @@ static inline int md_set_open_replay_data(struct obd_export *exp, struct lookup_intent *it) { int rc; - ENTRY; + 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)); + return rc; + + return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it); } static inline int md_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { int rc; - ENTRY; + 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)); + return rc; + + return MDP(exp->exp_obd, clear_open_replay_data)(exp, och); } static inline int md_set_lock_data(struct obd_export *exp, @@ -1713,12 +1649,12 @@ static inline int md_set_lock_data(struct obd_export *exp, void *data, __u64 *bits) { int rc; - ENTRY; + 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)); + return rc; + + return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits); } static inline @@ -1727,16 +1663,13 @@ int md_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, enum ldlm_cancel_flags cancel_flags, void *opaque) { int rc; - ENTRY; rc = exp_check_ops(exp); if (rc) - RETURN(rc); - EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); + return rc; - rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, - cancel_flags, opaque); - RETURN(rc); + return MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, + cancel_flags, opaque); } static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, @@ -1747,52 +1680,56 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, struct lustre_handle *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)); + return rc; + + 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; + 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)); + return rc; + + return MDP(exp->exp_obd, init_ea_size)(exp, ea_size, def_ea_size); } static inline int md_intent_getattr_async(struct obd_export *exp, struct md_enqueue_info *minfo) { 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); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_INTENT_GETATTR_ASYNC); + + return MDP(exp->exp_obd, intent_getattr_async)(exp, minfo); } static inline int md_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, struct lu_fid *fid, __u64 *bits) { - int rc; - ENTRY; + int rc; + 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); + return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_REVALIDATE_LOCK); + + return MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); } static inline int md_get_fid_from_lsm(struct obd_export *exp, @@ -1801,15 +1738,14 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, struct lu_fid *fid) { int rc; - ENTRY; + 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); -} + return rc; + return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, + fid); +} /* Unpack an MD struct from disk to in-memory format. * Returns +ve size of unpacked MD (0 for free), or -ve error. @@ -1822,13 +1758,12 @@ static inline int md_unpackmd(struct obd_export *exp, const union lmv_mds_md *lmm, size_t lmm_size) { int rc; - ENTRY; + 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); + return rc; + + return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size); } /* OBD Metadata Support */ @@ -1836,20 +1771,6 @@ static inline int md_unpackmd(struct obd_export *exp, extern int obd_init_caches(void); extern void obd_cleanup_caches(void); -/* support routines */ -extern struct kmem_cache *obdo_cachep; - -#define OBDO_ALLOC(ptr) \ -do { \ - OBD_SLAB_ALLOC_PTR_GFP((ptr), obdo_cachep, GFP_NOFS); \ -} while(0) - -#define OBDO_FREE(ptr) \ -do { \ - OBD_SLAB_FREE_PTR((ptr), obdo_cachep); \ -} while(0) - - typedef int (*register_lwp_cb)(void *data); struct lwp_register_item { @@ -1922,5 +1843,4 @@ 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); - #endif /* __LINUX_OBD_CLASS_H */