Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.25-rc7 /fs/aio.c

Filename:/fs/aio.c
Lines Added:27
Lines Deleted:9
Also changed in: (Previous) 2.6.25-rc6-git8  2.6.25-rc6-git7  2.6.25-rc6-git6  2.6.25-rc6-git5  2.6.25-rc6-git4  2.6.25-rc6 
(Following) 2.6.25-rc8  2.6.25-rc8-git9  2.6.25-rc8-git10  2.6.25-rc9  2.6.25  2.6.25-git12 

Location
[  2.6.25-rc7
  [  fs
     o  aio.c

Patch

diff --git a/fs/aio.c b/fs/aio.c
index 9dec7d2..6af9219 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -317,7 +317,7 @@ out:
 /* wait_on_sync_kiocb:
  *   Waits on the given sync kiocb to complete.
  */
-ssize_t fastcall wait_on_sync_kiocb(struct kiocb *iocb)
+ssize_t wait_on_sync_kiocb(struct kiocb *iocb)
 {
    while (iocb->ki_users) {
       set_current_state(TASK_UNINTERRUPTIBLE);
@@ -336,7 +336,7 @@ ssize_t fastcall wait_on_sync_kiocb(struct kiocb *iocb)
  * go away, they will call put_ioctx and release any pinned memory
  * associated with the request (held via struct page * references).
  */
-void fastcall exit_aio(struct mm_struct *mm)
+void exit_aio(struct mm_struct *mm)
 {
    struct kioctx *ctx = mm->ioctx_list;
    mm->ioctx_list = NULL;
@@ -365,7 +365,7 @@ void fastcall exit_aio(struct mm_struct *mm)
  *   Called when the last user of an aio context has gone away,
  *   and the struct needs to be freed.
  */
-void fastcall __put_ioctx(struct kioctx *ctx)
+void __put_ioctx(struct kioctx *ctx)
 {
    unsigned nr_events = ctx->max_reqs;
 
@@ -397,8 +397,7 @@ void fastcall __put_ioctx(struct kioctx *ctx)
  * This prevents races between the aio code path referencing the
  * req (after submitting it) and aio_complete() freeing the req.
  */
-static struct kiocb *FASTCALL(__aio_get_req(struct kioctx *ctx));
-static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx)
+static struct kiocb *__aio_get_req(struct kioctx *ctx)
 {
    struct kiocb *req = NULL;
    struct aio_ring *ring;
@@ -533,7 +532,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
  *   Returns true if this put was the last user of the kiocb,
  *   false if the request is still in use.
  */
-int fastcall aio_put_req(struct kiocb *req)
+int aio_put_req(struct kiocb *req)
 {
    struct kioctx *ctx = req->ki_ctx;
    int ret;
@@ -893,7 +892,7 @@ static void try_queue_kicked_iocb(struct kiocb *iocb)
  *      The retry is usually executed by aio workqueue
  *      threads (See aio_kick_handler).
  */
-void fastcall kick_iocb(struct kiocb *iocb)
+void kick_iocb(struct kiocb *iocb)
 {
    /* sync iocbs are easy: they can only ever be executing from a 
     * single context. */
@@ -912,7 +911,7 @@ EXPORT_SYMBOL(kick_iocb);
  *   Returns true if this is the last user of the request.  The 
  *   only other user of the request can be the cancellation code.
  */
-int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
+int aio_complete(struct kiocb *iocb, long res, long res2)
 {
    struct kioctx   *ctx = iocb->ki_ctx;
    struct aio_ring_info   *info;
@@ -997,6 +996,14 @@ put_rq:
    /* everything turned out well, dispose of the aiocb. */
    ret = __aio_put_req(ctx, iocb);
 
+   /*
+    * We have to order our ring_info tail store above and test
+    * of the wait list below outside the wait lock.  This is
+    * like in wake_up_bit() where clearing a bit has to be
+    * ordered with the unlocked test.
+    */
+   smp_mb();
+
    if (waitqueue_active(&ctx->wait))
       wake_up(&ctx->wait);
 
@@ -1330,6 +1337,10 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb)
       opcode = IOCB_CMD_PWRITEV;
    }
 
+   /* This matches the pread()/pwrite() logic */
+   if (iocb->ki_pos < 0)
+      return -EINVAL;
+
    do {
       ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg],
              iocb->ki_nr_segs - iocb->ki_cur_seg,
@@ -1348,6 +1359,13 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb)
    if ((ret == 0) || (iocb->ki_left == 0))
       ret = iocb->ki_nbytes - iocb->ki_left;
 
+   /* If we managed to write some out we return that, rather than
+    * the eventual error. */
+   if (opcode == IOCB_CMD_PWRITEV
+       && ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY
+       && iocb->ki_nbytes - iocb->ki_left)
+      ret = iocb->ki_nbytes - iocb->ki_left;
+
    return ret;
 }
 
@@ -1523,7 +1541,7 @@ static int aio_wake_function(wait_queue_t *wait, unsigned mode,
    return 1;
 }
 
-int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
+int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
           struct iocb *iocb)
 {
    struct kiocb *req;


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.