xfs: pass xfsstats structures to handlers and macros
This patch is the next step toward per-fs xfs stats. The patch makes the show and clear routines able to handle any stats structure associated with a kobject. Instead of a single global xfsstats structure, add kobject and a pointer to a per-cpu struct xfsstats. Modify the macros that manipulate the stats accordingly: XFS_STATS_INC, XFS_STATS_DEC, and XFS_STATS_ADD now access xfsstats->xs_stats. The sysfs functions need to get from the kobject back to the xfsstats structure which contains it, and pass the pointer to the ->xs_stats percpu structure into the show & clear routines. Signed-off-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:

committed by
Dave Chinner

parent
a27c264009
commit
80529c45ab
@@ -18,9 +18,6 @@
|
||||
#ifndef __XFS_STATS_H__
|
||||
#define __XFS_STATS_H__
|
||||
|
||||
int xfs_stats_format(char *buf);
|
||||
void xfs_stats_clearall(void);
|
||||
|
||||
#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
|
||||
|
||||
#include <linux/percpu.h>
|
||||
@@ -217,15 +214,18 @@ struct xfsstats {
|
||||
__uint64_t xs_read_bytes;
|
||||
};
|
||||
|
||||
DECLARE_PER_CPU(struct xfsstats, xfsstats);
|
||||
int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
|
||||
void xfs_stats_clearall(struct xfsstats __percpu *stats);
|
||||
extern struct xstats xfsstats;
|
||||
|
||||
/*
|
||||
* We don't disable preempt, not too worried about poking the
|
||||
* wrong CPU's stat for now (also aggregated before reporting).
|
||||
*/
|
||||
#define XFS_STATS_INC(v) (per_cpu(xfsstats, current_cpu()).v++)
|
||||
#define XFS_STATS_DEC(v) (per_cpu(xfsstats, current_cpu()).v--)
|
||||
#define XFS_STATS_ADD(v, inc) (per_cpu(xfsstats, current_cpu()).v += (inc))
|
||||
#define XFS_STATS_INC(v) \
|
||||
(per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++)
|
||||
|
||||
#define XFS_STATS_DEC(v) \
|
||||
(per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--)
|
||||
|
||||
#define XFS_STATS_ADD(v, inc) \
|
||||
(per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc))
|
||||
|
||||
extern int xfs_init_procfs(void);
|
||||
extern void xfs_cleanup_procfs(void);
|
||||
|
Reference in New Issue
Block a user