xfs: per-fs stats in sysfs
v10 cover xfs: per-fs stats in sysfs
Hello-
Following is the next iteration of the series to add per-fs xfs stats to sysfs.
----------history---------------
v10:
-style fixups in patches 1,4,5,7
v9:
-adjust individual patch content, so that fixes actually correspond to reviews accordingly.
-fix xfs_btree.h XFS_BTREE_STATS_ADD macro error made in patch 7. -fix xfs_stats.h macro style errors made in patch 7
v8: (add patches 6 and 7)
-patch 6: per-filesystem stats in sysfs.
Implement per-filesystem stats objects in sysfs. Stats objects are instantiated when an xfs filesystem is mounted and deleted on unmount. With this patch, the stats directory is created and populated with the familiar stats and stats_clear files.
Example:
/sys/fs/xfs/sda9/stats/stats /sys/fs/xfs/sda9/stats/stats_clear
With this patch, the individual counts within the new per-fs stats file(s) remain at zero. Functions that use the the macros to increment, decrement, and add-to the per-fs stats counts will be covered in the next patch (7).
-patch 7: per-filesystem stats counter implementation Modify the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
global counts: /sys/fs/xfs/stats/stats
per-fs counts: /sys/fs/xfs/sda*/stats/stats
global clear: /sys/fs/xfs/stats/stats_clear per-fs clear: /sys/fs/xfs/sda*/stats/stats_clear
v7:
add patch 5/5: incorporate sysfs/kobject in xfsstats: handlers take kobjects. Allocate & deallocate per-fs stats structures and set up the sysfs entries for them. Add kobject and a pointer to a per-cpu struct xfsstats. Modify the macros that manipulate the stats accordingly.
v6:
-move to_xlog(kobject) to the relevant show/store operations. This keeps the xfs_sysfs_object_show/store functions generic. Also, with the change, there can be some cleanup of the show/store function arguments.
v5:
-optimization of sysfs_ops function.
-style fixups
v4:
-add patch 4 (sysfs ops consolidation - dbg, stats, log)
v3:
-style fixups.
v2:
-style fixups.
v1:
--------------------------------
We already have per-fs information in /sys, so it makes sense to have per-fs stats there too. The series moves existing global stats infrastructure to /sys and reuses that code to create per-fs stats in /sys.
Patch 1 handles the bring-up and tear down of xfs/stats directory structure in sysfs when an fs is mounted. The directory contains the stats file and the stats_clear file. The stats file contents mimic those of /proc/fs/xfs/stat. The stats_clear file is empty, and much like the current stat_clear command, handles the zeroing of the stats file when a "1" is echoed to the stats_clear file.
Patch 2 creates the symlink for stats from procfs to sysfs.
Patch 3 removes the now unused portions of procfs for stat.
Patch 4 consolidates the sysfs ops for dbg, stats, log.
Patch 5 allocates and deallocates per-fs stats structures and sets up the sysfs entries for them. Add kobject and a pointer to a per-cpu struct xfsstats. Modify the macros that manipulate
Patch 6 implements per-filesystem stats objects in sysfs. Stats objects are instantiated when an xfs filesystem is mounted and deleted on unmount.
Patch 7 modifies the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
Once again, comments and questions are welcome.
Thanks-
Bill
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v10 1/7 xfs: create global stats and stats_clear in sysfs
Currently, xfs global stats are in procfs. This patch introduces (replicates) the global stats in sysfs. Additionally a stats_clear file is introduced in sysfs.
--- fs/xfs/xfs_stats.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_stats.h | 2 ++ fs/xfs/xfs_super.c | 20 +++++++++---- fs/xfs/xfs_sysctl.c | 15 ++-------- fs/xfs/xfs_sysfs.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_sysfs.h | 1 + 6 files changed, 178 insertions(+), 17 deletions(-)
fs/xfs/xfs_stats.c +82 -0
@@ -29,6 +29,88 @@ static int counter_val(int idx)return val; } +int xfs_stats_format (char *buf) +{ +int i, j; +int len =0 ; +__uint64_t xs_xstrat_bytes =0 ; +__uint64_t xs_write_bytes =0 ; +__uint64_t xs_read_bytes =0 ; + +static const struct xstats_entry { +char *desc; +int endpoint; + } xstats[] = { + {"extent_alloc" ,XFSSTAT_END_EXTENT_ALLOC }, + {"abt" ,XFSSTAT_END_ALLOC_BTREE }, + {"blk_map" ,XFSSTAT_END_BLOCK_MAPPING }, + {"bmbt" ,XFSSTAT_END_BLOCK_MAP_BTREE }, + {"dir" ,XFSSTAT_END_DIRECTORY_OPS }, + {"trans" ,XFSSTAT_END_TRANSACTIONS }, + {"ig" ,XFSSTAT_END_INODE_OPS }, + {"log" ,XFSSTAT_END_LOG_OPS }, + {"push_ail" ,XFSSTAT_END_TAIL_PUSHING }, + {"xstrat" ,XFSSTAT_END_WRITE_CONVERT }, + {"rw" ,XFSSTAT_END_READ_WRITE_OPS }, + {"attr" ,XFSSTAT_END_ATTRIBUTE_OPS }, + {"icluster" ,XFSSTAT_END_INODE_CLUSTER }, + {"vnodes" ,XFSSTAT_END_VNODE_OPS }, + {"buf" ,XFSSTAT_END_BUF }, + {"abtb2" ,XFSSTAT_END_ABTB_V2 }, + {"abtc2" ,XFSSTAT_END_ABTC_V2 }, + {"bmbt2" ,XFSSTAT_END_BMBT_V2 }, + {"ibt2" ,XFSSTAT_END_IBT_V2 }, + {"fibt2" ,XFSSTAT_END_FIBT_V2 }, +/* we print both series of quota information together */ + {"qm" ,XFSSTAT_END_QM }, + }; + +/* Loop over all stats groups */ + +for (i = j =0 ; i <ARRAY_SIZE (xstats); i++) { + len +=snprintf (buf + len,PATH_MAX - len,"%s" , + xstats[i].desc); +/* inner loop does each group */ +for (; j < xstats[i].endpoint; j++) + len +=snprintf (buf + len,PATH_MAX - len," %u" , +counter_val (j)); + len +=snprintf (buf + len,PATH_MAX - len,"\n" ); + } +/* extra precision counters */ +for_each_possible_cpu (i) { + xs_xstrat_bytes +=per_cpu (xfsstats, i).xs_xstrat_bytes; + xs_write_bytes +=per_cpu (xfsstats, i).xs_write_bytes; + xs_read_bytes +=per_cpu (xfsstats, i).xs_read_bytes; + } + + len +=snprintf (buf + len,PATH_MAX -len,"xpc %Lu %Lu %Lu\n" , + xs_xstrat_bytes, xs_write_bytes, xs_read_bytes); + len +=snprintf (buf + len,PATH_MAX -len,"debug %u\n" , +#if defined(DEBUG) + 1); +#else + 0); +#endif + +return len; +} + +void xfs_stats_clearall (void ) +{ +int c; +__uint32_t vn_active; + +xfs_notice (NULL ,"Clearing xfsstats" ); +for_each_possible_cpu (c) { +preempt_disable (); +/* save vn_active, it's a universal truth! */ + vn_active =per_cpu (xfsstats, c).vn_active; +memset (&per_cpu (xfsstats, c),0 ,sizeof (struct xfsstats )); +per_cpu (xfsstats, c).vn_active = vn_active; +preempt_enable (); + } +} +static int xfs_stat_proc_show (struct seq_file *m,void *v) {int i, j;
fs/xfs/xfs_stats.h +2 -0
@@ -18,6 +18,8 @@#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 )
fs/xfs/xfs_super.c +15 -5
@@ -61,6 +61,7 @@ static kmem_zone_t *xfs_ioend_zone;mempool_t *xfs_ioend_pool;static struct kset *xfs_kset;/* top-level xfs sysfs dir */ +static struct xfs_kobj xfs_stats_kobj;/* global stats sysfs attrs */ #ifdef DEBUG static struct xfs_kobj xfs_dbg_kobj;/* global debug sysfs attrs */ #endif
@@ -1838,19 +1839,25 @@ init_xfs_fs(void) xfs_kset =kset_create_and_add ("xfs" ,NULL , fs_kobj);if (!xfs_kset) { error = -ENOMEM ; - goto out_sysctl_unregister;; + goto out_sysctl_unregister; } + xfs_stats_kobj.kobject.kset = xfs_kset; + error =xfs_sysfs_init (&xfs_stats_kobj, &xfs_stats_ktype,NULL , +"stats" ); +if (error) + goto out_kset_unregister; +#ifdef DEBUG xfs_dbg_kobj.kobject.kset = xfs_kset; error =xfs_sysfs_init (&xfs_dbg_kobj, &xfs_dbg_ktype,NULL ,"debug" );if (error) - goto out_kset_unregister; + goto out_remove_stats_kobj;#endif error =xfs_qm_init ();if (error) - goto out_remove_kobj; + goto out_remove_dbg_kobj; error =register_filesystem (&xfs_fs_type);if (error)
@@ -1859,11 +1866,13 @@ init_xfs_fs(void) out_qm_exit:xfs_qm_exit (); - out_remove_kobj: + out_remove_dbg_kobj:#ifdef DEBUG xfs_sysfs_del (&xfs_dbg_kobj); - out_kset_unregister: + out_remove_stats_kobj:#endif +xfs_sysfs_del (&xfs_stats_kobj); + out_kset_unregister:kset_unregister (xfs_kset); out_sysctl_unregister:xfs_sysctl_unregister ();
@@ -1889,6 +1898,7 @@ exit_xfs_fs(void)#ifdef DEBUG xfs_sysfs_del (&xfs_dbg_kobj);#endif +xfs_sysfs_del (&xfs_stats_kobj);kset_unregister (xfs_kset);xfs_sysctl_unregister ();xfs_cleanup_procfs ();
fs/xfs/xfs_sysctl.c +3 -12
@@ -19,6 +19,7 @@#include <linux/sysctl.h> #include <linux/proc_fs.h> #include "xfs_error.h" +#include "xfs_stats.h" static struct ctl_table_header *xfs_table_header;
@@ -31,22 +32,12 @@ xfs_stats_clear_proc_handler(size_t *lenp, loff_t *ppos) { - int c, ret, *valp = ctl->data; -__uint32_t vn_active; + int ret, *valp = ctl->data; ret =proc_dointvec_minmax (ctl, write, buffer, lenp, ppos);if (!ret && write && *valp) { -xfs_notice (NULL ,"Clearing xfsstats" ); -for_each_possible_cpu (c) { -preempt_disable (); -/* save vn_active, it's a universal truth! */ - vn_active =per_cpu (xfsstats, c).vn_active; -memset (&per_cpu (xfsstats, c),0 , -sizeof (struct xfsstats )); -per_cpu (xfsstats, c).vn_active = vn_active; -preempt_enable (); - } +xfs_stats_clearall (); xfs_stats_clear =0 ; }
fs/xfs/xfs_sysfs.c +75 -0
93 lines not on this page · raw message
fs/xfs/xfs_sysfs.h +1 -0
@@ -22,6 +22,7 @@extern struct kobj_type xfs_mp_ktype;/* xfs_mount */ extern struct kobj_type xfs_dbg_ktype;/* debug */ extern struct kobj_type xfs_log_ktype;/* xlog */ +extern struct kobj_type xfs_stats_ktype;/* stats */ static inline struct xfs_kobj *to_kobj (struct kobject *kobject)
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v10 2/7 xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats
In reply to Bill O'DonnellAs a part of the work to move xfs global stats from procfs to sysfs, this patch creates the symlink from proc/fs/xfs/stat to sys/fs/xfs/stats.
--- fs/xfs/xfs_stats.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/xfs/xfs_stats.c +3 -2
@@ -243,9 +243,10 @@ xfs_init_procfs(void)if (!proc_mkdir ("fs/xfs" ,NULL )) goto out; -if (!proc_create ("fs/xfs/stat" ,0 ,NULL , - &xfs_stat_proc_fops)) +if (!proc_symlink ("fs/xfs/stat" ,NULL , +"/sys/fs/xfs/stats/stats" )) goto out_remove_xfs_dir; +#ifdef CONFIG_XFS_QUOTA if (!proc_create ("fs/xfs/xqmstat" ,0 ,NULL , &xqmstat_proc_fops))
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v10 3/7 xfs: remove unused procfs code
In reply to Bill O'DonnellAs a part of the work to move xfs global stats from procfs to sysfs, this patch removes the now unused procfs code that was xfs stat specific.
--- fs/xfs/xfs_stats.c | 74 ------------------------------------------------------ 1 file changed, 74 deletions(-)
fs/xfs/xfs_stats.c +0 -74
@@ -111,80 +111,6 @@ void xfs_stats_clearall(void) } } -static int xfs_stat_proc_show (struct seq_file *m,void *v) -{ -int i, j; -__uint64_t xs_xstrat_bytes =0 ; -__uint64_t xs_write_bytes =0 ; -__uint64_t xs_read_bytes =0 ; - -static const struct xstats_entry { -char *desc; -int endpoint; - } xstats[] = { - {"extent_alloc" ,XFSSTAT_END_EXTENT_ALLOC }, - {"abt" ,XFSSTAT_END_ALLOC_BTREE }, - {"blk_map" ,XFSSTAT_END_BLOCK_MAPPING }, - {"bmbt" ,XFSSTAT_END_BLOCK_MAP_BTREE }, - {"dir" ,XFSSTAT_END_DIRECTORY_OPS }, - {"trans" ,XFSSTAT_END_TRANSACTIONS }, - {"ig" ,XFSSTAT_END_INODE_OPS }, - {"log" ,XFSSTAT_END_LOG_OPS }, - {"push_ail" ,XFSSTAT_END_TAIL_PUSHING }, - {"xstrat" ,XFSSTAT_END_WRITE_CONVERT }, - {"rw" ,XFSSTAT_END_READ_WRITE_OPS }, - {"attr" ,XFSSTAT_END_ATTRIBUTE_OPS }, - {"icluster" ,XFSSTAT_END_INODE_CLUSTER }, - {"vnodes" ,XFSSTAT_END_VNODE_OPS }, - {"buf" ,XFSSTAT_END_BUF }, - {"abtb2" ,XFSSTAT_END_ABTB_V2 }, - {"abtc2" ,XFSSTAT_END_ABTC_V2 }, - {"bmbt2" ,XFSSTAT_END_BMBT_V2 }, - {"ibt2" ,XFSSTAT_END_IBT_V2 }, - {"fibt2" ,XFSSTAT_END_FIBT_V2 }, -/* we print both series of quota information together */ - {"qm" ,XFSSTAT_END_QM }, - }; - -/* Loop over all stats groups */ -for (i = j =0 ; i <ARRAY_SIZE (xstats); i++) { -seq_printf (m,"%s" , xstats[i].desc); -/* inner loop does each group */ -for (; j < xstats[i].endpoint; j++) -seq_printf (m," %u" ,counter_val (j)); -seq_putc (m,'\n' ); - } -/* extra precision counters */ -for_each_possible_cpu (i) { - xs_xstrat_bytes +=per_cpu (xfsstats, i).xs_xstrat_bytes; - xs_write_bytes +=per_cpu (xfsstats, i).xs_write_bytes; - xs_read_bytes +=per_cpu (xfsstats, i).xs_read_bytes; - } - -seq_printf (m,"xpc %Lu %Lu %Lu\n" , - xs_xstrat_bytes, xs_write_bytes, xs_read_bytes); -seq_printf (m,"debug %u\n" , -#if defined(DEBUG) - 1); -#else - 0); -#endif -return 0 ; -} - -static int xfs_stat_proc_open (struct inode *inode,struct file *file) -{ -return single_open (file, xfs_stat_proc_show,NULL ); -} - -static const struct file_operations xfs_stat_proc_fops = { - .owner =THIS_MODULE , - .open = xfs_stat_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; -/* legacy quota interfaces */ #ifdef CONFIG_XFS_QUOTA static int xqm_proc_show (struct seq_file *m,void *v)
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v10 4/7 xfs: consolidate sysfs ops (dbg, stats, log)
In reply to Bill O'DonnellAs a part of the series to move xfs global stats from procfs to sysfs, this patch consolidates the sysfs ops functions and removes redundancy.
--- fs/xfs/xfs_sysfs.c | 182 +++++++++++++++++++---------------------------------- 1 file changed, 63 insertions(+), 119 deletions(-)
fs/xfs/xfs_sysfs.c +63 -119
@@ -25,8 +25,9 @@struct xfs_sysfs_attr {struct attribute attr; -ssize_t (*show)(char *buf,void *data); -ssize_t (*store)(const char *buf,size_t count,void *data); +ssize_t (*show)(struct kobject *kobject,char *buf); +ssize_t (*store)(struct kobject *kobject,const char *buf, +size_t count); }; static inline struct xfs_sysfs_attr *
@@ -54,14 +55,42 @@ struct kobj_type xfs_mp_ktype = { .release = xfs_sysfs_release, }; +STATIC ssize_t +xfs_sysfs_object_show ( +struct kobject *kobject, +struct attribute *attr, +char *buf) +{ +struct xfs_sysfs_attr *xfs_attr =to_attr (attr); + +return xfs_attr->show ? xfs_attr->show (kobject, buf) :0 ; +} + +STATIC ssize_t +xfs_sysfs_object_store ( +struct kobject *kobject, +struct attribute *attr, +const char *buf, +size_t count) +{ +struct xfs_sysfs_attr *xfs_attr =to_attr (attr); + +return xfs_attr->store ? xfs_attr->store (kobject, buf, count) :0 ; +} + +static const struct sysfs_ops xfs_sysfs_ops = { + .show = xfs_sysfs_object_show, + .store = xfs_sysfs_object_store, +}; +#ifdef DEBUG /* debug */ STATIC ssize_tlog_recovery_delay_store ( +struct kobject *kobject,const char *buf, -size_t count, -void *data) +size_t count) {int ret;int val;
@@ -80,8 +109,8 @@ log_recovery_delay_store( STATIC ssize_tlog_recovery_delay_show ( -char *buf, -void *data) +struct kobject *kobject, +char *buf) {return snprintf (buf,PAGE_SIZE ,"%d\n" , xfs_globals.log_recovery_delay); }
@@ -92,49 +121,20 @@ static struct attribute *xfs_dbg_attrs[] = { NULL, }; -STATIC ssize_t -xfs_dbg_show ( -struct kobject *kobject, -struct attribute *attr, -char *buf) -{ -struct xfs_sysfs_attr *xfs_attr =to_attr (attr); - -return xfs_attr->show ? xfs_attr->show (buf,NULL ) :0 ; -} - -STATIC ssize_t -xfs_dbg_store ( -struct kobject *kobject, -struct attribute *attr, -const char *buf, -size_t count) -{ -struct xfs_sysfs_attr *xfs_attr =to_attr (attr); - -return xfs_attr->store ? xfs_attr->store (buf, count,NULL ) :0 ; -} - -static struct sysfs_ops xfs_dbg_ops = { - .show = xfs_dbg_show, - .store = xfs_dbg_store, -}; -struct kobj_type xfs_dbg_ktype = { .release = xfs_sysfs_release, - .sysfs_ops = &xfs_dbg_ops, + .sysfs_ops = &xfs_sysfs_ops, .default_attrs = xfs_dbg_attrs, };#endif /* DEBUG */ -/* stats */ STATIC ssize_tstats_show ( -char *buf, -void *data) +struct kobject *kobject, +char *buf) {return xfs_stats_format (buf); }
@@ -142,9 +142,9 @@ XFS_SYSFS_ATTR_RO(stats); STATIC ssize_tstats_clear_store ( +struct kobject *kobject,const char *buf, -size_t count, -void *data) +size_t count) {int ret;int val;
@@ -166,50 +166,30 @@ static struct attribute *xfs_stats_attrs[] = { NULL, }; -STATIC ssize_t -xfs_stats_show ( -struct kobject *kobject, -struct attribute *attr, -char *buf) -{ -struct xfs_sysfs_attr *xfs_attr =to_attr (attr); - -return xfs_attr->show ? xfs_attr->show (buf,NULL ) :0 ; -} - -STATIC ssize_t -xfs_stats_store ( -struct kobject *kobject, -struct attribute *attr, -const char *buf, -size_t count) -{ -struct xfs_sysfs_attr *xfs_attr =to_attr (attr); - -return xfs_attr->store ? xfs_attr->store (buf, count,NULL ) :0 ; -} - -static struct sysfs_ops xfs_stats_ops = { - .show = xfs_stats_show, - .store = xfs_stats_store, -}; -struct kobj_type xfs_stats_ktype = { .release = xfs_sysfs_release, - .sysfs_ops = &xfs_stats_ops, + .sysfs_ops = &xfs_sysfs_ops, .default_attrs = xfs_stats_attrs, };/* xlog */ +static inline struct xlog * +to_xlog (struct kobject *kobject) +{ +struct xfs_kobj *kobj =to_kobj (kobject); + + return container_of(kobj, struct xlog, l_kobj); +} + STATIC ssize_tlog_head_lsn_show ( -char *buf, -void *data) +struct kobject *kobject, +char *buf) { -struct xlog *log = data;int cycle;int block; +struct xlog *log =to_xlog (kobject);spin_lock (&log->l_icloglock); cycle = log->l_curr_cycle;
@@ -222,12 +202,12 @@ XFS_SYSFS_ATTR_RO(log_head_lsn); STATIC ssize_tlog_tail_lsn_show ( -char *buf, -void *data) +struct kobject *kobject, +char *buf) { -struct xlog *log = data;int cycle;int block; +struct xlog *log =to_xlog (kobject);xlog_crack_atomic_lsn (&log->l_tail_lsn, &cycle, &block);return snprintf (buf,PAGE_SIZE ,"%d:%d\n" , cycle, block);
@@ -236,12 +216,13 @@ XFS_SYSFS_ATTR_RO(log_tail_lsn); STATIC ssize_treserve_grant_head_show ( -char *buf, -void *data) +struct kobject *kobject, +char *buf) + { -struct xlog *log = data;int cycle;int bytes; +struct xlog *log =to_xlog (kobject);xlog_crack_grant_head (&log->l_reserve_head.grant, &cycle, &bytes);return snprintf (buf,PAGE_SIZE ,"%d:%d\n" , cycle, bytes);
@@ -250,12 +231,12 @@ XFS_SYSFS_ATTR_RO(reserve_grant_head); STATIC ssize_twrite_grant_head_show ( -char *buf, -void *data) +struct kobject *kobject, +char *buf) { -struct xlog *log = data;int cycle;int bytes; +struct xlog *log =to_xlog (kobject);xlog_crack_grant_head (&log->l_write_head.grant, &cycle, &bytes);return snprintf (buf,PAGE_SIZE ,"%d:%d\n" , cycle, bytes);
@@ -270,45 +251,8 @@ static struct attribute *xfs_log_attrs[] = { NULL, }; -static inline struct xlog * -to_xlog (struct kobject *kobject) -{ -struct xfs_kobj *kobj =to_kobj (kobject); - return container_of(kobj, struct xlog, l_kobj); -} - -STATIC ssize_t -xfs_log_show ( -struct kobject *kobject, -struct attribute *attr, -char *buf) -{ -struct xlog *log =to_xlog (kobject); -struct xfs_sysfs_attr *xfs_attr =to_attr (attr); - -return xfs_attr->show ? xfs_attr->show (buf, log) :0 ; -} - -STATIC ssize_t -xfs_log_store ( -struct kobject *kobject, -struct attribute *attr, -const char *buf, -size_t count) -{ -struct xlog *log =to_xlog (kobject); -struct xfs_sysfs_attr *xfs_attr =to_attr (attr); - -return xfs_attr->store ? xfs_attr->store (buf, count, log) :0 ; -} - -static struct sysfs_ops xfs_log_ops = { - .show = xfs_log_show, - .store = xfs_log_store, -}; -struct kobj_type xfs_log_ktype = { .release = xfs_sysfs_release, - .sysfs_ops = &xfs_log_ops, + .sysfs_ops = &xfs_sysfs_ops, .default_attrs = xfs_log_attrs, };
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v10 5/7 xfs: incorporate sysfs/kobject in xfsstats: handlers take kobjects.
In reply to Bill O'DonnellThis 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.
--- fs/xfs/xfs_linux.h | 7 +++++++ fs/xfs/xfs_stats.c | 32 +++++++++++++++----------------- fs/xfs/xfs_stats.h | 22 +++++++++++----------- fs/xfs/xfs_super.c | 21 +++++++++++++++------ fs/xfs/xfs_sysctl.c | 2 +- fs/xfs/xfs_sysfs.c | 16 ++++++++++++++-- 6 files changed, 63 insertions(+), 37 deletions(-)
fs/xfs/xfs_linux.h +7 -0
@@ -171,6 +171,13 @@ struct xfs_kobj {struct completion complete; }; +struct xstats { +struct xfsstats __percpu *xs_stats; +struct xfs_kobj xs_kobj; +}; + +extern struct xstats xfsstats; +/* Kernel uid/gid conversion. These are used to convert to/from the on disk * uid_t/gid_t types to the kuid_t/kgid_t types that the kernel uses internally. * The conversion here is type only, the value will remain the same since we
fs/xfs/xfs_stats.c +15 -17
@@ -18,18 +18,18 @@#include "xfs.h" #include <linux/proc_fs.h> -DEFINE_PER_CPU(struct xfsstats, xfsstats); +struct xstats xfsstats; -static int counter_val (int idx) +static int counter_val (struct xfsstats __percpu *stats,int idx) {int val =0 , cpu;for_each_possible_cpu (cpu) - val += *(((__u32 *)&per_cpu (xfsstats, cpu) + idx)); + val += *(((__u32 *)per_cpu_ptr (stats, cpu) + idx));return val; } -int xfs_stats_format (char *buf) +int xfs_stats_format (struct xfsstats __percpu *stats,char *buf) {int i, j;int len =0 ;
@@ -73,14 +73,14 @@ int xfs_stats_format(char *buf)/* inner loop does each group */ for (; j < xstats[i].endpoint; j++) len +=snprintf (buf + len,PATH_MAX - len," %u" , -counter_val (j)); +counter_val (stats, j)); len +=snprintf (buf + len,PATH_MAX - len,"\n" ); }/* extra precision counters */ for_each_possible_cpu (i) { - xs_xstrat_bytes +=per_cpu (xfsstats, i).xs_xstrat_bytes; - xs_write_bytes +=per_cpu (xfsstats, i).xs_write_bytes; - xs_read_bytes +=per_cpu (xfsstats, i).xs_read_bytes; + xs_xstrat_bytes +=per_cpu_ptr (stats, i)->xs_xstrat_bytes; + xs_write_bytes +=per_cpu_ptr (stats, i)->xs_write_bytes; + xs_read_bytes +=per_cpu_ptr (stats, i)->xs_read_bytes; } len += snprintf(buf + len, PATH_MAX-len, "xpc %Lu %Lu %Lu\n",
@@ -95,7 +95,7 @@ int xfs_stats_format(char *buf)return len; } -void xfs_stats_clearall (void ) +void xfs_stats_clearall (struct xfsstats __percpu *stats) {int c;__uint32_t vn_active;
@@ -104,9 +104,9 @@ void xfs_stats_clearall(void)for_each_possible_cpu (c) {preempt_disable ();/* save vn_active, it's a universal truth! */ - vn_active =per_cpu (xfsstats, c).vn_active; -memset (&per_cpu (xfsstats, c),0 ,sizeof (struct xfsstats )); -per_cpu (xfsstats, c).vn_active = vn_active; + vn_active =per_cpu_ptr (stats, c)->vn_active; +memset (per_cpu_ptr (stats, c),0 ,sizeof (*stats)); +per_cpu_ptr (stats, c)->vn_active = vn_active;preempt_enable (); } }
@@ -117,10 +117,8 @@ static int xqm_proc_show(struct seq_file *m, void *v) {/* maximum; incore; ratio free to inuse; freelist */ seq_printf (m,"%d\t%d\t%d\t%u\n" , -0 , -counter_val (XFSSTAT_END_XQMSTAT ), -0 , -counter_val (XFSSTAT_END_XQMSTAT +1 )); +0 ,counter_val (xfsstats.xs_stats,XFSSTAT_END_XQMSTAT ), +0 ,counter_val (xfsstats.xs_stats,XFSSTAT_END_XQMSTAT +1 ));return 0 ; }
@@ -144,7 +142,7 @@ static int xqmstat_proc_show(struct seq_file *m, void *v)seq_printf (m,"qm" );for (j =XFSSTAT_END_IBT_V2 ; j <XFSSTAT_END_XQMSTAT ; j++) -seq_printf (m," %u" ,counter_val (j)); +seq_printf (m," %u" ,counter_val (xfsstats.xs_stats, j));seq_putc (m,'\n' );return 0 ; }
fs/xfs/xfs_stats.h +11 -11
@@ -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 );
fs/xfs/xfs_super.c +15 -6
@@ -61,7 +61,6 @@ static kmem_zone_t *xfs_ioend_zone;mempool_t *xfs_ioend_pool;static struct kset *xfs_kset;/* top-level xfs sysfs dir */ -static struct xfs_kobj xfs_stats_kobj;/* global stats sysfs attrs */ #ifdef DEBUG static struct xfs_kobj xfs_dbg_kobj;/* global debug sysfs attrs */ #endif
@@ -1842,11 +1841,18 @@ init_xfs_fs(void) goto out_sysctl_unregister; } - xfs_stats_kobj.kobject.kset = xfs_kset; - error =xfs_sysfs_init (&xfs_stats_kobj, &xfs_stats_ktype,NULL , + xfsstats.xs_kobj.kobject.kset = xfs_kset; + + xfsstats.xs_stats = alloc_percpu(struct xfsstats); +if (!xfsstats.xs_stats) { + error = -ENOMEM ; + goto out_kset_unregister; + } + + error =xfs_sysfs_init (&xfsstats.xs_kobj, &xfs_stats_ktype,NULL ,"stats" );if (error) - goto out_kset_unregister; + goto out_free_stats;#ifdef DEBUG xfs_dbg_kobj.kobject.kset = xfs_kset;
@@ -1871,7 +1877,9 @@ init_xfs_fs(void)xfs_sysfs_del (&xfs_dbg_kobj); out_remove_stats_kobj:#endif -xfs_sysfs_del (&xfs_stats_kobj); +xfs_sysfs_del (&xfsstats.xs_kobj); + out_free_stats: +free_percpu (xfsstats.xs_stats); out_kset_unregister:kset_unregister (xfs_kset); out_sysctl_unregister:
@@ -1898,7 +1906,8 @@ exit_xfs_fs(void)#ifdef DEBUG xfs_sysfs_del (&xfs_dbg_kobj);#endif -xfs_sysfs_del (&xfs_stats_kobj); +xfs_sysfs_del (&xfsstats.xs_kobj); +free_percpu (xfsstats.xs_stats);kset_unregister (xfs_kset);xfs_sysctl_unregister ();xfs_cleanup_procfs ();
fs/xfs/xfs_sysctl.c +1 -1
@@ -37,7 +37,7 @@ xfs_stats_clear_proc_handler( ret =proc_dointvec_minmax (ctl, write, buffer, lenp, ppos);if (!ret && write && *valp) { -xfs_stats_clearall (); +xfs_stats_clearall (xfsstats.xs_stats); xfs_stats_clear =0 ; }
fs/xfs/xfs_sysfs.c +14 -2
@@ -131,12 +131,22 @@ struct kobj_type xfs_dbg_ktype = {/* stats */ +static inline struct xstats * +to_xstats (struct kobject *kobject) +{ +struct xfs_kobj *kobj =to_kobj (kobject); + + return container_of(kobj, struct xstats, xs_kobj); +} + STATIC ssize_tstats_show (struct kobject *kobject,char *buf) { -return xfs_stats_format (buf); +struct xstats *stats =to_xstats (kobject); + +return xfs_stats_format (stats->xs_stats, buf); }XFS_SYSFS_ATTR_RO (stats);
@@ -148,6 +158,7 @@ stats_clear_store( {int ret;int val; +struct xstats *stats =to_xstats (kobject); ret =kstrtoint (buf,0 , &val);if (ret)
@@ -155,7 +166,8 @@ stats_clear_store(if (val !=1 )return -EINVAL ; -xfs_stats_clearall (); + +xfs_stats_clearall (stats->xs_stats);return count; }XFS_SYSFS_ATTR_WO (stats_clear);
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v10 6/7 xfs: per-filesystem stats in sysfs.
In reply to Bill O'DonnellThis patch implements per-filesystem stats objects in sysfs. It depends on the application of the previous patch series that develops the infrastructure to support both xfs global stats and xfs per-fs stats in sysfs.
Stats objects are instantiated when an xfs filesystem is mounted and deleted on unmount. With this patch, the stats directory is created and populated with the familiar stats and stats_clear files. Example:
/sys/fs/xfs/sda9/stats/stats /sys/fs/xfs/sda9/stats/stats_clear
With this patch, the individual counts within the new per-fs stats file(s) remain at zero. Functions that use the the macros to increment, decrement, and add-to the per-fs stats counts will be covered in a separate new patch to follow this one. Note that the counts within the global stats file (/sys/fs/xfs/stats/stats) advance normally and can be cleared as it was prior to this patch.
--- fs/xfs/xfs_mount.c | 24 +++++++++++++++++++++++- fs/xfs/xfs_mount.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-)
fs/xfs/xfs_mount.c +23 -1
@@ -693,9 +693,23 @@ xfs_mountfs(if (error) goto out; +/* +* Allocate stats memory and create stats sysfs object. +*/ + mp->m_stats.xs_stats = alloc_percpu(struct xfsstats); +if (!mp->m_stats.xs_stats) { + error =PTR_ERR (mp->m_stats.xs_stats); + goto out_remove_sysfs; + } + error =xfs_sysfs_init (&mp->m_stats.xs_kobj, &xfs_stats_ktype, + &mp->m_kobj, +"stats" ); +if (error) + goto out_free_stats; + error =xfs_uuid_mount (mp);if (error) - goto out_remove_sysfs; + goto out_del_stats;/* * Set the minimum read and write sizes
@@ -971,6 +985,10 @@ xfs_mountfs(xfs_da_unmount (mp); out_remove_uuid:xfs_uuid_unmount (mp); + out_del_stats: +xfs_sysfs_del (&mp->m_stats.xs_kobj); + out_free_stats: +free_percpu (mp->m_stats.xs_stats); out_remove_sysfs:xfs_sysfs_del (&mp->m_kobj); out:
@@ -1047,6 +1065,10 @@ xfs_unmountfs(xfs_warn (mp,"Unable to update superblock counters. " "Freespace may not be correct on next mount." ); +/* remove the stats kobject and free stats memory */ +xfs_sysfs_del (&mp->m_stats.xs_kobj); +free_percpu (mp->m_stats.xs_stats); +xfs_log_unmount (mp);xfs_da_unmount (mp);xfs_uuid_unmount (mp);
fs/xfs/xfs_mount.h +1 -0
@@ -127,6 +127,7 @@ typedef struct xfs_mount {int64_t m_low_space[XFS_LOWSP_MAX ];/* low free space thresholds */ struct xfs_kobj m_kobj; +struct xstats m_stats;/* per-fs stats */ struct workqueue_struct *m_buf_workqueue;struct workqueue_struct *m_data_workqueue;
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 6/7] xfs: per-filesystem stats in sysfs.
Quoted 20 lines · Bill O'Donnell
This patch implements per-filesystem stats objects in sysfs. It depends on the application of the previous patch series that develops the infrastructure to support both xfs global stats and xfs per-fs stats in sysfs.
Stats objects are instantiated when an xfs filesystem is mounted and deleted on unmount. With this patch, the stats directory is created and populated with the familiar stats and
stats_clearfiles. Example:
/sys/fs/xfs/sda9/stats/stats/sys/fs/xfs/sda9/stats/stats_clearWith this patch, the individual counts within the new per-fs stats file(s) remain at zero. Functions that use the the macros to increment, decrement, and add-to the per-fs stats counts will be covered in a separate new patch to follow this one. Note that the counts within the global stats file (
/sys/fs/xfs/stats/stats) advance normally and can be cleared as it was prior to this patch.Signed-off-by Bill O'Donnell <[email protected]>
.....
Review xfs_unmountfs( · line 1072
Quoted 9 lines
(quoted diff) +4
-0@@ -1047,6 +1065,10 @@ xfs_unmountfs( xfs_warn(mp, "Unable to update superblock counters. " "Freespace may not be correct on next mount."); + /* remove the stats kobject and free stats memory */ + xfs_sysfs_del(&mp->m_stats.xs_kobj); + free_percpu(mp->m_stats.xs_stats); + xfs_log_unmount(mp);
Ok, there's an obvious (to me!) problem here. xfs_log_unmount() is called while there are still active objects in the AIL, which means there is still AIL operations that need to be done. The AIL operations have stats in them, so this will result in use-after-free of the mp->m_stats structure here.
Actually, looking at the alloc side of this patch, we're doing a XFS_STATS_INC(xb_create) through:
xfs_fs_fill_super
xfs_readsb
xfs_buf_read_uncached
xfs_buf_get_uncached
_xfs_buf_alloc
XFS_STATS_INC(target->bt_mount, xb_create)at mount time before we've set up mp->m_stats. Ok, so the initialisation and teardown of the per-mount stats memory is being done at the wrong layer - it needs to be done in xfs_fs_fill_super() before we do any IO at all and dropped in xfs_fs_put_super() after we've torn down all the IO structures. The sysfs object initialisation is fine where it is, but the actual stats storage is needed earlier/later than the sysfs object is.
/me now wonders why this doesn't go kaboom at mount time...
Reworked patch is inline below.
Cheers,
Dave.
Signature · 38 lines
Dave Chinner [email protected] xfs: per-filesystem stats in sysfs From: Bill O'Donnell <[email protected]> This patch implements per-filesystem stats objects in sysfs. It depends on the application of the previous patch series that develops the infrastructure to support both xfs global stats and xfs per-fs stats in sysfs. Stats objects are instantiated when an xfs filesystem is mounted and deleted on unmount. With this patch, the stats directory is created and populated with the familiar stats and stats_clear files. Example: /sys/fs/xfs/sda9/stats/stats /sys/fs/xfs/sda9/stats/stats_clear With this patch, the individual counts within the new per-fs stats file(s) remain at zero. Functions that use the the macros to increment, decrement, and add-to the per-fs stats counts will be covered in a separate new patch to follow this one. Note that the counts within the global stats file (/sys/fs/xfs/stats/stats) advance normally and can be cleared as it was prior to this patch. [dchinner: move setup/teardown to xfs_fs_{fill|put}_super() so it is down before/after any path that uses the per-mount stats. ] Signed-off-by: Bill O'Donnell <[email protected]> Reviewed-by: Eric Sandeen <[email protected]> Signed-off-by: Dave Chinner <[email protected]> --- fs/xfs/xfs_mount.c | 11 ++++++++++- fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_super.c | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-)
fs/xfs/xfs_mount.c +10 -1
@@ -693,10 +693,15 @@ xfs_mountfs(if (error) goto out; - error =xfs_uuid_mount (mp); + error =xfs_sysfs_init (&mp->m_stats.xs_kobj, &xfs_stats_ktype, + &mp->m_kobj,"stats" );if (error) goto out_remove_sysfs; + error =xfs_uuid_mount (mp); +if (error) + goto out_del_stats; +/* * Set the minimum read and write sizes */
@@ -971,6 +976,8 @@ xfs_mountfs(xfs_da_unmount (mp); out_remove_uuid:xfs_uuid_unmount (mp); + out_del_stats: +xfs_sysfs_del (&mp->m_stats.xs_kobj); out_remove_sysfs:xfs_sysfs_del (&mp->m_kobj); out:
@@ -1047,6 +1054,7 @@ xfs_unmountfs(xfs_warn (mp,"Unable to update superblock counters. " "Freespace may not be correct on next mount." ); +xfs_log_unmount (mp);xfs_da_unmount (mp);xfs_uuid_unmount (mp);
@@ -1056,6 +1064,7 @@ xfs_unmountfs(#endif xfs_free_perag (mp); +xfs_sysfs_del (&mp->m_stats.xs_kobj);xfs_sysfs_del (&mp->m_kobj); }
fs/xfs/xfs_mount.h +1 -0
@@ -127,6 +127,7 @@ typedef struct xfs_mount {int64_t m_low_space[XFS_LOWSP_MAX ];/* low free space thresholds */ struct xfs_kobj m_kobj; +struct xstats m_stats;/* per-fs stats */ struct workqueue_struct *m_buf_workqueue;struct workqueue_struct *m_data_workqueue;
fs/xfs/xfs_super.c +12 -2
@@ -1474,9 +1474,16 @@ xfs_fs_fill_super(if (error) goto out_destroy_workqueues; +/* Allocate stats memory before we do operations that might use it */ + mp->m_stats.xs_stats = alloc_percpu(struct xfsstats); +if (!mp->m_stats.xs_stats) { + error =PTR_ERR (mp->m_stats.xs_stats); + goto out_destroy_counters; + } + error =xfs_readsb (mp, flags);if (error) - goto out_destroy_counters; + goto out_free_stats; error =xfs_finish_flags (mp);if (error)
@@ -1545,9 +1552,11 @@ xfs_fs_fill_super(xfs_filestream_unmount (mp); out_free_sb:xfs_freesb (mp); + out_free_stats: +free_percpu (mp->m_stats.xs_stats); out_destroy_counters:xfs_destroy_percpu_counters (mp); -out_destroy_workqueues: + out_destroy_workqueues:xfs_destroy_mount_workqueues (mp); out_close_devices:xfs_close_devices (mp);
@@ -1574,6 +1583,7 @@ xfs_fs_put_super(xfs_unmountfs (mp);xfs_freesb (mp); +free_percpu (mp->m_stats.xs_stats);xfs_destroy_percpu_counters (mp);xfs_destroy_mount_workqueues (mp);xfs_close_devices (mp);
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v10 7/7 xfs: per-filesystem stats counter implementation
In reply to Bill O'DonnellThis patch modifies the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
global counts: /sys/fs/xfs/stats/stats
per-fs counts: /sys/fs/xfs/sda*/stats/stats
global clear: /sys/fs/xfs/stats/stats_clear per-fs clear: /sys/fs/xfs/sda*/stats/stats_clear
--- fs/xfs/libxfs/xfs_alloc.c | 8 ++++---- fs/xfs/libxfs/xfs_attr.c | 6 +++--- fs/xfs/libxfs/xfs_bmap.c | 20 ++++++++++---------- fs/xfs/libxfs/xfs_btree.h | 34 ++++++++++++++++++---------------- fs/xfs/libxfs/xfs_dir2.c | 6 +++--- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_buf.c | 18 +++++++++--------- fs/xfs/xfs_dir2_readdir.c | 2 +- fs/xfs/xfs_dquot.c | 12 ++++++------ fs/xfs/xfs_file.c | 12 ++++++------ fs/xfs/xfs_icache.c | 18 +++++++++--------- fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iomap.c | 4 ++-- fs/xfs/xfs_iops.c | 4 ++-- fs/xfs/xfs_log.c | 22 +++++++++++----------- fs/xfs/xfs_qm.c | 14 +++++++------- fs/xfs/xfs_stats.h | 21 +++++++++++++++------ fs/xfs/xfs_super.c | 6 +++--- fs/xfs/xfs_trans.c | 6 +++--- fs/xfs/xfs_trans_ail.c | 12 ++++++------ 21 files changed, 123 insertions(+), 112 deletions(-)
fs/xfs/libxfs/xfs_alloc.c +4 -4
@@ -651,8 +651,8 @@ xfs_alloc_ag_vextent( -((long)(args->len))); } -XFS_STATS_INC (xs_allocx); -XFS_STATS_ADD (xs_allocb, args->len); +XFS_STATS_INC (args->mp, xs_allocx); +XFS_STATS_ADD (args->mp, xs_allocb, args->len);return error; }
@@ -1808,8 +1808,8 @@ xfs_free_ag_extent(if (!isfl)xfs_trans_mod_sb (tp,XFS_TRANS_SB_FDBLOCKS , (long )len); -XFS_STATS_INC (xs_freex); -XFS_STATS_ADD (xs_freeb, len); +XFS_STATS_INC (mp, xs_freex); +XFS_STATS_ADD (mp, xs_freeb, len);trace_xfs_free_extent (mp, agno, bno, len, isfl, haveleft, haveright);
fs/xfs/libxfs/xfs_attr.c +3 -3
@@ -125,7 +125,7 @@ xfs_attr_get(uint lock_mode;int error; -XFS_STATS_INC (xs_attr_get); +XFS_STATS_INC (ip->i_mount, xs_attr_get);if (XFS_FORCED_SHUTDOWN (ip->i_mount))return -EIO ;
@@ -209,7 +209,7 @@ xfs_attr_set(int rsvd = (flags &ATTR_ROOT ) !=0 ;int error, err2, committed, local; -XFS_STATS_INC (xs_attr_set); +XFS_STATS_INC (mp, xs_attr_set);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ;
@@ -412,7 +412,7 @@ xfs_attr_remove(xfs_fsblock_t firstblock;int error; -XFS_STATS_INC (xs_attr_remove); +XFS_STATS_INC (mp, xs_attr_remove);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ;
fs/xfs/libxfs/xfs_bmap.c +10 -10
@@ -1435,7 +1435,7 @@ xfs_bmap_search_extents(xfs_ifork_t *ifp;/* inode fork pointer */ xfs_bmbt_rec_host_t *ep;/* extent record pointer */ -XFS_STATS_INC (xs_look_exlist); +XFS_STATS_INC (ip->i_mount, xs_look_exlist); ifp =XFS_IFORK_PTR (ip, fork); ep =xfs_bmap_search_multi_extents (ifp, bno, eofp, lastxp, gotp, prevp);
@@ -1732,7 +1732,7 @@ xfs_bmap_add_extent_delay_real(ASSERT (!bma->cur || (bma->cur->bc_private.b.flags &XFS_BTCUR_BPRV_WASDEL )); -XFS_STATS_INC (xs_add_exlist); +XFS_STATS_INC (mp, xs_add_exlist);#define LEFT r[0]#define RIGHT r[1]
@@ -2286,7 +2286,7 @@ xfs_bmap_add_extent_unwritten_real(ASSERT (*idx <= ifp->if_bytes /sizeof (struct xfs_bmbt_rec ));ASSERT (!isnullstartblock (new->br_startblock)); -XFS_STATS_INC (xs_add_exlist); +XFS_STATS_INC (mp, xs_add_exlist);#define LEFT r[0]#define RIGHT r[1]
@@ -2946,7 +2946,7 @@ xfs_bmap_add_extent_hole_real(ASSERT (!bma->cur || !(bma->cur->bc_private.b.flags &XFS_BTCUR_BPRV_WASDEL )); -XFS_STATS_INC (xs_add_exlist); +XFS_STATS_INC (mp, xs_add_exlist); state =0 ;if (whichfork ==XFS_ATTR_FORK )
@@ -4036,7 +4036,7 @@ xfs_bmapi_read(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -XFS_STATS_INC (xs_blk_mapr); +XFS_STATS_INC (mp, xs_blk_mapr); ifp =XFS_IFORK_PTR (ip, whichfork);
@@ -4221,7 +4221,7 @@ xfs_bmapi_delay(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -XFS_STATS_INC (xs_blk_mapw); +XFS_STATS_INC (mp, xs_blk_mapw);if (!(ifp->if_flags &XFS_IFEXTENTS )) { error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK );
@@ -4525,7 +4525,7 @@ xfs_bmapi_write( ifp =XFS_IFORK_PTR (ip, whichfork); -XFS_STATS_INC (xs_blk_mapw); +XFS_STATS_INC (mp, xs_blk_mapw);if (*firstblock ==NULLFSBLOCK ) {if (XFS_IFORK_FORMAT (ip, whichfork) ==XFS_DINODE_FMT_BTREE )
@@ -4718,12 +4718,12 @@ xfs_bmap_del_extent(xfs_filblks_t temp2;/* for indirect length calculations */ int state =0 ; -XFS_STATS_INC (xs_del_exlist); + mp = ip->i_mount; +XFS_STATS_INC (mp, xs_del_exlist);if (whichfork ==XFS_ATTR_FORK ) state |=BMAP_ATTRFORK ; - mp = ip->i_mount; ifp =XFS_IFORK_PTR (ip, whichfork);ASSERT ((*idx >=0 ) && (*idx < ifp->if_bytes / (uint )sizeof (xfs_bmbt_rec_t)));
@@ -5070,7 +5070,7 @@ xfs_bunmapi( *done =1 ;return 0 ; } -XFS_STATS_INC (xs_blk_unmap); +XFS_STATS_INC (mp, xs_blk_unmap); isrt = (whichfork ==XFS_DATA_FORK ) &&XFS_IS_REALTIME_INODE (ip); start = bno; bno = start + len -1 ;
fs/xfs/libxfs/xfs_btree.h +18 -16
@@ -84,31 +84,33 @@ union xfs_btree_rec {/* * Generic stats interface */ -#define __XFS_BTREE_STATS_INC (type, stat) \ - XFS_STATS_INC(xs_ ## type ## _2_ ## stat) -#define XFS_BTREE_STATS_INC (cur, stat) \ +#define __XFS_BTREE_STATS_INC (mp, type, stat) \ + XFS_STATS_INC(mp, xs_ ## type ## _2_ ## stat) +#define XFS_BTREE_STATS_INC (cur, stat) \ do { \ + struct xfs_mount *mp = cur->bc_mp; \ switch (cur->bc_btnum) { \ - case XFS_BTNUM_BNO: __XFS_BTREE_STATS_INC(abtb, stat); break; \ - case XFS_BTNUM_CNT: __XFS_BTREE_STATS_INC(abtc, stat); break; \ - case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(bmbt, stat); break; \ - case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(ibt, stat); break; \ - case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(fibt, stat); break; \ + case XFS_BTNUM_BNO: __XFS_BTREE_STATS_INC(mp, abtb, stat); break; \ + case XFS_BTNUM_CNT: __XFS_BTREE_STATS_INC(mp, abtc, stat); break; \ + case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(mp, bmbt, stat); break; \ + case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(mp, ibt, stat); break; \ + case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(mp, fibt, stat); break; \ case XFS_BTNUM_MAX: ASSERT(0);/* fucking gcc */ ;break ; \ } \ } while (0) -#define __XFS_BTREE_STATS_ADD (type, stat, val) \ - XFS_STATS_ADD(xs_ ## type ## _2_ ## stat, val) +#define __XFS_BTREE_STATS_ADD (mp, type, stat, val) \ + XFS_STATS_ADD(mp, xs_ ## type ## _2_ ## stat, val)#define XFS_BTREE_STATS_ADD (cur, stat, val) \ do { \ + struct xfs_mount *mp = cur->bc_mp; \ switch (cur->bc_btnum) { \ - case XFS_BTNUM_BNO: __XFS_BTREE_STATS_ADD(abtb, stat, val); break; \ - case XFS_BTNUM_CNT: __XFS_BTREE_STATS_ADD(abtc, stat, val); break; \ - case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_ADD(bmbt, stat, val); break; \ - case XFS_BTNUM_INO: __XFS_BTREE_STATS_ADD(ibt, stat, val); break; \ - case XFS_BTNUM_FINO: __XFS_BTREE_STATS_ADD(fibt, stat, val); break; \ - case XFS_BTNUM_MAX: ASSERT(0);/* fucking gcc */ ;break ; \ + case XFS_BTNUM_BNO: __XFS_BTREE_STATS_ADD(mp, abtb, stat, val); break; \ + case XFS_BTNUM_CNT: __XFS_BTREE_STATS_ADD(mp, abtc, stat, val); break; \ + case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_ADD(mp, bmbt, stat, val); break; \ + case XFS_BTNUM_INO: __XFS_BTREE_STATS_ADD(mp, ibt, stat, val); break; \ + case XFS_BTNUM_FINO: __XFS_BTREE_STATS_ADD(mp, fibt, stat, val); break; \ + case XFS_BTNUM_MAX: ASSERT(0);/* fucking gcc */ ;break ; \ } \ } while (0)
fs/xfs/libxfs/xfs_dir2.c +3 -3
@@ -271,7 +271,7 @@ xfs_dir_createname( rval =xfs_dir_ino_validate (tp->t_mountp, inum);if (rval)return rval; -XFS_STATS_INC (xs_dir_create); +XFS_STATS_INC (dp->i_mount, xs_dir_create); } args =kmem_zalloc (sizeof (*args),KM_SLEEP |KM_NOFS );
@@ -365,7 +365,7 @@ xfs_dir_lookup(int lock_mode;ASSERT (S_ISDIR (dp->i_d.di_mode)); -XFS_STATS_INC (xs_dir_lookup); +XFS_STATS_INC (dp->i_mount, xs_dir_lookup);/* * We need to use KM_NOFS here so that lockdep will not throw false
@@ -444,7 +444,7 @@ xfs_dir_removename(int v;/* type-checking value */ ASSERT (S_ISDIR (dp->i_d.di_mode)); -XFS_STATS_INC (xs_dir_remove); +XFS_STATS_INC (dp->i_mount, xs_dir_remove); args =kmem_zalloc (sizeof (*args),KM_SLEEP |KM_NOFS );if (!args)
fs/xfs/xfs_attr_list.c +1 -1
@@ -511,7 +511,7 @@ xfs_attr_list_int(xfs_inode_t *dp = context->dp;uint lock_mode; -XFS_STATS_INC (xs_attr_list); +XFS_STATS_INC (dp->i_mount, xs_attr_list);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ;
fs/xfs/xfs_buf.c +9 -9
@@ -201,7 +201,7 @@ _xfs_buf_alloc(atomic_set (&bp->b_pin_count,0 );init_waitqueue_head (&bp->b_waiters); -XFS_STATS_INC (xb_create); +XFS_STATS_INC (target->bt_mount, xb_create);trace_xfs_buf_init (bp, _RET_IP_);return bp;
@@ -357,12 +357,12 @@ retry:"possible memory allocation deadlock in %s (mode:0x%x)" , __func__, gfp_mask); -XFS_STATS_INC (xb_page_retries); +XFS_STATS_INC (bp->b_target->bt_mount, xb_page_retries);congestion_wait (BLK_RW_ASYNC ,HZ /50 ); goto retry; } -XFS_STATS_INC (xb_page_found); +XFS_STATS_INC (bp->b_target->bt_mount, xb_page_found); nbytes =min_t (size_t, size,PAGE_SIZE - offset); size -= nbytes;
@@ -516,7 +516,7 @@ _xfs_buf_find( new_bp->b_pag = pag;spin_unlock (&pag->pag_buf_lock); }else { -XFS_STATS_INC (xb_miss_locked); +XFS_STATS_INC (btp->bt_mount, xb_miss_locked);spin_unlock (&pag->pag_buf_lock);xfs_perag_put (pag); }
@@ -529,11 +529,11 @@ found:if (!xfs_buf_trylock (bp)) {if (flags &XBF_TRYLOCK ) {xfs_buf_rele (bp); -XFS_STATS_INC (xb_busy_locked); +XFS_STATS_INC (btp->bt_mount, xb_busy_locked);return NULL ; }xfs_buf_lock (bp); -XFS_STATS_INC (xb_get_locked_waited); +XFS_STATS_INC (btp->bt_mount, xb_get_locked_waited); }/*
@@ -549,7 +549,7 @@ found: }trace_xfs_buf_find (bp, flags, _RET_IP_); -XFS_STATS_INC (xb_get_locked); +XFS_STATS_INC (btp->bt_mount, xb_get_locked);return bp; }
@@ -603,7 +603,7 @@ found: } } -XFS_STATS_INC (xb_get); +XFS_STATS_INC (target->bt_mount, xb_get);trace_xfs_buf_get (bp, flags, _RET_IP_);return bp; }
@@ -643,7 +643,7 @@ xfs_buf_read_map(trace_xfs_buf_read (bp, flags, _RET_IP_);if (!XFS_BUF_ISDONE (bp)) { -XFS_STATS_INC (xb_get_read); +XFS_STATS_INC (target->bt_mount, xb_get_read); bp->b_ops = ops;_xfs_buf_read (bp, flags); }else if (flags &XBF_ASYNC ) {
fs/xfs/xfs_dir2_readdir.c +1 -1
@@ -666,7 +666,7 @@ xfs_readdir(return -EIO ;ASSERT (S_ISDIR (dp->i_d.di_mode)); -XFS_STATS_INC (xs_dir_getdents); +XFS_STATS_INC (dp->i_mount, xs_dir_getdents); args.dp = dp; args.geo = dp->i_mount->m_dir_geo;
fs/xfs/xfs_dquot.c +6 -6
@@ -77,7 +77,7 @@ xfs_qm_dqdestroy(mutex_destroy (&dqp->q_qlock);kmem_zone_free (xfs_qm_dqzone, dqp); -XFS_STATS_DEC (xs_qm_dquot); +XFS_STATS_DEC (dqp->q_mount, xs_qm_dquot); }/*
@@ -605,7 +605,7 @@ xfs_qm_dqread(break ; } -XFS_STATS_INC (xs_qm_dquot); +XFS_STATS_INC (dqp->q_mount, xs_qm_dquot);trace_xfs_dqread (dqp);
@@ -747,12 +747,12 @@ restart:mutex_unlock (&qi->qi_tree_lock);trace_xfs_dqget_hit (dqp); -XFS_STATS_INC (xs_qm_dqcachehits); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqcachehits); *O_dqpp = dqp;return 0 ; }mutex_unlock (&qi->qi_tree_lock); -XFS_STATS_INC (xs_qm_dqcachemisses); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqcachemisses);/* * Dquot cache miss. We don't want to keep the inode lock across
@@ -806,7 +806,7 @@ restart:mutex_unlock (&qi->qi_tree_lock);trace_xfs_dqget_dup (dqp);xfs_qm_dqdestroy (dqp); -XFS_STATS_INC (xs_qm_dquot_dups); +XFS_STATS_INC (dqp->q_mount, xs_qm_dquot_dups); goto restart; }
@@ -846,7 +846,7 @@ xfs_qm_dqput(trace_xfs_dqput_free (dqp);if (list_lru_add (&qi->qi_lru, &dqp->q_lru)) -XFS_STATS_INC (xs_qm_dquot_unused); +XFS_STATS_INC (dqp->q_mount, xs_qm_dquot_unused); }xfs_dqunlock (dqp); }
fs/xfs/xfs_file.c +6 -6
@@ -287,7 +287,7 @@ xfs_file_read_iter(xfs_fsize_t n;loff_t pos = iocb->ki_pos; -XFS_STATS_INC (xs_read_calls); +XFS_STATS_INC (mp, xs_read_calls);if (unlikely (iocb->ki_flags &IOCB_DIRECT )) ioflags |=XFS_IO_ISDIRECT ;
@@ -365,7 +365,7 @@ xfs_file_read_iter( ret =generic_file_read_iter (iocb, to);if (ret >0 ) -XFS_STATS_ADD (xs_read_bytes, ret); +XFS_STATS_ADD (mp, xs_read_bytes, ret);xfs_rw_iunlock (ip,XFS_IOLOCK_SHARED );return ret;
@@ -383,7 +383,7 @@ xfs_file_splice_read(int ioflags =0 ;ssize_t ret; -XFS_STATS_INC (xs_read_calls); +XFS_STATS_INC (ip->i_mount, xs_read_calls);if (infilp->f_mode &FMODE_NOCMTIME ) ioflags |=XFS_IO_INVIS ;
@@ -401,7 +401,7 @@ xfs_file_splice_read(else ret =generic_file_splice_read (infilp, ppos, pipe, count, flags);if (ret >0 ) -XFS_STATS_ADD (xs_read_bytes, ret); +XFS_STATS_ADD (ip->i_mount, xs_read_bytes, ret);xfs_rw_iunlock (ip,XFS_IOLOCK_SHARED );return ret;
@@ -867,7 +867,7 @@ xfs_file_write_iter(ssize_t ret;size_t ocount =iov_iter_count (from); -XFS_STATS_INC (xs_write_calls); +XFS_STATS_INC (ip->i_mount, xs_write_calls);if (ocount ==0 )return 0 ;
@@ -883,7 +883,7 @@ xfs_file_write_iter(if (ret >0 ) {ssize_t err; -XFS_STATS_ADD (xs_write_bytes, ret); +XFS_STATS_ADD (ip->i_mount, xs_write_bytes, ret);/* Handle various SYNC-type writes */ err =generic_write_sync (file, iocb->ki_pos - ret, ret);
fs/xfs/xfs_icache.c +9 -9
@@ -63,7 +63,7 @@ xfs_inode_alloc(return NULL ; } -XFS_STATS_INC (vn_active); +XFS_STATS_INC (mp, vn_active);ASSERT (atomic_read (&ip->i_pincount) ==0 );ASSERT (!spin_is_locked (&ip->i_flags_lock));ASSERT (!xfs_isiflocked (ip));
@@ -129,7 +129,7 @@ xfs_inode_free(/* asserts to verify all state is correct here */ ASSERT (atomic_read (&ip->i_pincount) ==0 );ASSERT (!xfs_isiflocked (ip)); -XFS_STATS_DEC (vn_active); +XFS_STATS_DEC (ip->i_mount, vn_active);call_rcu (&VFS_I (ip)->i_rcu, xfs_inode_free_callback); }
@@ -159,7 +159,7 @@ xfs_iget_cache_hit(spin_lock (&ip->i_flags_lock);if (ip->i_ino != ino) {trace_xfs_iget_skip (ip); -XFS_STATS_INC (xs_ig_frecycle); +XFS_STATS_INC (mp, xs_ig_frecycle); error = -EAGAIN ; goto out_error; }
@@ -177,7 +177,7 @@ xfs_iget_cache_hit(*/ if (ip->i_flags & (XFS_INEW |XFS_IRECLAIM )) {trace_xfs_iget_skip (ip); -XFS_STATS_INC (xs_ig_frecycle); +XFS_STATS_INC (mp, xs_ig_frecycle); error = -EAGAIN ; goto out_error; }
@@ -259,7 +259,7 @@ xfs_iget_cache_hit(xfs_ilock (ip, lock_flags);xfs_iflags_clear (ip,XFS_ISTALE |XFS_IDONTCACHE ); -XFS_STATS_INC (xs_ig_found); +XFS_STATS_INC (mp, xs_ig_found);return 0 ;
@@ -342,7 +342,7 @@ xfs_iget_cache_miss( error =radix_tree_insert (&pag->pag_ici_root, agino, ip);if (unlikely (error)) {WARN_ON (error != -EEXIST ); -XFS_STATS_INC (xs_ig_dup); +XFS_STATS_INC (mp, xs_ig_dup); error = -EAGAIN ; goto out_preload_end; }
@@ -412,7 +412,7 @@ xfs_iget(if (!ino ||XFS_INO_TO_AGNO (mp, ino) >= mp->m_sb.sb_agcount)return -EINVAL ; -XFS_STATS_INC (xs_ig_attempts); +XFS_STATS_INC (mp, xs_ig_attempts);/* get the perag structure and ensure that it's inode capable */ pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, ino));
@@ -429,7 +429,7 @@ again: goto out_error_or_again; }else {rcu_read_unlock (); -XFS_STATS_INC (xs_ig_missed); +XFS_STATS_INC (mp, xs_ig_missed); error =xfs_iget_cache_miss (mp, pag, tp, ino, &ip, flags, lock_flags);
@@ -965,7 +965,7 @@ reclaim:xfs_ifunlock (ip);xfs_iunlock (ip,XFS_ILOCK_EXCL ); -XFS_STATS_INC (xs_ig_reclaims); +XFS_STATS_INC (ip->i_mount, xs_ig_reclaims);/* * Remove the inode from the per-AG radix tree. *
fs/xfs/xfs_inode.c +3 -3
@@ -3271,8 +3271,8 @@ xfs_iflush_cluster( }if (clcount) { -XFS_STATS_INC (xs_icluster_flushcnt); -XFS_STATS_ADD (xs_icluster_flushinode, clcount); +XFS_STATS_INC (mp, xs_icluster_flushcnt); +XFS_STATS_ADD (mp, xs_icluster_flushinode, clcount); } out_free:
@@ -3345,7 +3345,7 @@ xfs_iflush(struct xfs_dinode *dip;int error; -XFS_STATS_INC (xs_iflush_count); +XFS_STATS_INC (mp, xs_iflush_count);ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED ));ASSERT (xfs_isiflocked (ip));
fs/xfs/xfs_ioctl.c +1 -1
@@ -1028,7 +1028,7 @@ xfs_ioctl_setattr_xflags(xfs_diflags_to_linux (ip);xfs_trans_ichgtime (tp, ip,XFS_ICHGTIME_CHG );xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -XFS_STATS_INC (xs_ig_attrchg); +XFS_STATS_INC (mp, xs_ig_attrchg);return 0 ; }
fs/xfs/xfs_iomap.c +2 -2
@@ -670,7 +670,7 @@ xfs_iomap_write_allocate( count_fsb = imap->br_blockcount; map_start_fsb = imap->br_startoff; -XFS_STATS_ADD (xs_xstrat_bytes,XFS_FSB_TO_B (mp, count_fsb)); +XFS_STATS_ADD (mp, xs_xstrat_bytes,XFS_FSB_TO_B (mp, count_fsb));while (count_fsb !=0 ) {/*
@@ -777,7 +777,7 @@ xfs_iomap_write_allocate(if ((offset_fsb >= imap->br_startoff) && (offset_fsb < (imap->br_startoff + imap->br_blockcount))) { -XFS_STATS_INC (xs_xstrat_quick); +XFS_STATS_INC (mp, xs_xstrat_quick);return 0 ; }
fs/xfs/xfs_iops.c +2 -2
@@ -695,7 +695,7 @@ xfs_setattr_nonsize(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -XFS_STATS_INC (xs_ig_attrchg); +XFS_STATS_INC (mp, xs_ig_attrchg);if (mp->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (tp);
@@ -922,7 +922,7 @@ xfs_setattr_size(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -XFS_STATS_INC (xs_ig_attrchg); +XFS_STATS_INC (mp, xs_ig_attrchg);if (mp->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (tp);
fs/xfs/xfs_log.c +11 -11
@@ -268,7 +268,7 @@ xlog_grant_head_wait(__set_current_state (TASK_UNINTERRUPTIBLE );spin_unlock (&head->lock); -XFS_STATS_INC (xs_sleep_logspace); +XFS_STATS_INC (log->l_mp, xs_sleep_logspace);trace_xfs_log_grant_sleep (log, tic);schedule ();
@@ -379,7 +379,7 @@ xfs_log_regrant(if (XLOG_FORCED_SHUTDOWN (log))return -EIO ; -XFS_STATS_INC (xs_try_logspace); +XFS_STATS_INC (mp, xs_try_logspace);/* * This is a new transaction on the ticket, so we need to change the
@@ -448,7 +448,7 @@ xfs_log_reserve(if (XLOG_FORCED_SHUTDOWN (log))return -EIO ; -XFS_STATS_INC (xs_try_logspace); +XFS_STATS_INC (mp, xs_try_logspace);ASSERT (*ticp ==NULL ); tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent,
@@ -1768,7 +1768,7 @@ xlog_sync(int v2 =xfs_sb_version_haslogv2 (&log->l_mp->m_sb);int size; -XFS_STATS_INC (xs_log_writes); +XFS_STATS_INC (log->l_mp, xs_log_writes);ASSERT (atomic_read (&iclog->ic_refcnt) ==0 );/* Add for LR header */
@@ -1805,7 +1805,7 @@ xlog_sync( bp = iclog->ic_bp;XFS_BUF_SET_ADDR (bp,BLOCK_LSN (be64_to_cpu (iclog->ic_header.h_lsn))); -XFS_STATS_ADD (xs_log_blocks,BTOBB (count)); +XFS_STATS_ADD (log->l_mp, xs_log_blocks,BTOBB (count));/* Do we need to split this write into 2 parts? */ if (XFS_BUF_ADDR (bp) +BTOBB (count) > log->l_logBBsize) {
@@ -2913,7 +2913,7 @@ restart: iclog = log->l_iclog;if (iclog->ic_state !=XLOG_STATE_ACTIVE ) { -XFS_STATS_INC (xs_log_noiclogs); +XFS_STATS_INC (log->l_mp, xs_log_noiclogs);/* Wait for log writes to have flushed */ xlog_wait (&log->l_flush_wait, &log->l_icloglock);
@@ -3212,7 +3212,7 @@ _xfs_log_force(struct xlog_in_core *iclog;xfs_lsn_t lsn; -XFS_STATS_INC (xs_log_force); +XFS_STATS_INC (mp, xs_log_force);xlog_cil_force (log);
@@ -3297,7 +3297,7 @@ maybe_sleep:spin_unlock (&log->l_icloglock);return -EIO ; } -XFS_STATS_INC (xs_log_force_sleep); +XFS_STATS_INC (mp, xs_log_force_sleep);xlog_wait (&iclog->ic_force_wait, &log->l_icloglock);/* * No need to grab the log lock here since we're
@@ -3362,7 +3362,7 @@ _xfs_log_force_lsn(ASSERT (lsn !=0 ); -XFS_STATS_INC (xs_log_force); +XFS_STATS_INC (mp, xs_log_force); lsn =xlog_cil_force_lsn (log, lsn);if (lsn ==NULLCOMMITLSN )
@@ -3411,7 +3411,7 @@ try_again: (XLOG_STATE_WANT_SYNC | XLOG_STATE_SYNCING))) {ASSERT (!(iclog->ic_state &XLOG_STATE_IOERROR )); -XFS_STATS_INC (xs_log_force_sleep); +XFS_STATS_INC (mp, xs_log_force_sleep);xlog_wait (&iclog->ic_prev->ic_write_wait, &log->l_icloglock);
@@ -3441,7 +3441,7 @@ try_again:spin_unlock (&log->l_icloglock);return -EIO ; } -XFS_STATS_INC (xs_log_force_sleep); +XFS_STATS_INC (mp, xs_log_force_sleep);xlog_wait (&iclog->ic_force_wait, &log->l_icloglock);/* * No need to grab the log lock here since we're
fs/xfs/xfs_qm.c +7 -7
@@ -184,7 +184,7 @@ xfs_qm_dqpurge(*/ ASSERT (!list_empty (&dqp->q_lru));list_lru_del (&qi->qi_lru, &dqp->q_lru); -XFS_STATS_DEC (xs_qm_dquot_unused); +XFS_STATS_DEC (mp, xs_qm_dquot_unused);xfs_qm_dqdestroy (dqp);return 0 ;
@@ -448,11 +448,11 @@ xfs_qm_dquot_isolate(*/ if (dqp->q_nrefs) {xfs_dqunlock (dqp); -XFS_STATS_INC (xs_qm_dqwants); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqwants);trace_xfs_dqreclaim_want (dqp);list_lru_isolate (lru, &dqp->q_lru); -XFS_STATS_DEC (xs_qm_dquot_unused); +XFS_STATS_DEC (dqp->q_mount, xs_qm_dquot_unused);return LRU_REMOVED ; }
@@ -496,19 +496,19 @@ xfs_qm_dquot_isolate(ASSERT (dqp->q_nrefs ==0 );list_lru_isolate_move (lru, &dqp->q_lru, &isol->dispose); -XFS_STATS_DEC (xs_qm_dquot_unused); +XFS_STATS_DEC (dqp->q_mount, xs_qm_dquot_unused);trace_xfs_dqreclaim_done (dqp); -XFS_STATS_INC (xs_qm_dqreclaims); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqreclaims);return LRU_REMOVED ; out_miss_busy:trace_xfs_dqreclaim_busy (dqp); -XFS_STATS_INC (xs_qm_dqreclaim_misses); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqreclaim_misses);return LRU_SKIP ; out_unlock_dirty:trace_xfs_dqreclaim_busy (dqp); -XFS_STATS_INC (xs_qm_dqreclaim_misses); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqreclaim_misses);xfs_dqunlock (dqp);spin_lock (lru_lock);return LRU_RETRY ;
fs/xfs/xfs_stats.h +15 -6
@@ -218,14 +218,23 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);void xfs_stats_clearall (struct xfsstats __percpu *stats);extern struct xstats xfsstats; -#define XFS_STATS_INC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++) +#define XFS_STATS_INC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v++; \ +} while (0) -#define XFS_STATS_DEC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--) +#define XFS_STATS_DEC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v--; \ +} while (0) -#define XFS_STATS_ADD (v, inc) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc)) +#define XFS_STATS_ADD (mp, v, inc) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc); \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v += (inc); \ +} while (0)extern int xfs_init_procfs (void );extern void xfs_cleanup_procfs (void );
fs/xfs/xfs_super.c +3 -3
@@ -922,7 +922,7 @@ xfs_fs_destroy_inode(trace_xfs_destroy_inode (ip); -XFS_STATS_INC (vn_reclaim); +XFS_STATS_INC (ip->i_mount, vn_reclaim);ASSERT (XFS_FORCED_SHUTDOWN (ip->i_mount) || ip->i_delayed_blks ==0 );
@@ -983,8 +983,8 @@ xfs_fs_evict_inode(truncate_inode_pages_final (&inode->i_data);clear_inode (inode); -XFS_STATS_INC (vn_rele); -XFS_STATS_INC (vn_remove); +XFS_STATS_INC (ip->i_mount, vn_rele); +XFS_STATS_INC (ip->i_mount, vn_remove);xfs_inactive (ip); }
fs/xfs/xfs_trans.c +3 -3
@@ -930,9 +930,9 @@ __xfs_trans_commit(*/ if (sync) { error =_xfs_log_force_lsn (mp, commit_lsn,XFS_LOG_SYNC ,NULL ); -XFS_STATS_INC (xs_trans_sync); +XFS_STATS_INC (mp, xs_trans_sync); }else { -XFS_STATS_INC (xs_trans_async); +XFS_STATS_INC (mp, xs_trans_async); }return error;
@@ -955,7 +955,7 @@ out_unreserve:xfs_trans_free_items (tp,NULLCOMMITLSN , !!error);xfs_trans_free (tp); -XFS_STATS_INC (xs_trans_empty); +XFS_STATS_INC (mp, xs_trans_empty);return error; }
fs/xfs/xfs_trans_ail.c +6 -6
@@ -349,7 +349,7 @@ xfsaild_push( xfs_ail_min_lsn(ailp))) { ailp->xa_log_flush =0 ; -XFS_STATS_INC (xs_push_ail_flush); +XFS_STATS_INC (mp, xs_push_ail_flush);xfs_log_force (mp,XFS_LOG_SYNC ); }
@@ -371,7 +371,7 @@ xfsaild_push( goto out_done; } -XFS_STATS_INC (xs_push_ail); +XFS_STATS_INC (mp, xs_push_ail); lsn = lip->li_lsn;while ((XFS_LSN_CMP (lip->li_lsn, target) <=0 )) {
@@ -385,7 +385,7 @@ xfsaild_push( lock_result = lip->li_ops->iop_push (lip, &ailp->xa_buf_list);switch (lock_result) {case XFS_ITEM_SUCCESS : -XFS_STATS_INC (xs_push_ail_success); +XFS_STATS_INC (mp, xs_push_ail_success);trace_xfs_ail_push (lip); ailp->xa_last_pushed_lsn = lsn;
@@ -403,7 +403,7 @@ xfsaild_push(* re-try the flushing relatively soon if most of the * AIL is beeing flushed. */ -XFS_STATS_INC (xs_push_ail_flushing); +XFS_STATS_INC (mp, xs_push_ail_flushing);trace_xfs_ail_flushing (lip); flushing++;
@@ -411,14 +411,14 @@ xfsaild_push(break ;case XFS_ITEM_PINNED : -XFS_STATS_INC (xs_push_ail_pinned); +XFS_STATS_INC (mp, xs_push_ail_pinned);trace_xfs_ail_pinned (lip); stuck++; ailp->xa_log_flush++;break ;case XFS_ITEM_LOCKED : -XFS_STATS_INC (xs_push_ail_locked); +XFS_STATS_INC (mp, xs_push_ail_locked);trace_xfs_ail_locked (lip); stuck++;
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 7/7 v11] xfs: per-filesystem stats counter implementation
UPDATE:
-v11: fix errors in dfs_dquot.c functions touching stats counts.
This patch modifies the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
global counts: /sys/fs/xfs/stats/stats
per-fs counts: /sys/fs/xfs/sda*/stats/stats
global clear: /sys/fs/xfs/stats/stats_clear per-fs clear: /sys/fs/xfs/sda*/stats/stats_clear
--- fs/xfs/libxfs/xfs_alloc.c | 8 ++++---- fs/xfs/libxfs/xfs_attr.c | 6 +++--- fs/xfs/libxfs/xfs_bmap.c | 20 ++++++++++---------- fs/xfs/libxfs/xfs_btree.h | 34 ++++++++++++++++++---------------- fs/xfs/libxfs/xfs_dir2.c | 6 +++--- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_buf.c | 18 +++++++++--------- fs/xfs/xfs_dir2_readdir.c | 2 +- fs/xfs/xfs_dquot.c | 14 +++++++------- fs/xfs/xfs_file.c | 12 ++++++------ fs/xfs/xfs_icache.c | 18 +++++++++--------- fs/xfs/xfs_inode.c | 6 +++--- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iomap.c | 4 ++-- fs/xfs/xfs_iops.c | 4 ++-- fs/xfs/xfs_log.c | 22 +++++++++++----------- fs/xfs/xfs_qm.c | 14 +++++++------- fs/xfs/xfs_stats.h | 21 +++++++++++++++------ fs/xfs/xfs_super.c | 6 +++--- fs/xfs/xfs_trans.c | 6 +++--- fs/xfs/xfs_trans_ail.c | 12 ++++++------ 21 files changed, 124 insertions(+), 113 deletions(-)
fs/xfs/libxfs/xfs_alloc.c +4 -4
@@ -651,8 +651,8 @@ xfs_alloc_ag_vextent( -((long)(args->len))); } -XFS_STATS_INC (xs_allocx); -XFS_STATS_ADD (xs_allocb, args->len); +XFS_STATS_INC (args->mp, xs_allocx); +XFS_STATS_ADD (args->mp, xs_allocb, args->len);return error; }
@@ -1808,8 +1808,8 @@ xfs_free_ag_extent(if (!isfl)xfs_trans_mod_sb (tp,XFS_TRANS_SB_FDBLOCKS , (long )len); -XFS_STATS_INC (xs_freex); -XFS_STATS_ADD (xs_freeb, len); +XFS_STATS_INC (mp, xs_freex); +XFS_STATS_ADD (mp, xs_freeb, len);trace_xfs_free_extent (mp, agno, bno, len, isfl, haveleft, haveright);
fs/xfs/libxfs/xfs_attr.c +3 -3
@@ -125,7 +125,7 @@ xfs_attr_get(uint lock_mode;int error; -XFS_STATS_INC (xs_attr_get); +XFS_STATS_INC (ip->i_mount, xs_attr_get);if (XFS_FORCED_SHUTDOWN (ip->i_mount))return -EIO ;
@@ -209,7 +209,7 @@ xfs_attr_set(int rsvd = (flags &ATTR_ROOT ) !=0 ;int error, err2, committed, local; -XFS_STATS_INC (xs_attr_set); +XFS_STATS_INC (mp, xs_attr_set);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ;
@@ -412,7 +412,7 @@ xfs_attr_remove(xfs_fsblock_t firstblock;int error; -XFS_STATS_INC (xs_attr_remove); +XFS_STATS_INC (mp, xs_attr_remove);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ;
fs/xfs/libxfs/xfs_bmap.c +10 -10
@@ -1435,7 +1435,7 @@ xfs_bmap_search_extents(xfs_ifork_t *ifp;/* inode fork pointer */ xfs_bmbt_rec_host_t *ep;/* extent record pointer */ -XFS_STATS_INC (xs_look_exlist); +XFS_STATS_INC (ip->i_mount, xs_look_exlist); ifp =XFS_IFORK_PTR (ip, fork); ep =xfs_bmap_search_multi_extents (ifp, bno, eofp, lastxp, gotp, prevp);
@@ -1732,7 +1732,7 @@ xfs_bmap_add_extent_delay_real(ASSERT (!bma->cur || (bma->cur->bc_private.b.flags &XFS_BTCUR_BPRV_WASDEL )); -XFS_STATS_INC (xs_add_exlist); +XFS_STATS_INC (mp, xs_add_exlist);#define LEFT r[0]#define RIGHT r[1]
@@ -2286,7 +2286,7 @@ xfs_bmap_add_extent_unwritten_real(ASSERT (*idx <= ifp->if_bytes /sizeof (struct xfs_bmbt_rec ));ASSERT (!isnullstartblock (new->br_startblock)); -XFS_STATS_INC (xs_add_exlist); +XFS_STATS_INC (mp, xs_add_exlist);#define LEFT r[0]#define RIGHT r[1]
@@ -2946,7 +2946,7 @@ xfs_bmap_add_extent_hole_real(ASSERT (!bma->cur || !(bma->cur->bc_private.b.flags &XFS_BTCUR_BPRV_WASDEL )); -XFS_STATS_INC (xs_add_exlist); +XFS_STATS_INC (mp, xs_add_exlist); state =0 ;if (whichfork ==XFS_ATTR_FORK )
@@ -4036,7 +4036,7 @@ xfs_bmapi_read(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -XFS_STATS_INC (xs_blk_mapr); +XFS_STATS_INC (mp, xs_blk_mapr); ifp =XFS_IFORK_PTR (ip, whichfork);
@@ -4221,7 +4221,7 @@ xfs_bmapi_delay(if (XFS_FORCED_SHUTDOWN (mp))return -EIO ; -XFS_STATS_INC (xs_blk_mapw); +XFS_STATS_INC (mp, xs_blk_mapw);if (!(ifp->if_flags &XFS_IFEXTENTS )) { error =xfs_iread_extents (NULL , ip,XFS_DATA_FORK );
@@ -4525,7 +4525,7 @@ xfs_bmapi_write( ifp =XFS_IFORK_PTR (ip, whichfork); -XFS_STATS_INC (xs_blk_mapw); +XFS_STATS_INC (mp, xs_blk_mapw);if (*firstblock ==NULLFSBLOCK ) {if (XFS_IFORK_FORMAT (ip, whichfork) ==XFS_DINODE_FMT_BTREE )
@@ -4718,12 +4718,12 @@ xfs_bmap_del_extent(xfs_filblks_t temp2;/* for indirect length calculations */ int state =0 ; -XFS_STATS_INC (xs_del_exlist); + mp = ip->i_mount; +XFS_STATS_INC (mp, xs_del_exlist);if (whichfork ==XFS_ATTR_FORK ) state |=BMAP_ATTRFORK ; - mp = ip->i_mount; ifp =XFS_IFORK_PTR (ip, whichfork);ASSERT ((*idx >=0 ) && (*idx < ifp->if_bytes / (uint )sizeof (xfs_bmbt_rec_t)));
@@ -5070,7 +5070,7 @@ xfs_bunmapi( *done =1 ;return 0 ; } -XFS_STATS_INC (xs_blk_unmap); +XFS_STATS_INC (mp, xs_blk_unmap); isrt = (whichfork ==XFS_DATA_FORK ) &&XFS_IS_REALTIME_INODE (ip); start = bno; bno = start + len -1 ;
fs/xfs/libxfs/xfs_btree.h +18 -16
@@ -84,31 +84,33 @@ union xfs_btree_rec {/* * Generic stats interface */ -#define __XFS_BTREE_STATS_INC (type, stat) \ - XFS_STATS_INC(xs_ ## type ## _2_ ## stat) -#define XFS_BTREE_STATS_INC (cur, stat) \ +#define __XFS_BTREE_STATS_INC (mp, type, stat) \ + XFS_STATS_INC(mp, xs_ ## type ## _2_ ## stat) +#define XFS_BTREE_STATS_INC (cur, stat) \ do { \ + struct xfs_mount *mp = cur->bc_mp; \ switch (cur->bc_btnum) { \ - case XFS_BTNUM_BNO: __XFS_BTREE_STATS_INC(abtb, stat); break; \ - case XFS_BTNUM_CNT: __XFS_BTREE_STATS_INC(abtc, stat); break; \ - case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(bmbt, stat); break; \ - case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(ibt, stat); break; \ - case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(fibt, stat); break; \ + case XFS_BTNUM_BNO: __XFS_BTREE_STATS_INC(mp, abtb, stat); break; \ + case XFS_BTNUM_CNT: __XFS_BTREE_STATS_INC(mp, abtc, stat); break; \ + case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_INC(mp, bmbt, stat); break; \ + case XFS_BTNUM_INO: __XFS_BTREE_STATS_INC(mp, ibt, stat); break; \ + case XFS_BTNUM_FINO: __XFS_BTREE_STATS_INC(mp, fibt, stat); break; \ case XFS_BTNUM_MAX: ASSERT(0);/* fucking gcc */ ;break ; \ } \ } while (0) -#define __XFS_BTREE_STATS_ADD (type, stat, val) \ - XFS_STATS_ADD(xs_ ## type ## _2_ ## stat, val) +#define __XFS_BTREE_STATS_ADD (mp, type, stat, val) \ + XFS_STATS_ADD(mp, xs_ ## type ## _2_ ## stat, val)#define XFS_BTREE_STATS_ADD (cur, stat, val) \ do { \ + struct xfs_mount *mp = cur->bc_mp; \ switch (cur->bc_btnum) { \ - case XFS_BTNUM_BNO: __XFS_BTREE_STATS_ADD(abtb, stat, val); break; \ - case XFS_BTNUM_CNT: __XFS_BTREE_STATS_ADD(abtc, stat, val); break; \ - case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_ADD(bmbt, stat, val); break; \ - case XFS_BTNUM_INO: __XFS_BTREE_STATS_ADD(ibt, stat, val); break; \ - case XFS_BTNUM_FINO: __XFS_BTREE_STATS_ADD(fibt, stat, val); break; \ - case XFS_BTNUM_MAX: ASSERT(0);/* fucking gcc */ ;break ; \ + case XFS_BTNUM_BNO: __XFS_BTREE_STATS_ADD(mp, abtb, stat, val); break; \ + case XFS_BTNUM_CNT: __XFS_BTREE_STATS_ADD(mp, abtc, stat, val); break; \ + case XFS_BTNUM_BMAP: __XFS_BTREE_STATS_ADD(mp, bmbt, stat, val); break; \ + case XFS_BTNUM_INO: __XFS_BTREE_STATS_ADD(mp, ibt, stat, val); break; \ + case XFS_BTNUM_FINO: __XFS_BTREE_STATS_ADD(mp, fibt, stat, val); break; \ + case XFS_BTNUM_MAX: ASSERT(0);/* fucking gcc */ ;break ; \ } \ } while (0)
fs/xfs/libxfs/xfs_dir2.c +3 -3
@@ -271,7 +271,7 @@ xfs_dir_createname( rval =xfs_dir_ino_validate (tp->t_mountp, inum);if (rval)return rval; -XFS_STATS_INC (xs_dir_create); +XFS_STATS_INC (dp->i_mount, xs_dir_create); } args =kmem_zalloc (sizeof (*args),KM_SLEEP |KM_NOFS );
@@ -365,7 +365,7 @@ xfs_dir_lookup(int lock_mode;ASSERT (S_ISDIR (dp->i_d.di_mode)); -XFS_STATS_INC (xs_dir_lookup); +XFS_STATS_INC (dp->i_mount, xs_dir_lookup);/* * We need to use KM_NOFS here so that lockdep will not throw false
@@ -444,7 +444,7 @@ xfs_dir_removename(int v;/* type-checking value */ ASSERT (S_ISDIR (dp->i_d.di_mode)); -XFS_STATS_INC (xs_dir_remove); +XFS_STATS_INC (dp->i_mount, xs_dir_remove); args =kmem_zalloc (sizeof (*args),KM_SLEEP |KM_NOFS );if (!args)
fs/xfs/xfs_attr_list.c +1 -1
@@ -511,7 +511,7 @@ xfs_attr_list_int(xfs_inode_t *dp = context->dp;uint lock_mode; -XFS_STATS_INC (xs_attr_list); +XFS_STATS_INC (dp->i_mount, xs_attr_list);if (XFS_FORCED_SHUTDOWN (dp->i_mount))return -EIO ;
fs/xfs/xfs_buf.c +9 -9
@@ -201,7 +201,7 @@ _xfs_buf_alloc(atomic_set (&bp->b_pin_count,0 );init_waitqueue_head (&bp->b_waiters); -XFS_STATS_INC (xb_create); +XFS_STATS_INC (target->bt_mount, xb_create);trace_xfs_buf_init (bp, _RET_IP_);return bp;
@@ -357,12 +357,12 @@ retry:"possible memory allocation deadlock in %s (mode:0x%x)" , __func__, gfp_mask); -XFS_STATS_INC (xb_page_retries); +XFS_STATS_INC (bp->b_target->bt_mount, xb_page_retries);congestion_wait (BLK_RW_ASYNC ,HZ /50 ); goto retry; } -XFS_STATS_INC (xb_page_found); +XFS_STATS_INC (bp->b_target->bt_mount, xb_page_found); nbytes =min_t (size_t, size,PAGE_SIZE - offset); size -= nbytes;
@@ -516,7 +516,7 @@ _xfs_buf_find( new_bp->b_pag = pag;spin_unlock (&pag->pag_buf_lock); }else { -XFS_STATS_INC (xb_miss_locked); +XFS_STATS_INC (btp->bt_mount, xb_miss_locked);spin_unlock (&pag->pag_buf_lock);xfs_perag_put (pag); }
@@ -529,11 +529,11 @@ found:if (!xfs_buf_trylock (bp)) {if (flags &XBF_TRYLOCK ) {xfs_buf_rele (bp); -XFS_STATS_INC (xb_busy_locked); +XFS_STATS_INC (btp->bt_mount, xb_busy_locked);return NULL ; }xfs_buf_lock (bp); -XFS_STATS_INC (xb_get_locked_waited); +XFS_STATS_INC (btp->bt_mount, xb_get_locked_waited); }/*
@@ -549,7 +549,7 @@ found: }trace_xfs_buf_find (bp, flags, _RET_IP_); -XFS_STATS_INC (xb_get_locked); +XFS_STATS_INC (btp->bt_mount, xb_get_locked);return bp; }
@@ -603,7 +603,7 @@ found: } } -XFS_STATS_INC (xb_get); +XFS_STATS_INC (target->bt_mount, xb_get);trace_xfs_buf_get (bp, flags, _RET_IP_);return bp; }
@@ -643,7 +643,7 @@ xfs_buf_read_map(trace_xfs_buf_read (bp, flags, _RET_IP_);if (!XFS_BUF_ISDONE (bp)) { -XFS_STATS_INC (xb_get_read); +XFS_STATS_INC (target->bt_mount, xb_get_read); bp->b_ops = ops;_xfs_buf_read (bp, flags); }else if (flags &XBF_ASYNC ) {
fs/xfs/xfs_dir2_readdir.c +1 -1
@@ -666,7 +666,7 @@ xfs_readdir(return -EIO ;ASSERT (S_ISDIR (dp->i_d.di_mode)); -XFS_STATS_INC (xs_dir_getdents); +XFS_STATS_INC (dp->i_mount, xs_dir_getdents); args.dp = dp; args.geo = dp->i_mount->m_dir_geo;
fs/xfs/xfs_dquot.c +7 -7
@@ -75,9 +75,9 @@ xfs_qm_dqdestroy(ASSERT (list_empty (&dqp->q_lru));mutex_destroy (&dqp->q_qlock); -kmem_zone_free (xfs_qm_dqzone, dqp); -XFS_STATS_DEC (xs_qm_dquot); +XFS_STATS_DEC (dqp->q_mount, xs_qm_dquot); +kmem_zone_free (xfs_qm_dqzone, dqp); }/*
@@ -605,7 +605,7 @@ xfs_qm_dqread(break ; } -XFS_STATS_INC (xs_qm_dquot); +XFS_STATS_INC (mp, xs_qm_dquot);trace_xfs_dqread (dqp);
@@ -747,12 +747,12 @@ restart:mutex_unlock (&qi->qi_tree_lock);trace_xfs_dqget_hit (dqp); -XFS_STATS_INC (xs_qm_dqcachehits); +XFS_STATS_INC (mp, xs_qm_dqcachehits); *O_dqpp = dqp;return 0 ; }mutex_unlock (&qi->qi_tree_lock); -XFS_STATS_INC (xs_qm_dqcachemisses); +XFS_STATS_INC (mp, xs_qm_dqcachemisses);/* * Dquot cache miss. We don't want to keep the inode lock across
@@ -806,7 +806,7 @@ restart:mutex_unlock (&qi->qi_tree_lock);trace_xfs_dqget_dup (dqp);xfs_qm_dqdestroy (dqp); -XFS_STATS_INC (xs_qm_dquot_dups); +XFS_STATS_INC (mp, xs_qm_dquot_dups); goto restart; }
@@ -846,7 +846,7 @@ xfs_qm_dqput(trace_xfs_dqput_free (dqp);if (list_lru_add (&qi->qi_lru, &dqp->q_lru)) -XFS_STATS_INC (xs_qm_dquot_unused); +XFS_STATS_INC (dqp->q_mount, xs_qm_dquot_unused); }xfs_dqunlock (dqp); }
fs/xfs/xfs_file.c +6 -6
@@ -287,7 +287,7 @@ xfs_file_read_iter(xfs_fsize_t n;loff_t pos = iocb->ki_pos; -XFS_STATS_INC (xs_read_calls); +XFS_STATS_INC (mp, xs_read_calls);if (unlikely (iocb->ki_flags &IOCB_DIRECT )) ioflags |=XFS_IO_ISDIRECT ;
@@ -365,7 +365,7 @@ xfs_file_read_iter( ret =generic_file_read_iter (iocb, to);if (ret >0 ) -XFS_STATS_ADD (xs_read_bytes, ret); +XFS_STATS_ADD (mp, xs_read_bytes, ret);xfs_rw_iunlock (ip,XFS_IOLOCK_SHARED );return ret;
@@ -383,7 +383,7 @@ xfs_file_splice_read(int ioflags =0 ;ssize_t ret; -XFS_STATS_INC (xs_read_calls); +XFS_STATS_INC (ip->i_mount, xs_read_calls);if (infilp->f_mode &FMODE_NOCMTIME ) ioflags |=XFS_IO_INVIS ;
@@ -401,7 +401,7 @@ xfs_file_splice_read(else ret =generic_file_splice_read (infilp, ppos, pipe, count, flags);if (ret >0 ) -XFS_STATS_ADD (xs_read_bytes, ret); +XFS_STATS_ADD (ip->i_mount, xs_read_bytes, ret);xfs_rw_iunlock (ip,XFS_IOLOCK_SHARED );return ret;
@@ -867,7 +867,7 @@ xfs_file_write_iter(ssize_t ret;size_t ocount =iov_iter_count (from); -XFS_STATS_INC (xs_write_calls); +XFS_STATS_INC (ip->i_mount, xs_write_calls);if (ocount ==0 )return 0 ;
@@ -883,7 +883,7 @@ xfs_file_write_iter(if (ret >0 ) {ssize_t err; -XFS_STATS_ADD (xs_write_bytes, ret); +XFS_STATS_ADD (ip->i_mount, xs_write_bytes, ret);/* Handle various SYNC-type writes */ err =generic_write_sync (file, iocb->ki_pos - ret, ret);
fs/xfs/xfs_icache.c +9 -9
@@ -63,7 +63,7 @@ xfs_inode_alloc(return NULL ; } -XFS_STATS_INC (vn_active); +XFS_STATS_INC (mp, vn_active);ASSERT (atomic_read (&ip->i_pincount) ==0 );ASSERT (!spin_is_locked (&ip->i_flags_lock));ASSERT (!xfs_isiflocked (ip));
@@ -129,7 +129,7 @@ xfs_inode_free(/* asserts to verify all state is correct here */ ASSERT (atomic_read (&ip->i_pincount) ==0 );ASSERT (!xfs_isiflocked (ip)); -XFS_STATS_DEC (vn_active); +XFS_STATS_DEC (ip->i_mount, vn_active);call_rcu (&VFS_I (ip)->i_rcu, xfs_inode_free_callback); }
@@ -159,7 +159,7 @@ xfs_iget_cache_hit(spin_lock (&ip->i_flags_lock);if (ip->i_ino != ino) {trace_xfs_iget_skip (ip); -XFS_STATS_INC (xs_ig_frecycle); +XFS_STATS_INC (mp, xs_ig_frecycle); error = -EAGAIN ; goto out_error; }
@@ -177,7 +177,7 @@ xfs_iget_cache_hit(*/ if (ip->i_flags & (XFS_INEW |XFS_IRECLAIM )) {trace_xfs_iget_skip (ip); -XFS_STATS_INC (xs_ig_frecycle); +XFS_STATS_INC (mp, xs_ig_frecycle); error = -EAGAIN ; goto out_error; }
@@ -259,7 +259,7 @@ xfs_iget_cache_hit(xfs_ilock (ip, lock_flags);xfs_iflags_clear (ip,XFS_ISTALE |XFS_IDONTCACHE ); -XFS_STATS_INC (xs_ig_found); +XFS_STATS_INC (mp, xs_ig_found);return 0 ;
@@ -342,7 +342,7 @@ xfs_iget_cache_miss( error =radix_tree_insert (&pag->pag_ici_root, agino, ip);if (unlikely (error)) {WARN_ON (error != -EEXIST ); -XFS_STATS_INC (xs_ig_dup); +XFS_STATS_INC (mp, xs_ig_dup); error = -EAGAIN ; goto out_preload_end; }
@@ -412,7 +412,7 @@ xfs_iget(if (!ino ||XFS_INO_TO_AGNO (mp, ino) >= mp->m_sb.sb_agcount)return -EINVAL ; -XFS_STATS_INC (xs_ig_attempts); +XFS_STATS_INC (mp, xs_ig_attempts);/* get the perag structure and ensure that it's inode capable */ pag =xfs_perag_get (mp,XFS_INO_TO_AGNO (mp, ino));
@@ -429,7 +429,7 @@ again: goto out_error_or_again; }else {rcu_read_unlock (); -XFS_STATS_INC (xs_ig_missed); +XFS_STATS_INC (mp, xs_ig_missed); error =xfs_iget_cache_miss (mp, pag, tp, ino, &ip, flags, lock_flags);
@@ -965,7 +965,7 @@ reclaim:xfs_ifunlock (ip);xfs_iunlock (ip,XFS_ILOCK_EXCL ); -XFS_STATS_INC (xs_ig_reclaims); +XFS_STATS_INC (ip->i_mount, xs_ig_reclaims);/* * Remove the inode from the per-AG radix tree. *
fs/xfs/xfs_inode.c +3 -3
@@ -3271,8 +3271,8 @@ xfs_iflush_cluster( }if (clcount) { -XFS_STATS_INC (xs_icluster_flushcnt); -XFS_STATS_ADD (xs_icluster_flushinode, clcount); +XFS_STATS_INC (mp, xs_icluster_flushcnt); +XFS_STATS_ADD (mp, xs_icluster_flushinode, clcount); } out_free:
@@ -3345,7 +3345,7 @@ xfs_iflush(struct xfs_dinode *dip;int error; -XFS_STATS_INC (xs_iflush_count); +XFS_STATS_INC (mp, xs_iflush_count);ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL |XFS_ILOCK_SHARED ));ASSERT (xfs_isiflocked (ip));
fs/xfs/xfs_ioctl.c +1 -1
@@ -1028,7 +1028,7 @@ xfs_ioctl_setattr_xflags(xfs_diflags_to_linux (ip);xfs_trans_ichgtime (tp, ip,XFS_ICHGTIME_CHG );xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -XFS_STATS_INC (xs_ig_attrchg); +XFS_STATS_INC (mp, xs_ig_attrchg);return 0 ; }
fs/xfs/xfs_iomap.c +2 -2
@@ -670,7 +670,7 @@ xfs_iomap_write_allocate( count_fsb = imap->br_blockcount; map_start_fsb = imap->br_startoff; -XFS_STATS_ADD (xs_xstrat_bytes,XFS_FSB_TO_B (mp, count_fsb)); +XFS_STATS_ADD (mp, xs_xstrat_bytes,XFS_FSB_TO_B (mp, count_fsb));while (count_fsb !=0 ) {/*
@@ -777,7 +777,7 @@ xfs_iomap_write_allocate(if ((offset_fsb >= imap->br_startoff) && (offset_fsb < (imap->br_startoff + imap->br_blockcount))) { -XFS_STATS_INC (xs_xstrat_quick); +XFS_STATS_INC (mp, xs_xstrat_quick);return 0 ; }
fs/xfs/xfs_iops.c +2 -2
@@ -695,7 +695,7 @@ xfs_setattr_nonsize(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -XFS_STATS_INC (xs_ig_attrchg); +XFS_STATS_INC (mp, xs_ig_attrchg);if (mp->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (tp);
@@ -922,7 +922,7 @@ xfs_setattr_size(xfs_trans_log_inode (tp, ip,XFS_ILOG_CORE ); -XFS_STATS_INC (xs_ig_attrchg); +XFS_STATS_INC (mp, xs_ig_attrchg);if (mp->m_flags &XFS_MOUNT_WSYNC )xfs_trans_set_sync (tp);
fs/xfs/xfs_log.c +11 -11
@@ -268,7 +268,7 @@ xlog_grant_head_wait(__set_current_state (TASK_UNINTERRUPTIBLE );spin_unlock (&head->lock); -XFS_STATS_INC (xs_sleep_logspace); +XFS_STATS_INC (log->l_mp, xs_sleep_logspace);trace_xfs_log_grant_sleep (log, tic);schedule ();
@@ -379,7 +379,7 @@ xfs_log_regrant(if (XLOG_FORCED_SHUTDOWN (log))return -EIO ; -XFS_STATS_INC (xs_try_logspace); +XFS_STATS_INC (mp, xs_try_logspace);/* * This is a new transaction on the ticket, so we need to change the
@@ -448,7 +448,7 @@ xfs_log_reserve(if (XLOG_FORCED_SHUTDOWN (log))return -EIO ; -XFS_STATS_INC (xs_try_logspace); +XFS_STATS_INC (mp, xs_try_logspace);ASSERT (*ticp ==NULL ); tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent,
@@ -1768,7 +1768,7 @@ xlog_sync(int v2 =xfs_sb_version_haslogv2 (&log->l_mp->m_sb);int size; -XFS_STATS_INC (xs_log_writes); +XFS_STATS_INC (log->l_mp, xs_log_writes);ASSERT (atomic_read (&iclog->ic_refcnt) ==0 );/* Add for LR header */
@@ -1805,7 +1805,7 @@ xlog_sync( bp = iclog->ic_bp;XFS_BUF_SET_ADDR (bp,BLOCK_LSN (be64_to_cpu (iclog->ic_header.h_lsn))); -XFS_STATS_ADD (xs_log_blocks,BTOBB (count)); +XFS_STATS_ADD (log->l_mp, xs_log_blocks,BTOBB (count));/* Do we need to split this write into 2 parts? */ if (XFS_BUF_ADDR (bp) +BTOBB (count) > log->l_logBBsize) {
@@ -2913,7 +2913,7 @@ restart: iclog = log->l_iclog;if (iclog->ic_state !=XLOG_STATE_ACTIVE ) { -XFS_STATS_INC (xs_log_noiclogs); +XFS_STATS_INC (log->l_mp, xs_log_noiclogs);/* Wait for log writes to have flushed */ xlog_wait (&log->l_flush_wait, &log->l_icloglock);
@@ -3212,7 +3212,7 @@ _xfs_log_force(struct xlog_in_core *iclog;xfs_lsn_t lsn; -XFS_STATS_INC (xs_log_force); +XFS_STATS_INC (mp, xs_log_force);xlog_cil_force (log);
@@ -3297,7 +3297,7 @@ maybe_sleep:spin_unlock (&log->l_icloglock);return -EIO ; } -XFS_STATS_INC (xs_log_force_sleep); +XFS_STATS_INC (mp, xs_log_force_sleep);xlog_wait (&iclog->ic_force_wait, &log->l_icloglock);/* * No need to grab the log lock here since we're
@@ -3362,7 +3362,7 @@ _xfs_log_force_lsn(ASSERT (lsn !=0 ); -XFS_STATS_INC (xs_log_force); +XFS_STATS_INC (mp, xs_log_force); lsn =xlog_cil_force_lsn (log, lsn);if (lsn ==NULLCOMMITLSN )
@@ -3411,7 +3411,7 @@ try_again: (XLOG_STATE_WANT_SYNC | XLOG_STATE_SYNCING))) {ASSERT (!(iclog->ic_state &XLOG_STATE_IOERROR )); -XFS_STATS_INC (xs_log_force_sleep); +XFS_STATS_INC (mp, xs_log_force_sleep);xlog_wait (&iclog->ic_prev->ic_write_wait, &log->l_icloglock);
@@ -3441,7 +3441,7 @@ try_again:spin_unlock (&log->l_icloglock);return -EIO ; } -XFS_STATS_INC (xs_log_force_sleep); +XFS_STATS_INC (mp, xs_log_force_sleep);xlog_wait (&iclog->ic_force_wait, &log->l_icloglock);/* * No need to grab the log lock here since we're
fs/xfs/xfs_qm.c +7 -7
@@ -184,7 +184,7 @@ xfs_qm_dqpurge(*/ ASSERT (!list_empty (&dqp->q_lru));list_lru_del (&qi->qi_lru, &dqp->q_lru); -XFS_STATS_DEC (xs_qm_dquot_unused); +XFS_STATS_DEC (mp, xs_qm_dquot_unused);xfs_qm_dqdestroy (dqp);return 0 ;
@@ -448,11 +448,11 @@ xfs_qm_dquot_isolate(*/ if (dqp->q_nrefs) {xfs_dqunlock (dqp); -XFS_STATS_INC (xs_qm_dqwants); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqwants);trace_xfs_dqreclaim_want (dqp);list_lru_isolate (lru, &dqp->q_lru); -XFS_STATS_DEC (xs_qm_dquot_unused); +XFS_STATS_DEC (dqp->q_mount, xs_qm_dquot_unused);return LRU_REMOVED ; }
@@ -496,19 +496,19 @@ xfs_qm_dquot_isolate(ASSERT (dqp->q_nrefs ==0 );list_lru_isolate_move (lru, &dqp->q_lru, &isol->dispose); -XFS_STATS_DEC (xs_qm_dquot_unused); +XFS_STATS_DEC (dqp->q_mount, xs_qm_dquot_unused);trace_xfs_dqreclaim_done (dqp); -XFS_STATS_INC (xs_qm_dqreclaims); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqreclaims);return LRU_REMOVED ; out_miss_busy:trace_xfs_dqreclaim_busy (dqp); -XFS_STATS_INC (xs_qm_dqreclaim_misses); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqreclaim_misses);return LRU_SKIP ; out_unlock_dirty:trace_xfs_dqreclaim_busy (dqp); -XFS_STATS_INC (xs_qm_dqreclaim_misses); +XFS_STATS_INC (dqp->q_mount, xs_qm_dqreclaim_misses);xfs_dqunlock (dqp);spin_lock (lru_lock);return LRU_RETRY ;
fs/xfs/xfs_stats.h +15 -6
@@ -218,14 +218,23 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);void xfs_stats_clearall (struct xfsstats __percpu *stats);extern struct xstats xfsstats; -#define XFS_STATS_INC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++) +#define XFS_STATS_INC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v++; \ +} while (0) -#define XFS_STATS_DEC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--) +#define XFS_STATS_DEC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v--; \ +} while (0) -#define XFS_STATS_ADD (v, inc) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc)) +#define XFS_STATS_ADD (mp, v, inc) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc); \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v += (inc); \ +} while (0)extern int xfs_init_procfs (void );extern void xfs_cleanup_procfs (void );
fs/xfs/xfs_super.c +3 -3
@@ -922,7 +922,7 @@ xfs_fs_destroy_inode(trace_xfs_destroy_inode (ip); -XFS_STATS_INC (vn_reclaim); +XFS_STATS_INC (ip->i_mount, vn_reclaim);ASSERT (XFS_FORCED_SHUTDOWN (ip->i_mount) || ip->i_delayed_blks ==0 );
@@ -983,8 +983,8 @@ xfs_fs_evict_inode(truncate_inode_pages_final (&inode->i_data);clear_inode (inode); -XFS_STATS_INC (vn_rele); -XFS_STATS_INC (vn_remove); +XFS_STATS_INC (ip->i_mount, vn_rele); +XFS_STATS_INC (ip->i_mount, vn_remove);xfs_inactive (ip); }
fs/xfs/xfs_trans.c +3 -3
@@ -930,9 +930,9 @@ __xfs_trans_commit(*/ if (sync) { error =_xfs_log_force_lsn (mp, commit_lsn,XFS_LOG_SYNC ,NULL ); -XFS_STATS_INC (xs_trans_sync); +XFS_STATS_INC (mp, xs_trans_sync); }else { -XFS_STATS_INC (xs_trans_async); +XFS_STATS_INC (mp, xs_trans_async); }return error;
@@ -955,7 +955,7 @@ out_unreserve:xfs_trans_free_items (tp,NULLCOMMITLSN , !!error);xfs_trans_free (tp); -XFS_STATS_INC (xs_trans_empty); +XFS_STATS_INC (mp, xs_trans_empty);return error; }
fs/xfs/xfs_trans_ail.c +6 -6
@@ -349,7 +349,7 @@ xfsaild_push( xfs_ail_min_lsn(ailp))) { ailp->xa_log_flush =0 ; -XFS_STATS_INC (xs_push_ail_flush); +XFS_STATS_INC (mp, xs_push_ail_flush);xfs_log_force (mp,XFS_LOG_SYNC ); }
@@ -371,7 +371,7 @@ xfsaild_push( goto out_done; } -XFS_STATS_INC (xs_push_ail); +XFS_STATS_INC (mp, xs_push_ail); lsn = lip->li_lsn;while ((XFS_LSN_CMP (lip->li_lsn, target) <=0 )) {
@@ -385,7 +385,7 @@ xfsaild_push( lock_result = lip->li_ops->iop_push (lip, &ailp->xa_buf_list);switch (lock_result) {case XFS_ITEM_SUCCESS : -XFS_STATS_INC (xs_push_ail_success); +XFS_STATS_INC (mp, xs_push_ail_success);trace_xfs_ail_push (lip); ailp->xa_last_pushed_lsn = lsn;
@@ -403,7 +403,7 @@ xfsaild_push(* re-try the flushing relatively soon if most of the * AIL is beeing flushed. */ -XFS_STATS_INC (xs_push_ail_flushing); +XFS_STATS_INC (mp, xs_push_ail_flushing);trace_xfs_ail_flushing (lip); flushing++;
@@ -411,14 +411,14 @@ xfsaild_push(break ;case XFS_ITEM_PINNED : -XFS_STATS_INC (xs_push_ail_pinned); +XFS_STATS_INC (mp, xs_push_ail_pinned);trace_xfs_ail_pinned (lip); stuck++; ailp->xa_log_flush++;break ;case XFS_ITEM_LOCKED : -XFS_STATS_INC (xs_push_ail_locked); +XFS_STATS_INC (mp, xs_push_ail_locked);trace_xfs_ail_locked (lip); stuck++;
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 7/7 v11] xfs: per-filesystem stats counter implementation
Quoted 17 lines · Bill O'Donnell
UPDATE:
-v11: fix errors indfs_dquot.cfunctions touching stats counts.This patch modifies the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
global counts:
/sys/fs/xfs/stats/stats
per-fs counts:/sys/fs/xfs/sda*/stats/statsglobal clear: /sys/fs/xfs/stats/stats_clear per-fs clear: /sys/fs/xfs/sda*/stats/stats_clearSigned-off-by Bill O'Donnell <[email protected]>---
...
Quoted 24 lines
fs/xfs/xfs_stats.h +10
-4@@ -218,14 +218,23 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);void xfs_stats_clearall (struct xfsstats __percpu *stats);extern struct xstats xfsstats; -#define XFS_STATS_INC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++) +#define XFS_STATS_INC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v++; \ +} while (0) -#define XFS_STATS_DEC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--) +#define XFS_STATS_DEC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v--; \ +} while (0)
fs/xfs/xfs_stats.h int xfs_stats_format(struct xfsstats __percpu *stats, char *buf); · line 240
Quoted 10 lines
fs/xfs/xfs_stats.h +5
-2-#define XFS_STATS_ADD (v, inc) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc)) +#define XFS_STATS_ADD (mp, v, inc) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc); \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v += (inc); \ +} while (0)extern int xfs_init_procfs (void );extern void xfs_cleanup_procfs (void );
One other thing that I just caught looking at the code (not enough context in the patch to see it) - this is all under #ifdef CONFIG_PROC_FS, and now that it's all moved to sysfs, we should just remove that conditional from this file. The only thing that matters w.r.t. procfs is the symlink creation, and that's already handled in xfs_init_procfs() definitions.
Dave, maybe you can just fix that on commit ...
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 7/7 v11] xfs: per-filesystem stats counter implementation
Quoted 64 lines · Eric Sandeen
Quoted 17 lines · Bill O'Donnell
UPDATE:
-v11: fix errors indfs_dquot.cfunctions touching stats counts.This patch modifies the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
global counts:
/sys/fs/xfs/stats/stats
per-fs counts:/sys/fs/xfs/sda*/stats/statsglobal clear: /sys/fs/xfs/stats/stats_clear per-fs clear: /sys/fs/xfs/sda*/stats/stats_clearSigned-off-by Bill O'Donnell <[email protected]>---
...
Quoted 24 lines
fs/xfs/xfs_stats.h +10
-4@@ -218,14 +218,23 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);void xfs_stats_clearall (struct xfsstats __percpu *stats);extern struct xstats xfsstats; -#define XFS_STATS_INC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++) +#define XFS_STATS_INC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v++; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v++; \ +} while (0) -#define XFS_STATS_DEC (v) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--) +#define XFS_STATS_DEC (mp, v) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v--; \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v--; \ +} while (0)fs/xfs/xfs_stats.h int xfs_stats_format(struct xfsstats __percpu *stats, char *buf); · line 240
Quoted 10 lines
fs/xfs/xfs_stats.h +5
-2-#define XFS_STATS_ADD (v, inc) \ - (per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc)) +#define XFS_STATS_ADD (mp, v, inc) \ +do { \ + per_cpu_ptr(xfsstats.xs_stats, current_cpu())->v += (inc); \ + per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->v += (inc); \ +} while (0)extern int xfs_init_procfs (void );extern void xfs_cleanup_procfs (void );One other thing that I just caught looking at the code (not enough context in the patch to see it) - this is all under #ifdef
CONFIG_PROC_FS, and now that it's all moved to sysfs, we should just remove that conditional from this file. The only thing that matters w.r.t. procfs is the symlink creation, and that's already handled inxfs_init_procfs()definitions.
Quoted 1 line
Dave, maybe you can just fix that on commit ...
I moved the conditional just to cover the xfs_init_procfs() definitions.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 7/7] xfs: per-filesystem stats counter implementation
In reply to Bill O'DonnellQuoted 13 lines · Bill O'Donnell
This patch modifies the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
global counts:
/sys/fs/xfs/stats/stats
per-fs counts:/sys/fs/xfs/sda*/stats/statsglobal clear: /sys/fs/xfs/stats/stats_clear per-fs clear: /sys/fs/xfs/sda*/stats/stats_clearSigned-off-by Bill O'Donnell <[email protected]>
....
fs/xfs/libxfs/xfs_btree.h union xfs_btree_rec { · line 91
Quoted 5 lines
fs/xfs/libxfs/xfs_btree.h +4
-0+#define __XFS_BTREE_STATS_INC (mp, type, stat) \ + XFS_STATS_INC(mp, xs_ ## type ## _2_ ## stat) +#define XFS_BTREE_STATS_INC (cur, stat) \ do { \ + struct xfs_mount *mp = cur->bc_mp; \
This will cause gcc to throw "shadow definition" warnings in userspace as the macro will be used in functions that already have a "mp" variable defined. In general, variables within a macro like this are given a "__" prefix so such namespace collisions are unlikely. I'll fix this up manually.
Otherwise looks OK.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
For the series:
I think we caught everything! ;)
Thanks,
-Eric
Quoted 108 lines · Bill O'Donnell
Hello-
Following is the next iteration of the series to add per-fs xfs stats to sysfs.
----------history---------------
v10:
-style fixups in patches 1,4,5,7v9:
-adjust individual patch content, so that fixes actually correspond to reviews accordingly.(quoted diff) +0
-2-fix xfs_btree.h XFS_BTREE_STATS_ADD macro error made in patch 7. -fix xfs_stats.h macro style errors made in patch 7v8: (add patches 6 and 7)
-patch 6: per-filesystem stats in sysfs.
Implement per-filesystem stats objects in sysfs. Stats objects are instantiated when an xfs filesystem is mounted and deleted on unmount. With this patch, the stats directory is created and populated with the familiar stats andstats_clearfiles.
Example:
/sys/fs/xfs/sda9/stats/stats/sys/fs/xfs/sda9/stats/stats_clearWith this patch, the individual counts within the new per-fs stats file(s) remain at zero. Functions that use the the macros to increment, decrement, and add-to the per-fs stats counts will be covered in the next patch (7).
-patch 7: per-filesystem stats counter implementation Modify the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
global counts:
/sys/fs/xfs/stats/stats
per-fs counts:/sys/fs/xfs/sda*/stats/statsglobal clear: /sys/fs/xfs/stats/stats_clear per-fs clear: /sys/fs/xfs/sda*/stats/stats_clearv7:
add patch 5/5: incorporate sysfs/kobject in xfsstats: handlers take kobjects. Allocate & deallocate per-fs stats structures and set up the sysfs entries for them. Add kobject and a pointer to a per-cpu struct xfsstats. Modify the macros that manipulate the stats accordingly.v6:
-moveto_xlog(kobject)to the relevant show/store operations. This keeps the xfs_sysfs_object_show/store functions generic. Also, with the change, there can be some cleanup of the show/store function arguments.v5:
(quoted diff) +0
-2-optimization of sysfs_ops function. -style fixupsv4:
-add patch 4 (sysfs ops consolidation - dbg, stats, log)v3:
-style fixups.v2:
-style fixups.
v1:
--------------------------------We already have per-fs information in /sys, so it makes sense to have per-fs stats there too. The series moves existing global stats infrastructure to /sys and reuses that code to create per-fs stats in /sys.
Patch 1 handles the bring-up and tear down of xfs/stats directory structure in sysfs when an fs is mounted. The directory contains the stats file and the
stats_clearfile. The stats file contents mimic those of/proc/fs/xfs/stat. Thestats_clearfile is empty, and much like the currentstat_clearcommand, handles the zeroing of the stats file when a "1" is echoed to thestats_clearfile.Patch 2 creates the symlink for stats from procfs to sysfs.
Patch 3 removes the now unused portions of procfs for stat.
Patch 4 consolidates the sysfs ops for dbg, stats, log.
Patch 5 allocates and deallocates per-fs stats structures and sets up the sysfs entries for them. Add kobject and a pointer to a per-cpu struct xfsstats. Modify the macros that manipulate
Patch 6 implements per-filesystem stats objects in sysfs. Stats objects are instantiated when an xfs filesystem is mounted and deleted on unmount.
Patch 7 modifies the stats counting macros and the callers to those macros to properly increment, decrement, and add-to the xfs stats counts. The counts for global and per-fs stats are correctly advanced, and cleared by writing a "1" to the corresponding clear file.
Once again, comments and questions are welcome.
Quoted 8 lines
Thanks-
Bill_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs