nfsd: fix GET_DIR_DELEGATION when VFS leases are disabled
Subsystems (2)
Olga Kornievskaia
reviewerPATCH 1/1 nfsd: fix GET_DIR_DELEGATION when VFS leases are disabled
When leases are disabled on the server, running xfstest generic/309 leads to an error because GET_DIR_DELEGATION returns EINVAL.
nfsd_get_dir_deleg() can fail in several ways: like memory allocation and unable to get a lease because either leases are disable or it's already held. Currently only the condition "already held" is translated to returning directory-delegation-is-unavailable error. However, other failure conditions are likely temporary and thus should result in the same kind of error.
---
Notes:
I'm unsure if kernel_setlease() can return some other error that shouldnt be converted to GDD4_UNAVAIL. Alternatively, I propose to recognize ENOMEM, EINVAL and EAGAIN as errors to translate to GDD4_UNAVAIL.
--- fs/nfsd/nfs4proc.c | 4 ---- 1 file changed, 4 deletions(-)
fs/nfsd/nfs4proc.c +0 -4
@@ -2535,10 +2535,6 @@ nfsd4_get_dir_delegation(struct svc_rqst *rqstp, dd =nfsd_get_dir_deleg (cstate, gdd, nf);nfsd_file_put (nf);if (IS_ERR (dd)) { -int err =PTR_ERR (dd); - -if (err != -EAGAIN ) -return nfserrno (err); gdd->gddrnf_status =GDD4_UNAVAIL ;return nfs_ok; }
Signature · 1 line
2.52.0
Chuck Lever
maintainerQuoted 9 lines · Olga Kornievskaia
When leases are disabled on the server, running xfstest generic/309 leads to an error because
GET_DIR_DELEGATIONreturns EINVAL.
nfsd_get_dir_deleg()can fail in several ways: like memory allocation and unable to get a lease because either leases are disable or it's already held. Currently only the condition "already held" is translated to returning directory-delegation-is-unavailable error. However, other failure conditions are likely temporary and thus should result in the same kind of error.
This is a bit misleading. -EINVAL from disabled leases is a permanent condition, not temporary, in the sense that retrying the request is going to get the same error until the server administrator modifies the server configuration to enable leases again. (I think if CONFIG_FILE_LOCKING is disabled, it becomes even more of a permanent situation).
However, since directory delegations are advisory, IMO GDD4_UNAVAIL is an appropriate response for both temporary and permanent inability to grant a directory delegation.
Quoted 29 lines
Fixes 8b99f6a8c116 ("nfsd: wire up GET_DIR_DELEGATION handling")Signed-off-by Olga Kornievskaia <[email protected]>---
Notes:
I'm unsure ifkernel_setlease()can return some other error that shouldnt be converted toGDD4_UNAVAIL. Alternatively, I propose to recognize ENOMEM, EINVAL and EAGAIN as errors to translate toGDD4_UNAVAIL.--- fs/nfsd/nfs4proc.c | 4 ---- 1 file changed, 4 deletions(-)fs/nfsd/nfs4proc.c +0
-4@@ -2535,10 +2535,6 @@ nfsd4_get_dir_delegation(struct svc_rqst *rqstp, dd =nfsd_get_dir_deleg (cstate, gdd, nf);nfsd_file_put (nf);if (IS_ERR (dd)) { -int err =PTR_ERR (dd); - -if (err != -EAGAIN ) -return nfserrno (err); gdd->gddrnf_status =GDD4_UNAVAIL ;return nfs_ok; }Signature · 1 line
2.52.0
Signature · 1 line
Chuck Lever
Jeff Layton
maintainerQuoted 27 lines · Olga Kornievskaia
When leases are disabled on the server, running xfstest generic/309 leads to an error because
GET_DIR_DELEGATIONreturns EINVAL.
nfsd_get_dir_deleg()can fail in several ways: like memory allocation and unable to get a lease because either leases are disable or it's already held. Currently only the condition "already held" is translated to returning directory-delegation-is-unavailable error. However, other failure conditions are likely temporary and thus should result in the same kind of error.Fixes 8b99f6a8c116 ("nfsd: wire up GET_DIR_DELEGATION handling")Signed-off-by Olga Kornievskaia <[email protected]>---
Notes:
I'm unsure ifkernel_setlease()can return some other error that shouldnt be converted toGDD4_UNAVAIL. Alternatively, I propose to recognize ENOMEM, EINVAL and EAGAIN as errors to translate toGDD4_UNAVAIL.--- fs/nfsd/nfs4proc.c | 4 ---- 1 file changed, 4 deletions(-)fs/nfsd/nfs4proc.c +0
-0
fs/nfsd/nfs4proc.c nfsd4_get_dir_delegation(struct svc_rqst *rqstp, · line 2540
Quoted 10 lines
fs/nfsd/nfs4proc.c +0
-4@@ -2535,10 +2535,6 @@ nfsd4_get_dir_delegation(struct svc_rqst *rqstp, dd =nfsd_get_dir_deleg (cstate, gdd, nf);nfsd_file_put (nf);if (IS_ERR (dd)) { -int err =PTR_ERR (dd); - -if (err != -EAGAIN ) -return nfserrno (err); gdd->gddrnf_status =GDD4_UNAVAIL ;return nfs_ok; }
-EINVAL is what you get when leases are disabled.
ISTM that returning a hard error in that case is probably the correct thing to do. Maybe we should translate -EINVAL to something like NFS4ERR_NOTSUPP, so the client doesn't keep trying to get dir delegations that will never be granted ?
Signature · 1 line
Jeff Layton <[email protected]>
Chuck Lever
maintainerFrom: Chuck Lever <[email protected]>
Quoted 11 lines · Olga Kornievskaia
When leases are disabled on the server, running xfstest generic/309 leads to an error because
GET_DIR_DELEGATIONreturns EINVAL.
nfsd_get_dir_deleg()can fail in several ways: like memory allocation and unable to get a lease because either leases are disable or it's already held. Currently only the condition "already held" is translated to returning directory-delegation-is-unavailable error. However, other failure conditions are likely temporary and thus should result in the same kind of error.[...]
Applied to nfsd-testing, thanks!
[1/1] nfsd: fix GET_DIR_DELEGATION when VFS leases are disabled
commit: 374af81f6188dce267a3bd5384fa8981de24d437
--
Chuck Lever