} while (0)
-#ifdef CONFIG_PROC_FS
-#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 EXP_MD_COUNTER_INCREMENT(exp, op)
-#endif
-
static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp)
{
/* Always add in ldlm_stats */
}
/* 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,
{
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,
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,
__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,
__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,
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,
{
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. */
{
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,
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,
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,
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,
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,
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,
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,
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
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,
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,
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.
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 */
struct obd_export *exp = req->rq_export;
if (exp->exp_obd && exp->exp_obd->obd_md_stats)
- lprocfs_counter_incr(exp->exp_obd->obd_md_stats, opcode);
+ lprocfs_counter_incr(exp->exp_obd->obd_md_stats,
+ opcode + LPROC_MD_LAST_OPC);
if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);
if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash &&
opcode, 1);
}
+static const char * const mdt_stats[] = {
+ [LPROC_MDT_OPEN] = "open",
+ [LPROC_MDT_CLOSE] = "close",
+ [LPROC_MDT_MKNOD] = "mknod",
+ [LPROC_MDT_LINK] = "link",
+ [LPROC_MDT_UNLINK] = "unlink",
+ [LPROC_MDT_MKDIR] = "mkdir",
+ [LPROC_MDT_RMDIR] = "rmdir",
+ [LPROC_MDT_RENAME] = "rename",
+ [LPROC_MDT_GETATTR] = "getattr",
+ [LPROC_MDT_SETATTR] = "setattr",
+ [LPROC_MDT_GETXATTR] = "getxattr",
+ [LPROC_MDT_SETXATTR] = "setxattr",
+ [LPROC_MDT_STATFS] = "statfs",
+ [LPROC_MDT_SYNC] = "sync",
+ [LPROC_MDT_SAMEDIR_RENAME] = "samedir_rename",
+ [LPROC_MDT_CROSSDIR_RENAME] = "crossdir_rename",
+ [LPROC_MDT_IO_READ] = "read_bytes",
+ [LPROC_MDT_IO_WRITE] = "write_bytes",
+ [LPROC_MDT_IO_PUNCH] = "punch",
+};
+
void mdt_stats_counter_init(struct lprocfs_stats *stats)
{
- LASSERT(stats && stats->ls_num >= LPROC_MDT_LAST);
-
- lprocfs_counter_init(stats, LPROC_MDT_OPEN, 0, "open", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_CLOSE, 0, "close", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_MKNOD, 0, "mknod", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_LINK, 0, "link", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_UNLINK, 0, "unlink", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_MKDIR, 0, "mkdir", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_RMDIR, 0, "rmdir", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_RENAME, 0, "rename", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_GETATTR, 0, "getattr", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_SETATTR, 0, "setattr", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_GETXATTR, 0, "getxattr", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_SETXATTR, 0, "setxattr", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_STATFS, 0, "statfs", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_SYNC, 0, "sync", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_SAMEDIR_RENAME, 0,
- "samedir_rename", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_CROSSDIR_RENAME, 0,
- "crossdir_rename", "reqs");
- lprocfs_counter_init(stats, LPROC_MDT_IO_READ,
- LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
- lprocfs_counter_init(stats, LPROC_MDT_IO_WRITE,
- LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
- lprocfs_counter_init(stats, LPROC_MDT_IO_PUNCH, 0, "punch", "reqs");
+ int idx;
+
+ LASSERT(stats && stats->ls_num >= ARRAY_SIZE(mdt_stats));
+
+ for (idx = 0; idx < ARRAY_SIZE(mdt_stats); idx++) {
+ int flags = 0;
+
+ if (idx == LPROC_MDT_IO_WRITE || idx == LPROC_MDT_IO_READ)
+ flags = LPROCFS_CNTR_AVGMINMAX;
+
+ lprocfs_counter_init(stats, idx, flags, mdt_stats[idx], "reqs");
+ }
}
int mdt_procfs_init(struct mdt_device *mdt, const char *name)
{
- struct obd_device *obd = mdt2obd_dev(mdt);
- int rc;
- ENTRY;
+ struct obd_device *obd = mdt2obd_dev(mdt);
+ int rc;
+ int i;
+ ENTRY;
LASSERT(name != NULL);
obd->obd_vars = lprocfs_mdt_obd_vars;
if (obd->obd_proc_exports_entry)
lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
obd, &mdt_nid_stats_clear_fops);
- rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST);
+
+ rc = lprocfs_alloc_md_stats(obd, ARRAY_SIZE(mdt_stats));
if (rc)
return rc;
- mdt_stats_counter_init(obd->obd_md_stats);
- rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST,
+ /* add additional MDT md_stats after the default ones */
+ for (i = 0; i < ARRAY_SIZE(mdt_stats); i++) {
+ int idx = i + LPROC_MD_LAST_OPC;
+ int flags = 0;
+
+ if (idx == LPROC_MDT_IO_WRITE || idx == LPROC_MDT_IO_READ)
+ flags = LPROCFS_CNTR_AVGMINMAX;
+
+ lprocfs_counter_init(obd->obd_md_stats, idx, flags,
+ mdt_stats[i], "reqs");
+ }
+
+ rc = lprocfs_job_stats_init(obd, ARRAY_SIZE(mdt_stats),
mdt_stats_counter_init);
rc = lproc_mdt_attach_rename_seqstat(mdt);
}
EXPORT_SYMBOL(lprocfs_counter_init);
-/* Note that we only init 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 LPROCFS_MD_OP_INIT(base, stats, op) \
- do { \
- unsigned int _idx = base + MD_COUNTER_OFFSET(op); \
- \
- if (MD_COUNTER_OFFSET(op) < NUM_MD_STATS) { \
- LASSERT(_idx < stats->ls_num); \
- lprocfs_counter_init(stats, _idx, 0, #op, "reqs"); \
- } \
- } while (0)
-
-void lprocfs_init_mps_stats(int num_private_stats, struct lprocfs_stats *stats)
-{
- LPROCFS_MD_OP_INIT(num_private_stats, stats, get_root);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, null_inode);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, close);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, create);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, enqueue);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr_name);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_lock);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, link);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, rename);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, setattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, fsync);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, read_page);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, unlink);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, setxattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, getxattr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, init_ea_size);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, get_lustre_md);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, free_lustre_md);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, merge_attr);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, set_open_replay_data);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, clear_open_replay_data);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, set_lock_data);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, lock_match);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, cancel_unused);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_getattr_async);
- LPROCFS_MD_OP_INIT(num_private_stats, stats, revalidate_lock);
-}
+static const char * const mps_stats[] = {
+ [LPROC_MD_CLOSE] = "close",
+ [LPROC_MD_CREATE] = "create",
+ [LPROC_MD_ENQUEUE] = "enqueue",
+ [LPROC_MD_GETATTR] = "getattr",
+ [LPROC_MD_INTENT_LOCK] = "intent_lock",
+ [LPROC_MD_LINK] = "link",
+ [LPROC_MD_RENAME] = "rename",
+ [LPROC_MD_SETATTR] = "setattr",
+ [LPROC_MD_FSYNC] = "fsync",
+ [LPROC_MD_READ_PAGE] = "read_page",
+ [LPROC_MD_UNLINK] = "unlink",
+ [LPROC_MD_SETXATTR] = "setxattr",
+ [LPROC_MD_GETXATTR] = "getxattr",
+ [LPROC_MD_INTENT_GETATTR_ASYNC] = "intent_getattr_async",
+ [LPROC_MD_REVALIDATE_LOCK] = "revalidate_lock",
+};
int lprocfs_alloc_md_stats(struct obd_device *obd,
unsigned int num_private_stats)
unsigned int num_stats;
int rc, i;
- CLASSERT(offsetof(struct md_ops, MD_STATS_FIRST_OP) == 0);
- CLASSERT(_MD_COUNTER_OFFSET(MD_STATS_FIRST_OP) == 0);
- CLASSERT(_MD_COUNTER_OFFSET(MD_STATS_LAST_OP) > 0);
-
/* TODO Ensure that this function is only used where
* appropriate by adding an assertion to the effect that
* obd->obd_type->typ_md_ops is not NULL. We can't do this now
*/
LASSERT(obd->obd_proc_entry != NULL);
LASSERT(obd->obd_md_stats == NULL);
- LASSERT(obd->obd_md_cntr_base == 0);
- num_stats = NUM_MD_STATS + num_private_stats;
+ num_stats = ARRAY_SIZE(mps_stats) + num_private_stats;
stats = lprocfs_alloc_stats(num_stats, 0);
- if (stats == NULL)
+ if (!stats)
return -ENOMEM;
- lprocfs_init_mps_stats(num_private_stats, stats);
-
- for (i = num_private_stats; i < num_stats; i++) {
- if (stats->ls_cnt_header[i].lc_name == NULL) {
- CERROR("Missing md_stat initializer md_op "
- "operation at offset %d. Aborting.\n",
- i - num_private_stats);
+ for (i = 0; i < ARRAY_SIZE(mps_stats); i++) {
+ lprocfs_counter_init(stats, i, 0, mps_stats[i], "reqs");
+ if (!stats->ls_cnt_header[i].lc_name) {
+ CERROR("Missing md_stat initializer md_op operation at offset %d. Aborting.\n",
+ i);
LBUG();
}
}
lprocfs_free_stats(&stats);
} else {
obd->obd_md_stats = stats;
- obd->obd_md_cntr_base = num_private_stats;
}
return rc;
if (stats != NULL) {
obd->obd_md_stats = NULL;
- obd->obd_md_cntr_base = 0;
lprocfs_free_stats(&stats);
}
}