From 8c49b5e84e6c913505ae686b6e0b3b57565751da Mon Sep 17 00:00:00 2001 From: yury Date: Mon, 15 Nov 2004 16:02:53 +0000 Subject: [PATCH] - added md_ops stats --- lustre/include/linux/lprocfs_status.h | 10 ++-- lustre/include/linux/obd.h | 9 ++-- lustre/include/linux/obd_class.h | 27 ++++++++--- lustre/mds/handler.c | 9 +++- lustre/obdclass/lprocfs_status.c | 89 +++++++++++++++++++++++++++++++++-- lustre/obdecho/echo.c | 2 +- 6 files changed, 128 insertions(+), 18 deletions(-) diff --git a/lustre/include/linux/lprocfs_status.h b/lustre/include/linux/lprocfs_status.h index 44dff5b..2e2474f 100644 --- a/lustre/include/linux/lprocfs_status.h +++ b/lustre/include/linux/lprocfs_status.h @@ -173,13 +173,17 @@ static inline void lprocfs_counter_incr(struct lprocfs_stats *stats, int idx) extern struct lprocfs_stats *lprocfs_alloc_stats(unsigned int num); extern void lprocfs_free_stats(struct lprocfs_stats *stats); -extern int lprocfs_alloc_obd_stats(struct obd_device *obddev, - unsigned int num_private_stats); extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index, unsigned conf, const char *name, const char *units); +extern int lprocfs_alloc_obd_stats(struct obd_device *obddev, + unsigned int num_private_stats); extern void lprocfs_free_obd_stats(struct obd_device *obddev); -extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, +extern int lprocfs_alloc_md_stats(struct obd_device *obddev, + unsigned int num_private_stats); +extern void lprocfs_free_md_stats(struct obd_device *obddev); +extern int lprocfs_register_stats(struct proc_dir_entry *root, + const char *name, struct lprocfs_stats *stats); #define LPROCFS_INIT_MULTI_VARS(array, size) \ diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 2c7adc8..cde2a15 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -633,7 +633,6 @@ struct obd_device { time_t obd_recovery_start; time_t obd_recovery_end; - union { struct filter_obd filter; struct mds_obd mds; @@ -653,6 +652,9 @@ struct obd_device { /* fields used by LProcFS */ unsigned int obd_cntr_base; struct lprocfs_stats *obd_stats; + unsigned int md_cntr_base; + struct lprocfs_stats *md_stats; + struct proc_dir_entry *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; }; @@ -891,8 +893,9 @@ struct md_ops { int (*m_delete_inode)(struct obd_export *, struct lustre_id *); - /* NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line to - * lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. Also, add a + /* + * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to + * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a * wrapper function in include/linux/obd_class.h. */ }; diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 67a9cbd..a8cf209 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -312,11 +312,24 @@ do { \ unsigned int coffset; \ coffset = (unsigned int)(obd)->obd_cntr_base + \ OBD_COUNTER_OFFSET(op); \ - LASSERT(coffset < obd->obd_stats->ls_num); \ - lprocfs_counter_incr(obd->obd_stats, coffset); \ + LASSERT(coffset < (obd)->obd_stats->ls_num); \ + lprocfs_counter_incr((obd)->obd_stats, coffset); \ } -/* FIXME: real accounting here */ -#define MD_COUNTER_INCREMENT(obd, op) + +#define MD_COUNTER_OFFSET(op) \ + ((offsetof(struct md_ops, m_ ## op) - \ + offsetof(struct md_ops, m_getstatus)) \ + / sizeof(((struct md_ops *)(0))->m_getstatus)) + +#define MD_COUNTER_INCREMENT(obd, op) \ + if ((obd)->md_stats != NULL) { \ + unsigned int coffset; \ + coffset = (unsigned int)(obd)->md_cntr_base + \ + MD_COUNTER_OFFSET(op); \ + LASSERT(coffset < (obd)->md_stats->ls_num); \ + lprocfs_counter_incr((obd)->md_stats, coffset); \ + } + #else #define OBD_COUNTER_OFFSET(op) #define OBD_COUNTER_INCREMENT(obd, op) @@ -379,12 +392,12 @@ do { \ } \ } while (0) -#define CTXT_CHECK_OP(ctxt, op, err) \ +#define CTXT_CHECK_OP(ctxt, op, err) \ do { \ - if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ + if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ if (err) \ CERROR("lop_" #op ": dev %d no operation\n", \ - ctxt->loc_obd->obd_minor); \ + ctxt->loc_obd->obd_minor); \ RETURN(err); \ } \ } while (0) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 1c62018..c118886 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -3252,13 +3252,20 @@ static int mds_intent_policy(struct ldlm_namespace *ns, int mds_attach(struct obd_device *dev, obd_count len, void *data) { struct lprocfs_static_vars lvars; + int rc = 0; lprocfs_init_multi_vars(0, &lvars); - return lprocfs_obd_attach(dev, lvars.obd_vars); + + rc = lprocfs_obd_attach(dev, lvars.obd_vars); + if (rc) + return rc; + + return lprocfs_alloc_md_stats(dev, 0); } int mds_detach(struct obd_device *dev) { + lprocfs_free_md_stats(dev); return lprocfs_obd_detach(dev); } diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 8c2e1b1..e5796cf 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -547,7 +547,8 @@ struct file_operations lprocfs_stats_seq_fops = { .release = seq_release, }; -int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, +int lprocfs_register_stats(struct proc_dir_entry *root, + const char *name, struct lprocfs_stats *stats) { struct proc_dir_entry *entry; @@ -563,7 +564,8 @@ int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, } void lprocfs_counter_init(struct lprocfs_stats *stats, int index, - unsigned conf, const char *name, const char *units) + unsigned conf, const char *name, + const char *units) { struct lprocfs_counter *c; int i; @@ -586,7 +588,8 @@ do { \ lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \ } while (0) -int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats) +int lprocfs_alloc_obd_stats(struct obd_device *obd, + unsigned num_private_stats) { struct lprocfs_stats *stats; unsigned int num_stats; @@ -694,6 +697,83 @@ void lprocfs_free_obd_stats(struct obd_device *obd) } } +#define LPROCFS_MD_OP_INIT(base, stats, op) \ +do { \ + unsigned int coffset = base + MD_COUNTER_OFFSET(op); \ + LASSERT(coffset < stats->ls_num); \ + lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \ +} while (0) + +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(delete_inode) + + num_private_stats; + stats = lprocfs_alloc_stats(num_stats); + 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, change_cbdata_name); + 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, done_writing); + 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_lock); + 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, sync); + LPROCFS_MD_OP_INIT(num_private_stats, stats, readpage); + LPROCFS_MD_OP_INIT(num_private_stats, stats, unlink); + LPROCFS_MD_OP_INIT(num_private_stats, stats, valid_attrs); + LPROCFS_MD_OP_INIT(num_private_stats, stats, get_real_obd); + LPROCFS_MD_OP_INIT(num_private_stats, stats, req2lustre_md); + 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, store_inode_generation); + LPROCFS_MD_OP_INIT(num_private_stats, stats, set_lock_data); + LPROCFS_MD_OP_INIT(num_private_stats, stats, delete_inode); + + for (i = num_private_stats; i < num_stats; i++) { + if (stats->ls_percpu[0]->lp_cntr[i].lc_name == NULL) { + CERROR("Missing md_stat initializer md_op " + "operation at offset %d. Aborting.\n", + i - num_private_stats); + LBUG(); + } + } + rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats); + if (rc < 0) { + lprocfs_free_stats(stats); + } else { + obd->md_stats = stats; + obd->md_cntr_base = num_private_stats; + } + return rc; +} + +void lprocfs_free_md_stats(struct obd_device *obd) +{ + struct lprocfs_stats *stats = obd->md_stats; + + if (stats != NULL) { + obd->md_stats = NULL; + lprocfs_free_stats(stats); + } +} + int lprocfs_write_helper(const char *buffer, unsigned long count, int *val) { @@ -800,6 +880,7 @@ static long timeval_sub(struct timeval *large, struct timeval *small) return ((large->tv_sec - small->tv_sec) * 1000000) + (large->tv_usec - small->tv_usec); } + void lprocfs_stime_record(struct obd_service_time *stime, struct timeval *large, struct timeval *small) { @@ -920,6 +1001,8 @@ EXPORT_SYMBOL(lprocfs_free_stats); EXPORT_SYMBOL(lprocfs_register_stats); EXPORT_SYMBOL(lprocfs_alloc_obd_stats); EXPORT_SYMBOL(lprocfs_free_obd_stats); +EXPORT_SYMBOL(lprocfs_alloc_md_stats); +EXPORT_SYMBOL(lprocfs_free_md_stats); EXPORT_SYMBOL(lprocfs_rd_u64); EXPORT_SYMBOL(lprocfs_rd_uuid); diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index b36b02a..6b579e1 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -55,7 +55,7 @@ static struct page *echo_persistent_pages[ECHO_PERSISTENT_PAGES]; enum { LPROC_ECHO_READ_BYTES = 1, LPROC_ECHO_WRITE_BYTES = 2, - LPROC_ECHO_LAST = LPROC_ECHO_WRITE_BYTES +1 + LPROC_ECHO_LAST }; static int echo_connect(struct lustre_handle *conn, struct obd_device *obd, -- 1.8.3.1