mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: trondmy@kernel.org, anna@kernel.org
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>
Subject: [PATCH] NFS: handle wait_on_bit_action() errors in nfs_vm_page_mkwrite()
Date: Mon,  3 Mar 2025 22:03:14 +0800	[thread overview]
Message-ID: <20250303140314.1650-1-vulab@iscas.ac.cn> (raw)

Add error handling for wait_on_bit_action() failures in the page
fault path. Return VM_FAULT_SIGBUS instead of proceeding with
folio operations when wait_on_bit_action() fails.

Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 fs/nfs/file.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 1bb646752e46..9e492391687b 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -590,6 +590,7 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
 	struct file *filp = vmf->vma->vm_file;
 	struct inode *inode = file_inode(filp);
 	unsigned pagelen;
+	int r;
 	vm_fault_t ret = VM_FAULT_NOPAGE;
 	struct address_space *mapping;
 	struct folio *folio = page_folio(vmf->page);
@@ -607,9 +608,13 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
 		goto out;
 	}
 
-	wait_on_bit_action(&NFS_I(inode)->flags, NFS_INO_INVALIDATING,
+	r = wait_on_bit_action(&NFS_I(inode)->flags, NFS_INO_INVALIDATING,
 			   nfs_wait_bit_killable,
 			   TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
+	if (r) {
+		ret = VM_FAULT_SIGBUS;
+		goto out;
+	}
 
 	folio_lock(folio);
 	mapping = folio->mapping;
-- 
2.42.0.windows.2


             reply	other threads:[~2025-03-03 14:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03 14:03 Wentao Liang [this message]
2025-03-07 17:29 ` Markus Elfring

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=20250303140314.1650-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=anna@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@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

all inboxes | Powered by JetHome®