Whamcloud - gitweb
e2fsck: merge dirs_to_hash when threads finish
authorWang Shilong <wshilong@ddn.com>
Mon, 24 Feb 2020 04:44:06 +0000 (12:44 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Mon, 28 Mar 2022 22:13:09 +0000 (16:13 -0600)
@dirs_to_hash list need be merged after threads finish,
test covered by t_dangerous.

E2fsprogs-commit: e2db6c19943065909c11af3b03c2904c35e5e4f8

Change-Id: I99b44c40afa22ce8e4530c874b077493cf969e03
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c

index 14e33ee..922de3d 100644 (file)
@@ -2497,6 +2497,25 @@ static errcode_t e2fsck_pass1_merge_icounts(e2fsck_t global_ctx, e2fsck_t thread
        return ret;
 }
 
+static errcode_t e2fsck_pass1_merge_dirs_to_hash(e2fsck_t global_ctx,
+                                                e2fsck_t thread_ctx)
+{
+       errcode_t retval = 0;
+
+       if (!thread_ctx->dirs_to_hash)
+               return 0;
+
+       if (!global_ctx->dirs_to_hash)
+               retval = ext2fs_badblocks_copy(thread_ctx->dirs_to_hash,
+                                              &global_ctx->dirs_to_hash);
+       else
+               retval = ext2fs_badblocks_merge(thread_ctx->dirs_to_hash,
+                                               global_ctx->dirs_to_hash);
+
+       return retval;
+}
+
+
 static int e2fsck_pass1_thread_join_one(e2fsck_t global_ctx, e2fsck_t thread_ctx)
 {
        errcode_t        retval;
@@ -2539,6 +2558,7 @@ static int e2fsck_pass1_thread_join_one(e2fsck_t global_ctx, e2fsck_t thread_ctx
        __u32 large_files = global_ctx->large_files;
        ext2_ino_t dx_dir_info_size = global_ctx->dx_dir_info_size;
        ext2_ino_t dx_dir_info_count = global_ctx->dx_dir_info_count;
+       ext2_u32_list dirs_to_hash = global_ctx->dirs_to_hash;
 
 #ifdef HAVE_SETJMP_H
        jmp_buf          old_jmp;
@@ -2608,6 +2628,14 @@ static int e2fsck_pass1_thread_join_one(e2fsck_t global_ctx, e2fsck_t thread_ctx
                return retval;
        }
 
+       global_ctx->dirs_to_hash = dirs_to_hash;
+       retval = e2fsck_pass1_merge_dirs_to_hash(global_ctx, thread_ctx);
+       if (retval) {
+               com_err(global_ctx->program_name, 0,
+                       _("while merging dirs to hash\n"));
+               return retval;
+       }
+
        retval = e2fsck_pass1_merge_bitmap(global_fs,
                                &thread_ctx->inode_used_map,
                                &global_ctx->inode_used_map);
@@ -2694,6 +2722,8 @@ static int e2fsck_pass1_thread_join(e2fsck_t global_ctx, e2fsck_t thread_ctx)
        e2fsck_free_dir_info(thread_ctx);
        ext2fs_free_icount(thread_ctx->inode_count);
        ext2fs_free_icount(thread_ctx->inode_link_info);
+       if (thread_ctx->dirs_to_hash)
+               ext2fs_badblocks_list_free(thread_ctx->dirs_to_hash);
        ext2fs_free_mem(&thread_ctx);
 
        return retval;