From 75990388365c5688dbade9c33a3394e40f757526 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 6 Dec 2010 10:10:33 -0500 Subject: [PATCH] e2fsck: Add the ability to force a problem to not be fixed The boolean options "force_no" in the problems stanza of e2fsck.conf allows a particular problem code be treated as if the user will answer "no" to the question of whether a particular problem should be fixed --- even if e2fsck is run with the -y option. As an example use case, suppose a distribution had widely deployed a version of the kernel where under some circumstances, the EOFBLOCKS_FL flag would be left set even though it should not be left set, and a customer had a workload which exercised the fencepost error all the time, resulting in many large number of inodes that had EOFBLOCKS_FL set erroneously. Enough, in fact, the e2fsck runs were taking too long. (There was such a bug in the kernel, which was fixed by commit 58590b06d in 2.6.36). Leaving EOFBLOCKS_FL set when it should not be isn't a huge deal, and is certainly than having high availability timeout alerts going off left and right. So in this case, the best fix might be to put the following in /etc/e2fsck.conf: [problems] 0x010060 = { # PR_1_EOFBLOCKS_FL_SET force_no = true no_ok = true no_nomsg = true } Signed-off-by: "Theodore Ts'o" --- e2fsck/e2fsck.conf.5.in | 15 +++++++++++++-- e2fsck/problem.c | 9 +++++++-- e2fsck/problemP.h | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/e2fsck/e2fsck.conf.5.in b/e2fsck/e2fsck.conf.5.in index 4c90293..e09cd6d 100644 --- a/e2fsck/e2fsck.conf.5.in +++ b/e2fsck/e2fsck.conf.5.in @@ -190,11 +190,22 @@ is running in preen mode. .I no_nomsg This boolean relation overrides the default behavior controlling whether or not the description for this filesystem problem should -be suppressed when +be suppressed when a problem forced not to be fixed, either because .B e2fsck is run with the .B -n -option. +option or because the +.I force_no +flag has been set for the problem. +.TP +.I force_no +This boolean option, if set to true, forces a problem to never be fixed. +That is, it will be as if the user problem responds 'no' to the question +of 'should this problem be fixed?'. The +.I force_no +option even overrides the +.B -y +option given on the command-line (just for the specific problem, of course). .SH THE [scratch_files] STANZA The following relations are defined in the .I [scratch_files] diff --git a/e2fsck/problem.c b/e2fsck/problem.c index 8032fda..8f0b211 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -1773,6 +1773,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) reconfigure_bool(ctx, ptr, key, PR_NOCOLLATE, "no_collate"); reconfigure_bool(ctx, ptr, key, PR_NO_NOMSG, "no_nomsg"); reconfigure_bool(ctx, ptr, key, PR_PREEN_NOHDR, "preen_noheader"); + reconfigure_bool(ctx, ptr, key, PR_FORCE_NO, "force_no"); ptr->flags |= PR_CONFIG; } @@ -1803,7 +1804,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) (ctx->options & E2F_OPT_PREEN)) suppress++; if ((ptr->flags & PR_NO_NOMSG) && - (ctx->options & E2F_OPT_NO)) + ((ctx->options & E2F_OPT_NO) || (ptr->flags & PR_FORCE_NO))) suppress++; if (!suppress) { message = ptr->e2p_description; @@ -1827,7 +1828,11 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx) else answer = def_yn; } else { - if (ctx->options & E2F_OPT_PREEN) { + if (ptr->flags & PR_FORCE_NO) { + answer = 0; + if (!suppress) + print_answer = 1; + } else if (ctx->options & E2F_OPT_PREEN) { answer = def_yn; if (!(ptr->flags & PR_PREEN_NOMSG)) print_answer = 1; diff --git a/e2fsck/problemP.h b/e2fsck/problemP.h index 6161189..a2ed35e 100644 --- a/e2fsck/problemP.h +++ b/e2fsck/problemP.h @@ -41,3 +41,4 @@ struct latch_descr { #define PR_PREEN_NOHDR 0x040000 /* Don't print the preen header */ #define PR_CONFIG 0x080000 /* This problem has been customized from the config file */ +#define PR_FORCE_NO 0x100000 /* Force the answer to be no */ -- 1.8.3.1