OSDN Git Service

e2fsck: add e2fsck.conf options for extra reporting
authorTheodore Ts'o <tytso@mit.edu>
Sun, 29 Jul 2012 21:44:11 +0000 (17:44 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Jul 2012 21:44:11 +0000 (17:44 -0400)
Add report_time, report_verbose, and report_features options to
e2fsck.conf which enable additional, more verbose reporting by e2fsck.
This is useful for large cloud installations where there are a large
number file systems being managed, and where it may not be obvious
from the e2fsck log files exactly how a particular file system is
configured.

The report_time and report_verbose options, which are the same as the
-tt and -v command line options, respectively, are useful because they
are options specific to e2fsck, and the fsck program does not have a
way of passing certain options only to a specific /sbin/fsck.<fstype>
program.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/e2fsck.conf.5.in
e2fsck/unix.c

index 89a1cf7..085a951 100644 (file)
@@ -148,6 +148,16 @@ filesystem checks (either based on time or number of mounts) should
 be doubled if the system is running on battery.  This setting defaults to 
 true.
 .TP
+.I indexed_dir_slack_percentage
+When
+.BR e2fsck (8)
+repacks a indexed directory, reserve the specified percentage of
+empty space in each leaf nodes so that a few new entries can
+be added to the directory without splitting leaf nodes, so that
+the average fill ratio of directories can be maintained at a
+higher, more efficient level.  This relation defaults to 20
+percent.
+.TP
 .I log_dir
 If the
 .I log_filename
@@ -196,15 +206,23 @@ of that type are squelched.  This can be useful if the console is slow
 (i.e., connected to a serial port) and so a large amount of output could
 end up delaying the boot process for a long time (potentially hours).
 .TP
-.I indexed_dir_slack_percentage
-When
-.BR e2fsck (8)
-repacks a indexed directory, reserve the specified percentage of
-empty space in each leaf nodes so that a few new entries can
-be added to the directory without splitting leaf nodes, so that
-the average fill ratio of directories can be maintained at a
-higher, more efficient level.  This relation defaults to 20
-percent.
+.I report_features
+If this boolean relation is true, e2fsck will print the file system
+features as part of its verbose reporting (i.e., if the
+.B -v
+option is specified)
+.TP
+.I report_time
+If this boolean relation is true, e2fsck will run as if the options
+.B -tt
+are always specified.  This will cause e2fsck to print timing statistics
+on a pass by pass basis for full file system checks.
+.TP
+.I report_verbose
+If this boolean relation is true, e2fsck will run as if the option
+.B -v
+is always specified.  This will cause e2fsck to print some additional
+information at the end of each full file system check.
 .SH THE [problems] STANZA
 Each tag in the
 .I [problems] 
index da41f69..d1837ed 100644 (file)
@@ -102,8 +102,9 @@ static void show_stats(e2fsck_t     ctx)
        blk64_t blocks, blocks_used;
        unsigned int dir_links;
        unsigned int num_files, num_links;
+       __u32 *mask, m;
        int frag_percent_file, frag_percent_dir, frag_percent_total;
-       int i, j;
+       int i, j, printed = 0;
 
        dir_links = 2 * ctx->fs_directory_count - 1;
        num_files = ctx->fs_total_count - dir_links;
@@ -134,6 +135,25 @@ static void show_stats(e2fsck_t    ctx)
                        blocks_used, blocks);
                return;
        }
+       profile_get_boolean(ctx->profile, "options", "report_features", 0, 0,
+                           &i);
+       if (verbose && i) {
+               log_out(ctx, "\nFilesystem features:");
+               mask = &ctx->fs->super->s_feature_compat;
+               for (i = 0; i < 3; i++, mask++) {
+                       for (j = 0, m = 1; j < 32; j++, m <<= 1) {
+                               if (*mask & m) {
+                                       log_out(ctx, " %s",
+                                               e2p_feature2string(i, m));
+                                       printed++;
+                               }
+                       }
+               }
+               if (printed == 0)
+                       log_out(ctx, " (none)");
+               log_out(ctx, "\n");
+       }
+
        log_out(ctx, P_("\n%8u inode used (%2.2f%%)\n",
                        "\n%8u inodes used (%2.2f%%)\n",
                        inodes_used), inodes_used,
@@ -920,6 +940,15 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
        profile_set_syntax_err_cb(syntax_err_report);
        profile_init(config_fn, &ctx->profile);
 
+       profile_get_boolean(ctx->profile, "options", "report_time", 0, 0,
+                           &c);
+       if (c)
+               ctx->options |= E2F_OPT_TIME | E2F_OPT_TIME2;
+       profile_get_boolean(ctx->profile, "options", "report_verbose", 0, 0,
+                           &c);
+       if (c)
+               verbose = 1;
+
        /* Turn off discard in read-only mode */
        if ((ctx->options & E2F_OPT_NO) &&
            (ctx->options & E2F_OPT_DISCARD))