2011/5/31 Andreas Dilger <adilger@xxxxxxxxx>: > Looking more closely at these operations, ext4_set_bit_atomic() is not used anywhere in the code and could be removed. > > There is only one place where ext4_clear_bit_atomic() is used (ext4_add_groupblocks()), and this is likely incorrect. None of the other ext4 code is using ext4_set_bit_atomic(), and all of the ext2_clear_bit_atomic() macros are silently ignoring the "lock" argument, so these changes are done without ext4_group_lock() being held for that group. I suspect this is never a problem in normal usage because ext4_add_groupblocks() is only used during filesystem resizing, which is rare, and doubly rare for any allocations to be made in the same group concurrently. > > This one usage of ext4_clear_bit_atomic() should just be moved inside the ext4_lock_group() a few lines down and then use ext4_clear_bit() for consistency, and ext4_clear_bit_atomic() can be removed entirely. > > A further cleanup would be to change this whole function to use mb_clear_bits(), which is not only faster because it operates on many bits at once, but also doesn't require that the buddy bitmap be marked invalid ("NEED_INIT") after these changes are made, but that is work for a separate patch. Looks like this is already done by the commit e73a347b7723757bb5fb5c502814dc205a7f496d ("ext4: implement ext4_add_groupblocks() by freeing blocks") So we can remove ext4_{set,clear}_bit_atomic now. > I would also encourage you to finish off this patch series by pushing up the generic ext2_{set,clear}_bit_atomic() to the few places that are currently using ext2_{set,clear}_bit_atomic() directly (looks like only fs/nilfs2/alloc.h and include/linux/ext3.h) and then removing them from the arch headers. The difficulty of doing this is that there are two different implementations of ext2_{set,clear}_bit_atomic (spin lock version and test_and_{set,clear}_bit_le version). If we can switch to one of which on all architectures, the change is easy. But I don't have less messy idea to keep current behavior on all architectures. -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html