]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: Check for cases where EOFBLOCKS_FL is unnecessarily set
authorTheodore Ts'o <tytso@mit.edu>
Mon, 10 May 2010 14:17:44 +0000 (10:17 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 10 May 2010 14:29:14 +0000 (10:29 -0400)
Some kernels will crash if EOFBLOCKS_FL is set when it is it not
needed, and this if it is left set when it isn't needed, it is a sign
of a kernel bug.

Addresses-Google-Bug: #2604224

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/pass1.c
e2fsck/problem.c
e2fsck/problem.h
tests/f_bad_disconnected_inode/expect.1

index bb5604b897bbbb6cfc38e6e79315c3e61d2e09f0..a0249ff91f2e438cefffb5c9c4c95ff09cbd0bb0 100644 (file)
@@ -2000,6 +2000,19 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
                         ((1ULL << (32 + EXT2_BLOCK_SIZE_BITS(fs->super))) - 1))
                        /* too big for an extent-based file - 32bit ee_block */
                        bad_size = 6;
+
+               /*
+                * Check to see if the EOFBLOCKS flag is set where it
+                * doesn't need to be.
+                */
+               if ((inode->i_flags & EXT4_EOFBLOCKS_FL) &&
+                   (size <= (((__u64)pb.last_block + 1) * fs->blocksize))) {
+                       pctx->blkcount = pb.last_block;
+                       if (fix_problem(ctx, PR_1_EOFBLOCKS_FL_SET, pctx)) {
+                               inode->i_flags &= ~EXT4_EOFBLOCKS_FL;
+                               dirty_inode++;
+                       }
+               }
        }
        /* i_size for symlinks is checked elsewhere */
        if (bad_size && !LINUX_S_ISLNK(inode->i_mode)) {
index 9043281dcdd28f27e8c9ab3bcd2bde4cfc815007..ceb2ae9bd98957a8492b3118100301202fd7ec18 100644 (file)
@@ -885,6 +885,11 @@ static struct e2fsck_problem problem_table[] = {
          N_("@i %i has an invalid extent node (blk %b, lblk %c)\n"),
          PROMPT_CLEAR, 0 },
 
+       { PR_1_EOFBLOCKS_FL_SET,
+         N_("@i %i should not have EOFBLOCKS_FL set "
+            "(size %Is, lblk %r)\n"),
+         PROMPT_CLEAR, PR_PREEN_OK },
+
        /* Pass 1b errors */
 
        /* Pass 1B: Rescan for duplicate/bad blocks */
index f3969e0768c5f994eb636a5ac2a0fdf5490edbc6..b1bc97f5c2ed5026d7bd7f7203e3a85ea44c95db 100644 (file)
@@ -517,6 +517,9 @@ struct problem_context {
 /* Extent node header invalid */
 #define PR_1_EXTENT_HEADER_INVALID     0x01005F
 
+/* EOFBLOCKS flag set when not necessary */
+#define PR_1_EOFBLOCKS_FL_SET          0x010060
+
 /*
  * Pass 1b errors
  */
index 11862f65fdc1bb1af1cf80c80e8762fb07836c82..d3920e30f6f4c0284fed614c11c59b3a12028453 100644 (file)
@@ -2,12 +2,21 @@ Pass 1: Checking inodes, blocks, and sizes
 Inode 1 has EXTENTS_FL flag set on filesystem without extents support.
 Clear? yes
 
+Inode 9 should not have EOFBLOCKS_FL set (size 0, lblk -1)
+Clear? yes
+
+Inode 10 should not have EOFBLOCKS_FL set (size 0, lblk -1)
+Clear? yes
+
 Inode 15 has EXTENTS_FL flag set on filesystem without extents support.
 Clear? yes
 
 Inode 16 has EXTENTS_FL flag set on filesystem without extents support.
 Clear? yes
 
+Inode 13 should not have EOFBLOCKS_FL set (size 0, lblk -1)
+Clear? yes
+
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 /lost+found not found.  Create? yes