On Sat, 10 Mar 2018, Ian Lepore wrote:

Author: ian
...
Log:
 Make root mount timeout logic work for filesystems other than ufs.
...
 These changes are based on the patch attached to the PR, but it's rewritten
 enough that all mistakes belong to me.

 PR:            208882
 X-MFC after:   sufficient testing, and hopefully in time for 11.1

This clones overflow bug, and I just noticed that the existing delays
are misplaced too.

Modified: head/sys/kern/vfs_mountroot.c
==============================================================================
--- head/sys/kern/vfs_mountroot.c       Sat Mar 10 20:46:36 2018        
(r330744)
+++ head/sys/kern/vfs_mountroot.c       Sat Mar 10 22:07:57 2018        
(r330745)
@@ -755,15 +755,31 @@ parse_mount(char **conf)
        if (error != 0)
                goto out;

-       ma = NULL;
-       ma = mount_arg(ma, "fstype", fs, -1);
-       ma = mount_arg(ma, "fspath", "/", -1);
-       ma = mount_arg(ma, "from", dev, -1);
-       ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL);
-       ma = mount_arg(ma, "ro", NULL, 0);
-       ma = parse_mountroot_options(ma, opts);
-       error = kernel_mount(ma, MNT_ROOTFS);
+       delay = hz / 10;
+       timeout = root_mount_timeout * hz;

Old bugs cloned from vfs_mountroot_wait_if_necessary():
- when hz < 10, delay is 0 which means infinity for pause(), and also for
  the loop
- when hz >= 10 but is not a multiple of 10, there is a minor inaccuracy
- when hz is "infinity" or just large, root_mount_timeout * hz overflows.
These bugs can be fixed using sbt_pause().


+       for (;;) {
+               ma = NULL;
+               ma = mount_arg(ma, "fstype", fs, -1);
+               ma = mount_arg(ma, "fspath", "/", -1);
+               ma = mount_arg(ma, "from", dev, -1);
+               ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL);
+               ma = mount_arg(ma, "ro", NULL, 0);
+               ma = parse_mountroot_options(ma, opts);
+
+               error = kernel_mount(ma, MNT_ROOTFS);
+               if (error == 0 || timeout <= 0)
+                       break;
+
+               if (root_mount_timeout * hz == timeout ||
+                   (bootverbose && timeout % hz == 0)) {
+                       printf("Mounting from %s:%s failed with error %d; "
+                           "retrying for %d more second%s\n", fs, dev, error,
+                           timeout / hz, (timeout / hz > 1) ? "s" : "");
+               }
+               pause("rmretry", delay);
+               timeout -= delay;
+       }
 out:
        if (error) {
                printf("Mounting from %s:%s failed with error %d",

Misplaced delays: the order is to try each device in vfs.root.mountfrom
in the outer loop with delays in the inner loop, but should be to try
each device in the inner loop with delays in the outer loop.

I use a generic vfs.root.mountfrom with entries for many different FreeBSD
versions and target systems.  Renaming and renumbering devices causes
problems, but it can usually be arranged that the preferred device either
exists initially or never exists.  Retrying for never-existing devices in
the inner loop wastes many seconds.  Retrying in the outer loop would
waste at most <number of devices> * 0.1 seconds.

Only the error reporting for the correct is complicated.  Currently, failure
is reported once for devices probed but not found, so later devices in my
list are not probed and not reported.  The above gives a new bug: double
error reporting for the first retry and the final failure for devices early
on the list that never exist. I want to see exactly 1 report for all nonexistent devices early in the list. In the usual case, there is 1
failure and no retries for devices early in the list; then mount succeeds
on the first try for some device and the probe completes (it is too difficult
to probe the list after 1 success).

Bruce
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to