]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFSv4: Always set NLINK even if the server doesn't support it
authorHan Young <hanyang.tony@bytedance.com>
Sun, 4 May 2025 12:57:04 +0000 (20:57 +0800)
committerAnna Schumaker <anna.schumaker@oracle.com>
Wed, 28 May 2025 21:17:13 +0000 (17:17 -0400)
fattr4_numlinks is a recommended attribute, so the client should emulate
it even if the server doesn't support it. In decode_attr_nlink function
in nfs4xdr.c, nlink is initialized to 1. However, this default value
isn't set to the inode due to the check in nfs_fhget.

So if the server doesn't support numlinks, inode's nlink will be zero,
the mount will fail with error "Stale file handle". Set the nlink to 1
if the server doesn't support it.

Signed-off-by: Han Young <hanyang.tony@bytedance.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/inode.c

index 6472b95bfd883003f6aab3f9e58922cce4e7e166..8ab7868807a7d919f0d78cab49f991dd734edf53 100644 (file)
@@ -557,6 +557,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                        set_nlink(inode, fattr->nlink);
                else if (fattr_supported & NFS_ATTR_FATTR_NLINK)
                        nfs_set_cache_invalid(inode, NFS_INO_INVALID_NLINK);
+               else
+                       set_nlink(inode, 1);
                if (fattr->valid & NFS_ATTR_FATTR_OWNER)
                        inode->i_uid = fattr->uid;
                else if (fattr_supported & NFS_ATTR_FATTR_OWNER)