linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Anna Schumaker <anna@kernel.org>,
	linux-nfs@vger.kernel.org,  linux-fsdevel@vger.kernel.org,
	Mike Snitzer <snitzer@kernel.org>
Subject: Re: [PATCH v3 2/2] NFS: Enable the RWF_DONTCACHE flag for the NFS client
Date: Mon, 18 Aug 2025 08:56:31 -0700	[thread overview]
Message-ID: <88e2e70a827618b5301d92b094ef07efacba0577.camel@kernel.org> (raw)
In-Reply-To: <aKNE9UnyBoaE_UzJ@casper.infradead.org>

On Mon, 2025-08-18 at 16:21 +0100, Matthew Wilcox wrote:
> On Mon, Aug 18, 2025 at 07:39:50AM -0700, Trond Myklebust wrote:
> > @@ -349,8 +349,12 @@ static void nfs_folio_end_writeback(struct
> > folio *folio)
> >  static void nfs_page_end_writeback(struct nfs_page *req)
> >  {
> >  	if (nfs_page_group_sync_on_bit(req, PG_WB_END)) {
> > +		struct folio *folio = nfs_page_to_folio(req);
> > +
> > +		if (folio_test_clear_dropbehind(folio))
> > +			set_bit(PG_DROPBEHIND, &req->wb_head-
> > >wb_flags);
> >  		nfs_unlock_request(req);
> > @@ -787,8 +791,15 @@ static void nfs_inode_remove_request(struct
> > nfs_page *req)
> >  			clear_bit(PG_MAPPED, &req->wb_head-
> > >wb_flags);
> >  		}
> >  		spin_unlock(&mapping->i_private_lock);
> > -	}
> > -	nfs_page_group_unlock(req);
> > +		nfs_page_group_unlock(req);
> > +
> > +		if (test_and_clear_bit(PG_DROPBEHIND,
> > +				       &req->wb_head->wb_flags)) {
> > +			folio_set_dropbehind(folio);
> > +			folio_end_dropbehind(folio);
> > +		}
> 
> I don't think this technique is "safe".  By clearing the flag early,
> the page cache can't see that a folio that was created by dropbehind
> has now been reused and should have its dropbehind flag cleared.  So
> we
> might see pages dropped from the cache that really should not be.

The only alternative would be to add back in a helper in mm/filemap.c
that does the normal folio_end_writeback() routine, but ignores the
dropbehind flag. (folio_end_writeback_ignore_dropbehind()?)

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

  reply	other threads:[~2025-08-18 15:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-18 14:39 [PATCH v3 0/2] Initial NFS client support for RWF_DONTCACHE Trond Myklebust
2025-08-18 14:39 ` [PATCH v3 1/2] filemap: Add a helper for filesystems implementing dropbehind Trond Myklebust
2025-08-18 14:51   ` Matthew Wilcox
2025-08-18 15:59     ` Trond Myklebust
2025-08-18 16:08       ` Matthew Wilcox
2025-08-18 14:39 ` [PATCH v3 2/2] NFS: Enable the RWF_DONTCACHE flag for the NFS client Trond Myklebust
2025-08-18 15:21   ` Matthew Wilcox
2025-08-18 15:56     ` Trond Myklebust [this message]
2025-08-18 15:58       ` Matthew Wilcox
2025-08-18 16:49         ` Trond Myklebust
2025-08-18 17:04           ` Matthew Wilcox

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=88e2e70a827618b5301d92b094ef07efacba0577.camel@kernel.org \
    --to=trondmy@kernel.org \
    --cc=anna@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=snitzer@kernel.org \
    --cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).