Re: [PATCH v3] ext4: Properly sync file size update after O_SYNC direct IO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed 18-10-23 14:45:49, Joseph Qi wrote:
> On 10/13/23 8:13 PM, Jan Kara wrote:
> > Gao Xiang has reported that on ext4 O_SYNC direct IO does not properly
> > sync file size update and thus if we crash at unfortunate moment, the
> > file can have smaller size although O_SYNC IO has reported successful
> > completion. The problem happens because update of on-disk inode size is
> > handled in ext4_dio_write_iter() *after* iomap_dio_rw() (and thus
> > dio_complete() in particular) has returned and generic_file_sync() gets
> > called by dio_complete(). Fix the problem by handling on-disk inode size
> > update directly in our ->end_io completion handler.
> > 
> > References: https://lore.kernel.org/all/02d18236-26ef-09b0-90ad-030c4fe3ee20@xxxxxxxxxxxxxxxxx
> > Reported-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>
> > CC: stable@xxxxxxxxxxxxxxx
> > Fixes: 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure")
> > Signed-off-by: Jan Kara <jack@xxxxxxx>
> 
> Tested with the reproducer after applying to 6.6-rc5,
> Tested-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>

Thanks for testing!

> BTW, once backported to older kernel like 5.10, it seems that it depends
> on the following commit:
> 936e114a245b iomap: update ki_pos a little later in iomap_dio_complete
> 
> Otherwise, it will fail the following xfstests cases:
> generic/091 generic/094 generic/225 generic/263 generic/311 generic/617

That is kind of curious because that commit should not influence how the
ext4 fix behaves. It only influences what is in iocb->ki_pos when we are
invalidating pagecache pages...

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux