linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] nfs: Ensure NFS_MOUNT_TCP is correctly set for v4 mounts
@ 2014-05-29 17:25 Scott Mayhew
  2014-05-29 17:25 ` [PATCH 1/1] " Scott Mayhew
  0 siblings, 1 reply; 3+ messages in thread
From: Scott Mayhew @ 2014-05-29 17:25 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

When a 'mount -o remount...' is issued, the mount program reads the current
mount options from /etc/mtab so that it can pass them to the helper program.  On
newer distros where /etc/mtab is a symlink to /proc/mounts, this will result in
a call to nfs_show_mount_options(), which has the following snippet:

        seq_printf(m, ",proto=%s",
	                   rpc_peeraddr2str(nfss->client, RPC_DISPLAY_NETID));

which in most cases will result in the mount program passing 'proto=tcp' to the
mount.nfs4 program, which mount.nfs4 then passes in the data field of the mount
syscall. 

nfs_remount() calls nfs_parse_mount_options(), where the NFS_MOUNT_TCP flag will
be set in the nfs_parsed_mount_data's flag field.  But nfs_remount() then calls
nfs_compare_remount_data(), where we will fail the very first check:

static int
nfs_compare_remount_data(struct nfs_server *nfss,
                         struct nfs_parsed_mount_data *data)
{
	        if (data->flags != nfss->flags ||
...
                return -EINVAL;
...

because NFS_MOUNT_TCP was never set in the nfs_server's flags field in the first
place.

As a result, the remount operation fails:
# mount -o remount,ro /mnt/t
mount.nfs4: an incorrect mount option was specified

The following patch corrects that issue by having nfs4_validate_mount_flags()
set the NFS_MOUNT_TCP flag when appropriate.


Scott Mayhew (1):
  nfs: Ensure NFS_MOUNT_TCP is correctly set for v4 mounts

 fs/nfs/super.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
1.9.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] nfs: Ensure NFS_MOUNT_TCP is correctly set for v4 mounts
  2014-05-29 17:25 [PATCH 0/1] nfs: Ensure NFS_MOUNT_TCP is correctly set for v4 mounts Scott Mayhew
@ 2014-05-29 17:25 ` Scott Mayhew
  2014-05-29 17:33   ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Scott Mayhew @ 2014-05-29 17:25 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

The NFS_MOUNT_TCP flag needs to be correctly set in the nfs_server->flags
field, otherwise remount operations are likely to run afoul of the flags
check in nfs_compare_remount_data() on systems where /etc/mtab is
symlinked to /proc/mounts.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 fs/nfs/super.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 2cb5694..0ae4e73 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2726,6 +2726,9 @@ static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args)
 {
 	args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3|
 			 NFS_MOUNT_LOCAL_FLOCK|NFS_MOUNT_LOCAL_FCNTL);
+
+	if (args->nfs_server.protocol == XPRT_TRANSPORT_TCP)
+		args->flags |= NFS_MOUNT_TCP;
 }
 
 /*
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] nfs: Ensure NFS_MOUNT_TCP is correctly set for v4 mounts
  2014-05-29 17:25 ` [PATCH 1/1] " Scott Mayhew
@ 2014-05-29 17:33   ` Trond Myklebust
  0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2014-05-29 17:33 UTC (permalink / raw)
  To: Scott Mayhew; +Cc: Linux NFS Mailing List

On Thu, May 29, 2014 at 1:25 PM, Scott Mayhew <smayhew@redhat.com> wrote:
> The NFS_MOUNT_TCP flag needs to be correctly set in the nfs_server->flags
> field, otherwise remount operations are likely to run afoul of the flags
> check in nfs_compare_remount_data() on systems where /etc/mtab is
> symlinked to /proc/mounts.
>
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> ---
>  fs/nfs/super.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index 2cb5694..0ae4e73 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -2726,6 +2726,9 @@ static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args)
>  {
>         args->flags &= ~(NFS_MOUNT_NONLM|NFS_MOUNT_NOACL|NFS_MOUNT_VER3|
>                          NFS_MOUNT_LOCAL_FLOCK|NFS_MOUNT_LOCAL_FCNTL);
> +
> +       if (args->nfs_server.protocol == XPRT_TRANSPORT_TCP)
> +               args->flags |= NFS_MOUNT_TCP;
>  }
>
>  /*
> --
> 1.9.0
>

Hi Scott,

Why can't we just apply the NFS_MOUNT_CMP_FLAGMASK to
nfs_compare_remount_data? NFS_MOUNT_TCP really is just legacy crud
from the bad old days of binary mount structures.

Cheers
  Trond

-- 
Trond Myklebust

Linux NFS client maintainer, PrimaryData

trond.myklebust@primarydata.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-29 17:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-29 17:25 [PATCH 0/1] nfs: Ensure NFS_MOUNT_TCP is correctly set for v4 mounts Scott Mayhew
2014-05-29 17:25 ` [PATCH 1/1] " Scott Mayhew
2014-05-29 17:33   ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).