Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jun 2024 15:02:58 +0100
From:      Doug Rabson <dfr@rabson.org>
To:        Baptiste Daroussin <bapt@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org
Subject:   Re: git: e97ad33a89a7 - main - Add an implementation of the 9P filesystem
Message-ID:  <CACA0VUjcbf_pG=%2Bb0g_3ccU_w=vKzyPTwcf7D0ez=LYv6bknxg@mail.gmail.com>
In-Reply-To: <mab7s6g3n7e64kjp6ygs5cqqrv6vl564qmkcpvw7p4jw3aofgo@tscl33lisgqk>
References:  <202406191213.45JCDPPP051964@gitrepo.freebsd.org> <mab7s6g3n7e64kjp6ygs5cqqrv6vl564qmkcpvw7p4jw3aofgo@tscl33lisgqk>

next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000008ca9fd061b3ea80a
Content-Type: text/plain; charset="UTF-8"

On Wed, 19 Jun 2024 at 13:23, Baptiste Daroussin <bapt@freebsd.org> wrote:

> On Wed 19 Jun 12:13, Doug Rabson wrote:
> > The branch main has been updated by dfr:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=e97ad33a89a78f55280b0485b3249ee9b907a718
> >
> > commit e97ad33a89a78f55280b0485b3249ee9b907a718
> > Author:     Doug Rabson <dfr@FreeBSD.org>
> > AuthorDate: 2022-12-06 13:07:46 +0000
> > Commit:     Doug Rabson <dfr@FreeBSD.org>
> > CommitDate: 2024-06-19 12:12:04 +0000
> >
> >     Add an implementation of the 9P filesystem
> >
> >     This is derived from swills@ fork of the Juniper virtfs with many
> >     changes by me including bug fixes, style improvements, clearer
> layering
> >     and more consistent logging. The filesystem is renamed to p9fs to
> better
> >     reflect its function and to prevent possible future confusion with
> >     virtio-fs.
> >
> >     Several updates and fixes from Juniper have been integrated into this
> >     version by Val Packett and these contributions along with the
> original
> >     Juniper authors are credited below.
> >
> >     To use this with bhyve, add 'virtio_p9fs_load=YES' to loader.conf.
> The
> >     bhyve virtio-9p device allows access from the guest to files on the
> host
> >     by mapping a 'sharename' to a host path. It is possible to use p9fs
> as a
> >     root filesystem by adding this to /boot/loader.conf:
> >
> >             vfs.root.mountfrom="p9fs:sharename"
> >
> >     for non-root filesystems add something like this to /etc/fstab:
> >
> >             sharename /mnt p9fs rw 0 0
> >
> >     In both examples, substitute the share name used on the bhyve command
> >     line.
> >
> >     The 9P filesystem protocol relies on stateful file opens which map
> >     protocol-level FIDs to host file descriptors. The FreeBSD vnode
> >     interface doesn't really support this and we use heuristics to guess
> the
> >     right FID to use for file operations.  This can be confused by
> privilege
> >     lowering and does not guarantee that the FID created for a given file
> >     open is always used for file operations, even if the calling process
> is
> >     using the file descriptor from the original open call. Improving this
> >     would involve changes to the vnode interface which is out-of-scope
> for
> >     this import.
> >
>
> First of all: thanks a lot! you say the changes in the vnode interface are
> out
> of scope for this import, which makes perfectly sense, but it is part of
> your
> TODO for later?
>

It is something I would like to work on but I'm not sure exactly when. I
may try a quick-and-dirty approximation to get a better idea about how much
in vnode will need to change. Basically, we need to track state from the
VOP_OPEN in struct file so that we can match the right 9P fid with each i/o
operation. This seems possible since we already have an f_data member in
struct file.

Doug.

