From: zhengda1936@gmail.com (Da Zheng)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Asynchronous read
Date: Sun, 31 Jul 2011 15:58:55 -0700 [thread overview]
Message-ID: <4E35DE2F.4020604@gmail.com> (raw)
Hello,
I'm trying to understand the read operation in VFS, and get confused by the
asynchronous and synchronous operations.
At the beginning, do_sync_read() invokes aio_read, which is
generic_file_aio_read for ext4. generic_file_aio_read should be asynchronous
read. But what really confuses me is do_generic_file_read, which is called by
generic_file_aio_read. It seems to me do_generic_file_read implements
synchronous read as this is the only function I can find that copy data to the
user space by invoking the actor callback function. If do_generic_file_read is
synchronous, how can generic_file_aio_read be asynchronous?
In do_generic_file_read, if the data to be read isn't in the cache, normally
page_cache_sync_readahead should be called. As far as I understand, when
page_cache_sync_readahead returns, the pages will be ready in the cache, but the
corresponding data in the disk isn't necessarily copied to the pages yet
(because it eventually only invokes submit_bio to submit the IO requests to the
block layer), so PageUptodate of the requested page might still return false,
and then do_generic_file_read tries to invoke readpage to read the page again
instead of waiting. Since the disk is always very slow, doesn't it just waste
CPU time? Or do I miss something?
Best,
Da
next reply other threads:[~2011-07-31 22:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-31 22:58 Da Zheng [this message]
2011-08-01 2:45 ` Asynchronous read Adam Cozzette
2011-08-02 5:33 ` Da Zheng
[not found] ` <20110801024508.GA3857@192.168.0.12>
2011-08-01 5:43 ` Rajat Sharma
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=4E35DE2F.4020604@gmail.com \
--to=zhengda1936@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.