Re: [RFC] iomap: fix race between readahead and direct write

From: yukuai (C)
Date: Sun Jan 19 2020 - 01:55:36 EST




On 2020/1/19 14:14, Matthew Wilcox wrote:
I don't understand your reasoning here. If another process wants to
access a page of the file which isn't currently in cache, it would have
to first read the page in from storage. If it's under readahead, it
has to wait for the read to finish. Why is the second case worse than
the second? It seems better to me.

Thanks for your response! My worries is that, for example:

We read page 0, and trigger readahead to read n pages(0 - n-1). While in another thread, we read page n-1.

In the current implementation, if readahead is in the process of reading
page 0 - n-2, later operation doesn't need to wait the former one to finish. However, later operation will have to wait if we add all pages
to page cache first. And that is why I said it might cause problem for
performance overhead.

At the same time, the iomap code is switched from ->readpages to
->readahead, so yes, the pages are added to the page cache.

Yes, it's not a problem in your implementation.

Thanks!
Yu Kuai