Lines Matching +full:cs +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-or-later
20 /* all 32-bit counters here */
37 /* all 64-bit items here */
43 /* non-counter state must go at the end for clearall */
88 struct xchk_stats *cs, in xchk_stats_format() argument
92 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_format()
94 ssize_t copied = 0; in xchk_stats_format()
95 int ret = 0; in xchk_stats_format()
97 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) { in xchk_stats_format()
104 (unsigned int)css->invocations, in xchk_stats_format()
105 (unsigned int)css->clean, in xchk_stats_format()
106 (unsigned int)css->corrupt, in xchk_stats_format()
107 (unsigned int)css->preen, in xchk_stats_format()
108 (unsigned int)css->xfail, in xchk_stats_format()
109 (unsigned int)css->xcorrupt, in xchk_stats_format()
110 (unsigned int)css->incomplete, in xchk_stats_format()
111 (unsigned int)css->warning, in xchk_stats_format()
112 (unsigned int)css->retries, in xchk_stats_format()
113 (unsigned long long)css->checktime_us, in xchk_stats_format()
114 (unsigned int)css->repair_invocations, in xchk_stats_format()
115 (unsigned int)css->repair_success, in xchk_stats_format()
116 (unsigned long long)css->repairtime_us); in xchk_stats_format()
117 if (ret <= 0) in xchk_stats_format()
120 remaining -= ret; in xchk_stats_format()
125 return copied > 0 ? copied : ret; in xchk_stats_format()
131 struct xchk_stats *cs) in xchk_stats_estimate_bufsize() argument
133 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_estimate_bufsize()
136 size_t ret = 0; in xchk_stats_estimate_bufsize()
143 field_width += 21 * ((offsetof(struct xchk_scrub_stats, css_lock) - in xchk_stats_estimate_bufsize()
147 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) { in xchk_stats_estimate_bufsize()
164 struct xchk_stats *cs) in xchk_stats_clearall() argument
166 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_clearall()
169 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) { in xchk_stats_clearall()
170 spin_lock(&css->css_lock); in xchk_stats_clearall()
171 memset(css, 0, offsetof(struct xchk_scrub_stats, css_lock)); in xchk_stats_clearall()
172 spin_unlock(&css->css_lock); in xchk_stats_clearall()
185 struct xchk_stats *cs, in xchk_stats_merge_one() argument
191 if (sm->sm_type >= XFS_SCRUB_TYPE_NR) { in xchk_stats_merge_one()
192 ASSERT(sm->sm_type < XFS_SCRUB_TYPE_NR); in xchk_stats_merge_one()
196 css = &cs->cs_stats[sm->sm_type]; in xchk_stats_merge_one()
197 spin_lock(&css->css_lock); in xchk_stats_merge_one()
198 css->invocations++; in xchk_stats_merge_one()
199 if (!(sm->sm_flags & XFS_SCRUB_OFLAG_UNCLEAN)) in xchk_stats_merge_one()
200 css->clean++; in xchk_stats_merge_one()
201 if (sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_stats_merge_one()
202 css->corrupt++; in xchk_stats_merge_one()
203 if (sm->sm_flags & XFS_SCRUB_OFLAG_PREEN) in xchk_stats_merge_one()
204 css->preen++; in xchk_stats_merge_one()
205 if (sm->sm_flags & XFS_SCRUB_OFLAG_XFAIL) in xchk_stats_merge_one()
206 css->xfail++; in xchk_stats_merge_one()
207 if (sm->sm_flags & XFS_SCRUB_OFLAG_XCORRUPT) in xchk_stats_merge_one()
208 css->xcorrupt++; in xchk_stats_merge_one()
209 if (sm->sm_flags & XFS_SCRUB_OFLAG_INCOMPLETE) in xchk_stats_merge_one()
210 css->incomplete++; in xchk_stats_merge_one()
211 if (sm->sm_flags & XFS_SCRUB_OFLAG_WARNING) in xchk_stats_merge_one()
212 css->warning++; in xchk_stats_merge_one()
213 css->retries += run->retries; in xchk_stats_merge_one()
214 css->checktime_us += howmany_64(run->scrub_ns, NSEC_PER_USEC); in xchk_stats_merge_one()
216 if (run->repair_attempted) in xchk_stats_merge_one()
217 css->repair_invocations++; in xchk_stats_merge_one()
218 if (run->repair_succeeded) in xchk_stats_merge_one()
219 css->repair_success++; in xchk_stats_merge_one()
220 css->repairtime_us += howmany_64(run->repair_ns, NSEC_PER_USEC); in xchk_stats_merge_one()
221 spin_unlock(&css->css_lock); in xchk_stats_merge_one()
224 /* Merge these scrub-run stats into the global and mount stat data. */
232 xchk_stats_merge_one(mp->m_scrub_stats, sm, run); in xchk_stats_merge()
244 struct xchk_stats *cs = file->private_data; in xchk_scrub_stats_read() local
252 * If the file position is greater than 0, return a short read. in xchk_scrub_stats_read()
254 if (*ppos > 0) in xchk_scrub_stats_read()
255 return 0; in xchk_scrub_stats_read()
257 bufsize = xchk_stats_estimate_bufsize(cs); in xchk_scrub_stats_read()
261 return -ENOMEM; in xchk_scrub_stats_read()
263 avail = xchk_stats_format(cs, buf, bufsize); in xchk_scrub_stats_read()
264 if (avail < 0) { in xchk_scrub_stats_read()
287 struct xchk_stats *cs = file->private_data; in xchk_clear_scrub_stats_write() local
291 ret = kstrtouint_from_user(ubuf, count, 0, &val); in xchk_clear_scrub_stats_write()
296 return -EINVAL; in xchk_clear_scrub_stats_write()
298 xchk_stats_clearall(cs); in xchk_clear_scrub_stats_write()
310 struct xchk_stats *cs, in xchk_stats_init() argument
313 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_init()
316 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) in xchk_stats_init()
317 spin_lock_init(&css->css_lock); in xchk_stats_init()
319 return 0; in xchk_stats_init()
325 struct xchk_stats *cs, in xchk_stats_register() argument
331 cs->cs_debugfs = xfs_debugfs_mkdir("scrub", parent); in xchk_stats_register()
332 if (!cs->cs_debugfs) in xchk_stats_register()
335 debugfs_create_file("stats", 0444, cs->cs_debugfs, cs, in xchk_stats_register()
337 debugfs_create_file("clear_stats", 0200, cs->cs_debugfs, cs, in xchk_stats_register()
344 struct xchk_stats *cs) in xchk_stats_teardown() argument
346 return 0; in xchk_stats_teardown()
352 struct xchk_stats *cs) in xchk_stats_unregister() argument
354 debugfs_remove(cs->cs_debugfs); in xchk_stats_unregister()
369 return 0; in xchk_global_stats_setup()
380 /* Allocate per-mount stats */
385 struct xchk_stats *cs; in xchk_mount_stats_alloc() local
388 cs = kvzalloc(sizeof(struct xchk_stats), GFP_KERNEL); in xchk_mount_stats_alloc()
389 if (!cs) in xchk_mount_stats_alloc()
390 return -ENOMEM; in xchk_mount_stats_alloc()
392 error = xchk_stats_init(cs, mp); in xchk_mount_stats_alloc()
396 mp->m_scrub_stats = cs; in xchk_mount_stats_alloc()
397 return 0; in xchk_mount_stats_alloc()
399 kvfree(cs); in xchk_mount_stats_alloc()
403 /* Free per-mount stats */
408 xchk_stats_teardown(mp->m_scrub_stats); in xchk_mount_stats_free()
409 kvfree(mp->m_scrub_stats); in xchk_mount_stats_free()
410 mp->m_scrub_stats = NULL; in xchk_mount_stats_free()