2023-04-19 18:05:40

by Dai Ngo

[permalink] [raw]
Subject: [PATCH v2] NFSD: Fix problem of COMMIT and NFS4ERR_DELAY in infinite loop

The following request sequence to the same file causes the NFS client and
server getting into an infinite loop with COMMIT and NFS4ERR_DELAY:

OPEN
REMOVE
WRITE
COMMIT

Problem reported by recall11, recall12, recall14, recall20, recall22,
recall40, recall42, recall48, recall50 of nfstest suite.

This patch restores the handling of race condition in nfsd_file_do_acquire
with unlink to that prior of the regression.

Fixes: ac3a2585f018 ("nfsd: rework refcounting in filecache")
Signed-off-by: Dai Ngo <[email protected]>
---
fs/nfsd/filecache.c | 2 --
1 file changed, 2 deletions(-)

V2: rebase with nfsd-next

diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index f40d8f3b35a4..ee9c923192e0 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -1099,8 +1099,6 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
* then unhash.
*/
if (status != nfs_ok || inode->i_nlink == 0)
- status = nfserr_jukebox;
- if (status != nfs_ok)
nfsd_file_unhash(nf);
clear_and_wake_up_bit(NFSD_FILE_PENDING, &nf->nf_flags);
if (status == nfs_ok)
--
2.9.5


2023-04-19 18:09:20

by Jeff Layton

[permalink] [raw]
Subject: Re: [PATCH v2] NFSD: Fix problem of COMMIT and NFS4ERR_DELAY in infinite loop

On Wed, 2023-04-19 at 10:53 -0700, Dai Ngo wrote:
> The following request sequence to the same file causes the NFS client and
> server getting into an infinite loop with COMMIT and NFS4ERR_DELAY:
>
> OPEN
> REMOVE
> WRITE
> COMMIT
>
> Problem reported by recall11, recall12, recall14, recall20, recall22,
> recall40, recall42, recall48, recall50 of nfstest suite.
>
> This patch restores the handling of race condition in nfsd_file_do_acquire
> with unlink to that prior of the regression.
>
> Fixes: ac3a2585f018 ("nfsd: rework refcounting in filecache")
> Signed-off-by: Dai Ngo <[email protected]>
> ---
> fs/nfsd/filecache.c | 2 --
> 1 file changed, 2 deletions(-)
>
> V2: rebase with nfsd-next
>
> diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
> index f40d8f3b35a4..ee9c923192e0 100644
> --- a/fs/nfsd/filecache.c
> +++ b/fs/nfsd/filecache.c
> @@ -1099,8 +1099,6 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
> * then unhash.
> */
> if (status != nfs_ok || inode->i_nlink == 0)
> - status = nfserr_jukebox;
> - if (status != nfs_ok)
> nfsd_file_unhash(nf);
> clear_and_wake_up_bit(NFSD_FILE_PENDING, &nf->nf_flags);
> if (status == nfs_ok)

Reviewed-by: Jeff Layton <[email protected]>

2023-04-19 19:05:46

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH v2] NFSD: Fix problem of COMMIT and NFS4ERR_DELAY in infinite loop


> On Apr 19, 2023, at 2:03 PM, Jeff Layton <[email protected]> wrote:
>
> On Wed, 2023-04-19 at 10:53 -0700, Dai Ngo wrote:
>> The following request sequence to the same file causes the NFS client and
>> server getting into an infinite loop with COMMIT and NFS4ERR_DELAY:
>>
>> OPEN
>> REMOVE
>> WRITE
>> COMMIT
>>
>> Problem reported by recall11, recall12, recall14, recall20, recall22,
>> recall40, recall42, recall48, recall50 of nfstest suite.
>>
>> This patch restores the handling of race condition in nfsd_file_do_acquire
>> with unlink to that prior of the regression.
>>
>> Fixes: ac3a2585f018 ("nfsd: rework refcounting in filecache")
>> Signed-off-by: Dai Ngo <[email protected]>
>> ---
>> fs/nfsd/filecache.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> V2: rebase with nfsd-next
>>
>> diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
>> index f40d8f3b35a4..ee9c923192e0 100644
>> --- a/fs/nfsd/filecache.c
>> +++ b/fs/nfsd/filecache.c
>> @@ -1099,8 +1099,6 @@ nfsd_file_do_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
>> * then unhash.
>> */
>> if (status != nfs_ok || inode->i_nlink == 0)
>> - status = nfserr_jukebox;
>> - if (status != nfs_ok)
>> nfsd_file_unhash(nf);
>> clear_and_wake_up_bit(NFSD_FILE_PENDING, &nf->nf_flags);
>> if (status == nfs_ok)
>
> Reviewed-by: Jeff Layton <[email protected]>

Thanks, applied to nfsd-next.


--
Chuck Lever