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

From: yukuai (C)
Date: Sat Jan 18 2020 - 20:57:15 EST




On 2020/1/19 9:42, Matthew Wilcox wrote:
Did you read my patch series? The current code allocates pages,
but does not put them in the page cache until after iomap is called.
My patch series changes that to put the pages in the page cache as soon
as they're allocated, and before iomap is called.

The current code to determin if page need to be allocated:

page = xa_load(&mapping->i_pages, page_offset);
if (page && !xa_is_value(page)) {
/*
┊* Page already present? Kick off the current batch of
┊* contiguous pages before continuing with the next
┊* batch.
┊*/
if (nr_pages)
read_pages(mapping, filp, &page_pool, nr_pages,
gfp_mask);
nr_pages = 0;
continue;
}

page = __page_cache_alloc(gfp_mask);
if (!page)
break;

Page will be allocated if the page do not exist in page cache. And I
don't see your patch series change that. Or am I missing something?

Thanks!
Yu Kuai