]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: fix fractional reporting of single inodes
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 12 Dec 2018 17:42:40 +0000 (11:42 -0600)
committerEric Sandeen <sandeen@redhat.com>
Wed, 12 Dec 2018 17:42:40 +0000 (11:42 -0600)
When there are fewer than 1024 inodes in the filesystem, scrub reports
fractional inodes in its final report:

35.2MiB data used;  5.0 inodes used.
34.2MiB data found; 5.0 inodes found.
5.0 inodes counted; 5.0 inodes checked.

Inodes are indivisible, so only report the fractional part when we have
a large enough number of inodes to perform a unit conversion:

35.2MiB data used;  5 inodes used.
34.2MiB data found; 5 inodes found.
5 inodes counted; 5 inodes checked.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/common.c
scrub/common.h
scrub/phase7.c

index 96b86a26e75282966cb6c7db73e4d607deffa294..78afc4bff8c48c931b814c6c307c853a9f6f9e05 100644 (file)
@@ -200,10 +200,12 @@ no_prefix:
 double
 auto_units(
        unsigned long long      number,
-       char                    **units)
+       char                    **units,
+       int                     *precision)
 {
        if (debug > 1)
                goto no_prefix;
+       *precision = 1;
        if (number > 1000000000000ULL) {
                *units = "T";
                return number / 1000000000000.0;
@@ -220,6 +222,7 @@ auto_units(
 
 no_prefix:
        *units = "";
+       *precision = 0;
        return number;
 }
 
index 5a43ac0cc97512cfdcaf531fcf71e80c67350212..e85a0333c728265773c1a4d0ffd62702f22f6492 100644 (file)
@@ -62,7 +62,7 @@ debug_tweak_on(
 
 double timeval_subtract(struct timeval *tv1, struct timeval *tv2);
 double auto_space_units(unsigned long long kilobytes, char **units);
-double auto_units(unsigned long long number, char **units);
+double auto_units(unsigned long long number, char **units, int *precision);
 unsigned int scrub_nproc(struct scrub_ctx *ctx);
 unsigned int scrub_nproc_workqueue(struct scrub_ctx *ctx);
 
index cac0c75af1f3025a031a7a3e0c370aa9f2576a94..504a69277a4cc59de7658b5d3cdaeed303b852cf 100644 (file)
@@ -107,6 +107,7 @@ xfs_scan_summary(
        unsigned long long              f_free;
        bool                            moveon;
        bool                            complain;
+       int                             ip;
        int                             error;
 
        /* Flush everything out to disk before we start counting. */
@@ -176,27 +177,27 @@ xfs_scan_summary(
                if (used_rt || stat_rt) {
                        d = auto_space_units(used_data, &du);
                        r = auto_space_units(used_rt, &ru);
-                       i = auto_units(used_files, &iu);
+                       i = auto_units(used_files, &iu, &ip);
                        fprintf(stdout,
-_("%.1f%s data used;  %.1f%s realtime data used;  %.2f%s inodes used.\n"),
-                                       d, du, r, ru, i, iu);
+_("%.1f%s data used;  %.1f%s realtime data used;  %.*f%s inodes used.\n"),
+                                       d, du, r, ru, ip, i, iu);
                        d = auto_space_units(stat_data, &du);
                        r = auto_space_units(stat_rt, &ru);
-                       i = auto_units(counted_inodes, &iu);
+                       i = auto_units(counted_inodes, &iu, &ip);
                        fprintf(stdout,
-_("%.1f%s data found; %.1f%s realtime data found; %.2f%s inodes found.\n"),
-                                       d, du, r, ru, i, iu);
+_("%.1f%s data found; %.1f%s realtime data found; %.*f%s inodes found.\n"),
+                                       d, du, r, ru, ip, i, iu);
                } else {
                        d = auto_space_units(used_data, &du);
-                       i = auto_units(used_files, &iu);
+                       i = auto_units(used_files, &iu, &ip);
                        fprintf(stdout,
-_("%.1f%s data used;  %.1f%s inodes used.\n"),
-                                       d, du, i, iu);
+_("%.1f%s data used;  %.*f%s inodes used.\n"),
+                                       d, du, ip, i, iu);
                        d = auto_space_units(stat_data, &du);
-                       i = auto_units(counted_inodes, &iu);
+                       i = auto_units(counted_inodes, &iu, &ip);
                        fprintf(stdout,
-_("%.1f%s data found; %.1f%s inodes found.\n"),
-                                       d, du, i, iu);
+_("%.1f%s data found; %.*f%s inodes found.\n"),
+                                       d, du, ip, i, iu);
                }
                fflush(stdout);
        }
@@ -210,12 +211,13 @@ _("%.1f%s data found; %.1f%s inodes found.\n"),
                        _("checked inodes"))) {
                double          i1, i2;
                char            *i1u, *i2u;
+               int             i1p, i2p;
 
-               i1 = auto_units(counted_inodes, &i1u);
-               i2 = auto_units(ctx->inodes_checked, &i2u);
+               i1 = auto_units(counted_inodes, &i1u, &i1p);
+               i2 = auto_units(ctx->inodes_checked, &i2u, &i2p);
                fprintf(stdout,
-_("%.1f%s inodes counted; %.1f%s inodes checked.\n"),
-                               i1, i1u, i2, i2u);
+_("%.*f%s inodes counted; %.*f%s inodes checked.\n"),
+                               i1p, i1, i1u, i2p, i2, i2u);
                fflush(stdout);
        }