From: Trond Myklebust <trondmy@kernel.org>
To: Lucheng Bao <lubao@everpuredata.com>,
linux-nfs@vger.kernel.org, Anna Schumaker <anna@kernel.org>
Cc: linux-kernel@vger.kernel.org, tmenninger@everpuredata.com,
jcurley@everpuredata.com, stable@vger.kernel.org
Subject: Re: [PATCH 1/2] NFSv4/pNFS: prevent i_size regression while layoutcommit is outstanding
Date: Fri, 09 Oct 2026 00:43:19 -0400 [thread overview]
Message-ID: <6855034f0b219b0b8e6a6f47aef802cf2803e42b.camel@kernel.org> (raw)
In-Reply-To: <20261008222843.63319-2-lubao@everpuredata.com>
On Thu, 2026-10-08 at 22:28 +0000, Lucheng Bao wrote:
> Commit ac46bd374c9a ("pNFS: Ensure we layoutcommit before
> revalidating
> attributes") replaced outstanding-layoutcommit attribute filtering
> with
> synchronization before explicit revalidation. For layouts requiring
> LAYOUTCOMMIT, OPEN attributes can still shrink i_size before metadata
> synchronization completes.
The client can't police OPEN. It has no idea which file will be
affected (particularly when doing an open-by-filename) so unlike the
case of an explicit truncate() call, it can't serialise with the
truncate.
It is therefore up to the server to resolve any ambiguity, either by
recalling or revoking the layout before allowing the OPEN truncate to
proceed.
>
> Commit d8c951c313ed ("NFSv4.1: Don't trust attributes if a pNFS
> LAYOUTCOMMIT is outstanding") moved LAYOUTCOMMIT post-op attribute
> processing after cleanup, leaving another unprotected window after
> NFS_INO_LAYOUTCOMMITTING is cleared.
This is unrelated to the above problem, so fixes for this issue need to
be in a separate patch.
>
> Extend the existing writeback checks to reject smaller sizes while a
> LAYOUTCOMMIT is pending or in flight, preserving size increases and
> WCC
> checks. Process the reply's attributes and establish their generation
> barrier before cleanup removes that protection.
>
> Fixes: d8c951c313ed ("NFSv4.1: Don't trust attributes if a pNFS
> LAYOUTCOMMIT is outstanding")
> Fixes: ac46bd374c9a ("pNFS: Ensure we layoutcommit before
> revalidating attributes")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lucheng Bao <lubao@everpuredata.com>
> ---
> fs/nfs/inode.c | 8 ++++++--
> fs/nfs/nfs4proc.c | 2 +-
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 3022454f7698..11432f521b04 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -1636,7 +1636,9 @@ static void nfs_wcc_update_inode(struct inode
> *inode, struct nfs_fattr *fattr)
> if ((fattr->valid & NFS_ATTR_FATTR_PRESIZE)
> && (fattr->valid & NFS_ATTR_FATTR_SIZE)
> && i_size_read(inode) ==
> nfs_size_to_loff_t(fattr->pre_size)
> - && !nfs_have_writebacks(inode)) {
> + && !nfs_have_writebacks(inode)
> + && (nfs_size_to_loff_t(fattr->size) >=
> i_size_read(inode)
> + ||
> !pnfs_layoutcommit_outstanding(inode))) {
Under what circumstance is the client legally supposed to be able to
call nfs_wcc_update_inode() with NFS_ATTR_FATTR_PRESIZE set, while
there is an outstanding layoutcommit?
> trace_nfs_size_wcc(inode, fattr->size);
> i_size_write(inode, nfs_size_to_loff_t(fattr-
> >size));
> }
> @@ -2392,7 +2394,9 @@ static int nfs_update_inode(struct inode
> *inode, struct nfs_fattr *fattr)
> if (new_isize != cur_isize && !have_delegation) {
> /* Do we perhaps have any outstanding
> writes, or has
> * the file grown beyond our last write? */
> - if (!nfs_have_writebacks(inode) || new_isize
> > cur_isize) {
> + if ((!nfs_have_writebacks(inode) &&
> + !pnfs_layoutcommit_outstanding(inode))
> ||
> + new_isize > cur_isize) {
> trace_nfs_size_update(inode,
> new_isize);
> i_size_write(inode, new_isize);
> if (!have_writers)
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 04b1987115d5..1ae047a062b8 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -10093,9 +10093,9 @@ static void nfs4_layoutcommit_release(void
> *calldata)
> {
> struct nfs4_layoutcommit_data *data = calldata;
>
> - pnfs_cleanup_layoutcommit(data);
> nfs_post_op_update_inode_force_wcc(data->args.inode,
> data->res.fattr);
> + pnfs_cleanup_layoutcommit(data);
> put_cred(data->cred);
> nfs_iput_and_deactive(data->inode);
> kfree(data);
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@kernel.org, trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2026-10-09 4:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 22:28 [PATCH 0/2] NFSv4/pNFS: don't trust inode size from MDS while LAYOUTCOMMIT " Lucheng Bao
2026-10-08 22:28 ` [PATCH 1/2] NFSv4/pNFS: prevent i_size regression while layoutcommit " Lucheng Bao
2026-10-09 4:43 ` Trond Myklebust [this message]
2026-10-08 22:28 ` [PATCH 2/2] NFSv4/pNFS: defer LAYOUTRETURN after an unsuccessful OLD_STATEID refresh Lucheng Bao
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=6855034f0b219b0b8e6a6f47aef802cf2803e42b.camel@kernel.org \
--to=trondmy@kernel.org \
--cc=anna@kernel.org \
--cc=jcurley@everpuredata.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=lubao@everpuredata.com \
--cc=stable@vger.kernel.org \
--cc=tmenninger@everpuredata.com \
/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
all inboxes | Powered by JetHome®