|
@@ -20,16 +20,9 @@
|
|
|
|
|
|
DEFINE_PER_CPU(struct xfsstats, xfsstats);
|
|
DEFINE_PER_CPU(struct xfsstats, xfsstats);
|
|
|
|
|
|
-STATIC int
|
|
|
|
-xfs_read_xfsstats(
|
|
|
|
- char *buffer,
|
|
|
|
- char **start,
|
|
|
|
- off_t offset,
|
|
|
|
- int count,
|
|
|
|
- int *eof,
|
|
|
|
- void *data)
|
|
|
|
|
|
+static int xfs_stat_proc_show(struct seq_file *m, void *v)
|
|
{
|
|
{
|
|
- int c, i, j, len, val;
|
|
|
|
|
|
+ int c, i, j, val;
|
|
__uint64_t xs_xstrat_bytes = 0;
|
|
__uint64_t xs_xstrat_bytes = 0;
|
|
__uint64_t xs_write_bytes = 0;
|
|
__uint64_t xs_write_bytes = 0;
|
|
__uint64_t xs_read_bytes = 0;
|
|
__uint64_t xs_read_bytes = 0;
|
|
@@ -60,18 +53,18 @@ xfs_read_xfsstats(
|
|
};
|
|
};
|
|
|
|
|
|
/* Loop over all stats groups */
|
|
/* Loop over all stats groups */
|
|
- for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
|
|
|
|
- len += sprintf(buffer + len, "%s", xstats[i].desc);
|
|
|
|
|
|
+ for (i=j = 0; i < ARRAY_SIZE(xstats); i++) {
|
|
|
|
+ seq_printf(m, "%s", xstats[i].desc);
|
|
/* inner loop does each group */
|
|
/* inner loop does each group */
|
|
while (j < xstats[i].endpoint) {
|
|
while (j < xstats[i].endpoint) {
|
|
val = 0;
|
|
val = 0;
|
|
/* sum over all cpus */
|
|
/* sum over all cpus */
|
|
for_each_possible_cpu(c)
|
|
for_each_possible_cpu(c)
|
|
val += *(((__u32*)&per_cpu(xfsstats, c) + j));
|
|
val += *(((__u32*)&per_cpu(xfsstats, c) + j));
|
|
- len += sprintf(buffer + len, " %u", val);
|
|
|
|
|
|
+ seq_printf(m, " %u", val);
|
|
j++;
|
|
j++;
|
|
}
|
|
}
|
|
- buffer[len++] = '\n';
|
|
|
|
|
|
+ seq_putc(m, '\n');
|
|
}
|
|
}
|
|
/* extra precision counters */
|
|
/* extra precision counters */
|
|
for_each_possible_cpu(i) {
|
|
for_each_possible_cpu(i) {
|
|
@@ -80,36 +73,38 @@ xfs_read_xfsstats(
|
|
xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
|
|
xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
|
|
}
|
|
}
|
|
|
|
|
|
- len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n",
|
|
|
|
|
|
+ seq_printf(m, "xpc %Lu %Lu %Lu\n",
|
|
xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
|
|
xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
|
|
- len += sprintf(buffer + len, "debug %u\n",
|
|
|
|
|
|
+ seq_printf(m, "debug %u\n",
|
|
#if defined(DEBUG)
|
|
#if defined(DEBUG)
|
|
1);
|
|
1);
|
|
#else
|
|
#else
|
|
0);
|
|
0);
|
|
#endif
|
|
#endif
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
|
|
- if (offset >= len) {
|
|
|
|
- *start = buffer;
|
|
|
|
- *eof = 1;
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- *start = buffer + offset;
|
|
|
|
- if ((len -= offset) > count)
|
|
|
|
- return count;
|
|
|
|
- *eof = 1;
|
|
|
|
-
|
|
|
|
- return len;
|
|
|
|
|
|
+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,
|
|
|
|
+};
|
|
|
|
+
|
|
int
|
|
int
|
|
xfs_init_procfs(void)
|
|
xfs_init_procfs(void)
|
|
{
|
|
{
|
|
if (!proc_mkdir("fs/xfs", NULL))
|
|
if (!proc_mkdir("fs/xfs", NULL))
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- if (!create_proc_read_entry("fs/xfs/stat", 0, NULL,
|
|
|
|
- xfs_read_xfsstats, NULL))
|
|
|
|
|
|
+ if (!proc_create("fs/xfs/stat", 0, NULL,
|
|
|
|
+ &xfs_stat_proc_fops))
|
|
goto out_remove_entry;
|
|
goto out_remove_entry;
|
|
return 0;
|
|
return 0;
|
|
|
|
|