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 */
85 struct xchk_stats *cs, in xchk_stats_format() argument
89 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_format()
91 ssize_t copied = 0; in xchk_stats_format()
92 int ret = 0; in xchk_stats_format()
94 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) { in xchk_stats_format()
101 (unsigned int)css->invocations, in xchk_stats_format()
102 (unsigned int)css->clean, in xchk_stats_format()
103 (unsigned int)css->corrupt, in xchk_stats_format()
104 (unsigned int)css->preen, in xchk_stats_format()
105 (unsigned int)css->xfail, in xchk_stats_format()
106 (unsigned int)css->xcorrupt, in xchk_stats_format()
107 (unsigned int)css->incomplete, in xchk_stats_format()
108 (unsigned int)css->warning, in xchk_stats_format()
109 (unsigned int)css->retries, in xchk_stats_format()
110 (unsigned long long)css->checktime_us, in xchk_stats_format()
111 (unsigned int)css->repair_invocations, in xchk_stats_format()
112 (unsigned int)css->repair_success, in xchk_stats_format()
113 (unsigned long long)css->repairtime_us); in xchk_stats_format()
114 if (ret <= 0) in xchk_stats_format()
117 remaining -= ret; in xchk_stats_format()
122 return copied > 0 ? copied : ret; in xchk_stats_format()
128 struct xchk_stats *cs) in xchk_stats_estimate_bufsize() argument
130 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_estimate_bufsize()
133 size_t ret = 0; in xchk_stats_estimate_bufsize()
140 field_width += 21 * ((offsetof(struct xchk_scrub_stats, css_lock) - in xchk_stats_estimate_bufsize()
144 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) { in xchk_stats_estimate_bufsize()
161 struct xchk_stats *cs) in xchk_stats_clearall() argument
163 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_clearall()
166 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) { in xchk_stats_clearall()
167 spin_lock(&css->css_lock); in xchk_stats_clearall()
168 memset(css, 0, offsetof(struct xchk_scrub_stats, css_lock)); in xchk_stats_clearall()
169 spin_unlock(&css->css_lock); in xchk_stats_clearall()
182 struct xchk_stats *cs, in xchk_stats_merge_one() argument
188 if (sm->sm_type >= XFS_SCRUB_TYPE_NR) { in xchk_stats_merge_one()
189 ASSERT(sm->sm_type < XFS_SCRUB_TYPE_NR); in xchk_stats_merge_one()
193 css = &cs->cs_stats[sm->sm_type]; in xchk_stats_merge_one()
194 spin_lock(&css->css_lock); in xchk_stats_merge_one()
195 css->invocations++; in xchk_stats_merge_one()
196 if (!(sm->sm_flags & XFS_SCRUB_OFLAG_UNCLEAN)) in xchk_stats_merge_one()
197 css->clean++; in xchk_stats_merge_one()
198 if (sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_stats_merge_one()
199 css->corrupt++; in xchk_stats_merge_one()
200 if (sm->sm_flags & XFS_SCRUB_OFLAG_PREEN) in xchk_stats_merge_one()
201 css->preen++; in xchk_stats_merge_one()
202 if (sm->sm_flags & XFS_SCRUB_OFLAG_XFAIL) in xchk_stats_merge_one()
203 css->xfail++; in xchk_stats_merge_one()
204 if (sm->sm_flags & XFS_SCRUB_OFLAG_XCORRUPT) in xchk_stats_merge_one()
205 css->xcorrupt++; in xchk_stats_merge_one()
206 if (sm->sm_flags & XFS_SCRUB_OFLAG_INCOMPLETE) in xchk_stats_merge_one()
207 css->incomplete++; in xchk_stats_merge_one()
208 if (sm->sm_flags & XFS_SCRUB_OFLAG_WARNING) in xchk_stats_merge_one()
209 css->warning++; in xchk_stats_merge_one()
210 css->retries += run->retries; in xchk_stats_merge_one()
211 css->checktime_us += howmany_64(run->scrub_ns, NSEC_PER_USEC); in xchk_stats_merge_one()
213 if (run->repair_attempted) in xchk_stats_merge_one()
214 css->repair_invocations++; in xchk_stats_merge_one()
215 if (run->repair_succeeded) in xchk_stats_merge_one()
216 css->repair_success++; in xchk_stats_merge_one()
217 css->repairtime_us += howmany_64(run->repair_ns, NSEC_PER_USEC); in xchk_stats_merge_one()
218 spin_unlock(&css->css_lock); in xchk_stats_merge_one()
221 /* Merge these scrub-run stats into the global and mount stat data. */
229 xchk_stats_merge_one(mp->m_scrub_stats, sm, run); in xchk_stats_merge()
241 struct xchk_stats *cs = file->private_data; in xchk_scrub_stats_read() local
249 * If the file position is greater than 0, return a short read. in xchk_scrub_stats_read()
251 if (*ppos > 0) in xchk_scrub_stats_read()
252 return 0; in xchk_scrub_stats_read()
254 bufsize = xchk_stats_estimate_bufsize(cs); in xchk_scrub_stats_read()
258 return -ENOMEM; in xchk_scrub_stats_read()
260 avail = xchk_stats_format(cs, buf, bufsize); in xchk_scrub_stats_read()
261 if (avail < 0) { in xchk_scrub_stats_read()
284 struct xchk_stats *cs = file->private_data; in xchk_clear_scrub_stats_write() local
288 ret = kstrtouint_from_user(ubuf, count, 0, &val); in xchk_clear_scrub_stats_write()
293 return -EINVAL; in xchk_clear_scrub_stats_write()
295 xchk_stats_clearall(cs); in xchk_clear_scrub_stats_write()
307 struct xchk_stats *cs, in xchk_stats_init() argument
310 struct xchk_scrub_stats *css = &cs->cs_stats[0]; in xchk_stats_init()
313 for (i = 0; i < XFS_SCRUB_TYPE_NR; i++, css++) in xchk_stats_init()
314 spin_lock_init(&css->css_lock); in xchk_stats_init()
316 return 0; in xchk_stats_init()
322 struct xchk_stats *cs, in xchk_stats_register() argument
328 cs->cs_debugfs = xfs_debugfs_mkdir("scrub", parent); in xchk_stats_register()
329 if (!cs->cs_debugfs) in xchk_stats_register()
332 debugfs_create_file("stats", 0644, cs->cs_debugfs, cs, in xchk_stats_register()
334 debugfs_create_file("clear_stats", 0400, cs->cs_debugfs, cs, in xchk_stats_register()
341 struct xchk_stats *cs) in xchk_stats_teardown() argument
343 return 0; in xchk_stats_teardown()
349 struct xchk_stats *cs) in xchk_stats_unregister() argument
351 debugfs_remove(cs->cs_debugfs); in xchk_stats_unregister()
366 return 0; in xchk_global_stats_setup()
377 /* Allocate per-mount stats */
382 struct xchk_stats *cs; in xchk_mount_stats_alloc() local
385 cs = kvzalloc(sizeof(struct xchk_stats), GFP_KERNEL); in xchk_mount_stats_alloc()
386 if (!cs) in xchk_mount_stats_alloc()
387 return -ENOMEM; in xchk_mount_stats_alloc()
389 error = xchk_stats_init(cs, mp); in xchk_mount_stats_alloc()
393 mp->m_scrub_stats = cs; in xchk_mount_stats_alloc()
394 return 0; in xchk_mount_stats_alloc()
396 kvfree(cs); in xchk_mount_stats_alloc()
400 /* Free per-mount stats */
405 xchk_stats_teardown(mp->m_scrub_stats); in xchk_mount_stats_free()
406 kvfree(mp->m_scrub_stats); in xchk_mount_stats_free()
407 mp->m_scrub_stats = NULL; in xchk_mount_stats_free()