]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fsck.c (wait_many): Rename wait_all() to wait_many(), and have
authorTheodore Ts'o <tytso@mit.edu>
Tue, 22 Jul 2003 00:43:21 +0000 (20:43 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 22 Jul 2003 00:43:21 +0000 (20:43 -0400)
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.

misc/ChangeLog
misc/fsck.c

index 3ec27c9398255d31923d5fb897ae53460164db00..e3d534b6a2d8185094fa27fddaa8d3ab011f67ab 100644 (file)
@@ -1,3 +1,10 @@
+2003-07-21  Theodore Ts'o  <tytso@mit.edu>
+
+       * 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.
+
 2003-07-12  Theodore Ts'o  <tytso@mit.edu>
 
        * badblocks.c (do_read, do_write, test_rw): Change the read/write
index b069cd5832de60dec70f8da79ed3ed0bc7b7046e..28bd7a2af304ec191255d93eef4587796b66c06d 100644 (file)
@@ -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;