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) \
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)
} \
} 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)
.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;
}
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;
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;
}
}
+#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)
{
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)
{
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);