diff --git a/sbin/fsck/fsck.8 b/sbin/fsck/fsck.8 index 9c7055a1a3f6..775747c5eb6b 100644 --- a/sbin/fsck/fsck.8 +++ b/sbin/fsck/fsck.8 @@ -62,12 +62,24 @@ to determine which filesystems to check. Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro'' and that have non-zero pass number are checked. Filesystems with pass number 1 (normally just the root filesystem) -are checked one at a time. -When pass 1 completes, all remaining filesystems are checked, -running one process per disk drive. +are always checked one at a time. +.Pp +If not in preen mode, the remaining entries are checked in order of +increasing pass number one at a time. +This is needed when interaction with fsck is required. +.Pp +In preen mode, after pass 1 completes, all remaining filesystems are checked, +in pass number order running one process per disk drive in parallel for each +pass number in increasing order. +.Pp +In other words: In preen mode all pass 1 partitions are checked sequentially. +Next all pass 2 partitions are checked in parallel, one process per disk drive. +Next all pass 3 partitions are checked in parallel, one process per disk drive. +etc. +.Pp The disk drive containing each filesystem is inferred from the shortest prefix of the device name that ends in a digit; the remaining characters are assumed -to be the partition and slice designator. +to be the partition and slice designators. .Pp The options are as follows: .Bl -tag -width indent @@ -79,11 +91,6 @@ is compiled to support it. .It Fl f Force checking of filesystems, even when they are marked clean (for filesystems that support this). -.It Fl l Ar maxparallel -Limit the number of parallel checks to the number specified in -the following argument. By default, the limit is the number of -disks, running one process per disk. If a smaller limit is giv- -en, the disks are checked round-robin, one filesystem at a time. .It Fl n Causes .Nm diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index 2eb26a077acd..a4d241a8bb59 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -76,7 +76,6 @@ struct entry { TAILQ_ENTRY(entry) entries; }; -static int maxrun = 0; static char *options = NULL; static int flags = 0; @@ -132,7 +131,7 @@ main(argc, argv) break; case 'l': - maxrun = atoi(optarg); + warnx("Ignoring obsolete -l option\n"); break; case 'T': @@ -158,7 +157,7 @@ main(argc, argv) argv += optind; if (argc == 0) - return checkfstab(flags, maxrun, isok, checkfs); + return checkfstab(flags, isok, checkfs); #define BADTYPE(type) \ (strcmp(type, FSTAB_RO) && \ diff --git a/sbin/fsck/fsutil.h b/sbin/fsck/fsutil.h index 98c45066ac3e..a4eca070082c 100644 --- a/sbin/fsck/fsutil.h +++ b/sbin/fsck/fsutil.h @@ -58,5 +58,5 @@ char *estrdup __P((const char *)); #define CHECK_DEBUG 4 struct fstab; -int checkfstab __P((int, int, void *(*)(struct fstab *), +int checkfstab __P((int, void *(*)(struct fstab *), int (*) (const char *, const char *, const char *, void *, pid_t *))); diff --git a/sbin/fsck/preen.c b/sbin/fsck/preen.c index 3beda3ed6d73..ee1aad2702d6 100644 --- a/sbin/fsck/preen.c +++ b/sbin/fsck/preen.c @@ -87,8 +87,8 @@ static int startdisk __P((struct diskentry *, static void printpart __P((void)); int -checkfstab(flags, maxrun, docheck, checkit) - int flags, maxrun; +checkfstab(flags, docheck, checkit) + int flags; void *(*docheck) __P((struct fstab *)); int (*checkit) __P((const char *, const char *, const char *, void *, pid_t *)); @@ -96,7 +96,7 @@ checkfstab(flags, maxrun, docheck, checkit) struct fstab *fs; struct diskentry *d, *nextdisk; struct partentry *p; - int ret, pid, retcode, passno, sumstatus, status; + int ret, pid, retcode, passno, sumstatus, status, nextpass; void *auxarg; const char *name; @@ -105,7 +105,12 @@ checkfstab(flags, maxrun, docheck, checkit) sumstatus = 0; - for (passno = 1; passno <= 2; passno++) { + nextpass = 0; + for (passno = 1; nextpass != INT_MAX; passno = nextpass) { + if (flags & CHECK_DEBUG) + printf("pass %d\n", passno); + + nextpass = INT_MAX; if (setfsent() == 0) { warnx("Can't open checklist file: %s\n", _PATH_FSTAB); return (8); @@ -114,14 +119,17 @@ checkfstab(flags, maxrun, docheck, checkit) if ((auxarg = (*docheck)(fs)) == NULL) continue; - /* XXX We don't need to search for blockdevs .. */ - /* name = blockcheck(fs->fs_spec); */ name = fs->fs_spec; + if (fs->fs_passno > passno && fs->fs_passno < nextpass) + nextpass = fs->fs_passno; + + if (passno != fs->fs_passno) + continue; + if (flags & CHECK_DEBUG) printf("pass %d, name %s\n", passno, name); - if ((flags & CHECK_PREEN) == 0 || - (passno == 1 && fs->fs_passno == 1)) { + if ((flags & CHECK_PREEN) == 0 || passno == 1) { if (name == NULL) { if (flags & CHECK_PREEN) return 8; @@ -133,36 +141,33 @@ checkfstab(flags, maxrun, docheck, checkit) if (sumstatus) return (sumstatus); - } else if (passno == 2 && fs->fs_passno > 1) { - if (name == NULL) { - (void) fprintf(stderr, - "BAD DISK NAME %s\n", fs->fs_spec); - sumstatus |= 8; - continue; - } - addpart(fs->fs_vfstype, name, fs->fs_file, - auxarg); + continue; + } + if (name == NULL) { + (void) fprintf(stderr, + "BAD DISK NAME %s\n", fs->fs_spec); + sumstatus |= 8; + continue; } + addpart(fs->fs_vfstype, name, fs->fs_file, + auxarg); } - if ((flags & CHECK_PREEN) == 0) - return 0; - } - if (flags & CHECK_DEBUG) - printpart(); + if ((flags & CHECK_PREEN) == 0 || passno == 1) + continue; - if (flags & CHECK_PREEN) { - if (maxrun == 0) - maxrun = ndisks; - if (maxrun > ndisks) - maxrun = ndisks; - nextdisk = TAILQ_FIRST(&diskh); - for (passno = 0; passno < maxrun; ++passno) { + if (flags & CHECK_DEBUG) { + printf("Parallel start\n"); + printpart(); + } + + TAILQ_FOREACH(nextdisk, &diskh, d_entries) { if ((ret = startdisk(nextdisk, checkit)) != 0) return ret; - nextdisk = TAILQ_NEXT(nextdisk, d_entries); } + if (flags & CHECK_DEBUG) + printf("Parallel wait\n"); while ((pid = wait(&status)) != -1) { TAILQ_FOREACH(d, &diskh, d_entries) if (d->d_pid == pid) @@ -207,28 +212,20 @@ checkfstab(flags, maxrun, docheck, checkit) d->d_pid = 0; nrun--; - if (TAILQ_EMPTY(&d->d_part)) + if (TAILQ_EMPTY(&d->d_part)) { + TAILQ_REMOVE(&diskh, d, d_entries); ndisks--; - - if (nextdisk == NULL) { - if (!TAILQ_EMPTY(&d->d_part)) { - if ((ret = startdisk(d, checkit)) != 0) - return ret; - } - } else if (nrun < maxrun && nrun < ndisks) { - for ( ;; ) { - nextdisk = TAILQ_NEXT(nextdisk, d_entries); - if (nextdisk == NULL) - nextdisk = TAILQ_FIRST(&diskh); - if (!TAILQ_EMPTY(&nextdisk->d_part) - && nextdisk->d_pid == 0) - break; - } - if ((ret = startdisk(nextdisk, checkit)) != 0) - return ret; } } + if (flags & CHECK_DEBUG) { + printf("Parallel end\n"); + printpart(); + } } + + if (!(flags & CHECK_PREEN)) + return 0; + if (sumstatus) { p = TAILQ_FIRST(&badh); if (p == NULL)