From f57b371506734f381a1612be9ac465499f1c1676 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Thu, 2 Aug 2012 20:47:45 -0400 Subject: [PATCH] e2fsck: verify and correct MMP checksum problems Check and handle MMP checksum problems by resetting the block. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- e2fsck/problem.c | 5 +++++ e2fsck/problem.h | 3 +++ e2fsck/unix.c | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/e2fsck/problem.c b/e2fsck/problem.c index c948fcd..78b05bb 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -442,6 +442,11 @@ static struct e2fsck_problem problem_table[] = { "bits cannot be set simultaneously."), PROMPT_FIX, PR_PREEN_OK | PR_NO_OK}, + /* Superblock has invalid MMP checksum. */ + { PR_0_MMP_CSUM_INVALID, + N_("@S MMP block checksum does not match MMP block. "), + PROMPT_FIX, PR_PREEN_OK | PR_NO_OK}, + /* Pass 1 errors */ /* Pass 1: Checking inodes, blocks, and sizes */ diff --git a/e2fsck/problem.h b/e2fsck/problem.h index db135dc..5caade4 100644 --- a/e2fsck/problem.h +++ b/e2fsck/problem.h @@ -255,6 +255,9 @@ struct problem_context { */ #define PR_0_META_AND_GDT_CSUM_SET 0x000046 +/* Superblock has invalid MMP checksum. */ +#define PR_0_MMP_CSUM_INVALID 0x000047 + /* * Pass 1 errors diff --git a/e2fsck/unix.c b/e2fsck/unix.c index e058d2b..d2b1bbd 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1151,6 +1151,11 @@ check_error: ext2fs_mmp_clear(fs); retval = 0; } + } else if (retval == EXT2_ET_MMP_CSUM_INVALID) { + if (fix_problem(ctx, PR_0_MMP_CSUM_INVALID, &pctx)) { + ext2fs_mmp_clear(fs); + retval = 0; + } } return retval; } -- 1.8.3.1