[PATCH 5/5] Make wait_on_retry_sync_kiocb killable

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Matthew Wilcox <matthew@...>
Date: Thursday, October 18, 2007 - 6:26 pm

Use TASK_KILLABLE to allow wait_on_retry_sync_kiocb to return -EINTR.
All callers then check the return value and break out of their loops.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>
---
 fs/read_write.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 124693e..3196a3b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -218,14 +218,15 @@ Einval:
 	return -EINVAL;
 }
 
-static void wait_on_retry_sync_kiocb(struct kiocb *iocb)
+static int wait_on_retry_sync_kiocb(struct kiocb *iocb)
 {
-	set_current_state(TASK_UNINTERRUPTIBLE);
+	set_current_state(TASK_KILLABLE);
 	if (!kiocbIsKicked(iocb))
 		schedule();
 	else
 		kiocbClearKicked(iocb);
 	__set_current_state(TASK_RUNNING);
+	return fatal_signal_pending(current) ? -EINTR : 0;
 }
 
 ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
@@ -242,7 +243,9 @@ ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *pp
 		ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
 		if (ret != -EIOCBRETRY)
 			break;
-		wait_on_retry_sync_kiocb(&kiocb);
+		ret = wait_on_retry_sync_kiocb(&kiocb);
+		if (ret)
+			break;
 	}
 
 	if (-EIOCBQUEUED == ret)
@@ -300,7 +303,9 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
 		ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
 		if (ret != -EIOCBRETRY)
 			break;
-		wait_on_retry_sync_kiocb(&kiocb);
+		ret = wait_on_retry_sync_kiocb(&kiocb);
+		if (ret)
+			break;
 	}
 
 	if (-EIOCBQUEUED == ret)
@@ -466,7 +471,9 @@ ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov,
 		ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos);
 		if (ret != -EIOCBRETRY)
 			break;
-		wait_on_retry_sync_kiocb(&kiocb);
+		ret = wait_on_retry_sync_kiocb(&kiocb);
+		if (ret)
+			break;
 	}
 
 	if (ret == -EIOCBQUEUED)
-- 
1.4.4.2

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/5] TASK_KILLABLE, Matthew Wilcox, (Thu Oct 18, 6:25 pm)
Re: [PATCH 0/5] TASK_KILLABLE, Nick Piggin, (Wed Oct 24, 11:55 pm)
[PATCH 2/5] Use macros instead of TASK_ flags, Matthew Wilcox, (Thu Oct 18, 6:25 pm)
Re: [PATCH 2/5] Use macros instead of TASK_ flags, Nick Piggin, (Wed Oct 24, 11:50 pm)
[PATCH 3/5] Add TASK_WAKEKILL, Matthew Wilcox, (Thu Oct 18, 6:26 pm)
[PATCH 4/5] Add lock_page_killable, Matthew Wilcox, (Thu Oct 18, 6:26 pm)
[PATCH 5/5] Make wait_on_retry_sync_kiocb killable, Matthew Wilcox, (Thu Oct 18, 6:26 pm)
Re: [PATCH 5/5] Make wait_on_retry_sync_kiocb killable, Nick Piggin, (Wed Oct 24, 11:53 pm)
[PATCH 1/5] Use wake_up_locked() in eventpoll, Matthew Wilcox, (Thu Oct 18, 6:25 pm)
Re: [PATCH 1/5] Use wake_up_locked() in eventpoll, Arjan van de Ven, (Thu Oct 18, 11:56 pm)
Re: [PATCH 1/5] Use wake_up_locked() in eventpoll, Matthew Wilcox, (Fri Oct 19, 12:28 pm)