Re: [PATCH][RFC] truncate vs add_to_page_cache race

From: Nick Piggin
Date: Thu May 13 2004 - 22:17:23 EST

Nick Piggin wrote:
Nick Piggin wrote:

Andrew Morton wrote:

Nick Piggin <nickpiggin@xxxxxxxxxxxx> wrote:

OK, I made a debug patch to printk and schedule_timeout in this
race window so I can easily truncate the file. When this happens,
it turns out that the readpage thinks it is reading a hole and
fills the page with zeros -> invalid result?

A zero-filled pagecache page outside i_size is OK.

Yes. But in this case the zero filled page actually gets
read by read(2).

In any case, I think my patch won't close the race completely.

This following patch should be right.

It causes the zeros to not get copied back unless i_size
gets extended again.

However, it causes the fast path reading off the end of a file
to always go into ->readpage and copy the non-existant page of
zeros. This could be fixed no problem, but I'll shut up and let
others comment in case I'm making a fool of myself :)
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at