[rfc][patch] mm: half-fix page tail zeroing on write problem
Nick Piggin <npiggin <at> suse.de>
2007-02-02 05:51:42 GMT
For no important reason, I've again looked at those zeroing patches that
Neil did a while back. I've always thought that a simple
`write(fd, NULL, size)` would cause the same sorts of problems.
Turns out it does. If you first write all 1s into a page, then do the
`write(fd, NULL, size)` at the same position, you end up with all 0s in
the page (test-case available on request). Incredible; surely this
violates the spec?
The buffered-write fixes I've got actually fix this properly, but they
don't look like getting merged any time soon. We could do this simple
patch which just reduces the chance of corruption from a certainty down
to a small race.
--- linux-2.6.orig/include/linux/pagemap.h 2007-02-02 13:41:21.000000000 +1100
+++ linux-2.6/include/linux/pagemap.h 2007-02-02 13:42:09.000000000 +1100
<at> <at> -198,6 +198,9 <at> <at> static inline int fault_in_pages_writeab
+ if (unlikely(size == 0))
+ return 0;