Hi all,

here's a diff to fsck to accept pass numbers greater than 2 so that one
can avoid slaughtering IO-limited deviced. This is useful for people who
have stacked softraids, all backed by the same disk, as might be found
on a laptop with encrypted home:

        /dev/wd0a / ... 1
        /dev/wd0d /usr ... 2
        /dev/wd0e /var ... 2
        # /dev/wd0f is a RAID crypto slice used to create sd0
        /dev/sd0a /home ... 3

Obviously, wd0a is checked first, then wd0d and wd0e; serially because
they are on the same device. Only after those two have finished dragging
the heads all over the place proceed to check sd0a. Or:

        /dev/wd0a / ... 1
        /dev/wd1a /usr ... 2
        /dev/wd2a /var ... 2
        /dev/wd3a /tmp ... 2
        # /dev/sd0a is a raid of wd[0123]d
        /dev/sd0a /home ... 3

Again, avoid a truckload of head moves on the component disks while
trying to check the raid volume.

diff -ur ./preen.c /usr/src/sbin/fsck/preen.c
--- ./preen.c   Tue Oct 19 11:32:34 2010
+++ /usr/src/sbin/fsck/preen.c  Fri Nov 12 19:02:20 2010
@@ -79,7 +79,7 @@
        struct fstab *fs;
        struct diskentry *d, *nextdisk;
        struct partentry *p;
-       int ret, retcode, passno, sumstatus, status;
+       int ret, retcode, passno, sumstatus, status, maxp;
        void *auxarg;
        char *name;
        pid_t pid;
@@ -88,8 +88,9 @@
        TAILQ_INIT(&diskh);

        sumstatus = 0;
+       maxp = 2;

-       for (passno = 1; passno <= 2; passno++) {
+       for (passno = 1; passno <= maxp; passno++) {
                if (setfsent() == 0) {
                        warnx("Can't open checklist file: %s", _PATH_FSTAB);
                        return (8);
@@ -101,6 +102,7 @@
                        name = blockcheck(fs->fs_spec);
                        if (flags & CHECK_DEBUG)
                                printf("pass %d, name %s\n", passno, name);
+                       maxp = (fs->fs_passno > maxp) ? fs->fs_passno : maxp;

                        if ((flags & CHECK_PREEN) == 0 ||
                            (passno == 1 && fs->fs_passno == 1)) {
@@ -115,15 +117,16 @@

                                if (sumstatus)
                                        return (sumstatus);
-                       } else if (passno == 2 && fs->fs_passno > 1) {
+                       } else  {
                                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 (passno == fs->fs_passno)
+                                       addpart(fs->fs_vfstype, name,
+                                           fs->fs_file, auxarg);
                        }
                }
                if ((flags & CHECK_PREEN) == 0)


-- 
GDB has a 'break' feature; why doesn't it have 'fix' too?

Reply via email to