[v2] nfs: Return EINVAL rather than ERANGE for mount parse errors
diff mbox series

Message ID 465149.1579276509@warthog.procyon.org.uk
State New
Headers show
Series
  • [v2] nfs: Return EINVAL rather than ERANGE for mount parse errors
Related show

Commit Message

David Howells Jan. 17, 2020, 3:55 p.m. UTC
commit b9423c912b770e5b9e4228d90da92b6a69693d8e
Author: David Howells <dhowells@redhat.com>
Date:   Fri Jan 17 15:37:46 2020 +0000

    nfs: Return EINVAL rather than ERANGE for mount parse errors
    
    Return EINVAL rather than ERANGE for mount parse errors as the userspace
    mount command doesn't necessarily understand what to do with anything other
    than EINVAL.
    
    The old code returned -ERANGE as an intermediate error that then get
    converted to -EINVAL, whereas the new code returns -ERANGE.
    
    This was induced by passing minorversion=1 to a v4 mount where
    CONFIG_NFS_V4_1 was disabled in the kernel build.
    
    Fixes: 68f65ef40e1e ("NFS: Convert mount option parsing to use functionality from fs_parser.h")
    Reported-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: David Howells <dhowells@redhat.com>

Comments

Krzysztof Kozlowski Jan. 17, 2020, 4:51 p.m. UTC | #1
On Fri, Jan 17, 2020 at 03:55:09PM +0000, David Howells wrote:
> commit b9423c912b770e5b9e4228d90da92b6a69693d8e
> Author: David Howells <dhowells@redhat.com>
> Date:   Fri Jan 17 15:37:46 2020 +0000
> 
>     nfs: Return EINVAL rather than ERANGE for mount parse errors
>     
>     Return EINVAL rather than ERANGE for mount parse errors as the userspace
>     mount command doesn't necessarily understand what to do with anything other
>     than EINVAL.
>     
>     The old code returned -ERANGE as an intermediate error that then get
>     converted to -EINVAL, whereas the new code returns -ERANGE.
>     
>     This was induced by passing minorversion=1 to a v4 mount where
>     CONFIG_NFS_V4_1 was disabled in the kernel build.
>     
>     Fixes: 68f65ef40e1e ("NFS: Convert mount option parsing to use functionality from fs_parser.h")
>     Reported-by: Krzysztof Kozlowski <krzk@kernel.org>
>     Signed-off-by: David Howells <dhowells@redhat.com>
> 
> diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
> index 429315c011ae..74508ed9aeec 100644
> --- a/fs/nfs/fs_context.c
> +++ b/fs/nfs/fs_context.c
> @@ -769,8 +769,7 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
>  out_invalid_address:
>  	return nfs_invalf(fc, "NFS: Bad IP address specified");
>  out_of_bounds:
> -	nfs_invalf(fc, "NFS: Value for '%s' out of range", param->key);
> -	return -ERANGE;
> +	return nfs_invalf(fc, "NFS: Value for '%s' out of range", param->key);
>  }
>  
>  /*

Yes, the boards boots up, thanks!

Tested-by: Krzysztof Kozlowski <krzk@kernel.org>

I did not run extensive tests but few boots show also 2-3 seconds faster
mount of NFS root (faster switch from initramfs to proper user-space
from NFS).

Best regards,
Krzysztof
David Howells Jan. 17, 2020, 5:18 p.m. UTC | #2
Hi Anna,

Can you pick this patch up and add it to your branch?

Thanks,
David
Anna Schumaker Jan. 17, 2020, 8:21 p.m. UTC | #3
On Fri, 2020-01-17 at 17:18 +0000, David Howells wrote:
> Hi Anna,
> 
> Can you pick this patch up and add it to your branch?

Sure! I have it applied on my laptop now, and I'll push it out before I sign off
for the weekend.

Thanks for fixing it so quickly!
Anna

> 
> Thanks,
> David
>
David Howells Jan. 17, 2020, 9:12 p.m. UTC | #4
Schumaker, Anna <Anna.Schumaker@netapp.com> wrote:

> Sure! I have it applied on my laptop now, and I'll push it out before I sign
> off for the weekend.

Ta!

David

Patch
diff mbox series

diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c
index 429315c011ae..74508ed9aeec 100644
--- a/fs/nfs/fs_context.c
+++ b/fs/nfs/fs_context.c
@@ -769,8 +769,7 @@  static int nfs_fs_context_parse_param(struct fs_context *fc,
 out_invalid_address:
 	return nfs_invalf(fc, "NFS: Bad IP address specified");
 out_of_bounds:
-	nfs_invalf(fc, "NFS: Value for '%s' out of range", param->key);
-	return -ERANGE;
+	return nfs_invalf(fc, "NFS: Value for '%s' out of range", param->key);
 }
 
 /*