X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=e2fsck%2Funix.c;h=ebb1b8471b62894f7e9f0a98e3f8c5476d556d75;hb=71b74579b7e6c5cfe6af05b00e45c8a75fce0d61;hp=e4e28e04b14d133455e7f851adeb65ff84c849a9;hpb=59c8379f2b51885ee74b248ab93bdf742c1eb96d;p=tools%2Fe2fsprogs.git diff --git a/e2fsck/unix.c b/e2fsck/unix.c index e4e28e0..ebb1b84 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -82,7 +82,9 @@ static void usage(e2fsck_t ctx) fprintf(stderr, "%s", _("\nEmergency help:\n" " -p Automatic repair (no questions)\n" +#ifdef CONFIG_PFSCK " -m multiple threads to speedup fsck\n" +#endif " -n Make no changes to the filesystem\n" " -y Assume \"yes\" to all questions\n" " -c Check for bad blocks and add them to the badblock list\n" @@ -907,6 +909,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) #ifdef CONFIG_JBD_DEBUG char *jbd_debug; #endif +#ifdef CONFIG_PFSCK + char *pm; + unsigned long thread_num; +#endif unsigned long long phys_mem_kb; retval = e2fsck_allocate_context(&ctx); @@ -947,7 +953,11 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) ctx->readahead_kb = ~0ULL; ctx->inode_badness_threshold = BADNESS_THRESHOLD; - while ((c = getopt(argc, argv, "pamnyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF) +#ifdef CONFIG_PFSCK + while ((c = getopt(argc, argv, "pam:nyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF) +#else + while ((c = getopt(argc, argv, "panyrcC:B:dE:fvtFVM:b:I:j:P:l:L:N:SsDkz:")) != EOF) +#endif switch (c) { case 'C': ctx->progress = e2fsck_update_progress; @@ -988,9 +998,22 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) } ctx->options |= E2F_OPT_PREEN; break; +#ifdef CONFIG_PFSCK case 'm': + thread_num = strtoul(optarg, &pm, 0); + if (*pm) + fatal_error(ctx, + _("Invalid multiple thread num.\n")); + if (thread_num > E2FSCK_MAX_THREADS) { + fprintf(stderr, + _("threads %lu too large (max %u)\n"), + thread_num, E2FSCK_MAX_THREADS); + fatal_error(ctx, 0); + } ctx->options |= E2F_OPT_MULTITHREAD; + ctx->pfs_num_threads = thread_num; break; +#endif case 'n': if (ctx->options & (E2F_OPT_YES|E2F_OPT_PREEN)) goto conflict_opt; @@ -1109,6 +1132,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) _("The -n and -l/-L options are incompatible.")); fatal_error(ctx, 0); } +#ifdef CONFIG_PFSCK if (ctx->options & E2F_OPT_MULTITHREAD) { if ((ctx->options & (E2F_OPT_YES|E2F_OPT_NO|E2F_OPT_PREEN)) == 0) { com_err(ctx->program_name, 0, "%s", @@ -1121,6 +1145,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) fatal_error(ctx, 0); } } +#endif if (ctx->options & E2F_OPT_NO) ctx->options |= E2F_OPT_READONLY; @@ -1616,6 +1641,7 @@ restart: } ctx->openfs_flags = flags; + ctx->io_manager = io_ptr; retval = try_open_fs(ctx, flags, io_ptr, &fs); if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&