Whamcloud - gitweb
LU-10641 e2fsck: avoid write inode attemp in readonly mode 26/31226/4
authorVladimir Saveliev <c17830@cray.com>
Wed, 8 Feb 2017 12:45:48 +0000 (14:45 +0200)
committerAndreas Dilger <andreas.dilger@intel.com>
Wed, 2 May 2018 03:15:55 +0000 (03:15 +0000)
disconnect_inode() in pass 4 tries to update inode's link count for EA
inodes even in readonly mode. That results in e2fsck -n stop while it
is to continue reporting filesystem inconsistencies.
Move the EA inode's link count update where write access is
guaranteed.

Change-Id: Ie3dcdde160ee9092f21a45fea8f75c4061788072
Signed-off-by: Vladimir Saveliev <c17830@cray.com>
Reviewed-by: Alexandr Boyko <c17825@cray.com>
Reviewed-by: Artem Blagodarenko <c17828@seagate.com>
Cray-bug-id: MRP-4164
Reviewed-on: https://review.whamcloud.com/31226
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
e2fsck/pass4.c

index d9210ea..6569cc1 100644 (file)
@@ -46,12 +46,6 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
                if (ext2fs_test_inode_bitmap2(ctx->inode_ea_map, i)) {
                        ext2fs_icount_store(ctx->inode_count, i, 1);
                        return 0;
-               } else {
-                       /* Zero the link count so that when inode is linked to
-                        * lost+found it has correct link count */
-                       inode->i_links_count = 0;
-                       e2fsck_write_inode(ctx, i, inode, "disconnect_inode");
-                       ext2fs_icount_store(ctx->inode_link_info, i, 0);
                }
        }
 
@@ -88,6 +82,13 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
         * Prompt to reconnect.
         */
        if (fix_problem(ctx, PR_4_UNATTACHED_INODE, &pctx)) {
+               if (inode->i_flags & EXT4_EA_INODE_FL) {
+                       /* Zero the link count so that when inode is linked to
+                        * lost+found it has correct link count */
+                       inode->i_links_count = 0;
+                       e2fsck_write_inode(ctx, i, inode, "disconnect_inode");
+                       ext2fs_icount_store(ctx->inode_link_info, i, 0);
+               }
                if (e2fsck_reconnect_file(ctx, i))
                        ext2fs_unmark_valid(fs);
        } else {