From 9eb3d1db42d2937daef25950f6527ccb46221f8e Mon Sep 17 00:00:00 2001 From: LiuYing Date: Fri, 8 Oct 2010 10:48:14 +0800 Subject: [PATCH] b=21420 Add mds/mgs stats to HEAD 1)remove useless counter from mds and move some definitions from mds to mdt; 2)move LPROCFS_MD_OP_INITs from lprocfs_alloc_md_stats() to lprocfs_init_mps_stats(), which is needed by this stats; 3)increase mdt counter for each type operation i=andreas i=wangdi --- lustre/include/lprocfs_status.h | 5 +++++ lustre/include/obd_class.h | 3 ++- lustre/mds/lproc_mds.c | 33 -------------------------------- lustre/mds/mds_internal.h | 16 ---------------- lustre/mdt/mdt_fs.c | 17 ++++++++++++++++- lustre/mdt/mdt_internal.h | 19 +++++++++++++++---- lustre/mdt/mdt_lproc.c | 28 ++++++++++++++++++++++++++- lustre/mdt/mdt_open.c | 2 ++ lustre/mdt/mdt_reint.c | 41 +++++++++++++++++++++++++++++++++++----- lustre/mdt/mdt_xattr.c | 6 +++++- lustre/mgs/mgs_fs.c | 19 +++++++++++++++++-- lustre/obdclass/lprocfs_status.c | 38 +++++++++++++++++++++---------------- lustre/obdclass/lu_time.c | 2 +- 13 files changed, 148 insertions(+), 81 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 5631f28..c7b077c 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -415,6 +415,8 @@ extern void lprocfs_clear_stats(struct lprocfs_stats *stats); extern void lprocfs_free_stats(struct lprocfs_stats **stats); extern void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats); +extern void lprocfs_init_mps_stats(int num_private_stats, + struct lprocfs_stats *stats); extern void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats); extern int lprocfs_alloc_obd_stats(struct obd_device *obddev, unsigned int num_private_stats); @@ -747,6 +749,9 @@ static inline int lprocfs_register_stats(cfs_proc_dir_entry_t *root, static inline void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats) { return; } +static inline void lprocfs_init_mps_stats(int num_private_stats, + struct lprocfs_stats *stats) +{ return; } static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) { return; } static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev, diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 7163582..37e50a9 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -382,7 +382,8 @@ do { \ #define EXP_MD_COUNTER_INCREMENT(exp, op) #endif -static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp) { +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); diff --git a/lustre/mds/lproc_mds.c b/lustre/mds/lproc_mds.c index 25ca6b6..343d3fe 100644 --- a/lustre/mds/lproc_mds.c +++ b/lustre/mds/lproc_mds.c @@ -182,43 +182,10 @@ struct lprocfs_vars lprocfs_mdt_obd_vars[] = { { 0 } }; -struct lprocfs_vars lprocfs_mdt_module_vars[] = { - { "num_refs", lprocfs_rd_numrefs, 0, 0 }, - { 0 } -}; - -void mds_counter_incr(struct obd_export *exp, int opcode) -{ - if (exp->exp_obd && exp->exp_obd->obd_stats) - lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode); - if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL) - lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode); - -} - -void mds_stats_counter_init(struct lprocfs_stats *stats) -{ - lprocfs_counter_init(stats, LPROC_MDS_OPEN, 0, "open", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_CLOSE, 0, "close", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_MKNOD, 0, "mknod", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_LINK, 0, "link", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_UNLINK, 0, "unlink", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_MKDIR, 0, "mkdir", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_RMDIR, 0, "rmdir", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_RENAME, 0, "rename", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_GETXATTR, 0, "getxattr", "reqs"); - lprocfs_counter_init(stats, LPROC_MDS_SETXATTR, 0, "setxattr", "reqs"); -} - void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars) { lvars->module_vars = lprocfs_mds_module_vars; lvars->obd_vars = lprocfs_mds_obd_vars; } -void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars) -{ - lvars->module_vars = lprocfs_mdt_module_vars; - lvars->obd_vars = lprocfs_mdt_obd_vars; -} #endif diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index 75e333e..f41deb4 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -76,21 +76,5 @@ int mds_obd_destroy(struct obd_export *exp, struct obdo *oa, extern struct lvfs_callback_ops mds_lvfs_ops; /* mds/lproc_mds.c */ -enum { - LPROC_MDS_OPEN = 0, - LPROC_MDS_CLOSE, - LPROC_MDS_MKNOD, - LPROC_MDS_LINK, - LPROC_MDS_UNLINK, - LPROC_MDS_MKDIR, - LPROC_MDS_RMDIR, - LPROC_MDS_RENAME, - LPROC_MDS_GETXATTR, - LPROC_MDS_SETXATTR, - LPROC_MDS_LAST, -}; -void mds_counter_incr(struct obd_export *exp, int opcode); -void mds_stats_counter_init(struct lprocfs_stats *stats); void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars); -void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars); #endif /* _MDS_INTERNAL_H */ diff --git a/lustre/mdt/mdt_fs.c b/lustre/mdt/mdt_fs.c index 1770620..b0ba74e 100644 --- a/lustre/mdt/mdt_fs.c +++ b/lustre/mdt/mdt_fs.c @@ -62,7 +62,22 @@ int mdt_export_stats_init(struct obd_device *obd, RETURN(rc); } if (newnid) { - rc = lprocfs_nid_ldlm_stats_init(exp->exp_nid_stats); + struct nid_stat *tmp = exp->exp_nid_stats; + int num_stats; + + num_stats = (sizeof(*obd->obd_type->typ_md_ops) / sizeof(void *)) + + LPROC_MDT_LAST; + tmp->nid_stats = lprocfs_alloc_stats(num_stats, + LPROCFS_STATS_FLAG_NOPERCPU); + if (tmp->nid_stats == NULL) + return -ENOMEM; + lprocfs_init_mps_stats(LPROC_MDT_LAST, tmp->nid_stats); + mdt_stats_counter_init(tmp->nid_stats); + rc = lprocfs_register_stats(tmp->nid_proc, "stats", + tmp->nid_stats); + if (rc) + GOTO(clean, rc); + rc = lprocfs_nid_ldlm_stats_init(tmp); if (rc) GOTO(clean, rc); } diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index fdee632..e84628f 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -806,6 +806,21 @@ int mdt_cos_is_enabled(struct mdt_device *); int mdt_hsm_copytool_send(struct obd_export *exp); /* lprocfs stuff */ +enum { + LPROC_MDT_OPEN = 0, + LPROC_MDT_CLOSE, + LPROC_MDT_MKNOD, + LPROC_MDT_LINK, + LPROC_MDT_UNLINK, + LPROC_MDT_MKDIR, + LPROC_MDT_RMDIR, + LPROC_MDT_RENAME, + LPROC_MDT_GETXATTR, + LPROC_MDT_SETXATTR, + LPROC_MDT_LAST, +}; +void mdt_counter_incr(struct obd_export *exp, int opcode); +void mdt_stats_counter_init(struct lprocfs_stats *stats); void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars); int mdt_procfs_init(struct mdt_device *mdt, const char *name); int mdt_procfs_fini(struct mdt_device *mdt); @@ -813,10 +828,6 @@ int mdt_procfs_fini(struct mdt_device *mdt); void mdt_time_start(const struct mdt_thread_info *info); void mdt_time_end(const struct mdt_thread_info *info, int idx); -enum { - LPROC_MDT_NR -}; - /* Capability */ int mdt_ck_thread_start(struct mdt_device *mdt); void mdt_ck_thread_stop(struct mdt_device *mdt); diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 557cabc..24932d9 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -68,6 +68,9 @@ #include "mdt_internal.h" #include +enum { + LPROC_MDT_NR +}; static const char *mdt_proc_names[LPROC_MDT_NR] = { }; @@ -108,7 +111,7 @@ int mdt_procfs_init(struct mdt_device *mdt, const char *name) lprocfs_add_simple(obd->obd_proc_exports_entry, "clear", lprocfs_nid_stats_clear_read, lprocfs_nid_stats_clear_write, obd, NULL); - rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_NR); + rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST); RETURN(rc); } @@ -807,3 +810,26 @@ void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars) lvars->module_vars = lprocfs_mdt_module_vars; lvars->obd_vars = lprocfs_mdt_obd_vars; } + +void mdt_counter_incr(struct obd_export *exp, int opcode) +{ + if (exp->exp_obd && exp->exp_obd->obd_stats) + lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode); + if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL) + lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode); + +} + +void mdt_stats_counter_init(struct lprocfs_stats *stats) +{ + 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_GETXATTR, 0, "getxattr", "reqs"); + lprocfs_counter_init(stats, LPROC_MDT_SETXATTR, 0, "setxattr", "reqs"); +} diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 9de4773..81d6069 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1163,6 +1163,7 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) OBD_FAIL_TIMEOUT_ORSET(OBD_FAIL_MDS_PAUSE_OPEN, OBD_FAIL_ONCE, (obd_timeout + 1) / 4); + mdt_counter_incr(req->rq_export, LPROC_MDT_OPEN); repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY); ma->ma_lmm = req_capsule_server_get(info->mti_pill, &RMF_MDT_MD); @@ -1522,6 +1523,7 @@ int mdt_close(struct mdt_thread_info *info) int rc, ret = 0; ENTRY; + mdt_counter_incr(req->rq_export, LPROC_MDT_CLOSE); /* Close may come with the Size-on-MDS update. Unpack it. */ rc = mdt_close_unpack(info); if (rc) diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 0755efd..3354f56 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -605,7 +605,8 @@ out: static int mdt_reint_create(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) { - int rc; + struct ptlrpc_request *req = mdt_info_req(info); + int rc; ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_CREATE)) @@ -617,10 +618,15 @@ static int mdt_reint_create(struct mdt_thread_info *info, switch (info->mti_attr.ma_attr.la_mode & S_IFMT) { case S_IFDIR:{ /* Cross-ref case. */ + /* TODO: we can add LPROC_MDT_CROSS for cross-ref stats */ if (info->mti_cross_ref) { rc = mdt_md_mkobj(info); - break; + } else { + LASSERT(info->mti_rr.rr_namelen > 0); + mdt_counter_incr(req->rq_export, LPROC_MDT_MKDIR); + rc = mdt_md_create(info); } + break; } case S_IFREG: case S_IFLNK: @@ -630,6 +636,7 @@ static int mdt_reint_create(struct mdt_thread_info *info, case S_IFSOCK:{ /* Special file should stay on the same node as parent. */ LASSERT(info->mti_rr.rr_namelen > 0); + mdt_counter_incr(req->rq_export, LPROC_MDT_MKNOD); rc = mdt_md_create(info); break; } @@ -641,7 +648,7 @@ static int mdt_reint_create(struct mdt_thread_info *info, /* * VBR: save parent version in reply and child version getting by its name. - * Version of child is getting and checking during its lookup. If + * Version of child is getting and checking during its lookup. If */ static int mdt_reint_unlink(struct mdt_thread_info *info, struct mdt_lock_handle *lhc) @@ -754,6 +761,24 @@ static int mdt_reint_unlink(struct mdt_thread_info *info, if (rc == 0) mdt_handle_last_unlink(info, mc, ma); + switch (ma->ma_attr.la_mode & S_IFMT) { + case S_IFDIR: + mdt_counter_incr(req->rq_export, LPROC_MDT_RMDIR); + break; + case S_IFREG: + case S_IFLNK: + case S_IFCHR: + case S_IFBLK: + case S_IFIFO: + case S_IFSOCK: + mdt_counter_incr(req->rq_export, LPROC_MDT_UNLINK); + break; + default: + CERROR("bad file type %o unlinking\n", ma->ma_attr.la_mode); + LBUG(); + GOTO(out, rc = -EINVAL); + } + EXIT; mdt_object_unlock_put(info, mc, child_lh, rc); @@ -861,6 +886,9 @@ static int mdt_reint_link(struct mdt_thread_info *info, rc = mdo_link(info->mti_env, mdt_object_child(mp), mdt_object_child(ms), lname, ma); + if (rc == 0) + mdt_counter_incr(req->rq_export, LPROC_MDT_LINK); + EXIT; out_unlock_child: mdt_object_unlock_put(info, ms, lhs, rc); @@ -1245,8 +1273,11 @@ static int mdt_reint_rename(struct mdt_thread_info *info, lname, ma); /* handle last link of tgt object */ - if (rc == 0 && mnew) - mdt_handle_last_unlink(info, mnew, ma); + if (rc == 0) { + mdt_counter_incr(req->rq_export, LPROC_MDT_RENAME); + if (mnew) + mdt_handle_last_unlink(info, mnew, ma); + } EXIT; out_unlock_new: diff --git a/lustre/mdt/mdt_xattr.c b/lustre/mdt/mdt_xattr.c index 5fd6ffc..0e5cc6d 100644 --- a/lustre/mdt/mdt_xattr.c +++ b/lustre/mdt/mdt_xattr.c @@ -215,6 +215,7 @@ int mdt_getxattr(struct mdt_thread_info *info) EXIT; out: if (rc >= 0) { + mdt_counter_incr(req->rq_export, LPROC_MDT_GETXATTR); repbody->eadatasize = rc; rc = 0; } @@ -238,7 +239,7 @@ static int mdt_rmtlsetfacl(struct mdt_thread_info *info, rc = lustre_ext_acl_xattr_id2server(uc, med->med_idmap, header); if (rc) RETURN(rc); - + rc = mo_xattr_get(info->mti_env, next, &LU_BUF_NULL, xattr_name); if (rc == -ENODATA) rc = 0; @@ -422,6 +423,9 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, CDEBUG(D_INFO, "valid bits: "LPX64"\n", valid); rc = -EINVAL; } + if (rc == 0) + mdt_counter_incr(req->rq_export, LPROC_MDT_SETXATTR); + EXIT; out_unlock: mdt_object_unlock_put(info, obj, lh, rc); diff --git a/lustre/mgs/mgs_fs.c b/lustre/mgs/mgs_fs.c index fe83a4d..9a48148 100644 --- a/lustre/mgs/mgs_fs.c +++ b/lustre/mgs/mgs_fs.c @@ -74,9 +74,24 @@ int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp, rc = 0; RETURN(rc); } - if (newnid) { - rc = lprocfs_nid_ldlm_stats_init(exp->exp_nid_stats); + struct nid_stat *tmp = exp->exp_nid_stats; + int num_stats = 0; + + num_stats = (sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) + + LPROC_MGS_LAST - 1; + tmp->nid_stats = lprocfs_alloc_stats(num_stats, + LPROCFS_STATS_FLAG_NOPERCPU); + if (tmp->nid_stats == NULL) + return -ENOMEM; + lprocfs_init_ops_stats(LPROC_MGS_LAST, tmp->nid_stats); + mgs_stats_counter_init(tmp->nid_stats); + rc = lprocfs_register_stats(tmp->nid_proc, "stats", + tmp->nid_stats); + if (rc) + GOTO(clean, rc); + + rc = lprocfs_nid_ldlm_stats_init(tmp); if (rc) GOTO(clean, rc); } diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index add4fd1..2b9e631 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1550,23 +1550,8 @@ do { \ lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \ } while (0) -int lprocfs_alloc_md_stats(struct obd_device *obd, - unsigned num_private_stats) +void lprocfs_init_mps_stats(int num_private_stats, struct lprocfs_stats *stats) { - struct lprocfs_stats *stats; - unsigned int num_stats; - int rc, i; - - LASSERT(obd->md_stats == NULL); - LASSERT(obd->obd_proc_entry != NULL); - LASSERT(obd->md_cntr_base == 0); - - num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) + - num_private_stats; - stats = lprocfs_alloc_stats(num_stats, 0); - if (stats == NULL) - return -ENOMEM; - LPROCFS_MD_OP_INIT(num_private_stats, stats, getstatus); LPROCFS_MD_OP_INIT(num_private_stats, stats, change_cbdata); LPROCFS_MD_OP_INIT(num_private_stats, stats, find_cbdata); @@ -1599,6 +1584,26 @@ int lprocfs_alloc_md_stats(struct obd_device *obd, LPROCFS_MD_OP_INIT(num_private_stats, stats, get_remote_perm); LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_getattr_async); LPROCFS_MD_OP_INIT(num_private_stats, stats, revalidate_lock); +} + +int lprocfs_alloc_md_stats(struct obd_device *obd, + unsigned num_private_stats) +{ + struct lprocfs_stats *stats; + unsigned int num_stats; + int rc, i; + + LASSERT(obd->md_stats == NULL); + LASSERT(obd->obd_proc_entry != NULL); + LASSERT(obd->md_cntr_base == 0); + + num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) + + num_private_stats; + stats = lprocfs_alloc_stats(num_stats, 0); + if (stats == NULL) + return -ENOMEM; + + lprocfs_init_mps_stats(num_private_stats, stats); for (i = num_private_stats; i < num_stats; i++) { if (stats->ls_percpu[0]->lp_cntr[i].lc_name == NULL) { @@ -2375,6 +2380,7 @@ EXPORT_SYMBOL(lprocfs_free_stats); EXPORT_SYMBOL(lprocfs_clear_stats); EXPORT_SYMBOL(lprocfs_register_stats); EXPORT_SYMBOL(lprocfs_init_ops_stats); +EXPORT_SYMBOL(lprocfs_init_mps_stats); EXPORT_SYMBOL(lprocfs_init_ldlm_stats); EXPORT_SYMBOL(lprocfs_alloc_obd_stats); EXPORT_SYMBOL(lprocfs_alloc_md_stats); diff --git a/lustre/obdclass/lu_time.c b/lustre/obdclass/lu_time.c index 70a658b..0da2c1c 100644 --- a/lustre/obdclass/lu_time.c +++ b/lustre/obdclass/lu_time.c @@ -131,7 +131,7 @@ EXPORT_SYMBOL(lu_time_named_init); int lu_time_init(struct lprocfs_stats **stats, cfs_proc_dir_entry_t *entry, const char **names, int nr) { - return lu_time_named_init(stats, "stats", entry, names, nr); + return lu_time_named_init(stats, "lu_stats", entry, names, nr); } EXPORT_SYMBOL(lu_time_init); -- 1.8.3.1