]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] aio: fix do_sync_(read|write) to properly handle aio retries
authorBenjamin LaHaise <bcrl@kvack.org>
Thu, 23 Jun 2005 07:10:27 +0000 (00:10 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 23 Jun 2005 16:45:34 +0000 (09:45 -0700)
When do_sync_(read|write) encounters an aio method that makes use of the
retry mechanism, they fail to correctly retry the operation.  This fixes
that by adding the appropriate sleep and retry mechanism.

Signed-off-by: Benjamin LaHaise <benjamin.c.lahaise@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/read_write.c

index c4c2bee373eddeab7b0d3bb9e110453a63ccd436..9292f5fa4d6225e7e0254344e990b35e107103f2 100644 (file)
@@ -203,6 +203,16 @@ Einval:
        return -EINVAL;
 }
 
+static void wait_on_retry_sync_kiocb(struct kiocb *iocb)
+{
+       set_current_state(TASK_UNINTERRUPTIBLE);
+       if (!kiocbIsKicked(iocb))
+               schedule();
+       else
+               kiocbClearKicked(iocb);
+       __set_current_state(TASK_RUNNING);
+}
+
 ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
 {
        struct kiocb kiocb;
@@ -210,7 +220,10 @@ ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *pp
 
        init_sync_kiocb(&kiocb, filp);
        kiocb.ki_pos = *ppos;
-       ret = filp->f_op->aio_read(&kiocb, buf, len, kiocb.ki_pos);
+       while (-EIOCBRETRY ==
+               (ret = filp->f_op->aio_read(&kiocb, buf, len, kiocb.ki_pos)))
+               wait_on_retry_sync_kiocb(&kiocb);
+
        if (-EIOCBQUEUED == ret)
                ret = wait_on_sync_kiocb(&kiocb);
        *ppos = kiocb.ki_pos;
@@ -258,7 +271,10 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
 
        init_sync_kiocb(&kiocb, filp);
        kiocb.ki_pos = *ppos;
-       ret = filp->f_op->aio_write(&kiocb, buf, len, kiocb.ki_pos);
+       while (-EIOCBRETRY ==
+              (ret = filp->f_op->aio_write(&kiocb, buf, len, kiocb.ki_pos)))
+               wait_on_retry_sync_kiocb(&kiocb);
+
        if (-EIOCBQUEUED == ret)
                ret = wait_on_sync_kiocb(&kiocb);
        *ppos = kiocb.ki_pos;