Whamcloud - gitweb
e2fsck: add problem descriptions and check inline data feature
authorZheng Liu <wenqing.lz@taobao.com>
Mon, 3 Mar 2014 06:02:28 +0000 (01:02 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 4 Mar 2014 13:46:15 +0000 (08:46 -0500)
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/pass1.c
e2fsck/problem.c
e2fsck/problem.h

index 7554f4e..95930c9 100644 (file)
@@ -592,7 +592,7 @@ void e2fsck_pass1(e2fsck_t ctx)
        struct ext2_super_block *sb = ctx->fs->super;
        const char      *old_op;
        unsigned int    save_type;
-       int             imagic_fs, extent_fs;
+       int             imagic_fs, extent_fs, inlinedata_fs;
        int             busted_fs_time = 0;
        int             inode_size;
        int             failed_csum = 0;
@@ -626,6 +626,8 @@ void e2fsck_pass1(e2fsck_t ctx)
 
        imagic_fs = (sb->s_feature_compat & EXT2_FEATURE_COMPAT_IMAGIC_INODES);
        extent_fs = (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS);
+       inlinedata_fs = (sb->s_feature_incompat &
+                       EXT4_FEATURE_INCOMPAT_INLINE_DATA);
 
        /*
         * Allocate bitmaps structures
@@ -804,6 +806,24 @@ void e2fsck_pass1(e2fsck_t ctx)
                        }
                }
 
+               /* Test for incorrect inline_data flags settings. */
+               if ((inode->i_flags & EXT4_INLINE_DATA_FL) && !inlinedata_fs &&
+                   (ino >= EXT2_FIRST_INODE(fs->super))) {
+                       size_t size = 0;
+
+                       pctx.errcode = ext2fs_inline_data_size(fs, ino, &size);
+                       if (!pctx.errcode && size &&
+                           !fix_problem(ctx, PR_1_INLINE_DATA_FEATURE, &pctx)) {
+                               sb->s_feature_incompat |=
+                                       EXT4_FEATURE_INCOMPAT_INLINE_DATA;
+                               ext2fs_mark_super_dirty(fs);
+                               inlinedata_fs = 1;
+                       } else if (!fix_problem(ctx, PR_1_INLINE_DATA_SET, &pctx)) {
+                               e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
+                               continue;
+                       }
+               }
+
                /*
                 * Test for incorrect extent flag settings.
                 *
index be9d3ec..dbbbe99 100644 (file)
@@ -1020,6 +1020,15 @@ static struct e2fsck_problem problem_table[] = {
          N_("@i %i, end of extent exceeds allowed value\n\t(logical @b %c, physical @b %b, len %N)\n"),
          PROMPT_CLEAR, 0 },
 
+       /* Inode has inline data, but superblock is missing INLINE_DATA feature. */
+       { PR_1_INLINE_DATA_FEATURE,
+         N_("@i %i has inline data, but @S is missing INLINE_DATA feature\n"),
+         PROMPT_CLEAR, PR_PREEN_OK },
+
+       /* INLINE_DATA feature is set in a non-inline-data filesystem */
+       { PR_1_INLINE_DATA_SET,
+         N_("@i %i has INLINE_DATA_FL flag on @f without inline data support.\n"),
+         PROMPT_CLEAR, 0 },
 
        /* Pass 1b errors */
 
index 8999a64..52c9898 100644 (file)
@@ -593,6 +593,13 @@ struct problem_context {
 #define PR_1_EXTENT_INDEX_START_INVALID        0x01006D
 
 #define PR_1_EXTENT_END_OUT_OF_BOUNDS  0x01006E
+
+/* Inode has inline data, but superblock is missing INLINE_DATA feature. */
+#define PR_1_INLINE_DATA_FEATURE       0x01006F
+
+/* INLINE_DATA feature is set in a non-inline-data filesystem */
+#define PR_1_INLINE_DATA_SET          0x010070
+
 /*
  * Pass 1b errors
  */