diff options
| author | Han Young <hanyang.tony@bytedance.com> | 2025-05-04 20:57:04 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-07-06 10:57:54 +0200 |
| commit | e0de34ea6deb9d49e1cca1d79042d6a5c78e6ab6 (patch) | |
| tree | c7409b730ac9dd584cb38330acabcf009db7d1e5 /fs | |
| parent | 9a5e5318c885a27dedd573d9279322073c259e6a (diff) | |
| download | linux-e0de34ea6deb9d49e1cca1d79042d6a5c78e6ab6.tar.gz linux-e0de34ea6deb9d49e1cca1d79042d6a5c78e6ab6.tar.bz2 linux-e0de34ea6deb9d49e1cca1d79042d6a5c78e6ab6.zip | |
NFSv4: Always set NLINK even if the server doesn't support it
[ Upstream commit 3a3065352f73381d3a1aa0ccab44aec3a5a9b365 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/nfs/inode.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index f2e66b946f4b..e774cfc85eee 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -555,6 +555,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) |
