[Devel,vz7,26/46] fuse: simplify request_wait()

Submitted by Maxim Patlasov on March 25, 2017, 2:23 a.m.

Details

Message ID 149040858243.25341.15269034484724385921.stgit@maxim-thinkpad
State New
Series "fuse: add multi-threading support"
Headers show

Commit Message

Maxim Patlasov March 25, 2017, 2:23 a.m.
Backport from ml:

commit 5250921bb0b25e7fc77ba732e569224410743a05
Author: Miklos Szeredi <mszeredi@suse.cz>
Date:   Wed Jul 1 16:26:03 2015 +0200

    fuse: simplify request_wait()

    wait_event_interruptible_exclusive_locked() will do everything
    request_wait() does, so replace it.

    Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
    Reviewed-by: Ashish Samant <ashish.samant@oracle.com>

Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/fuse/dev.c |   30 +++++-------------------------
 1 file changed, 5 insertions(+), 25 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index de6731b..10c126b 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1036,27 +1036,6 @@  static int request_pending(struct fuse_iqueue *fiq)
 		forget_pending(fiq);
 }
 
-/* Wait until a request is available on the pending list */
-static void request_wait(struct fuse_iqueue *fiq)
-__releases(fiq->waitq.lock)
-__acquires(fiq->waitq.lock)
-{
-	DECLARE_WAITQUEUE(wait, current);
-
-	add_wait_queue_exclusive(&fiq->waitq, &wait);
-	while (fiq->connected && !request_pending(fiq)) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (signal_pending(current))
-			break;
-
-		spin_unlock(&fiq->waitq.lock);
-		schedule();
-		spin_lock(&fiq->waitq.lock);
-	}
-	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&fiq->waitq, &wait);
-}
-
 /*
  * Transfer an interrupt request to userspace
  *
@@ -1236,13 +1215,14 @@  static ssize_t fuse_dev_do_read(struct fuse_conn *fc, struct file *file,
 	    !request_pending(fiq))
 		goto err_unlock;
 
-	request_wait(fiq);
+	err = wait_event_interruptible_exclusive_locked(fiq->waitq,
+				!fiq->connected || request_pending(fiq));
+	if (err)
+		goto err_unlock;
+
 	err = -ENODEV;
 	if (!fiq->connected)
 		goto err_unlock;
-	err = -ERESTARTSYS;
-	if (!request_pending(fiq))
-		goto err_unlock;
 
 	if (!list_empty(&fiq->interrupts)) {
 		req = list_entry(fiq->interrupts.next, struct fuse_req,