linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hubcap@kernel.org
To: linux-fsdevel@vger.kernel.org
Cc: Mike Marshall <hubcap@omnibond.com>
Subject: [PATCH] orangefs: drop the write range when page_mkwrite loses the folio
Date: Wed, 25 Nov 2026 13:49:37 -0500	[thread overview]
Message-ID: <20261125184941.431036-1-hubcap@kernel.org> (raw)

From: Mike Marshall <hubcap@omnibond.com>

orangefs_page_mkwrite attaches a private range for the whole folio,
then returns VM_FAULT_NOPAGE if folio->mapping is no longer this
inode's mapping. Truncate can clear that mapping before the fault
locks the folio. The new range stayed attached. The folio stayed on
the LRU with mapping NULL, so reclaim called try_to_free_buffers.
drop_buffers walked the range as a buffer_head and faulted. The word
at offset 8 was the range length, 0x1000 or 0x2000.

Detach and free the range before unlocking. The folio lock is held,
so this is the range just attached or updated.

The detatch and free has been missing since orangefs_page_mkwrite was
added. attach_page_private replaced the open-coded attach in 2020 and
this failure path was left unchanged.

A full xfstests run hit this from kswapd in generic/751, generic/694,
and generic/551. The private object was an orangefs_write_range for
the folio being freed, and mapping was already NULL.

Signed-off-by: Mike Marshall <hubcap@omnibond.com>
---
 fs/orangefs/inode.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 04a2c928452e..7b17af735a9e 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -732,6 +732,11 @@ vm_fault_t orangefs_page_mkwrite(struct vm_fault *vmf)
 
 	file_update_time(vmf->vma->vm_file);
 	if (folio->mapping != inode->i_mapping) {
+		/*
+		 * Truncate already dropped this folio. Drop the write
+		 * range too, or reclaim will read it as a buffer_head.
+		 */
+		kfree(folio_detach_private(folio));
 		folio_unlock(folio);
 		ret = VM_FAULT_LOCKED|VM_FAULT_NOPAGE;
 		goto out;
-- 
2.56.1


                 reply	other threads:[~2026-11-25 18:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261125184941.431036-1-hubcap@kernel.org \
    --to=hubcap@kernel.org \
    --cc=hubcap@omnibond.com \
    --cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).