Whamcloud - gitweb
ext2fs_set_gdt_csum(): Return an error code on errors instead of void
[tools/e2fsprogs.git] / e2fsck / pass4.c
index e6fe604..ebc19a8 100644 (file)
@@ -155,6 +155,9 @@ void e2fsck_pass4(e2fsck_t ctx)
                        ext2fs_icount_fetch(ctx->inode_count, i,
                                            &link_counted);
                }
+               if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, i) &&
+                   (link_counted > EXT2_LINK_MAX))
+                       link_counted = 1;
                if (link_counted != link_count) {
                        e2fsck_read_inode(ctx, i, inode, "pass4");
                        pctx.ino = i;
@@ -165,7 +168,12 @@ void e2fsck_pass4(e2fsck_t ctx)
                                            PR_4_INCONSISTENT_COUNT, &pctx);
                        }
                        pctx.num = link_counted;
-                       if (fix_problem(ctx, PR_4_BAD_REF_COUNT, &pctx)) {
+                       /* i_link_count was previously exceeded, but no longer
+                        * is, fix this but don't consider it an error */
+                       if ((LINUX_S_ISDIR(inode->i_mode) && link_counted > 1 &&
+                            (inode->i_flags & EXT2_INDEX_FL) &&
+                            link_count == 1 && !(ctx->options & E2F_OPT_NO)) ||
+                            (fix_problem(ctx, PR_4_BAD_REF_COUNT, &pctx))) {
                                inode->i_links_count = link_counted;
                                e2fsck_write_inode(ctx, i, inode, "pass4");
                        }