tux3: Support mmap write: Fix race of mmap write with truncate(2)
mmap write and truncate(2) can race on delta boundary.
cpu0 cpu1
delta-1 = get_delta();
truncate(2)
delta++
mmap write
delta-2 = get_delta();
page-B = pagefork(page-A);
tux3_truncate_inode_page(page-B);
If mmap write and truncate(2) ran by above order, truncate(2) see
dirty page for delta-2. We should guarantee one doesn't see data in
future delta.
To avoid this race, this introduces ->truncate_lock. And protects mmap
write while truncate(2) is running.
FIXME: This race would be rare cases in real usage though, more fine
granulate lock would be better.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
4 files changed