Patch "nfs: don't invalidate dentries on transient errors" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nfs: don't invalidate dentries on transient errors

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nfs-don-t-invalidate-dentries-on-transient-errors.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2e1a7bbdec42e38939d00d4a20337ffe2564429e
Author: Scott Mayhew <smayhew@xxxxxxxxxx>
Date:   Thu May 23 15:01:22 2024 -0400

    nfs: don't invalidate dentries on transient errors
    
    [ Upstream commit 0c8c7c559740d2d8b66048162af6c4dba8f0c88c ]
    
    This is a slight variation on a patch previously proposed by Neil Brown
    that never got merged.
    
    Prior to commit 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()"),
    any error from nfs_lookup_verify_inode() other than -ESTALE would result
    in nfs_lookup_revalidate() returning that error (-ESTALE is mapped to
    zero).
    
    Since that commit, all errors result in nfs_lookup_revalidate()
    returning zero, resulting in dentries being invalidated where they
    previously were not (particularly in the case of -ERESTARTSYS).
    
    Fix it by passing the actual error code to nfs_lookup_revalidate_done(),
    and leaving the decision on whether to  map the error code to zero or
    one to nfs_lookup_revalidate_done().
    
    A simple reproducer is to run the following python code in a
    subdirectory of an NFS mount (not in the root of the NFS mount):
    
    ---8<---
    import os
    import multiprocessing
    import time
    
    if __name__=="__main__":
        multiprocessing.set_start_method("spawn")
    
        count = 0
        while True:
            try:
                os.getcwd()
                pool = multiprocessing.Pool(10)
                pool.close()
                pool.terminate()
                count += 1
            except Exception as e:
                print(f"Failed after {count} iterations")
                print(e)
                break
    ---8<---
    
    Prior to commit 5ceb9d7fdaaf, the above code would run indefinitely.
    After commit 5ceb9d7fdaaf, it fails almost immediately with -ENOENT.
    
    Signed-off-by: Scott Mayhew <smayhew@xxxxxxxxxx>
    Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 2a0f069d5a096..39f7549afcf5b 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1625,7 +1625,16 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry,
 	switch (error) {
 	case 1:
 		break;
-	case 0:
+	case -ETIMEDOUT:
+		if (inode && (IS_ROOT(dentry) ||
+			      NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL))
+			error = 1;
+		break;
+	case -ESTALE:
+	case -ENOENT:
+		error = 0;
+		fallthrough;
+	default:
 		/*
 		 * We can't d_drop the root of a disconnected tree:
 		 * its d_hash is on the s_anon list and d_drop() would hide
@@ -1680,18 +1689,8 @@ static int nfs_lookup_revalidate_dentry(struct inode *dir,
 
 	dir_verifier = nfs_save_change_attribute(dir);
 	ret = NFS_PROTO(dir)->lookup(dir, dentry, fhandle, fattr);
-	if (ret < 0) {
-		switch (ret) {
-		case -ESTALE:
-		case -ENOENT:
-			ret = 0;
-			break;
-		case -ETIMEDOUT:
-			if (NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL)
-				ret = 1;
-		}
+	if (ret < 0)
 		goto out;
-	}
 
 	/* Request help from readdirplus */
 	nfs_lookup_advise_force_readdirplus(dir, flags);
@@ -1735,7 +1734,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
 			 unsigned int flags)
 {
 	struct inode *inode;
-	int error;
+	int error = 0;
 
 	nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE);
 	inode = d_inode(dentry);
@@ -1780,7 +1779,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
 out_bad:
 	if (flags & LOOKUP_RCU)
 		return -ECHILD;
-	return nfs_lookup_revalidate_done(dir, dentry, inode, 0);
+	return nfs_lookup_revalidate_done(dir, dentry, inode, error);
 }
 
 static int




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux