Skip to content

Commit 3a30653

Browse files
hanyang-tonyAnna Schumaker
authored andcommitted
NFSv4: Always set NLINK even if the server doesn't support it
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 <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 77be29b commit 3a30653

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/nfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
557557
set_nlink(inode, fattr->nlink);
558558
else if (fattr_supported & NFS_ATTR_FATTR_NLINK)
559559
nfs_set_cache_invalid(inode, NFS_INO_INVALID_NLINK);
560+
else
561+
set_nlink(inode, 1);
560562
if (fattr->valid & NFS_ATTR_FATTR_OWNER)
561563
inode->i_uid = fattr->uid;
562564
else if (fattr_supported & NFS_ATTR_FATTR_OWNER)

0 commit comments

Comments
 (0)