diff mbox series

btrfs: check if task has died in btrfs_uring_read_finished()

Message ID 20241213124626.130075-1-maharmstone@fb.com (mailing list archive)
State New
Headers show
Series btrfs: check if task has died in btrfs_uring_read_finished() | expand

Commit Message

Mark Harmstone Dec. 13, 2024, 12:46 p.m. UTC
If the task has died by the time we call btrfs_uring_read_finished(),
return -ECANCELED rather than trying to copy the pages back to
userspace.

Signed-off-by: Mark Harmstone <maharmstone@fb.com>
Suggested-by: Pavel Begunkov <asml.silence@gmail.com>
---
(This is quite possibly a resend. I intended this to be the sequel to
"[PATCH 1/2] io_uring/cmd: let cmds to know about dying task", but I
can't find it anywhere on the mailing lists now.)

 fs/btrfs/ioctl.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 64cebc32fe76..6913967083fe 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4754,6 +4754,11 @@  static void btrfs_uring_read_finished(struct io_uring_cmd *cmd, unsigned int iss
 	/* The inode lock has already been acquired in btrfs_uring_read_extent.  */
 	btrfs_lockdep_inode_acquire(inode, i_rwsem);
 
+	if (unlikely(issue_flags & IO_URING_F_TASK_DEAD)) {
+		ret = -ECANCELED;
+		goto out;
+	}
+
 	if (priv->err) {
 		ret = priv->err;
 		goto out;