2003-07-20 22:46:52

by Olaf Dietsche

[permalink] [raw]
Subject: [PATCH][RFC] speeding up fsck -A

With this patch, I get a speedup of about 60%. During boot time it is
even more. Can someone please tell me, why and when this WNOHANG was
introduced. fsck seems to work fine without it.

You will probably gain nothing on SMP, because it doesn't hurt when
fsck hogs one CPU and the real fsck.ext2 does the main work on
another CPU.

This is on Debian unstable and kernel 2.5.72.

Regards, Olaf.

--- e2fsprogs/misc/fsck.c.orig Wed Apr 16 22:13:56 2003
+++ e2fsprogs/misc/fsck.c Sun Jul 20 23:35:03 2003
@@ -105,6 +105,7 @@
int parallel_root = 0;
int progress = 0;
int force_all_parallel = 0;
+int no_busy_waiting = 0;
int num_running = 0;
int max_running = 0;
volatile int cancel_requested = 0;
@@ -1007,7 +1008,8 @@
break;
if (verbose > 1)
printf(_("--waiting-- (pass %d)\n"), passno);
- status |= wait_all(pass_done ? 0 : WNOHANG);
+ status |= wait_all((pass_done || no_busy_waiting) ? 0 : WNOHANG);
+
if (pass_done) {
if (verbose > 1)
printf("----------------------------------\n");
@@ -1153,6 +1155,9 @@
fstype = string_copy(tmp);
compile_fs_type(fstype, &fs_type_compiled);
goto next_arg;
+ case 'X':
+ no_busy_waiting++;
+ break;
case '-':
opts_for_fsck++;
break;


2003-07-22 01:17:29

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH][RFC] speeding up fsck -A

On Mon, Jul 21, 2003 at 01:01:44AM +0200, Olaf Dietsche wrote:
> With this patch, I get a speedup of about 60%. During boot time it is
> even more. Can someone please tell me, why and when this WNOHANG was
> introduced. fsck seems to work fine without it.

This isn't a kernel problem; you should have just sent it to me
directly as an e2fsprogs maintainer, as documented in the README file
in the e2fsprogs source tree, or in /usr/shared/doc/e2fsprogs/README
on a Debian system, instead of bothering folks on the kernel list.

In any case, thanks for reporting this bug; I've fixed it
appropriately in the latest e2fsprogs sources. The WNOHANG was
introduced when I added support for the FSCK_MAX_INST environment
variable, which allows to user to constrain the maximum number of
child fsck's running at the same time, and FSCK_FORCE_ALL_PARALLEL.
What I needed to do was to call wait_one in blocking mode the first
time, and then call it in WNOHANG mode until all exited children have
been reaped. This is necessary so that fsck will start keep the
necesary number of children in parallel at the same time. What I did
instead was to always call it with WNOHANG always, which caused a
CPU-burning loop. Oops.

Anyway, this will be fixed in the next release, which will be soon at
this point....

- Ted