]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/linux-2.6/xfs_stats.c
[XFS] streamline init/exit path
[linux-2.6-omap-h63xx.git] / fs / xfs / linux-2.6 / xfs_stats.c
index 8955720a2c6b0685bde93bdfeff24e1006355771..3d5b67c075c7ab5b927884313f35196fd9249e80 100644 (file)
@@ -56,24 +56,21 @@ xfs_read_xfsstats(
        };
 
        /* Loop over all stats groups */
-       for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
+       for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
                len += sprintf(buffer + len, xstats[i].desc);
                /* inner loop does each group */
                while (j < xstats[i].endpoint) {
                        val = 0;
                        /* sum over all cpus */
-                       for (c = 0; c < NR_CPUS; c++) {
-                               if (!cpu_possible(c)) continue;
+                       for_each_possible_cpu(c)
                                val += *(((__u32*)&per_cpu(xfsstats, c) + j));
-                       }
                        len += sprintf(buffer + len, " %u", val);
                        j++;
                }
                buffer[len++] = '\n';
        }
        /* extra precision counters */
-       for (i = 0; i < NR_CPUS; i++) {
-               if (!cpu_possible(i)) continue;
+       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;
@@ -101,12 +98,21 @@ xfs_read_xfsstats(
        return len;
 }
 
-void
+int
 xfs_init_procfs(void)
 {
        if (!proc_mkdir("fs/xfs", NULL))
-               return;
-       create_proc_read_entry("fs/xfs/stat", 0, NULL, xfs_read_xfsstats, NULL);
+               goto out;
+
+       if (!create_proc_read_entry("fs/xfs/stat", 0, NULL,
+                       xfs_read_xfsstats, NULL))
+               goto out_remove_entry;
+       return 0;
+
+ out_remove_entry:
+       remove_proc_entry("fs/xfs", NULL);
+ out:
+       return -ENOMEM;
 }
 
 void