--0000000000008ca9fd061b3ea80a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Wed, 19 Jun 2024 at 13:23, Baptist=
e Daroussin &lt;<a href=3D"mailto:bapt@freebsd.org">bapt@freebsd.org</a>&gt=
; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:=
rgb(204,204,204);padding-left:1ex">On Wed 19 Jun 12:13, Doug Rabson wrote:<=
br>
&gt; The branch main has been updated by dfr:<br>
&gt; <br>
&gt; URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3De97ad33a89a7=
8f55280b0485b3249ee9b907a718" rel=3D"noreferrer" target=3D"_blank">https://=
cgit.FreeBSD.org/src/commit/?id=3De97ad33a89a78f55280b0485b3249ee9b907a718<=
/a><br>
&gt; <br>
&gt; commit e97ad33a89a78f55280b0485b3249ee9b907a718<br>
&gt; Author:=C2=A0 =C2=A0 =C2=A0Doug Rabson &lt;dfr@FreeBSD.org&gt;<br>
&gt; AuthorDate: 2022-12-06 13:07:46 +0000<br>
&gt; Commit:=C2=A0 =C2=A0 =C2=A0Doug Rabson &lt;dfr@FreeBSD.org&gt;<br>
&gt; CommitDate: 2024-06-19 12:12:04 +0000<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0Add an implementation of the 9P filesystem<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0This is derived from swills@ fork of the Juniper vi=
rtfs with many<br>
&gt;=C2=A0 =C2=A0 =C2=A0changes by me including bug fixes, style improvemen=
ts, clearer layering<br>
&gt;=C2=A0 =C2=A0 =C2=A0and more consistent logging. The filesystem is rena=
med to p9fs to better<br>
&gt;=C2=A0 =C2=A0 =C2=A0reflect its function and to prevent possible future=
 confusion with<br>
&gt;=C2=A0 =C2=A0 =C2=A0virtio-fs.<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0Several updates and fixes from Juniper have been in=
tegrated into this<br>
&gt;=C2=A0 =C2=A0 =C2=A0version by Val Packett and these contributions alon=
g with the original<br>
&gt;=C2=A0 =C2=A0 =C2=A0Juniper authors are credited below.<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0To use this with bhyve, add &#39;virtio_p9fs_load=
=3DYES&#39; to loader.conf. The<br>
&gt;=C2=A0 =C2=A0 =C2=A0bhyve virtio-9p device allows access from the guest=
 to files on the host<br>
&gt;=C2=A0 =C2=A0 =C2=A0by mapping a &#39;sharename&#39; to a host path. It=
 is possible to use p9fs as a<br>
&gt;=C2=A0 =C2=A0 =C2=A0root filesystem by adding this to /boot/loader.conf=
:<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vfs.root.mountfrom=3D&q=
uot;p9fs:sharename&quot;<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0for non-root filesystems add something like this to=
 /etc/fstab:<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sharename /mnt p9fs rw =
0 0<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0In both examples, substitute the share name used on=
 the bhyve command<br>
&gt;=C2=A0 =C2=A0 =C2=A0line.<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
&gt;=C2=A0 =C2=A0 =C2=A0The 9P filesystem protocol relies on stateful file =
opens which map<br>
&gt;=C2=A0 =C2=A0 =C2=A0protocol-level FIDs to host file descriptors. The F=
reeBSD vnode<br>
&gt;=C2=A0 =C2=A0 =C2=A0interface doesn&#39;t really support this and we us=
e heuristics to guess the<br>
&gt;=C2=A0 =C2=A0 =C2=A0right FID to use for file operations.=C2=A0 This ca=
n be confused by privilege<br>
&gt;=C2=A0 =C2=A0 =C2=A0lowering and does not guarantee that the FID create=
d for a given file<br>
&gt;=C2=A0 =C2=A0 =C2=A0open is always used for file operations, even if th=
e calling process is<br>
&gt;=C2=A0 =C2=A0 =C2=A0using the file descriptor from the original open ca=
ll. Improving this<br>
&gt;=C2=A0 =C2=A0 =C2=A0would involve changes to the vnode interface which =
is out-of-scope for<br>
&gt;=C2=A0 =C2=A0 =C2=A0this import.<br>
&gt;=C2=A0 =C2=A0 =C2=A0<br>
<br>
First of all: thanks a lot! you say the changes in the vnode interface are =
out<br>
of scope for this import, which makes perfectly sense, but it is part of yo=
ur<br>
TODO for later?<br></blockquote><div><br></div><div>It is something I would=
 like to work on but I&#39;m not sure exactly when. I may try a quick-and-d=
irty approximation to get a better idea about how much in vnode will need t=
o change. Basically, we need to track state from the VOP_OPEN in struct fil=
e so that we can match the right 9P fid with each i/o operation. This seems=
 possible since we already have an f_data member in struct file.</div><div>=
<br></div><div>Doug.=C2=A0</div></div></div>

--0000000000008ca9fd061b3ea80a--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACA0VUjcbf_pG=%2Bb0g_3ccU_w=vKzyPTwcf7D0ez=LYv6bknxg>