On Mon, Sep 10, 2012 at 11:51:35AM +0200, Jan Kara wrote: > On Sun 09-09-12 21:27:11, Dmitry Monakhov wrote: > > fsync and punch_hole are the places where we have to wait for all > > existing writers (writeback, aio, dio), but currently we simply > > flush pended end_io request which is not sufficient. > Why not? I guess you mean the fact that there can be DIO in flight for > which end_io() was not called so it is not queued in the queue? But that is > OK - we have not yet called aio_complete() for that IO so for userspace the > write has not happened yet. Thus there's no need to flush it to disk - > fsync() does not say anything about writes in progress while fsync is > called. > > > Even more i_mutex is not holded while punch_hole which obviously > > result in dangerous data corruption due to write-after-free. > Yes, that's a bug. I also noticed that but didn't get to fixing it (I'm > actually working on a more long term fix using range locking but that's > more of a research project so having somehow fixed at least the most > blatant locking problems is good). Hi Jan, Could you please share more detailed information about range locking with me? Actually, the goal of extent status tree is to implement a range locking in ext4 [1], and I am working on it. So I think that you have some good ideas to share with me. :-) 1. http://www.spinics.net/lists/linux-ext4/msg32661.html If you have some problems, please let me know. Thanks! Regards, Zheng -- 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