From: Li Dongyang Date: Mon, 30 Aug 2021 12:43:52 +0000 (+1000) Subject: LU-14953 e2fsck: pfsck progress report X-Git-Tag: v1.47.0-wc1~37 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fd125d8cf90a7eacf698387b3297d9e4f879a00b;p=tools%2Fe2fsprogs.git LU-14953 e2fsck: pfsck progress report Re-enable progress support for pfsck. To make it work, in pass1 before calling e2fsck_update_progress, figure out the the progress for other threads as well. Change-Id: Ia039aa20f35990b550680169c8b3670b4346ce8b Signed-off-by: Li Dongyang Reviewed-on: https://review.whamcloud.com/44784 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index 04906a9..3749b68 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -494,6 +494,7 @@ struct e2fsck_struct { pthread_rwlock_t fs_fix_rwlock; /* protect block_found_map, block_dup_map */ pthread_rwlock_t fs_block_map_rwlock; + struct e2fsck_thread_info *infos; #endif }; diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 7229686..d6c2e12 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -3221,11 +3221,11 @@ static int e2fsck_pass1_thread_join(e2fsck_t global_ctx, e2fsck_t thread_ctx) return retval; } -static int e2fsck_pass1_threads_join(struct e2fsck_thread_info *infos, - e2fsck_t global_ctx) +static int e2fsck_pass1_threads_join(e2fsck_t global_ctx) { errcode_t rc; errcode_t ret = 0; + struct e2fsck_thread_info *infos = global_ctx->infos; struct e2fsck_thread_info *pinfo; int num_threads = global_ctx->pfs_num_threads; int i; @@ -3254,6 +3254,7 @@ static int e2fsck_pass1_threads_join(struct e2fsck_thread_info *infos, } } free(infos); + global_ctx->infos = NULL; return ret; } @@ -3338,8 +3339,7 @@ static dgrp_t ext2fs_get_avg_group(ext2_filsys fs) #endif } -static int e2fsck_pass1_threads_start(struct e2fsck_thread_info **pinfo, - e2fsck_t global_ctx) +static int e2fsck_pass1_threads_start(e2fsck_t global_ctx) { struct e2fsck_thread_info *infos; pthread_attr_t attr; @@ -3372,6 +3372,7 @@ static int e2fsck_pass1_threads_start(struct e2fsck_thread_info **pinfo, pthread_attr_destroy(&attr); return retval; } + global_ctx->infos = infos; average_group = ext2fs_get_avg_group(global_ctx->fs); for (i = 0; i < num_threads; i++) { @@ -3412,26 +3413,24 @@ static int e2fsck_pass1_threads_start(struct e2fsck_thread_info **pinfo, } if (retval) { - e2fsck_pass1_threads_join(infos, global_ctx); + e2fsck_pass1_threads_join(global_ctx); return retval; } - *pinfo = infos; return 0; } static void e2fsck_pass1_multithread(e2fsck_t global_ctx) { - struct e2fsck_thread_info *infos = NULL; errcode_t retval; - retval = e2fsck_pass1_threads_start(&infos, global_ctx); + retval = e2fsck_pass1_threads_start(global_ctx); if (retval) { com_err(global_ctx->program_name, retval, _("while starting pass1 threads\n")); goto out_abort; } - retval = e2fsck_pass1_threads_join(infos, global_ctx); + retval = e2fsck_pass1_threads_join(global_ctx); if (retval) { com_err(global_ctx->program_name, retval, _("while joining pass1 threads\n")); @@ -3477,7 +3476,10 @@ static errcode_t scan_callback(ext2_filsys fs, { struct scan_callback_struct *scan_struct; e2fsck_t ctx; + dgrp_t cur = group + 1; struct e2fsck_thread *tinfo; + struct e2fsck_thread_info *pinfo, *infos; + int i; scan_struct = (struct scan_callback_struct *) priv_data; ctx = scan_struct->ctx; @@ -3486,8 +3488,28 @@ static errcode_t scan_callback(ext2_filsys fs, scan_struct->inodes_to_process, scan_struct->process_inode_count); +#ifdef HAVE_PTHREAD + if (ctx->global_ctx) { + cur = 0; + infos = ctx->global_ctx->infos; + for (i = 0; i < ctx->global_ctx->pfs_num_threads; i++) { + pinfo = &infos[i]; + + if (!pinfo->eti_started) + continue; + + tinfo = &pinfo->eti_thread_ctx->thread_info; + if (ctx == pinfo->eti_thread_ctx) + cur += group + 1 - tinfo->et_group_start; + else + cur += tinfo->et_group_next - + tinfo->et_group_start; + } + } +#endif + if (ctx->progress) - if ((ctx->progress)(ctx, 1, group+1, + if ((ctx->progress)(ctx, 1, cur, ctx->fs->group_desc_count)) return EXT2_ET_CANCEL_REQUESTED; diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 9ee7d33..0288f03 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -1049,11 +1049,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) _("The -m option should be used together with one of -p/-y/-n options.")); fatal_error(ctx, 0); } - if (ctx->progress) { - com_err(ctx->program_name, 0, "%s", - _("Only one of the options -C or -m may be specified.")); - fatal_error(ctx, 0); - } } #endif if (ctx->options & E2F_OPT_NO) @@ -1162,12 +1157,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) #ifdef SA_RESTART sa.sa_flags = SA_RESTART; #endif - if ((ctx->options & E2F_OPT_MULTITHREAD) == 0) { - sa.sa_handler = signal_progress_on; - sigaction(SIGUSR1, &sa, 0); - sa.sa_handler = signal_progress_off; - sigaction(SIGUSR2, &sa, 0); - } + sa.sa_handler = signal_progress_on; + sigaction(SIGUSR1, &sa, 0); + sa.sa_handler = signal_progress_off; + sigaction(SIGUSR2, &sa, 0); #endif /* Update our PATH to include /sbin if we need to run badblocks */ diff --git a/tests/f_multithread_completion/expect.1 b/tests/f_multithread_completion/expect.1 deleted file mode 100644 index 61cac9b..0000000 --- a/tests/f_multithread_completion/expect.1 +++ /dev/null @@ -1,2 +0,0 @@ -../e2fsck/e2fsck: Only one of the options -C or -m may be specified. -Exit status is 8 diff --git a/tests/f_multithread_completion/expect.2 b/tests/f_multithread_completion/expect.2 deleted file mode 100644 index e2b954d..0000000 --- a/tests/f_multithread_completion/expect.2 +++ /dev/null @@ -1,23 +0,0 @@ -ext2fs_open2: Bad magic number in super-block -../e2fsck/e2fsck: Superblock invalid, trying backup blocks... -Pass 1: Checking inodes, blocks, and sizes -Pass 2: Checking directory structure -Pass 3: Checking directory connectivity -Pass 4: Checking reference counts -Pass 5: Checking group summary information -Free blocks count wrong for group #0 (7987, counted=7982). -Fix? yes - -Free blocks count wrong (11602, counted=11597). -Fix? yes - -Free inodes count wrong for group #0 (1493, counted=1488). -Fix? yes - -Free inodes count wrong (2997, counted=2992). -Fix? yes - - -test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** -test_filesys: 16/3008 files (0.0% non-contiguous), 403/12000 blocks -Exit status is 1 diff --git a/tests/f_multithread_completion/image.gz b/tests/f_multithread_completion/image.gz deleted file mode 120000 index 0fd4001..0000000 --- a/tests/f_multithread_completion/image.gz +++ /dev/null @@ -1 +0,0 @@ -../f_zero_super/image.gz \ No newline at end of file diff --git a/tests/f_multithread_completion/name b/tests/f_multithread_completion/name deleted file mode 100644 index a959045..0000000 --- a/tests/f_multithread_completion/name +++ /dev/null @@ -1 +0,0 @@ -test "e2fsck -m" option conflicts with "-C" \ No newline at end of file diff --git a/tests/f_multithread_completion/script b/tests/f_multithread_completion/script deleted file mode 100644 index 0ec1381..0000000 --- a/tests/f_multithread_completion/script +++ /dev/null @@ -1,4 +0,0 @@ -FSCK_OPT="-fy -m1 -C 1" -SECOND_FSCK_OPT=-yf - -. $cmd_dir/run_e2fsck