diff options
author | Carlos Maiolino <cmaiolino@redhat.com> | 2018-10-18 02:21:39 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2018-10-18 02:21:39 -0400 |
commit | 26ca39015ef210d728df53d66c1ae85e8b48b2f3 (patch) | |
tree | 7008ec8f6605d864c0bc7c7449ddb2139ae98b95 | |
parent | 41657e5507b13e963be906d5d874f4f02374fd5c (diff) |
xfs: use offsetof() in place of offset macros for __xfsstats
Most offset macro mess is used in xfs_stats_format() only, and we can
simply get the right offsets using offsetof(), instead of several macros
to mark the offsets inside __xfsstats structure.
Replace all XFSSTAT_END_* macros by a single helper macro to get the
right offset into __xfsstats, and use this helper in xfs_stats_format()
directly.
The quota stats code, still looks a bit cleaner when using XFSSTAT_*
macros, so, this patch also defines XFSSTAT_START_XQMSTAT and
XFSSTAT_END_XQMSTAT locally to that code. This also should prevent
offset mistakes when updates are done into __xfsstats.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/xfs_stats.c | 52 | ||||
-rw-r--r-- | fs/xfs/xfs_stats.h | 28 |
2 files changed, 31 insertions, 49 deletions
diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c index 740ac9674848..cc509743facd 100644 --- a/fs/xfs/xfs_stats.c +++ b/fs/xfs/xfs_stats.c | |||
@@ -29,30 +29,30 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf) | |||
29 | char *desc; | 29 | char *desc; |
30 | int endpoint; | 30 | int endpoint; |
31 | } xstats[] = { | 31 | } xstats[] = { |
32 | { "extent_alloc", XFSSTAT_END_EXTENT_ALLOC }, | 32 | { "extent_alloc", xfsstats_offset(xs_abt_lookup) }, |
33 | { "abt", XFSSTAT_END_ALLOC_BTREE }, | 33 | { "abt", xfsstats_offset(xs_blk_mapr) }, |
34 | { "blk_map", XFSSTAT_END_BLOCK_MAPPING }, | 34 | { "blk_map", xfsstats_offset(xs_bmbt_lookup) }, |
35 | { "bmbt", XFSSTAT_END_BLOCK_MAP_BTREE }, | 35 | { "bmbt", xfsstats_offset(xs_dir_lookup) }, |
36 | { "dir", XFSSTAT_END_DIRECTORY_OPS }, | 36 | { "dir", xfsstats_offset(xs_trans_sync) }, |
37 | { "trans", XFSSTAT_END_TRANSACTIONS }, | 37 | { "trans", xfsstats_offset(xs_ig_attempts) }, |
38 | { "ig", XFSSTAT_END_INODE_OPS }, | 38 | { "ig", xfsstats_offset(xs_log_writes) }, |
39 | { "log", XFSSTAT_END_LOG_OPS }, | 39 | { "log", xfsstats_offset(xs_try_logspace)}, |
40 | { "push_ail", XFSSTAT_END_TAIL_PUSHING }, | 40 | { "push_ail", xfsstats_offset(xs_xstrat_quick)}, |
41 | { "xstrat", XFSSTAT_END_WRITE_CONVERT }, | 41 | { "xstrat", xfsstats_offset(xs_write_calls) }, |
42 | { "rw", XFSSTAT_END_READ_WRITE_OPS }, | 42 | { "rw", xfsstats_offset(xs_attr_get) }, |
43 | { "attr", XFSSTAT_END_ATTRIBUTE_OPS }, | 43 | { "attr", xfsstats_offset(xs_iflush_count)}, |
44 | { "icluster", XFSSTAT_END_INODE_CLUSTER }, | 44 | { "icluster", xfsstats_offset(vn_active) }, |
45 | { "vnodes", XFSSTAT_END_VNODE_OPS }, | 45 | { "vnodes", xfsstats_offset(xb_get) }, |
46 | { "buf", XFSSTAT_END_BUF }, | 46 | { "buf", xfsstats_offset(xs_abtb_2) }, |
47 | { "abtb2", XFSSTAT_END_ABTB_V2 }, | 47 | { "abtb2", xfsstats_offset(xs_abtc_2) }, |
48 | { "abtc2", XFSSTAT_END_ABTC_V2 }, | 48 | { "abtc2", xfsstats_offset(xs_bmbt_2) }, |
49 | { "bmbt2", XFSSTAT_END_BMBT_V2 }, | 49 | { "bmbt2", xfsstats_offset(xs_ibt_2) }, |
50 | { "ibt2", XFSSTAT_END_IBT_V2 }, | 50 | { "ibt2", xfsstats_offset(xs_fibt_2) }, |
51 | { "fibt2", XFSSTAT_END_FIBT_V2 }, | 51 | { "fibt2", xfsstats_offset(xs_rmap_2) }, |
52 | { "rmapbt", XFSSTAT_END_RMAP_V2 }, | 52 | { "rmapbt", xfsstats_offset(xs_refcbt_2) }, |
53 | { "refcntbt", XFSSTAT_END_REFCOUNT }, | 53 | { "refcntbt", xfsstats_offset(xs_qm_dqreclaims)}, |
54 | /* we print both series of quota information together */ | 54 | /* we print both series of quota information together */ |
55 | { "qm", XFSSTAT_END_QM }, | 55 | { "qm", xfsstats_offset(xs_xstrat_bytes)}, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | /* Loop over all stats groups */ | 58 | /* Loop over all stats groups */ |
@@ -104,6 +104,10 @@ void xfs_stats_clearall(struct xfsstats __percpu *stats) | |||
104 | #ifdef CONFIG_PROC_FS | 104 | #ifdef CONFIG_PROC_FS |
105 | /* legacy quota interfaces */ | 105 | /* legacy quota interfaces */ |
106 | #ifdef CONFIG_XFS_QUOTA | 106 | #ifdef CONFIG_XFS_QUOTA |
107 | |||
108 | #define XFSSTAT_START_XQMSTAT xfsstats_offset(xs_qm_dqreclaims) | ||
109 | #define XFSSTAT_END_XQMSTAT xfsstats_offset(xs_qm_dquot) | ||
110 | |||
107 | static int xqm_proc_show(struct seq_file *m, void *v) | 111 | static int xqm_proc_show(struct seq_file *m, void *v) |
108 | { | 112 | { |
109 | /* maximum; incore; ratio free to inuse; freelist */ | 113 | /* maximum; incore; ratio free to inuse; freelist */ |
@@ -119,7 +123,7 @@ static int xqmstat_proc_show(struct seq_file *m, void *v) | |||
119 | int j; | 123 | int j; |
120 | 124 | ||
121 | seq_printf(m, "qm"); | 125 | seq_printf(m, "qm"); |
122 | for (j = XFSSTAT_END_REFCOUNT; j < XFSSTAT_END_XQMSTAT; j++) | 126 | for (j = XFSSTAT_START_XQMSTAT; j < XFSSTAT_END_XQMSTAT; j++) |
123 | seq_printf(m, " %u", counter_val(xfsstats.xs_stats, j)); | 127 | seq_printf(m, " %u", counter_val(xfsstats.xs_stats, j)); |
124 | seq_putc(m, '\n'); | 128 | seq_putc(m, '\n'); |
125 | return 0; | 129 | return 0; |
diff --git a/fs/xfs/xfs_stats.h b/fs/xfs/xfs_stats.h index 130db070e4d8..34d704f703d2 100644 --- a/fs/xfs/xfs_stats.h +++ b/fs/xfs/xfs_stats.h | |||
@@ -41,17 +41,14 @@ enum { | |||
41 | * XFS global statistics | 41 | * XFS global statistics |
42 | */ | 42 | */ |
43 | struct __xfsstats { | 43 | struct __xfsstats { |
44 | # define XFSSTAT_END_EXTENT_ALLOC 4 | ||
45 | uint32_t xs_allocx; | 44 | uint32_t xs_allocx; |
46 | uint32_t xs_allocb; | 45 | uint32_t xs_allocb; |
47 | uint32_t xs_freex; | 46 | uint32_t xs_freex; |
48 | uint32_t xs_freeb; | 47 | uint32_t xs_freeb; |
49 | # define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4) | ||
50 | uint32_t xs_abt_lookup; | 48 | uint32_t xs_abt_lookup; |
51 | uint32_t xs_abt_compare; | 49 | uint32_t xs_abt_compare; |
52 | uint32_t xs_abt_insrec; | 50 | uint32_t xs_abt_insrec; |
53 | uint32_t xs_abt_delrec; | 51 | uint32_t xs_abt_delrec; |
54 | # define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7) | ||
55 | uint32_t xs_blk_mapr; | 52 | uint32_t xs_blk_mapr; |
56 | uint32_t xs_blk_mapw; | 53 | uint32_t xs_blk_mapw; |
57 | uint32_t xs_blk_unmap; | 54 | uint32_t xs_blk_unmap; |
@@ -59,21 +56,17 @@ struct __xfsstats { | |||
59 | uint32_t xs_del_exlist; | 56 | uint32_t xs_del_exlist; |
60 | uint32_t xs_look_exlist; | 57 | uint32_t xs_look_exlist; |
61 | uint32_t xs_cmp_exlist; | 58 | uint32_t xs_cmp_exlist; |
62 | # define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4) | ||
63 | uint32_t xs_bmbt_lookup; | 59 | uint32_t xs_bmbt_lookup; |
64 | uint32_t xs_bmbt_compare; | 60 | uint32_t xs_bmbt_compare; |
65 | uint32_t xs_bmbt_insrec; | 61 | uint32_t xs_bmbt_insrec; |
66 | uint32_t xs_bmbt_delrec; | 62 | uint32_t xs_bmbt_delrec; |
67 | # define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4) | ||
68 | uint32_t xs_dir_lookup; | 63 | uint32_t xs_dir_lookup; |
69 | uint32_t xs_dir_create; | 64 | uint32_t xs_dir_create; |
70 | uint32_t xs_dir_remove; | 65 | uint32_t xs_dir_remove; |
71 | uint32_t xs_dir_getdents; | 66 | uint32_t xs_dir_getdents; |
72 | # define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3) | ||
73 | uint32_t xs_trans_sync; | 67 | uint32_t xs_trans_sync; |
74 | uint32_t xs_trans_async; | 68 | uint32_t xs_trans_async; |
75 | uint32_t xs_trans_empty; | 69 | uint32_t xs_trans_empty; |
76 | # define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7) | ||
77 | uint32_t xs_ig_attempts; | 70 | uint32_t xs_ig_attempts; |
78 | uint32_t xs_ig_found; | 71 | uint32_t xs_ig_found; |
79 | uint32_t xs_ig_frecycle; | 72 | uint32_t xs_ig_frecycle; |
@@ -81,13 +74,11 @@ struct __xfsstats { | |||
81 | uint32_t xs_ig_dup; | 74 | uint32_t xs_ig_dup; |
82 | uint32_t xs_ig_reclaims; | 75 | uint32_t xs_ig_reclaims; |
83 | uint32_t xs_ig_attrchg; | 76 | uint32_t xs_ig_attrchg; |
84 | # define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5) | ||
85 | uint32_t xs_log_writes; | 77 | uint32_t xs_log_writes; |
86 | uint32_t xs_log_blocks; | 78 | uint32_t xs_log_blocks; |
87 | uint32_t xs_log_noiclogs; | 79 | uint32_t xs_log_noiclogs; |
88 | uint32_t xs_log_force; | 80 | uint32_t xs_log_force; |
89 | uint32_t xs_log_force_sleep; | 81 | uint32_t xs_log_force_sleep; |
90 | # define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10) | ||
91 | uint32_t xs_try_logspace; | 82 | uint32_t xs_try_logspace; |
92 | uint32_t xs_sleep_logspace; | 83 | uint32_t xs_sleep_logspace; |
93 | uint32_t xs_push_ail; | 84 | uint32_t xs_push_ail; |
@@ -98,22 +89,17 @@ struct __xfsstats { | |||
98 | uint32_t xs_push_ail_flushing; | 89 | uint32_t xs_push_ail_flushing; |
99 | uint32_t xs_push_ail_restarts; | 90 | uint32_t xs_push_ail_restarts; |
100 | uint32_t xs_push_ail_flush; | 91 | uint32_t xs_push_ail_flush; |
101 | # define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2) | ||
102 | uint32_t xs_xstrat_quick; | 92 | uint32_t xs_xstrat_quick; |
103 | uint32_t xs_xstrat_split; | 93 | uint32_t xs_xstrat_split; |
104 | # define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2) | ||
105 | uint32_t xs_write_calls; | 94 | uint32_t xs_write_calls; |
106 | uint32_t xs_read_calls; | 95 | uint32_t xs_read_calls; |
107 | # define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4) | ||
108 | uint32_t xs_attr_get; | 96 | uint32_t xs_attr_get; |
109 | uint32_t xs_attr_set; | 97 | uint32_t xs_attr_set; |
110 | uint32_t xs_attr_remove; | 98 | uint32_t xs_attr_remove; |
111 | uint32_t xs_attr_list; | 99 | uint32_t xs_attr_list; |
112 | # define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3) | ||
113 | uint32_t xs_iflush_count; | 100 | uint32_t xs_iflush_count; |
114 | uint32_t xs_icluster_flushcnt; | 101 | uint32_t xs_icluster_flushcnt; |
115 | uint32_t xs_icluster_flushinode; | 102 | uint32_t xs_icluster_flushinode; |
116 | # define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8) | ||
117 | uint32_t vn_active; /* # vnodes not on free lists */ | 103 | uint32_t vn_active; /* # vnodes not on free lists */ |
118 | uint32_t vn_alloc; /* # times vn_alloc called */ | 104 | uint32_t vn_alloc; /* # times vn_alloc called */ |
119 | uint32_t vn_get; /* # times vn_get called */ | 105 | uint32_t vn_get; /* # times vn_get called */ |
@@ -122,7 +108,6 @@ struct __xfsstats { | |||
122 | uint32_t vn_reclaim; /* # times vn_reclaim called */ | 108 | uint32_t vn_reclaim; /* # times vn_reclaim called */ |
123 | uint32_t vn_remove; /* # times vn_remove called */ | 109 | uint32_t vn_remove; /* # times vn_remove called */ |
124 | uint32_t vn_free; /* # times vn_free called */ | 110 | uint32_t vn_free; /* # times vn_free called */ |
125 | #define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9) | ||
126 | uint32_t xb_get; | 111 | uint32_t xb_get; |
127 | uint32_t xb_create; | 112 | uint32_t xb_create; |
128 | uint32_t xb_get_locked; | 113 | uint32_t xb_get_locked; |
@@ -133,28 +118,19 @@ struct __xfsstats { | |||
133 | uint32_t xb_page_found; | 118 | uint32_t xb_page_found; |
134 | uint32_t xb_get_read; | 119 | uint32_t xb_get_read; |
135 | /* Version 2 btree counters */ | 120 | /* Version 2 btree counters */ |
136 | #define XFSSTAT_END_ABTB_V2 (XFSSTAT_END_BUF + __XBTS_MAX) | ||
137 | uint32_t xs_abtb_2[__XBTS_MAX]; | 121 | uint32_t xs_abtb_2[__XBTS_MAX]; |
138 | #define XFSSTAT_END_ABTC_V2 (XFSSTAT_END_ABTB_V2 + __XBTS_MAX) | ||
139 | uint32_t xs_abtc_2[__XBTS_MAX]; | 122 | uint32_t xs_abtc_2[__XBTS_MAX]; |
140 | #define XFSSTAT_END_BMBT_V2 (XFSSTAT_END_ABTC_V2 + __XBTS_MAX) | ||
141 | uint32_t xs_bmbt_2[__XBTS_MAX]; | 123 | uint32_t xs_bmbt_2[__XBTS_MAX]; |
142 | #define XFSSTAT_END_IBT_V2 (XFSSTAT_END_BMBT_V2 + __XBTS_MAX) | ||
143 | uint32_t xs_ibt_2[__XBTS_MAX]; | 124 | uint32_t xs_ibt_2[__XBTS_MAX]; |
144 | #define XFSSTAT_END_FIBT_V2 (XFSSTAT_END_IBT_V2 + __XBTS_MAX) | ||
145 | uint32_t xs_fibt_2[__XBTS_MAX]; | 125 | uint32_t xs_fibt_2[__XBTS_MAX]; |
146 | #define XFSSTAT_END_RMAP_V2 (XFSSTAT_END_FIBT_V2 + __XBTS_MAX) | ||
147 | uint32_t xs_rmap_2[__XBTS_MAX]; | 126 | uint32_t xs_rmap_2[__XBTS_MAX]; |
148 | #define XFSSTAT_END_REFCOUNT (XFSSTAT_END_RMAP_V2 + __XBTS_MAX) | ||
149 | uint32_t xs_refcbt_2[__XBTS_MAX]; | 127 | uint32_t xs_refcbt_2[__XBTS_MAX]; |
150 | #define XFSSTAT_END_XQMSTAT (XFSSTAT_END_REFCOUNT + 6) | ||
151 | uint32_t xs_qm_dqreclaims; | 128 | uint32_t xs_qm_dqreclaims; |
152 | uint32_t xs_qm_dqreclaim_misses; | 129 | uint32_t xs_qm_dqreclaim_misses; |
153 | uint32_t xs_qm_dquot_dups; | 130 | uint32_t xs_qm_dquot_dups; |
154 | uint32_t xs_qm_dqcachemisses; | 131 | uint32_t xs_qm_dqcachemisses; |
155 | uint32_t xs_qm_dqcachehits; | 132 | uint32_t xs_qm_dqcachehits; |
156 | uint32_t xs_qm_dqwants; | 133 | uint32_t xs_qm_dqwants; |
157 | #define XFSSTAT_END_QM (XFSSTAT_END_XQMSTAT+2) | ||
158 | uint32_t xs_qm_dquot; | 134 | uint32_t xs_qm_dquot; |
159 | uint32_t xs_qm_dquot_unused; | 135 | uint32_t xs_qm_dquot_unused; |
160 | /* Extra precision counters */ | 136 | /* Extra precision counters */ |
@@ -163,10 +139,12 @@ struct __xfsstats { | |||
163 | uint64_t xs_read_bytes; | 139 | uint64_t xs_read_bytes; |
164 | }; | 140 | }; |
165 | 141 | ||
142 | #define xfsstats_offset(f) (offsetof(struct __xfsstats, f)/sizeof(uint32_t)) | ||
143 | |||
166 | struct xfsstats { | 144 | struct xfsstats { |
167 | union { | 145 | union { |
168 | struct __xfsstats s; | 146 | struct __xfsstats s; |
169 | uint32_t a[XFSSTAT_END_XQMSTAT]; | 147 | uint32_t a[xfsstats_offset(xs_qm_dquot)]; |
170 | }; | 148 | }; |
171 | }; | 149 | }; |
172 | 150 | ||