|
|
3b974a |
From 334cc898f177771a5f1ca14c181d6df775cc55ec Mon Sep 17 00:00:00 2001
|
|
|
3b974a |
From: Jan Kara <jack@suse.cz>
|
|
|
3b974a |
Date: Thu, 13 Feb 2020 11:15:56 +0100
|
|
|
3b974a |
Subject: [PATCH 7/7] e2fsck: clarify overflow link count error message
|
|
|
3b974a |
|
|
|
3b974a |
When directory link count is set to overflow value (1) but during pass 4
|
|
|
3b974a |
we find out the exact link count would fit, we either silently fix this
|
|
|
3b974a |
(which is not great because e2fsck then reports the fs was modified but
|
|
|
3b974a |
output doesn't indicate why in any way), or we report that link count is
|
|
|
3b974a |
wrong and ask whether we should fix it (in case -n option was
|
|
|
3b974a |
specified). The second case is even more misleading because it suggests
|
|
|
3b974a |
non-trivial fs corruption which then gets silently fixed on the next
|
|
|
3b974a |
run. Similarly to how we fix up other non-problems, just create a new
|
|
|
3b974a |
error message for the case directory link count is not overflown anymore
|
|
|
3b974a |
and always report it to clarify what is going on.
|
|
|
3b974a |
|
|
|
3b974a |
RHBZ: 1820048
|
|
|
3b974a |
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
|
|
|
3b974a |
Signed-off-by: Jan Kara <jack@suse.cz>
|
|
|
3b974a |
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
|
|
3b974a |
(cherry picked from commit 4ebce13292f54c96f43dcb1bd1d5b8df5dc8749d)
|
|
|
3b974a |
---
|
|
|
3b974a |
e2fsck/pass4.c | 19 +++++++++++++++----
|
|
|
3b974a |
e2fsck/problem.c | 5 +++++
|
|
|
3b974a |
e2fsck/problem.h | 3 +++
|
|
|
3b974a |
3 files changed, 23 insertions(+), 4 deletions(-)
|
|
|
3b974a |
|
|
|
3b974a |
diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c
|
|
|
3b974a |
index ad95227c..c9586dfb 100644
|
|
|
3b974a |
--- a/e2fsck/pass4.c
|
|
|
3b974a |
+++ b/e2fsck/pass4.c
|
|
|
3b974a |
@@ -173,6 +173,7 @@ void e2fsck_pass4(e2fsck_t ctx)
|
|
|
3b974a |
link_counted = 1;
|
|
|
3b974a |
}
|
|
|
3b974a |
if (link_counted != link_count) {
|
|
|
3b974a |
+ int fix_nlink = 0;
|
|
|
3b974a |
e2fsck_read_inode(ctx, i, inode, "pass4");
|
|
|
3b974a |
pctx.ino = i;
|
|
|
3b974a |
pctx.inode = inode;
|
|
|
3b974a |
@@ -185,10 +186,20 @@ void e2fsck_pass4(e2fsck_t ctx)
|
|
|
3b974a |
pctx.num = link_counted;
|
|
|
3b974a |
/* i_link_count was previously exceeded, but no longer
|
|
|
3b974a |
* is, fix this but don't consider it an error */
|
|
|
3b974a |
- if ((isdir && link_counted > 1 &&
|
|
|
3b974a |
- (inode->i_flags & EXT2_INDEX_FL) &&
|
|
|
3b974a |
- link_count == 1 && !(ctx->options & E2F_OPT_NO)) ||
|
|
|
3b974a |
- fix_problem(ctx, PR_4_BAD_REF_COUNT, &pctx)) {
|
|
|
3b974a |
+ if (isdir && link_counted > 1 &&
|
|
|
3b974a |
+ (inode->i_flags & EXT2_INDEX_FL) &&
|
|
|
3b974a |
+ link_count == 1) {
|
|
|
3b974a |
+ if ((ctx->options & E2F_OPT_READONLY) == 0) {
|
|
|
3b974a |
+ fix_nlink =
|
|
|
3b974a |
+ fix_problem(ctx,
|
|
|
3b974a |
+ PR_4_DIR_OVERFLOW_REF_COUNT,
|
|
|
3b974a |
+ &pctx);
|
|
|
3b974a |
+ }
|
|
|
3b974a |
+ } else {
|
|
|
3b974a |
+ fix_nlink = fix_problem(ctx, PR_4_BAD_REF_COUNT,
|
|
|
3b974a |
+ &pctx);
|
|
|
3b974a |
+ }
|
|
|
3b974a |
+ if (fix_nlink) {
|
|
|
3b974a |
inode->i_links_count = link_counted;
|
|
|
3b974a |
e2fsck_write_inode(ctx, i, inode, "pass4");
|
|
|
3b974a |
}
|
|
|
3b974a |
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
|
|
|
3b974a |
index 0210ff8f..2e41bb2e 100644
|
|
|
3b974a |
--- a/e2fsck/problem.c
|
|
|
3b974a |
+++ b/e2fsck/problem.c
|
|
|
3b974a |
@@ -1581,6 +1581,11 @@ static struct e2fsck_problem problem_table[] = {
|
|
|
3b974a |
N_("@d exceeds max links, but no DIR_NLINK feature in @S.\n"),
|
|
|
3b974a |
PROMPT_FIX, 0 },
|
|
|
3b974a |
|
|
|
3b974a |
+ /* Directory inode ref count set to overflow but could be exact value */
|
|
|
3b974a |
+ { PR_4_DIR_OVERFLOW_REF_COUNT,
|
|
|
3b974a |
+ N_("@d @i %i ref count set to overflow but could be exact value %N. "),
|
|
|
3b974a |
+ PROMPT_FIX, PR_PREEN_OK, 0, 0, 0 },
|
|
|
3b974a |
+
|
|
|
3b974a |
/* Pass 5 errors */
|
|
|
3b974a |
|
|
|
3b974a |
/* Pass 5: Checking group summary information */
|
|
|
3b974a |
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
|
|
|
3b974a |
index 5712de59..a591974e 100644
|
|
|
3b974a |
--- a/e2fsck/problem.h
|
|
|
3b974a |
+++ b/e2fsck/problem.h
|
|
|
3b974a |
@@ -948,6 +948,9 @@ struct problem_context {
|
|
|
3b974a |
/* Inconsistent inode count information cached */
|
|
|
3b974a |
#define PR_4_INCONSISTENT_COUNT 0x040004
|
|
|
3b974a |
|
|
|
3b974a |
+/* Directory ref count set to overflow but it doesn't have to be */
|
|
|
3b974a |
+#define PR_4_DIR_OVERFLOW_REF_COUNT 0x040007
|
|
|
3b974a |
+
|
|
|
3b974a |
/*
|
|
|
3b974a |
* Pass 5 errors
|
|
|
3b974a |
*/
|
|
|
3b974a |
--
|
|
|
3b974a |
2.21.1
|
|
|
3b974a |
|