diff options
author | Theodore Ts'o <tytso@mit.edu> | 2003-07-21 20:43:21 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2003-07-21 20:43:21 -0400 |
commit | 5e38fed9c5e5c0741ff00fc7001b44a075bfb64c (patch) | |
tree | 9cb2f6866879b336ef484604b9e6dd38f78101b3 /misc/fsck.c | |
parent | e7a8a9df55bae3f189a68f5bf7ae461441bb3a21 (diff) | |
download | e2fsprogs-5e38fed9c5e5c0741ff00fc7001b44a075bfb64c.tar.gz |
fsck.c (wait_many): Rename wait_all() to wait_many(), and have
new semantics: WAIT_ALL vs. WAIT_ATLEAST_ONE. This fixes
a bug where when fsck is waiting for another partition on
the same spindle, it spins wasting a lot of CPU.
Diffstat (limited to 'misc/fsck.c')
-rw-r--r-- | misc/fsck.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/misc/fsck.c b/misc/fsck.c index b069cd58..28bd7a2a 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -635,22 +635,27 @@ ret_inst: return inst; } +#define FLAG_WAIT_ALL 0 +#define FLAG_WAIT_ATLEAST_ONE 1 /* * Wait until all executing child processes have exited; return the * logical OR of all of their exit code values. */ -static int wait_all(int flags) +static int wait_many(int flags) { struct fsck_instance *inst; int global_status = 0; + int wait_flags = 0; - while ((inst = wait_one(flags))) { + while ((inst = wait_one(wait_flags))) { global_status |= inst->exit_status; free_instance(inst); #ifdef RANDOM_DEBUG if (noexecute && (flags & WNOHANG) && !(random() % 3)) break; #endif + if (flags & FLAG_WAIT_ATLEAST_ONE) + wait_flags = WNOHANG; } return global_status; } @@ -943,7 +948,7 @@ static int check_all(NOARGS) if (fs) { if (!skip_root && !ignore(fs)) { fsck_device(fs, 1); - status |= wait_all(0); + status |= wait_many(FLAG_WAIT_ALL); if (status > EXIT_NONDESTRUCT) return status; } @@ -1007,7 +1012,8 @@ static int check_all(NOARGS) break; if (verbose > 1) printf(_("--waiting-- (pass %d)\n"), passno); - status |= wait_all(pass_done ? 0 : WNOHANG); + status |= wait_many(pass_done ? FLAG_WAIT_ALL : + FLAG_WAIT_ATLEAST_ONE); if (pass_done) { if (verbose > 1) printf("----------------------------------\n"); @@ -1019,7 +1025,7 @@ static int check_all(NOARGS) kill_all(SIGTERM); kill_sent++; } - status |= wait_all(0); + status |= wait_many(FLAG_WAIT_ATLEAST_ONE); return status; } @@ -1264,7 +1270,7 @@ int main(int argc, char *argv[]) printf("----------------------------------\n"); } } - status |= wait_all(0); + status |= wait_many(FLAG_WAIT_ALL); free(fsck_path); blkid_put_cache(cache); return status; |