From: Suparna Bhattacharya <suparna@in.ibm.com>
To: linux-aio@kvack.org
Cc: linux-kernel@vger.kernel.org, bcrl@kvack.org, wli@holomorphy.com,
zab@zabbo.net, mason@suse.com
Subject: [PATCH 1/2] Filesystem AIO read
Date: Fri, 24 Jun 2005 16:51:11 +0530 [thread overview]
Message-ID: <20050624112111.GA4574@in.ibm.com> (raw)
In-Reply-To: <20050624104928.GA4408@in.ibm.com>
On Fri, Jun 24, 2005 at 04:19:28PM +0530, Suparna Bhattacharya wrote:
> > (2) Buffered filesystem AIO read/write (me/Ben)
Filesystem aio read:
Converts the wait for page to become uptodate (lock page)
after readahead/readpage (in do_generic_mapping_read) to a retry
exit, to make buffered filesystem AIO reads actually synchronous.
The patch avoids exclusive wakeups with AIO, a problem originally
spotted by Chris Mason, though the reasoning for why it is an
issue is now much clearer (see explanation in the comment below
in aio.c), and the solution is perhaps slightly simpler.
fs/aio.c | 11 ++++++++++-
mm/filemap.c | 20 +++++++++++++++++---
2 files changed, 27 insertions(+), 4 deletions(-)
diff -u orig/mm/filemap.c linux-2.6.12-rc6/mm/filemap.c
--- orig/mm/filemap.c 2005-06-23 21:50:28.000000000 +0530
+++ linux-2.6.12-rc6/mm/filemap.c 2005-06-21 12:13:21.000000000 +0530
@@ -770,6 +770,11 @@
if (!isize)
goto out;
+ if (in_aio()) {
+ /* Avoid repeat readahead */
+ if (is_retried_kiocb(io_wait_to_kiocb(current->io_wait)))
+ next_index = last_index;
+ }
end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
for (;;) {
struct page *page;
@@ -771,7 +771,11 @@ page_ok:
page_not_up_to_date:
/* Get exclusive access to the page ... */
- lock_page(page);
+
+ if ((error = __lock_page(page, current->io_wait))) {
+ pr_debug("queued lock page \n");
+ goto readpage_error;
+ }
/* Did it get unhashed before we got the lock? */
if (!page->mapping) {
@@ -793,7 +798,8 @@ readpage:
goto readpage_error;
if (!PageUptodate(page)) {
- lock_page(page);
+ if ((error = __lock_page(page, current->io_wait)))
+ goto readpage_error;
if (!PageUptodate(page)) {
if (page->mapping == NULL) {
/*
@@ -880,7 +880,11 @@ readpage:
goto page_ok;
readpage_error:
- /* UHHUH! A synchronous read error occurred. Report it */
+ /* We don't have uptodate data in the page yet */
+ /* Could be due to an error or because we need to
+ * retry when we get an async i/o notification.
+ * Report the reason.
+ */
desc->error = error;
page_cache_release(page);
goto out;
diff -u orig/fs/aio.c linux-2.6.12-rc6/fs/aio.c
--- orig/fs/aio.c 2005-06-23 21:51:14.000000000 +0530
+++ linux-2.6.12-rc6/fs/aio.c 2005-06-23 18:47:18.000000000 +0530
@@ -1473,7 +1473,16 @@
list_del_init(&wait->task_list);
kick_iocb(iocb);
- return 1;
+ /*
+ * Avoid exclusive wakeups with retries since an exclusive wakeup
+ * may involve implicit expectations of waking up the next waiter
+ * and there is no guarantee that the retry will take a path that
+ * would do so. For example if a page has become up-to-date, then
+ * a retried read may end up straightaway performing a copyout
+ * and not go through a lock_page - unlock_page that would have
+ * passed the baton to the next waiter.
+ */
+ return 0;
}
int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
--
Suparna Bhattacharya (suparna@in.ibm.com)
Linux Technology Center
IBM Software Lab, India
next prev parent reply other threads:[~2005-06-24 11:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-20 12:01 Pending AIO work/patches Suparna Bhattacharya
2005-06-20 13:13 ` Trond Myklebust
2005-06-20 14:32 ` Sébastien Dugué
2005-06-20 16:01 ` [PATCH 0/6] Integrate AIO with wait-bit based filtered wakeups Suparna Bhattacharya
2005-06-20 16:20 ` [PATCH 1/6] Add a wait queue argument to wait_bit action() Suparna Bhattacharya
2005-06-20 16:24 ` [PATCH 2/6] Rename __lock_page to lock_page_slow Suparna Bhattacharya
2005-06-28 16:52 ` Zach Brown
2005-06-29 9:51 ` Suparna Bhattacharya
2005-07-24 22:17 ` Christoph Hellwig
2005-07-24 22:36 ` Christoph Hellwig
2005-07-26 1:10 ` Suparna Bhattacharya
2005-06-20 16:28 ` [PATCH 3/6] Interfaces to initialize and to test a wait_bit key Suparna Bhattacharya
2005-06-20 16:30 ` [PATCH 4/6] Add default io wait bit field in task struct Suparna Bhattacharya
2005-06-20 16:33 ` [PATCH 5/6] AIO wait bit and AIO wake bit for filtered wakeups Suparna Bhattacharya
2005-06-20 16:36 ` [PATCH 6/6] AIO wait page and AIO lock page Suparna Bhattacharya
2005-06-30 15:49 ` [PATCH 0/6] Integrate AIO with wait-bit based filtered wakeups Sébastien Dugué
2005-07-01 7:37 ` Suparna Bhattacharya
2005-06-20 18:10 ` Pending AIO work/patches Benjamin LaHaise
2005-06-20 18:51 ` Zach Brown
2005-06-21 7:36 ` Sébastien Dugué
2005-06-21 19:03 ` William Lee Irwin III
2005-06-24 10:49 ` [PATCH 0/2] Buffered filesystem AIO read/write Suparna Bhattacharya
2005-06-24 11:21 ` Suparna Bhattacharya [this message]
2005-06-24 11:40 ` [PATCH 2/2] Filesystem AIO write Suparna Bhattacharya
2005-06-24 16:10 ` [PATCH 0/2] Buffered filesystem AIO read/write Jeremy Allison
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=20050624112111.GA4574@in.ibm.com \
--to=suparna@in.ibm.com \
--cc=bcrl@kvack.org \
--cc=linux-aio@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mason@suse.com \
--cc=wli@holomorphy.com \
--cc=zab@zabbo.net \
/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