9p: add support for root file systems
Subsystems (3)
v3 cover 9p: add support for root file systems
Just like cifs and nfs, this short series enables rootfs support for 9p. Bellow is an example which mounts v9fs with tag 'r' as rootfs in qemu guest via virtio transport.
$ qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
-virtfs local,path=$rootfs_dir,mount_tag=r,security_model=passthrough,id=r \
-kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
-append "root=/dev/v9fs v9fsroot=r,trans=virtio rw console=ttyS0 3"v3:
o rebase.
v2:
o use pr_err instead of printk.
o ROOT_DEV is only set after checking.
o cleanup DEFAULT_MNT_OPTS.
o do not retry mount for fd and virtio transport.
Changbin Du (3):
9p: add support for root file systems
9p: doc: move to a new dedicated folder
9p: doc: add v9fsroot description
Changbin Du (3):
9p: add support for root file systems
9p: doc: move to a new dedicated folder
9p: doc: add v9fsroot description
Documentation/filesystems/index.rst | 2 +-
Documentation/filesystems/{ => v9fs}/9p.rst | 0
Documentation/filesystems/v9fs/index.rst | 12 ++++
Documentation/filesystems/v9fs/v9fsroot.rst | 52 +++++++++++++++++
MAINTAINERS | 8 ++-
fs/9p/Kconfig | 6 ++
fs/9p/Makefile | 1 +
fs/9p/v9fsroot.c | 64 +++++++++++++++++++++
include/linux/root_dev.h | 1 +
init/do_mounts.c | 55 ++++++++++++++++++
10 files changed, 199 insertions(+), 2 deletions(-)
rename Documentation/filesystems/{ => v9fs}/9p.rst (100%)
create mode 100644 Documentation/filesystems/v9fs/index.rst
create mode 100644 Documentation/filesystems/v9fs/v9fsroot.rst
create mode 100644 fs/9p/v9fsroot.cSignature · 1 line
2.30.2
PATCH v3 1/3 9p: add support for root file systems
This introduces a new kernel command-line option called 'v9fsroot=' which will tell the kernel to mount the root file system by utilizing the 9p protocol.
This allows us to mount host folder as rootfs for guest linux in qemu. Bellow is an example which mounts v9fs with tag 'r' as rootfs in qemu guest via virtio transport.
$ qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
-virtfs local,path=$rootfs_dir,mount_tag=r,security_model=passthrough,id=r \
-kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
-append "root=/dev/v9fs v9fsroot=r,trans=virtio rw console=ttyS0 3"---
v2:
o use pr_err instead of printk.
o ROOT_DEV is only set after checking.
o cleanup DEFAULT_MNT_OPTS.
o do not retry mount for fd and virtio transport.
--- MAINTAINERS | 5 ++++ fs/9p/Kconfig | 6 ++++ fs/9p/Makefile | 1 + fs/9p/v9fsroot.c | 64 ++++++++++++++++++++++++++++++++++++++++ include/linux/root_dev.h | 1 + init/do_mounts.c | 55 ++++++++++++++++++++++++++++++++++ 6 files changed, 132 insertions(+) create mode 100644 fs/9p/v9fsroot.c
MAINTAINERS +5 -0
@@ -239,6 +239,11 @@ F: include/trace/events/9p.h F: include/uapi/linux/virtio_9p.h F: net/9p/ +9P FILE SYSTEM ROOTFS SUPPORT +R: Changbin Du <[email protected]> +S: Supported +F: fs/9p/v9fsroot.c + A8293 MEDIA DRIVER M: Antti Palosaari <[email protected]> L: [email protected]
fs/9p/Kconfig +6 -0
@@ -42,3 +42,9 @@ config 9P_FS_SECURITY If you are not using a security module that requires using extended attributes for file security labels, say N. + +config 9P_FS_ROOT + bool "9p root file system" + depends on 9P_FS=y + help + Enables root file system support over 9p protocol.
fs/9p/Makefile +1 -0
@@ -15,3 +15,4 @@ obj-$(CONFIG_9P_FS) := 9p.o 9p-$(CONFIG_9P_FSCACHE) += cache.o 9p-$(CONFIG_9P_FS_POSIX_ACL) += acl.o +9p-$(CONFIG_9P_FS_ROOT) += v9fsroot.o
fs/9p/v9fsroot.c new file +64 -0
64 lines not on this page · raw message
include/linux/root_dev.h +1 -0
@@ -9,6 +9,7 @@enum { Root_NFS =MKDEV (UNNAMED_MAJOR ,255 ), Root_CIFS =MKDEV (UNNAMED_MAJOR ,254 ), + Root_V9FS =MKDEV (UNNAMED_MAJOR ,253 ), Root_RAM0 =MKDEV (RAMDISK_MAJOR ,0 ), Root_RAM1 =MKDEV (RAMDISK_MAJOR ,1 ), Root_FD0 =MKDEV (FLOPPY_MAJOR ,0 ),
init/do_mounts.c +55 -0
73 lines not on this page · raw message
Signature · 1 line
2.30.2
kernel test robot
build botI love your patch! Perhaps something to improve:
Hi Changbin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on lwn/docs-next]
[also build test WARNING on linus/master v5.13-rc5 next-20210604] [cannot apply to v9fs/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Changbin-Du/9p-add-support-for-root-file-systems/20210607-071229 base: git://git.lwn.net/linux-2.6 docs-next config: arm-allyesconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/96098f751038703cc0fda4f018236d240a86930d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Changbin-Du/9p-add-support-for-root-file-systems/20210607-071229 git checkout 96098f751038703cc0fda4f018236d240a86930d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> fs/9p/v9fsroot.c:53:12: warning: no previous prototype for 'v9fs_root_data' [-Wmissing-prototypes]
53 | int __init v9fs_root_data(char **dev, char **opts)
| ^~~~~~~~~~~~~~vim +/v9fs_root_data +53 fs/9p/v9fsroot.c
52 > 53 int __init v9fs_root_data(char **dev, char **opts)
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 25 lines · kernel test robot
Hi Changbin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on lwn/docs-next]
[also build test WARNING on linus/master v5.13-rc5 next-20210604] [cannot apply to v9fs/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]url: https://github.com/0day-ci/linux/commits/Changbin-Du/9p-add-support-for-root-file-systems/20210607-071229 base: git://git.lwn.net/linux-2.6 docs-next config: arm-allyesconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/96098f751038703cc0fda4f018236d240a86930d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Changbin-Du/9p-add-support-for-root-file-systems/20210607-071229 git checkout96098f751038703cc0fda4f018236d240a86930d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
Quoted 9 lines
If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
fs/9p/v9fsroot.c:53:12: warning: no previous prototype for 'v9fs_root_data' [-Wmissing-prototypes]53 | int __init v9fs_root_data(char **dev, char **opts) | ^~~~~~~~~~~~~~
This just follows the existing rootfs support manner. This function doesn't have a dedicated header file to place. So I think we can ignore this warning.
Quoted 9 lines
vim +/v9fs_root_data +53
fs/9p/v9fsroot.c52Quoted 1 line
53 int
__initv9fs_root_data(char **dev, char **opts)---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Signature · 2 lines
Cheers, Changbin Du
PATCH v3 2/3 9p: doc: move to a new dedicated folder
In reply to Changbin DuLater we will add another documentation for v9fs.
---
Documentation/filesystems/index.rst | 2 +-
Documentation/filesystems/{ => v9fs}/9p.rst | 0
Documentation/filesystems/v9fs/index.rst | 11 +++++++++++
MAINTAINERS | 2 +-
4 files changed, 13 insertions(+), 2 deletions(-)
rename Documentation/filesystems/{ => v9fs}/9p.rst (100%)
create mode 100644 Documentation/filesystems/v9fs/index.rstDocumentation/filesystems/index.rst +1 -1
@@ -63,7 +63,7 @@ Documentation for filesystem implementations. .. toctree:: :maxdepth: 2 - 9p + v9fs/index adfs affs afs
Documentation/filesystems/v9fs/9p.rst renamed from Documentation/filesystems/9p.rst +0 -0
Documentation/filesystems/v9fs/index.rst new file +11 -0
@@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: GPL-2.0 + +==== +v9fs +==== + +.. toctree:: + :maxdepth: 6 + :numbered: + + 9p
MAINTAINERS +1 -1
@@ -232,7 +232,7 @@ W: http://swik.net/v9fs Q: http://patchwork.kernel.org/project/v9fs-devel/list/ T: git git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs.git T: git git://github.com/martinetd/linux.git -F: Documentation/filesystems/9p.rst +F: Documentation/filesystems/v9fs/ F: fs/9p/ F: include/net/9p/ F: include/trace/events/9p.h
Signature · 1 line
2.30.2
PATCH v3 3/3 9p: doc: add v9fsroot description
In reply to Changbin DuThis documentation is modified from cifs/cifsroot.rst.
--- Documentation/filesystems/v9fs/index.rst | 1 + Documentation/filesystems/v9fs/v9fsroot.rst | 52 +++++++++++++++++++++ MAINTAINERS | 1 + 3 files changed, 54 insertions(+) create mode 100644 Documentation/filesystems/v9fs/v9fsroot.rst
Documentation/filesystems/v9fs/index.rst +1 -0
@@ -9,3 +9,4 @@ v9fs :numbered: 9p + v9fsroot
Documentation/filesystems/v9fs/v9fsroot.rst new file +52 -0
52 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -243,6 +243,7 @@ F: net/9p/ R: Changbin Du <[email protected]> S: Supported F: fs/9p/v9fsroot.c +F: Documentation/filesystems/v9fs/v9fsroot.rst A8293 MEDIA DRIVER M: Antti Palosaari <[email protected]>
Signature · 1 line
2.30.2
Dominique Martinet
maintainerChangbin Du wrote on Mon, Jun 07, 2021 at 07:09:19AM +0800:
Quoted 8 lines
Just like cifs and nfs, this short series enables rootfs support for 9p. Bellow is an example which mounts v9fs with tag 'r' as rootfs in qemu guest via virtio transport.
$ qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \ -virtfs local,path=$rootfs_dir,mount_tag=r,security_model=passthrough,id=r \ -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \ -append "root=/dev/v9fs v9fsroot=r,trans=virtio rw console=ttyS0 3"
Thanks for rebasing -- I haven't forgotten, just been otherwise busy.
Will make time for this and the netfs rework over the next couple of weeks.
Just a couple of notes:
linux-fsdevel@vger is still not in Cc of the patches, and they weren't for any other version except for one of my replies, so it might be worth resending just for them as it touches do_mounts.c / root_dev.h
Quoted 1 line
MAINTAINERS | 8 ++-
I don't think it's worth adding yourself as MAINTAINERS for this, will likely strip it out (I know I'm the one who asked for your help if people have problems with this, but we should keep contacts simple) I'll forward you requests when they come if it's not trivial and you're not subscribed to the v9fs-developer@sf list
Signature · 1 line
Dominique
Quoted 8 lines · Changbin Du
Just like cifs and nfs, this short series enables rootfs support for 9p. Bellow is an example which mounts v9fs with tag 'r' as rootfs in qemu guest via virtio transport.
$ qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \ -virtfs local,path=$rootfs_dir,mount_tag=r,security_model=passthrough,id=r \ -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \ -append "root=/dev/v9fs v9fsroot=r,trans=virtio rw console=ttyS0 3"
Rather than inventing a pseudo-device /dev/v9fs for this, would it potentially work to use the existing rootfstype and rootflags options for this? rootfstype already determines what filesystem should be used to mount the root, and rootflags already provides options for that filesystem.
For instance, for the above example:
rootfstype=9p root=r rootflags=trans=virtio
That would require a bit of fiddling to make rootfstype=9p allow a root that's just the mount_tag. If that isn't an option, then even with root=/dev/v9fs I think it still makes sense to use the existing rootflags for "trans=virtio" rather than creating a new "v9fsroot" option for that.
- Josh Triplett
Dominique Martinet
maintainerJosh Triplett wrote on Mon, Jun 14, 2021 at 01:57:54AM -0700:
Quoted 16 lines · Changbin Du
Quoted 8 lines
Just like cifs and nfs, this short series enables rootfs support for 9p. Bellow is an example which mounts v9fs with tag 'r' as rootfs in qemu guest via virtio transport.
$ qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \ -virtfs local,path=$rootfs_dir,mount_tag=r,security_model=passthrough,id=r \ -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \ -append "root=/dev/v9fs v9fsroot=r,trans=virtio rw console=ttyS0 3"Rather than inventing a pseudo-device
/dev/v9fsfor this, would it potentially work to use the existing rootfstype and rootflags options for this? rootfstype already determines what filesystem should be used to mount the root, and rootflags already provides options for that filesystem.
Quoted 8 lines
For instance, for the above example:
rootfstype=9p root=r rootflags=trans=virtioThat would require a bit of fiddling to make rootfstype=9p allow a root that's just the
mount_tag. If that isn't an option, then even with root=/dev/v9fs I think it still makes sense to use the existing rootflags for "trans=virtio" rather than creating a new "v9fsroot" option for that.
This doesn't work as is because of the way the code is written, if there's no block device associated with a root=x option right now it will lead to kernel panic.
I replied with folks in Cc but there's another thread on linux-fsdevel@ with a more generic approach that will build a list of filesystems which don't require such a block device (either hardcoded with virtiofs and 9p or based on FS_REQUIRES_DEV), thread started there but there's a second patch hidden an more discussion below:
https://lore.kernel.org/linux-fsdevel/[email protected]/
My preferred approach right now would be to go with their approach, and adjust the documentation Changbin Du wrote here, to have the best of both worlds.
Signature · 1 line
Dominique
Quoted 30 lines · Dominique Martinet
Josh Triplett wrote on Mon, Jun 14, 2021 at 01:57:54AM -0700:
Quoted 16 lines · Changbin Du
Quoted 8 lines
Just like cifs and nfs, this short series enables rootfs support for 9p. Bellow is an example which mounts v9fs with tag 'r' as rootfs in qemu guest via virtio transport.
$ qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \ -virtfs local,path=$rootfs_dir,mount_tag=r,security_model=passthrough,id=r \ -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \ -append "root=/dev/v9fs v9fsroot=r,trans=virtio rw console=ttyS0 3"Rather than inventing a pseudo-device
/dev/v9fsfor this, would it potentially work to use the existing rootfstype and rootflags options for this? rootfstype already determines what filesystem should be used to mount the root, and rootflags already provides options for that filesystem.Quoted 8 lines
For instance, for the above example:
rootfstype=9p root=r rootflags=trans=virtioThat would require a bit of fiddling to make rootfstype=9p allow a root that's just the
mount_tag. If that isn't an option, then even with root=/dev/v9fs I think it still makes sense to use the existing rootflags for "trans=virtio" rather than creating a new "v9fsroot" option for that.This doesn't work as is because of the way the code is written, if there's no block device associated with a root=x option right now it will lead to kernel panic.
Quoted 6 lines
I replied with folks in Cc but there's another thread on linux-fsdevel@ with a more generic approach that will build a list of filesystems which don't require such a block device (either hardcoded with virtiofs and 9p or based on
FS_REQUIRES_DEV), thread started there but there's a second patch hidden an more discussion below:
https://lore.kernel.org/linux-fsdevel/[email protected]/
The patch later on in that thread (either using a list of non-block-device filesystems or the version referenced elsewhere that uses a flag in the filesystem definition) looks really appealing! That's exactly what I was hoping for. That gets us closer to directly translating mount -t type -o options rootdesc into rootfstype=type rootflags=options root=rootdesc in the general case, rather than having special cases for different filesystems.
Quoted 38 lines · Josh Triplett
Quoted 30 lines · Dominique Martinet
Josh Triplett wrote on Mon, Jun 14, 2021 at 01:57:54AM -0700:
Quoted 16 lines · Changbin Du
Quoted 8 lines
Just like cifs and nfs, this short series enables rootfs support for 9p. Bellow is an example which mounts v9fs with tag 'r' as rootfs in qemu guest via virtio transport.
$ qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \ -virtfs local,path=$rootfs_dir,mount_tag=r,security_model=passthrough,id=r \ -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \ -append "root=/dev/v9fs v9fsroot=r,trans=virtio rw console=ttyS0 3"Rather than inventing a pseudo-device
/dev/v9fsfor this, would it potentially work to use the existing rootfstype and rootflags options for this? rootfstype already determines what filesystem should be used to mount the root, and rootflags already provides options for that filesystem.Quoted 8 lines
For instance, for the above example:
rootfstype=9p root=r rootflags=trans=virtioThat would require a bit of fiddling to make rootfstype=9p allow a root that's just the
mount_tag. If that isn't an option, then even with root=/dev/v9fs I think it still makes sense to use the existing rootflags for "trans=virtio" rather than creating a new "v9fsroot" option for that.This doesn't work as is because of the way the code is written, if there's no block device associated with a root=x option right now it will lead to kernel panic.
Quoted 6 lines
I replied with folks in Cc but there's another thread on linux-fsdevel@ with a more generic approach that will build a list of filesystems which don't require such a block device (either hardcoded with virtiofs and 9p or based on
FS_REQUIRES_DEV), thread started there but there's a second patch hidden an more discussion below:
https://lore.kernel.org/linux-fsdevel/[email protected]/
Quoted 7 lines
The patch later on in that thread (either using a list of non-block-device filesystems or the version referenced elsewhere that uses a flag in the filesystem definition) looks really appealing! That's exactly what I was hoping for. That gets us closer to directly translating
mount -t type -o options rootdescintorootfstype=type rootflags=options root=rootdescin the general case, rather than having special cases for different filesystems.
Bellow is all the parameters of non-block rootfs support.
nfs: nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] cifs: cifsroot=//<server-ip>/<share>[,options] v9fs: v9fsroot=<tag/ip>[,options] mtd: root=mtd:<identifier> or root=ubi:<identifier>
virtiofs: root=fstag:<tag>
The main problem is we lack a generic handing for non-block rootdev. I think maybe we can unify all of above.
non-block: root=<type>:<identifier>
blockdev: root=<bock-dev-path> or root=<blockdev major/minor>
Then:
nfs: root=nfs:[<server-ip>:]<root-dir> rootflags=[nfs-options] cifs: root=cifs://<server-ip>/<share> rootflags=[options] v9fs: root=9p:<tag/ip> rootflags=[options] mtd: root=mtd:<identifier> rootflags=[options] ubi: root=ubi:<identifier> rootflags=[options] virtiofs: root=virtiofs:<tag> rootflags=[options]
And maybe we can also remove all the special fs code out of init/do_mounts.c.
Signature · 2 lines
Cheers, Changbin Du
Dominique Martinet
maintainerChangbin Du wrote on Sun, Jun 20, 2021 at 11:36:59AM +0800:
Quoted 2 lines
The main problem is we lack a generic handing for non-block rootdev. I think maybe we can unify all of above.
We're already going in that direction, please have a look at the threads on fsdevel:
(new patch by Christoph)
https://lore.kernel.org/linux-fsdevel/[email protected]/
(older threads I linked earlier)
https://lore.kernel.org/linux-fsdevel/[email protected]/
I think it's getting there, Christoph should send a v2 addressing Vivek remarks that will likely get picked up.
Signature · 1 line
Dominique