]> git.hungrycats.org Git - linux/commit
[PATCH] ext3 block allocator locking fix
authorAndrew Morton <akpm@osdl.org>
Sun, 5 Oct 2003 04:03:45 +0000 (21:03 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Sun, 5 Oct 2003 04:03:45 +0000 (21:03 -0700)
commit3101501b8dc5f8b662f3a3d5f83cdac245cd133c
treeae16100eae6b5bc119d33a61cb6f683ea933f7ce
parent9626f94d83eadcb569471d72ee4ce9f0fbb66379
[PATCH] ext3 block allocator locking fix

When the BKL was removed from ext3 we lost locking coverage for
get_block()-versus-get_block().  Nobody seems to have hit the race because
get_block() almost always runs under i_sem: only memory pressure-based
writeout over a file hole runs outside i_sem.

ext2 uses the dedicated i_meta_lock spinlock in the inode to provide the
needed locking.  But ext3 already has an rwsem around all the get_block()
activity to protect it from truncate-related races.

So this patch just converts that rwsem into a semaphore, so concurrent
get_block() can never occur.  This will be more efficient than adding the new
spinlock.

We lose the ability to have two threads run get_block() against the same file
at the same time but again, that only happens during pageout over a hole
anyway.

(Kudos Alex Tomas for noticing the bug)
fs/ext3/inode.c
fs/ext3/super.c
include/linux/ext3_fs_i.h