Linux NFS development
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@kernel.org>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/5] NFS: Protect against 'eof page pollution'
Date: Sat, 24 Jan 2026 17:20:19 -0500	[thread overview]
Message-ID: <7c86e2c3ec73650696579a3e03be937a8b4205a1.camel@kernel.org> (raw)
In-Reply-To: <4a0a8181-b0b5-4f2f-84e1-3c935273b7df@lucifer.local>

On Sat, 2026-01-24 at 21:01 +0000, Lorenzo Stoakes wrote:
> On Fri, Sep 05, 2025 at 03:35:16PM -0400, Trond Myklebust wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > 
> > This commit fixes the failing xfstest 'generic/363'.
> > 
> > When the user mmaps() an area that extends beyond the end of file,
> > and
> > proceeds to write data into the folio that straddles that eof,
> > we're
> > required to discard that folio data if the user calls some function
> > that
> > extends the file length.
> > 
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> Hi Trond,
> 
> Sorry to dig up an old patch but I wanted to ask about this change:
> 
> > ---
> >  fs/nfs/file.c      | 33 +++++++++++++++++++++++++++++++++
> >  fs/nfs/inode.c     |  9 +++++++--
> >  fs/nfs/internal.h  |  2 ++
> >  fs/nfs/nfs42proc.c | 14 +++++++++++---
> >  fs/nfs/nfstrace.h  |  1 +
> >  5 files changed, 54 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> > index 86e36c630f09..af2fdbfcbbf6 100644
> > --- a/fs/nfs/file.c
> > +++ b/fs/nfs/file.c
> > @@ -28,6 +28,7 @@
> >  #include <linux/mm.h>
> >  #include <linux/pagemap.h>
> >  #include <linux/gfp.h>
> > +#include <linux/rmap.h>
> >  #include <linux/swap.h>
> >  #include <linux/compaction.h>
> > 
> > @@ -280,6 +281,37 @@ nfs_file_fsync(struct file *file, loff_t
> > start, loff_t end, int datasync)
> >  }
> >  EXPORT_SYMBOL_GPL(nfs_file_fsync);
> > 
> > +void nfs_truncate_last_folio(struct address_space *mapping, loff_t
> > from,
> > +      loff_t to)
> 
> So this seems to be a slightly adjusted version of
> pagecache_isize_extend(),
> what was it about that that didn't work for you?
> 
> It seems the main differences are - block size alignment (surely you
> still need
> that though?) switching folio_test_dirty() for folio_test_uptodate()
> (I'm not
> sure about this change though?) and adding the trace line.

   1. NFS is not a block protocol. Reads and writes are byte aligned.
   2. The test for bsize >= PAGE_SIZE is nonsense for a byte aligned
      filesystem.
   3. NFS does care about using folio_mkclean() to fix races between an
      application that is writing to the folio, and any zeroing of the
      data that may result from the file truncation.
   4. The existing folio dirty state isn't of interest here, since NFS
      won't extend existing writes to cover the part of the folio that
      lies after the old eof.
   5. The folio uptodate state is of interest, since any future
      pagecache read needs to see zeroed bytes starting at the old eof
      and extending either to the offset at the end of the folio, or to
      the new eof (whichever of the two is smaller).


-- 
Trond Myklebust Linux NFS client maintainer, Hammerspace
trondmy@kernel.org, trond.myklebust@hammerspace.com

  reply	other threads:[~2026-01-24 22:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-05 19:35 [PATCH 0/5] Assortment of I/O fixes for the NFS client Trond Myklebust
2025-09-05 19:35 ` [PATCH 1/5] NFS: Protect against 'eof page pollution' Trond Myklebust
2026-01-24 21:01   ` Lorenzo Stoakes
2026-01-24 22:20     ` Trond Myklebust [this message]
2026-01-26 13:03       ` Lorenzo Stoakes
2025-09-05 19:35 ` [PATCH 2/5] NFS: Serialise O_DIRECT i/o and truncate() Trond Myklebust
2025-09-05 19:35 ` [PATCH 3/5] NFSv4.2: Serialise O_DIRECT i/o and fallocate() Trond Myklebust
2025-09-05 19:35 ` [PATCH 4/5] NFS: nfs_invalidate_folio() must observe the offset and size arguments Trond Myklebust
2025-09-05 19:35 ` [PATCH 5/5] NFS: Fix the marking of the folio as up to date Trond Myklebust
2025-09-06 16:42 ` [PATCH v2 0/8] Assortment of I/O fixes for the NFS client Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 1/8] NFS: Protect against 'eof page pollution' Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 2/8] NFSv4.2: Protect copy offload and clone " Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 3/8] NFS: Serialise O_DIRECT i/o and truncate() Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 4/8] NFSv4.2: Serialise O_DIRECT i/o and fallocate() Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 5/8] NFSv4.2: Serialise O_DIRECT i/o and clone range Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 6/8] NFSv4.2: Serialise O_DIRECT i/o and copy range Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 7/8] NFS: nfs_invalidate_folio() must observe the offset and size arguments Trond Myklebust
2025-09-06 16:42   ` [PATCH v2 8/8] NFS: Fix the marking of the folio as up to date Trond Myklebust

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=7c86e2c3ec73650696579a3e03be937a8b4205a1.camel@kernel.org \
    --to=trondmy@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.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