[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)
Showing
Please register or sign in to comment