2012-06-08 15:33:00

by Anna Schumaker

[permalink] [raw]
Subject: [PATCH] NFS: Use the NFS_DEFAULT_VERSION for v2 and v3 mounts

From: Bryan Schumaker <[email protected]>

Older versions of nfs utils don't always pass a "vers=" mount option for
NFS. This chould lead to attempts at using NFS v0 due to a zeroed out
nfs_parsed_mount_data struct. I solve this by setting the default NFS
version to NFS_DEFAULT_VERSION in the v2 and v3 cases (v4 has already been
taken care of by a similar patch).

Reported-by: Joerg Roedel <joro@&bytes.org>
Signed-off-by: Bryan Schumaker <[email protected]>
---
fs/nfs/super.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ff656c0..97a3b30 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1867,6 +1867,7 @@ static int nfs23_validate_mount_data(void *options,
if (data == NULL)
goto out_no_data;

+ args->version = NFS_DEFAULT_VERSION;
switch (data->version) {
case 1:
data->namlen = 0;
--
1.7.10.3



2012-06-08 16:00:34

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH] NFS: Use the NFS_DEFAULT_VERSION for v2 and v3 mounts

On Fri, Jun 08, 2012 at 11:32:56AM -0400, [email protected] wrote:
> From: Bryan Schumaker <[email protected]>
>
> Older versions of nfs utils don't always pass a "vers=" mount option for
> NFS. This chould lead to attempts at using NFS v0 due to a zeroed out
> nfs_parsed_mount_data struct. I solve this by setting the default NFS
> version to NFS_DEFAULT_VERSION in the v2 and v3 cases (v4 has already been
> taken care of by a similar patch).
>
> Reported-by: Joerg Roedel <joro@&bytes.org>

8bytes.org

> Signed-off-by: Bryan Schumaker <[email protected]>
> ---
> fs/nfs/super.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index ff656c0..97a3b30 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -1867,6 +1867,7 @@ static int nfs23_validate_mount_data(void *options,
> if (data == NULL)
> goto out_no_data;
>
> + args->version = NFS_DEFAULT_VERSION;
> switch (data->version) {
> case 1:
> data->namlen = 0;

Hmm, I still think that the revert-patch is a better solution. The
data-structure is allocated and initialized in
nfs_alloc_parsed_mount_data() so this function is the logical place to
also initialize the version-field with a meaningful value.

Regards,

Joerg