[PATCH 29/31] e2fsck: Enable extents on all 64bit filesystems

Darrick J. Wong
2013-10-01T01:29:56Z

Since it's impossible to address all blocks of a 64bit filesystem without
extents, have e2fsck turn on the feature if it finds (64bit && !extents).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
e2fsck/problem.c | 5 +++++
e2fsck/problem.h | 2 ++
e2fsck/super.c | 11 +++++++++++
3 files changed, 18 insertions(+)

diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index b0a6e19..897693a 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -447,6 +447,11 @@ static struct e2fsck_problem problem_table[] = {
N_("@S MMP block checksum does not match MMP block. "),
PROMPT_FIX, PR_PREEN_OK | PR_NO_OK},

+ /* 64bit is set but extents is unset. */
+ { PR_0_64BIT_WITHOUT_EXTENTS,
+ N_("@S 64bit filesystems needs extents to access the whole disk. "),
+ 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 fcdc1a1..dd17e37 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -258,6 +258,8 @@ struct problem_context {
/* Superblock has invalid MMP checksum. */
#define PR_0_MMP_CSUM_INVALID 0x000047

+/* 64bit is set but extents are not set. */
+#define PR_0_64BIT_WITHOUT_EXTENTS 0x000048

/*
* Pass 1 errors
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 16a1c23..0c879f5 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -595,6 +595,17 @@ void check_super_block(e2fsck_t ctx)
ext2fs_group_desc_csum_set(fs, i);
}

+ /* Is 64bit set and extents unset? */
+ if (EXT2_HAS_INCOMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_INCOMPAT_64BIT) &&
+ !EXT2_HAS_INCOMPAT_FEATURE(fs->super,
+ EXT3_FEATURE_INCOMPAT_EXTENTS) &&
+ fix_problem(ctx, PR_0_64BIT_WITHOUT_EXTENTS, &pctx)) {
+ fs->super->s_feature_incompat |=
+ EXT3_FEATURE_INCOMPAT_EXTENTS;
+ ext2fs_mark_super_dirty(fs);
+ }
+
/*
* Verify the group descriptors....
*/