2024-06-03 02:53:21

by Matt Kinni

[permalink] [raw]
Subject: exports option "mountpoint" ignored in nfsv4, works in v3

Wasn't sure if this was a bug or just an outdated manpage, but the
"mountpoint" option will _not_ stop a v4 client from mounting an
unmounted server directory in Fedora 40 with kernel 6.8.10-300 and
nfs-utils-2.6.4-0.rc6.fc40.x86_64, however it _does_ work as expected if
the client mounts with v3 instead:

# setup
mkdir /mnt/nfs_localhost && mkdir /srv/somemountpoint
chmod 777 /srv/somemountpoint

# in /etc/exports:
/srv *(rw,all_squash,fsid=0)
/srv/somemountpoint *(rw,all_squash,mountpoint)

# in /etc/nfs.conf:
[nfsd]
port=20049
vers3=y
vers4=y

# try mounting with nfs v3 while /srv/somemountpoint is a plain dir:
mount localhost:/srv/somemountpoint /mnt/nfs_localhost -t nfs -o vers=3

(cmd output)> mount.nfs: mounting localhost:/srv/somemountpoint failed,
reason given by server: No such file or directory
(log says)> rpc.mountd[5313]: request to export an unmounted filesystem:
/srv/somemountpoint

# so far so good
# but now try doing the same thing with v4:
mount localhost:/somemountpoint /mnt/nfs_localhost -t nfs -o vers=4.2
(works without error)

If I `mount -o bind /tmp /srv/somemountpoint` the v3 command works as
expected, but the v4 command always works regardless of whether the
underlying folder is a mount point or not. Is this intended behavior?

The exports(5) manpage does not say anything about the "mountpoint" or
"mp" options not being valid for NFSv4, so I would expect the same
behavior regardless of what "-o vers=..." is supplied by the client
mount command.


2024-06-03 12:56:47

by Benjamin Coddington

[permalink] [raw]
Subject: Re: exports option "mountpoint" ignored in nfsv4, works in v3

On 2 Jun 2024, at 22:43, Matt Kinni wrote:

> Wasn't sure if this was a bug or just an outdated manpage, but the
> "mountpoint" option will _not_ stop a v4 client from mounting an
> unmounted server directory in Fedora 40 with kernel 6.8.10-300 and
> nfs-utils-2.6.4-0.rc6.fc40.x86_64, however it _does_ work as expected if
> the client mounts with v3 instead:
>
> # setup
> mkdir /mnt/nfs_localhost && mkdir /srv/somemountpoint
> chmod 777 /srv/somemountpoint
>
> # in /etc/exports:
> /srv *(rw,all_squash,fsid=0)
> /srv/somemountpoint *(rw,all_squash,mountpoint)
>
> # in /etc/nfs.conf:
> [nfsd]
> port=20049
> vers3=y
> vers4=y
>
> # try mounting with nfs v3 while /srv/somemountpoint is a plain dir:
> mount localhost:/srv/somemountpoint /mnt/nfs_localhost -t nfs -o vers=3
>
> (cmd output)> mount.nfs: mounting localhost:/srv/somemountpoint failed,
> reason given by server: No such file or directory
> (log says)> rpc.mountd[5313]: request to export an unmounted filesystem:
> /srv/somemountpoint
>
> # so far so good
> # but now try doing the same thing with v4:
> mount localhost:/somemountpoint /mnt/nfs_localhost -t nfs -o vers=4.2
> (works without error)
>
> If I `mount -o bind /tmp /srv/somemountpoint` the v3 command works as
> expected, but the v4 command always works regardless of whether the
> underlying folder is a mount point or not. Is this intended behavior?
>
> The exports(5) manpage does not say anything about the "mountpoint" or
> "mp" options not being valid for NFSv4, so I would expect the same
> behavior regardless of what "-o vers=..." is supplied by the client
> mount command.

Hey Matt -
I suspect think the option is working properly. Its not that
/srv/somemountpoint is always being exported, its that the v4 mount is
mounting the root (/srv) and walking into /srv/somemountpoint.

If you're exporting /srv, /srv/somemountpoint going to be accessible.

Maybe we need to update the manpage to clear up confusion there?

Ben


2024-06-05 11:01:51

by Matt Kinni

[permalink] [raw]
Subject: Re: exports option "mountpoint" ignored in nfsv4, works in v3

On 6/3/24 05:56, Benjamin Coddington wrote:

> Its not that /srv/somemountpoint is always being exported, its that
> the v4 mount is mounting the root (/srv) and walking into
> /srv/somemountpoint.

But wouldn't this always be the case on an nfsv4 setup? There is some
root folder that contains any child directories being exported
underneath it.

FWIW If I export the folder by itself and apply the mountpoint option to
it, eg. "/srv/somemountpoint *(rw,all_squash,fsid=0,mp)" as the only
export line, the mount command *does* indeed fail using -o vers=4.2,
however it doesn't fail with an error message - mount just hangs forever.

I feel like this is a regression compared against nfsv3 functionality
where "mountpoint" or "mp" can be applied to individual exports, and
generates an immediate error message for the client. It seems with
nfsv4 the mp option only has an effect on the root export, and
accomplishes the deed by causing the client mount command to hang until
timeout