From: Trond Myklebust <trondmy@hammerspace.com>
To: "hanyang.tony@bytedance.com" <hanyang.tony@bytedance.com>,
"anna@kernel.org" <anna@kernel.org>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] NFSv4: Always set NLINK even if the server doesn't support it
Date: Fri, 2 May 2025 15:39:07 +0000 [thread overview]
Message-ID: <ed524dd7e4e20acef750c63e671407c3dc386c12.camel@hammerspace.com> (raw)
In-Reply-To: <20250502151544.76653-1-hanyang.tony@bytedance.com>
On Fri, 2025-05-02 at 23:15 +0800, Han Young wrote:
> 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". Change the check
> in
> nfs_fhget so that the nlink value is always set.
>
> Signed-off-by: Han Young <hanyang.tony@bytedance.com>
> ---
> fs/nfs/inode.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 119e447758b9..c19f135b5041 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -553,10 +553,11 @@ nfs_fhget(struct super_block *sb, struct nfs_fh
> *fh, struct nfs_fattr *fattr)
> inode->i_size = nfs_size_to_loff_t(fattr-
> >size);
> else
> nfs_set_cache_invalid(inode,
> NFS_INO_INVALID_SIZE);
> - if (fattr->valid & NFS_ATTR_FATTR_NLINK)
> - set_nlink(inode, fattr->nlink);
> - else if (fattr_supported & NFS_ATTR_FATTR_NLINK)
> + if (!(fattr->valid & NFS_ATTR_FATTR_NLINK) &&
> + fattr_supported & NFS_ATTR_FATTR_NLINK)
> nfs_set_cache_invalid(inode,
> NFS_INO_INVALID_NLINK);
> + else
> + set_nlink(inode, fattr->nlink);
No. You can't use the value of fattr->nlink when that value is
undefined.
> if (fattr->valid & NFS_ATTR_FATTR_OWNER)
> inode->i_uid = fattr->uid;
> else if (fattr_supported & NFS_ATTR_FATTR_OWNER)
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2025-05-02 15:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 15:15 [PATCH] NFSv4: Always set NLINK even if the server doesn't support it Han Young
2025-05-02 15:39 ` Trond Myklebust [this message]
2025-05-04 12:57 ` [PATCH v2] " Han Young
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed524dd7e4e20acef750c63e671407c3dc386c12.camel@hammerspace.com \
--to=trondmy@hammerspace.com \
--cc=anna@kernel.org \
--cc=hanyang.tony@bytedance.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox