On Wed, Mar 27, 2013 at 11:12:48AM -0400, Theodore Ts'o wrote: > On Wed, Mar 27, 2013 at 11:19:22PM +0800, Zheng Liu wrote: > > > > Otherwise, couldn't we end up with problems where a failed write calls > > > > ext4_truncate() without i_data_sem(), and that races with something > > > > else --- say, a punch or truncate call to that same inode? > > > > Let me think about it. I need to take a close look at it. > > Note that I'm not so concerned when we are creating symlink --- you > are quite right in pointing out in that case the inode isn't in the > namespace yet, so that prevents races --- but also what might happen > in an ENOSPC write(2) failure racing against a punch/truncate call. > > But again, this is why I added the warning --- it was to find these > edge cases that we might not have considered. :-) ext4_truncate_failed_write() is called by the following functions: - ext4_ind_direct_IO - ext4_convert_inline_data_to_extent - ext4_da_convert_inline_data_to_extent - ext4_write_begin - ext4_write_end - ext4_journalled_write_end - ext4_da_write_begin All these functions are protected by i_mutex. So we can serialize it with truncate/punch hole. 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