@@ -448,6 +448,7 @@ struct e2fsck_struct {
__u32 fs_ext_attr_inodes;
__u32 fs_ext_attr_blocks;
__u32 extent_depth_count[MAX_EXTENT_DEPTH_COUNT];
+ __u32 fs_num_threads;
/* serialize fix operation for multiple threads */
pthread_mutex_t fs_fix_mutex;
/* protect block_found_map, block_dup_map */
@@ -3127,11 +3127,14 @@ static void init_ext2_max_sizes()
static void e2fsck_pass1_multithread(e2fsck_t global_ctx)
{
struct e2fsck_thread_info *infos = NULL;
- int num_threads = 1;
+ int num_threads = global_ctx->fs_num_threads;
errcode_t retval;
unsigned flexbg_size = 1;
int max_threads;
+ if (num_threads < 1)
+ num_threads = 1;
+
retval = _e2fsck_pass1_prepare(global_ctx);
if (retval)
goto out_abort;
@@ -3149,11 +3152,12 @@ static void e2fsck_pass1_multithread(e2fsck_t global_ctx)
int times = max_threads / num_threads;
if (times == 0)
- num_threads = 1;
+ num_threads = max_threads;
else
num_threads = max_threads / times;
}
+ global_ctx->fs_num_threads = num_threads;
init_ext2_max_sizes();
retval = e2fsck_pass1_threads_start(&infos, num_threads, global_ctx);
if (retval) {
@@ -848,7 +848,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
phys_mem_kb = get_memory_size() / 1024;
ctx->readahead_kb = ~0ULL;
- while ((c = getopt(argc, argv, "pamnyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF)
+ while ((c = getopt(argc, argv, "pam:nyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF)
switch (c) {
case 'C':
ctx->progress = e2fsck_update_progress;
@@ -891,6 +891,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
break;
case 'm':
ctx->options |= E2F_OPT_MULTITHREAD;
+ ctx->fs_num_threads = atoi(optarg);
break;
case 'n':
if (ctx->options & (E2F_OPT_YES|E2F_OPT_PREEN))
@@ -1,4 +1,4 @@
-FSCK_OPT="-fy -m"
+FSCK_OPT="-fy -m1"
SECOND_FSCK_OPT=-yf
. $cmd_dir/run_e2fsck
@@ -1,4 +1,4 @@
-FSCK_OPT="-fy -m -C 1"
+FSCK_OPT="-fy -m1 -C 1"
SECOND_FSCK_OPT=-yf
. $cmd_dir/run_e2fsck
@@ -1,5 +1,5 @@
LOG_FNAME="f_multithread_logfile_xxx"
-FSCK_OPT="-fy -m -y -E log_filename=$LOG_FNAME"
+FSCK_OPT="-fy -m1 -y -E log_filename=$LOG_FNAME"
SKIP_VERIFY="true"
ONE_PASS_ONLY="true"
SKIP_CLEANUP="true"
@@ -1,4 +1,4 @@
-FSCK_OPT="-fn -m"
+FSCK_OPT="-fn -m1"
SECOND_FSCK_OPT=-yf
. $cmd_dir/run_e2fsck
@@ -1,4 +1,4 @@
-FSCK_OPT="-fp -m"
+FSCK_OPT="-fp -m1"
SECOND_FSCK_OPT=-yf
. $cmd_dir/run_e2fsck
@@ -1,4 +1,4 @@
-FSCK_OPT="-f -m"
+FSCK_OPT="-f -m1"
SECOND_FSCK_OPT=-yf
. $cmd_dir/run_e2fsck