From 40255f2eaf6e11a294dfd3f7871d551a0c9d0511 Mon Sep 17 00:00:00 2001 From: Vladimir Saveliev Date: Wed, 8 Feb 2017 14:45:48 +0200 Subject: [PATCH] LU-10641 e2fsck: avoid write inode attemp in readonly mode 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 Reviewed-by: Alexandr Boyko Reviewed-by: Artem Blagodarenko Cray-bug-id: MRP-4164 Reviewed-on: https://review.whamcloud.com/31226 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- e2fsck/pass4.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c index d9210ea..6569cc1 100644 --- a/e2fsck/pass4.c +++ b/e2fsck/pass4.c @@ -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 { -- 1.8.3.1