Re: [PATCH v3] rootfs: Fix support for rootfstype= when root= is given

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 12/21/23 17:58, Askar Safin wrote:
Hi, Rob. And Stefan.

First of all, this patch got to linux-next (
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/?qt=author&q=Stefan+Berger
), so it seems it soon will be in mainline.

On Thu, Dec 21, 2023 at 12:24 PM Rob Landley <rob@xxxxxxxxxxx> wrote:
Can you build tmpfs on a nommu system? Last I checked the plumbing expects swap,
but it's been a while...
Okay, I agree, let's not remove ramfs.

Still, I don't like this (already applied) patch. init= and rdinit=
are two different options, and this is good. So, I think we should
have two different options. Analogously they should be rootfstype= and
rdrootfstype=. rootfstype= should be read by kernel when deciding how
to mount real root (i. e. not initramfs or initrd) only and
rdrootfstype= when deciding how to mount initramfs only. This will
make everything cleaner. Also note that userspace tools read
rootfstype= and assume that it always applies to real root. For
example, this is Debian's rdinit:

https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/cf964bfb4362019fd7fba1e839e403ff950dca8e/init#L103

As you can see, this shell script parses /proc/cmdline and assumes
that rootfstype= always applies to real root. So, if someone sets
rootfstype= to tmpfs or ramfs, this will likely break this script.

Setting the kernel boot command line option rootfstype= to tmpfs or ramfs was possible so far and that's what the documentation and code supported so far as well. The bug surfaced when root= was provided, in which case it was ignored.


So, I think the code should look so:

+if (IS_ENABLED(CONFIG_TMPFS)) {
+        if (!rd_root_fs_names) // We assume rd_root_fs_names is set
by rdrootfstype=
+                is_tmpfs = true; // Use tmpfs if rdrootfstype= is not
set. To get all tmpfs benefits
+        else if (rd_root_fs_names && !!strstr(rd_root_fs_names, "tmpfs"))
+                is_tmpfs = true;
+}

Yes, this will slightly break compatibility. I. e. this will make
Linux always choose tmpfs if rdrootfstype= is not present. But I think

You may find someone who doesn't like this change, either, ...

there is nothing wrong with it. If a user cares, he will set
rdrootfstype= . And early boot code will become a lot more clean and
logical.

Rob, do you agree? Stefan, do you agree? Then I will write a patch,

... but go ahead.

with doc changes (currently I use gmail web interface, of course I
will use git send-email when I sent actual patch)





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux