From: Zach Brown <zach.brown@oracle.com>
To: linux-aio@kvack.org, linux-kernel@vger.kernel.org
Cc: Benjamin LaHaise <bcrl@kvack.org>,
Suparna bhattacharya <suparna@in.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Leonid Ananiev <leonid.i.ananiev@intel.com>
Subject: [PATCH 1/2] aio: create aio_ring_insert_entry() function
Date: Mon, 19 Feb 2007 13:38:30 -0800 (PST) [thread overview]
Message-ID: <20070219213830.4032.71308.sendpatchset@tetsuo.zabbo.net> (raw)
aio: create aio_ring_insert_entry() function
This patch just hoists the process of inserting an entry into the completion
ring into its own function. No functionality is changed. This is in
preparation for calling ring insertion from another path with slightly
different mechanics.
diff -r b551e6cbf434 fs/aio.c
Signed-off-by: Zach Brown <zach.brown@oracle.com>
---
fs/aio.c | 77 +++++++++++++++++++++++++++++------------------------
1 file changed, 43 insertions(+), 34 deletions(-)
--- a/fs/aio.c Mon Feb 19 13:09:01 2007 -0800
+++ b/fs/aio.c Mon Feb 19 13:12:04 2007 -0800
@@ -192,6 +192,47 @@ static int aio_setup_ring(struct kioctx
(void)__event; \
kunmap_atomic((void *)((unsigned long)__event & PAGE_MASK), km); \
} while(0)
+
+static void aio_ring_insert_entry(struct kioctx *ctx, struct kiocb *iocb,
+ long res, long res2)
+{
+ struct aio_ring_info *info;
+ struct aio_ring *ring;
+ struct io_event *event;
+ unsigned long tail;
+
+ assert_spin_locked(&ctx->ctx_lock);
+
+ info = &ctx->ring_info;
+ ring = kmap_atomic(info->ring_pages[0], KM_IRQ1);
+
+ tail = info->tail;
+ event = aio_ring_event(info, tail, KM_IRQ0);
+ if (++tail >= info->nr)
+ tail = 0;
+
+ event->obj = (u64)(unsigned long)iocb->ki_obj.user;
+ event->data = iocb->ki_user_data;
+ event->res = res;
+ event->res2 = res2;
+
+ dprintk("aio_complete: %p[%lu]: %p: %p %Lx %lx %lx\n",
+ ctx, tail, iocb, iocb->ki_obj.user, iocb->ki_user_data,
+ res, res2);
+
+ /* after flagging the request as done, we
+ * must never even look at it again
+ */
+ smp_wmb(); /* make event visible before updating tail */
+
+ info->tail = tail;
+ ring->tail = tail;
+
+ put_aio_ring_event(event, KM_IRQ0);
+ kunmap_atomic(ring, KM_IRQ1);
+
+ pr_debug("added to ring %p at [%lu]\n", iocb, tail);
+}
/* ioctx_alloc
* Allocates and initializes an ioctx. Returns an ERR_PTR if it failed.
@@ -924,11 +965,7 @@ int fastcall aio_complete(struct kiocb *
int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
{
struct kioctx *ctx = iocb->ki_ctx;
- struct aio_ring_info *info;
- struct aio_ring *ring;
- struct io_event *event;
unsigned long flags;
- unsigned long tail;
int ret;
/*
@@ -946,8 +983,6 @@ int fastcall aio_complete(struct kiocb *
return 1;
}
- info = &ctx->ring_info;
-
/* add a completion event to the ring buffer.
* must be done holding ctx->ctx_lock to prevent
* other code from messing with the tail
@@ -966,34 +1001,8 @@ int fastcall aio_complete(struct kiocb *
if (kiocbIsCancelled(iocb))
goto put_rq;
- ring = kmap_atomic(info->ring_pages[0], KM_IRQ1);
-
- tail = info->tail;
- event = aio_ring_event(info, tail, KM_IRQ0);
- if (++tail >= info->nr)
- tail = 0;
-
- event->obj = (u64)(unsigned long)iocb->ki_obj.user;
- event->data = iocb->ki_user_data;
- event->res = res;
- event->res2 = res2;
-
- dprintk("aio_complete: %p[%lu]: %p: %p %Lx %lx %lx\n",
- ctx, tail, iocb, iocb->ki_obj.user, iocb->ki_user_data,
- res, res2);
-
- /* after flagging the request as done, we
- * must never even look at it again
- */
- smp_wmb(); /* make event visible before updating tail */
-
- info->tail = tail;
- ring->tail = tail;
-
- put_aio_ring_event(event, KM_IRQ0);
- kunmap_atomic(ring, KM_IRQ1);
-
- pr_debug("added to ring %p at [%lu]\n", iocb, tail);
+ aio_ring_insert_entry(ctx, iocb, res, res2);
+
put_rq:
/* everything turned out well, dispose of the aiocb. */
ret = __aio_put_req(ctx, iocb);
next reply other threads:[~2007-02-19 21:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-19 21:38 Zach Brown [this message]
2007-02-19 21:38 ` [PATCH 2/2] aio: propogate post-EIOCBQUEUED errors to completion event Zach Brown
2007-02-19 22:48 ` Jeff Moyer
2007-02-19 22:57 ` Zach Brown
2007-02-20 16:57 ` Ananiev, Leonid I
2007-02-20 17:03 ` Chris Mason
2007-02-20 17:17 ` Ananiev, Leonid I
2007-02-20 17:54 ` Chris Mason
2007-02-20 21:09 ` Ananiev, Leonid I
2007-02-21 8:35 ` Ken Chen
2007-02-21 8:44 ` Ananiev, Leonid I
2007-02-21 18:24 ` Zach Brown
2007-02-21 19:15 ` Ananiev, Leonid I
2007-02-20 17:33 ` Ananiev, Leonid I
2007-02-20 18:26 ` Zach Brown
2007-02-21 14:13 ` Suparna Bhattacharya
2007-02-21 18:34 ` Zach Brown
2007-02-19 22:41 ` [PATCH 1/2] aio: create aio_ring_insert_entry() function Jeff Moyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070219213830.4032.71308.sendpatchset@tetsuo.zabbo.net \
--to=zach.brown@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=bcrl@kvack.org \
--cc=leonid.i.ananiev@intel.com \
--cc=linux-aio@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=suparna@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox