]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Jul 2025 13:57:31 +0000 (15:57 +0200)
commita35f2168961e20445d717149e155c202043b1a2a
tree9bfb45bc5cca823b08b76876c542cbd6572bd86c
parent80251a15ed6141a8840969f13b4c7b1a32f8dba8
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>
fs/nfs/inode.c