Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fix ufs write vs readpage race when writing into a hole

Followup to the UFS series - with the way we clear the new blocks (via
buffer cache, possibly on more than a page worth of file) we really
should not insert a reference to new block into inode block tree until
after we'd cleared it.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Al Viro and committed by
Linus Torvalds
bd2843fe daf0e1ed

+2 -2
+2 -2
fs/ufs/balloc.c
··· 417 417 if (oldcount == 0) { 418 418 result = ufs_alloc_fragments (inode, cgno, goal, count, err); 419 419 if (result) { 420 + ufs_clear_frags(inode, result + oldcount, 421 + newcount - oldcount, locked_page != NULL); 420 422 write_seqlock(&UFS_I(inode)->meta_lock); 421 423 ufs_cpu_to_data_ptr(sb, p, result); 422 424 write_sequnlock(&UFS_I(inode)->meta_lock); 423 425 *err = 0; 424 426 UFS_I(inode)->i_lastfrag = 425 427 max(UFS_I(inode)->i_lastfrag, fragment + count); 426 - ufs_clear_frags(inode, result + oldcount, 427 - newcount - oldcount, locked_page != NULL); 428 428 } 429 429 mutex_unlock(&UFS_SB(sb)->s_lock); 430 430 UFSD("EXIT, result %llu\n", (unsigned long long)result);