rootwait regression in linux-next

Fabio Estevam posted 1 patch 2 years, 8 months ago
rootwait regression in linux-next
Posted by Fabio Estevam 2 years, 8 months ago
Hi Christoph,

I observe the following boot regression in linux-next 20230606:

[    1.757719] ALSA device list:
[    1.760705]   No soundcards found.
[    1.774453] mmc1: SDHCI controller on 30b50000.mmc [30b50000.mmc] using ADMA
[    1.786190] Disabling rootwait; root= is invalid.
[    1.792548] /dev/root: Can't open blockdev
[    1.796689] VFS: Cannot open root device "/dev/mmcblk1p1" or
unknown-block(0,0): error -6
[    1.804886] Please append a correct "root=" boot option; here are
the available partitions:
[    1.813270] 1f00           32768 mtdblock0

Kernel command line: root=/dev/mmcblk1p1 rw rootwait

If I try an ugly hack like this:

--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -412,7 +412,7 @@ static dev_t __init parse_root_device(char
*root_device_name)
                return Root_RAM0;

        error = early_lookup_bdev(root_device_name, &dev);
-       if (error) {
+       if (0) {
                if (error == -EINVAL && root_wait) {
                        pr_err("Disabling rootwait; root= is invalid.\n");
                        root_wait = 0;

Then the board boots fine:

[    1.790845] Waiting for root device /dev/mmcblk1p1...
[    2.058169] mmc1: host does not support reading read-only switch,
assuming write-enable
[    2.097079] mmc1: new ultra high speed SDR104 SDHC card at address aaaa
[    2.104925] mmcblk1: mmc1:aaaa SP32G 29.7 GiB
[    2.113269]  mmcblk1: p1 p2 p3
[    2.154538] EXT4-fs (mmcblk1p1): recovery complete
[    2.160651] EXT4-fs (mmcblk1p1): mounted filesystem
3e7994a8-04cb-45d2-a6f5-64462aa0ea05 r/w with ordered data mode. Quota
mode: none.
[    2.172828] VFS: Mounted root (ext4 filesystem) on device 179:97.

What is the appropriate fix for this issue?

Thanks
Re: rootwait regression in linux-next
Posted by Christoph Hellwig 2 years, 8 months ago
Hi Fabio,

can you try this patch?

diff --git a/block/early-lookup.c b/block/early-lookup.c
index 3ff0d2e4dcbfb8..ca3b4f494c9330 100644
--- a/block/early-lookup.c
+++ b/block/early-lookup.c
@@ -174,7 +174,7 @@ static int __init devt_from_devname(const char *name, dev_t *devt)
 	while (p > s && isdigit(p[-1]))
 		p--;
 	if (p == s || !*p || *p == '0')
-		return -EINVAL;
+		return -ENOENT;
 
 	/* try disk name without <part number> */
 	part = simple_strtoul(p, NULL, 10);
Re: rootwait regression in linux-next
Posted by Fabio Estevam 2 years, 8 months ago
Hi Christoph,

On Wed, Jun 7, 2023 at 2:38 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Hi Fabio,
>
> can you try this patch?
>
> diff --git a/block/early-lookup.c b/block/early-lookup.c
> index 3ff0d2e4dcbfb8..ca3b4f494c9330 100644
> --- a/block/early-lookup.c
> +++ b/block/early-lookup.c
> @@ -174,7 +174,7 @@ static int __init devt_from_devname(const char *name, dev_t *devt)
>         while (p > s && isdigit(p[-1]))
>                 p--;
>         if (p == s || !*p || *p == '0')
> -               return -EINVAL;
> +               return -ENOENT;

Unfortunately, it does not help.

I have added some debug prints:

--- a/block/early-lookup.c
+++ b/block/early-lookup.c
@@ -157,15 +157,21 @@ static int __init devt_from_devname(const char
*name, dev_t *devt)

        if (strlen(name) > 31)
                return -EINVAL;
+
+       pr_err("***** %s: 1\n", __func__);
        strcpy(s, name);
        for (p = s; *p; p++) {
                if (*p == '/')
                        *p = '!';
        }
+
+       pr_err("***** %s: 2\n", __func__);

        *devt = blk_lookup_devt(s, 0);
        if (*devt)
                return 0;
+
+       pr_err("***** %s: 3\n", __func__);

        /*
         * Try non-existent, but valid partition, which may only exist after
@@ -174,7 +180,9 @@ static int __init devt_from_devname(const char
*name, dev_t *devt)
        while (p > s && isdigit(p[-1]))
                p--;
        if (p == s || !*p || *p == '0')
-               return -EINVAL;
+               return -ENOENT;
+
+       pr_err("***** %s: 4\n", __func__);

        /* try disk name without <part number> */
        part = simple_strtoul(p, NULL, 10);
@@ -182,14 +190,18 @@ static int __init devt_from_devname(const char
*name, dev_t *devt)
        *devt = blk_lookup_devt(s, part);
        if (*devt)
                return 0;
+
+       pr_err("***** %s: 5\n", __func__);

        /* try disk name without p<part number> */
        if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p')
                return -EINVAL;
+       pr_err("***** %s: 6\n", __func__);
        p[-1] = '\0';
        *devt = blk_lookup_devt(s, part);
        if (*devt)
                return 0;
+       pr_err("***** %s: 7\n", __func__);
        return -EINVAL;
 }

[    1.627144] mmc1: SDHCI controller on 30b50000.mmc [30b50000.mmc] using ADMA
[    1.629380] mmcblk2rpmb: mmc2:0001 DG4016 4.00 MiB, chardev (241:0)
[    1.664895] ***** devt_from_devname: 1
[    1.668681] ***** devt_from_devname: 2
[    1.672467] ***** devt_from_devname: 3
[    1.676230] ***** devt_from_devname: 4
[    1.680011] ***** devt_from_devname: 5
[    1.683778] ***** devt_from_devname: 6
[    1.687546] ***** devt_from_devname: 7
[    1.691314] Disabling rootwait; root= is invalid.
[    1.696842] /dev/root: Can't open blockdev
[    1.700988] VFS: Cannot open root device "/dev/mmcblk1p1" or
unknown-block(0,0): error -6

Let me know if you need me to run more debugging tests.
Re: rootwait regression in linux-next
Posted by Christoph Hellwig 2 years, 8 months ago
Hi Fabio,

I guess we need an ENODEV for that last case as well.  Please try this
patch:

diff --git a/block/early-lookup.c b/block/early-lookup.c
index 3ff0d2e4dcbfb8..48ea3e982419cc 100644
--- a/block/early-lookup.c
+++ b/block/early-lookup.c
@@ -181,7 +181,7 @@ static int __init devt_from_devname(const char *name, dev_t *devt)
 	*p = '\0';
 	*devt = blk_lookup_devt(s, part);
 	if (*devt)
-		return 0;
+		return -ENODEV;
 
 	/* try disk name without p<part number> */
 	if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p')
@@ -190,7 +190,7 @@ static int __init devt_from_devname(const char *name, dev_t *devt)
 	*devt = blk_lookup_devt(s, part);
 	if (*devt)
 		return 0;
-	return -EINVAL;
+	return -ENODEV;
 }
 
 static int __init devt_from_devnum(const char *name, dev_t *devt)
Re: rootwait regression in linux-next
Posted by Fabio Estevam 2 years, 8 months ago
Hi Christoph,

On Wed, Jun 7, 2023 at 10:37 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Hi Fabio,
>
> I guess we need an ENODEV for that last case as well.  Please try this
> patch:

Yes, this one fixes the issue, thanks!

Tested-by: Fabio Estevam <festevam@gmail.com>