Whamcloud - gitweb
e2fsck: zap extent-format inode with no extent header
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 30 Nov 2015 20:22:07 +0000 (15:22 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 30 Nov 2015 20:22:07 +0000 (15:22 -0500)
The kernel requires all inodes with the extent flag set to have a
valid extent tree header in i_block.  The ext2fs_extent_open2 prefers
to initialize the header if i_block is zeroed, but e2fsck never writes
the new header to disk.  Since the kernel won't create inodes with the
flag and no header anyway, zap such files.

Reported-by: Bo Branten <bosse@acc.umu.se>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c
e2fsck/problem.c
e2fsck/problem.h
tests/f_extents/expect.1
tests/f_zeroed_ext_header/expect.1 [new file with mode: 0644]
tests/f_zeroed_ext_header/expect.2 [new file with mode: 0644]
tests/f_zeroed_ext_header/image.gz [new file with mode: 0644]
tests/f_zeroed_ext_header/name [new file with mode: 0644]

index 66ff69a..2370bb0 100644 (file)
@@ -2138,7 +2138,20 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
        ext2_ino_t              ino = pctx->ino;
        errcode_t               retval;
        blk64_t                 eof_lblk;
+       struct ext3_extent_header       *eh;
 
+       /* Check for a proper extent header... */
+       eh = (struct ext3_extent_header *) &inode->i_block[0];
+       retval = ext2fs_extent_header_verify(eh, sizeof(inode->i_block));
+       if (retval) {
+               if (fix_problem(ctx, PR_1_MISSING_EXTENT_HEADER, pctx))
+                       e2fsck_clear_inode(ctx, ino, inode, 0,
+                                          "check_blocks_extents");
+               pctx->errcode = 0;
+               return;
+       }
+
+       /* ...since this function doesn't fail if i_block is zeroed. */
        pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
        if (pctx->errcode) {
                if (fix_problem(ctx, PR_1_READ_EXTENT, pctx))
index f442a33..e783148 100644 (file)
@@ -987,6 +987,11 @@ static struct e2fsck_problem problem_table[] = {
          N_("@i %i logical @b %b (physical @b %c) violates cluster allocation rules.\nWill fix in pass 1B.\n"),
          PROMPT_NONE, 0 },
 
+       /* Inode has corrupt extent header */
+       { PR_1_MISSING_EXTENT_HEADER,
+         N_("@i %i has corrupt @x header.  "),
+         PROMPT_CLEAR_INODE, 0 },
+
        /* Pass 1b errors */
 
        /* Pass 1B: Rescan for duplicate/bad blocks */
index 212ed35..85014f9 100644 (file)
@@ -587,6 +587,45 @@ struct problem_context {
 /* Inode logical block is misaligned */
 #define PR_1_MISALIGNED_CLUSTER                0x010074
 
+/* Inode has INLINE_DATA_FL flag but extended attribute not found */
+#define PR_1_INLINE_DATA_NO_ATTR       0x010075
+
+/* extents/inlinedata set on fifo/socket/device */
+#define PR_1_SPECIAL_EXTENTS_IDATA     0x010076
+
+/* idata/extent flag set and extent header found, clear idata flag */
+#define PR_1_CLEAR_INLINE_DATA_FOR_EXTENT      0x010077
+
+/* inlinedata/extent set and no extent header found, clear extent flag */
+#define PR_1_CLEAR_EXTENT_FOR_INLINE_DATA      0x010078
+
+/* inlinedata/extent set, clear both flags */
+#define PR_1_CLEAR_EXTENT_INLINE_DATA_FLAGS    0x010079
+
+/* inlinedata/extent set, clear inode */
+#define PR_1_CLEAR_EXTENT_INLINE_DATA_INODE    0x01007A
+
+/* badblocks is in badblocks */
+#define PR_1_BADBLOCKS_IN_BADBLOCKS            0x01007B
+
+/* can't allocate extent region */
+#define PR_1_EXTENT_ALLOC_REGION_ABORT         0x01007C
+
+/* leaf extent collision */
+#define PR_1_EXTENT_COLLISION                  0x01007D
+
+/* Error allocating memory for encrypted directory list */
+#define PR_1_ALLOCATE_ENCRYPTED_DIRLIST                0x01007E
+
+/* extent tree max depth too big */
+#define PR_1_EXTENT_BAD_MAX_DEPTH              0x01007F
+
+/* bigalloc fs cannot have blockmap files */
+#define PR_1_NO_BIGALLOC_BLOCKMAP_FILES                0x010080
+
+/* Missing extent header */
+#define PR_1_MISSING_EXTENT_HEADER             0x010081
+
 /*
  * Pass 1b errors
  */
index 2abe32e..882c321 100644 (file)
@@ -17,8 +17,7 @@ Clear? yes
 
 Inode 17, i_blocks is 32, should be 0.  Fix? yes
 
-Error while reading over extent tree in inode 18: Corrupt extent header
-Clear inode? yes
+Inode 18 has corrupt extent header.  Clear inode? yes
 
 Inode 18, i_blocks is 2, should be 0.  Fix? yes
 
diff --git a/tests/f_zeroed_ext_header/expect.1 b/tests/f_zeroed_ext_header/expect.1
new file mode 100644 (file)
index 0000000..2613e9f
--- /dev/null
@@ -0,0 +1,22 @@
+Pass 1: Checking inodes, blocks, and sizes
+Inode 12 has corrupt extent header.  Clear inode? yes
+
+Pass 2: Checking directory structure
+Entry 'testa' in / (2) has deleted/unused inode 12.  Clear? yes
+
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+Inode bitmap differences:  -12
+Fix? yes
+
+Free inodes count wrong for group #0 (115, counted=116).
+Fix? yes
+
+Free inodes count wrong (115, counted=116).
+Fix? yes
+
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+test_filesys: 12/128 files (0.0% non-contiguous), 15/256 blocks
+Exit status is 1
diff --git a/tests/f_zeroed_ext_header/expect.2 b/tests/f_zeroed_ext_header/expect.2
new file mode 100644 (file)
index 0000000..177288f
--- /dev/null
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 12/128 files (0.0% non-contiguous), 15/256 blocks
+Exit status is 0
diff --git a/tests/f_zeroed_ext_header/image.gz b/tests/f_zeroed_ext_header/image.gz
new file mode 100644 (file)
index 0000000..67a4334
Binary files /dev/null and b/tests/f_zeroed_ext_header/image.gz differ
diff --git a/tests/f_zeroed_ext_header/name b/tests/f_zeroed_ext_header/name
new file mode 100644 (file)
index 0000000..31394cf
--- /dev/null
@@ -0,0 +1 @@
+zap inode with zeroed extent header