public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Alessandro Carminati <alessandro.carminati@gmail.com>
To: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Fix tst_find_backing_dev when no initramfs
Date: Fri, 21 Oct 2022 14:18:08 +0000	[thread overview]
Message-ID: <Y1KqIExvM4LDcefZ@lab.hqhome163.com> (raw)

After having discussed this patch content with Jan Stancek, I realized that 
my patch log is too minimal.
By this message, I want to substantiate the case.
I will start by saying the problem I want to fix happens in minimal systems: 
the kernel and minimal onit scripts.
This is the case of many embedded system powered by linux.
Here is the link of a minimal system I used to test the patch.
https://gitlab.com/acarmina/test-files/-/blob/main/testenv.tar.gz
In such a system, you have:

# cat /proc/cmdline 
console=ttyS0 root=/dev/sda rw   rootwait
# cat /proc/self/mountinfo 
14 1 8:0 / / rw,relatime - ext2 /dev/root rw
15 14 0:5 / /dev rw,relatime - devtmpfs devtmpfs rw,size=505412k,nr_inodes=126353,mode=755
16 14 0:13 / /proc rw,relatime - proc proc rw
17 15 0:14 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
18 15 0:15 / /dev/shm rw,relatime - tmpfs tmpfs rw,mode=777
19 14 0:16 / /tmp rw,relatime - tmpfs tmpfs rw
20 14 0:17 / /run rw,nosuid,nodev,relatime - tmpfs tmpfs rw,mode=755
21 14 0:18 / /sys rw,relatime - sysfs sysfs rw
# /usr/lib/ltp-testsuite/testcases/bin/ioctl_loop05
tst_test.c:1363: TINFO: Timeout per run is 0h 05m 00s
tst_test.c:1115: TINFO: ext2/ext3/ext4 is supported by the test
tst_device.c:88: TINFO: Found free device 0 '/dev/loop0'
loop0: detected capacity change from 0 to 2048
tst_device.c:566: TWARN: stat(/dev/root) failed: ENOENT (2)

Summary:
passed   0
failed   0
broken   0
skipped  0
warnings 1
#

/dev/root is simply not there, and the test fails with a warning.

In the systems where the /dev/root is there, it is typically a symbolic link 
to the actual device.

Digging on why this device is not there, despite the mount info reports the / 
to be mounted over it, I discovered something weird in the early kernel 
initialization:
https://elixir.bootlin.com/linux/v6.0.3/source/init/do_mounts.c#L566
In this recent kernel release it is evident how the kernel creates the 
/dev/root device node and after it mounts the new device on the / .

The problem is not widely known since in systems where the /dev/root is 
used, typically, the init scripts handle it.
Although it may look strange, this behaviour is considered the intended 
behaviour for the kernel.
An indirect proof is that as early as 2013 a patch aimed to fix this 
behaviour circulated in the kernel mailing lists 
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg378443.html
But it never made to the upstream

Assuming the current the intended kernel behaviour, the thesis I'm 
trying to push is that the test, meant to test the kernel, should not 
rely on work done in userspace init scripts.

In the patch I am pushing, my intent is to deal with this /dev/root 
peculiarity at the LTP level, by basically add a logic that replaces 
the actual device in case of stat failing on the /dev/root case.

I hope this make my patch context clear.

Cheers
Alessandro

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2022-10-21 14:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 14:18 Alessandro Carminati [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-17 11:05 [LTP] [PATCH] Fix tst_find_backing_dev when no initramfs Alessandro Carminati
2022-10-24 13:49 ` Richard Palethorpe
2022-10-25  9:11   ` Alessandro Carminati

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1KqIExvM4LDcefZ@lab.hqhome163.com \
    --to=alessandro.carminati@gmail.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox