All of lore.kernel.org
 help / color / mirror / Atom feed
* Asynchronous read
@ 2011-07-31 22:58 Da Zheng
  2011-08-01  2:45 ` Adam Cozzette
       [not found] ` <20110801024508.GA3857@192.168.0.12>
  0 siblings, 2 replies; 4+ messages in thread
From: Da Zheng @ 2011-07-31 22:58 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-02  5:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-31 22:58 Asynchronous read Da Zheng
2011-08-01  2:45 ` Adam Cozzette
2011-08-02  5:33   ` Da Zheng
     [not found] ` <20110801024508.GA3857@192.168.0.12>
2011-08-01  5:43   ` Rajat Sharma

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.