Re: Updating i_disksize without acquiring i_data_sem semaphore

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

 



Hello.

On 2024/7/9 20:46, Rohit Singh wrote:
> Hello.
> I am looking around ext4 code and I observed the following issue.
> 
> Within ext4_insert_range(), EXT4_I(inode)->i_disksize is being updated
> without acquiring i_data_sem.
> 
> I have seen code where this operation is done after acquiring
> i_data_sem such as in
> ext4_update_i_disksize()
> 
> So, is this as expected or is it problematic?
> 

Thanks for pointing this out,  At the moment, IIUC,I don't think it
will cause any real problem since inode->i_rwsem could protect
i_disksize updating from most of race conditions except the write back.
ext4_do_writepages()->mpage_map_and_submit_extent() doesn't hold
inode->i_rwsem when updating i_disksize, but we have flushed dirty
blocks through filemap_write_and_wait_range() in ext4_insert_range()
and can prevent from generating new dirty pages beyond current
i_disksize, so this race is also closed.

However, I suppose we'd still better to move the updating under
i_data_sem to prevent some potential race conditions in the future.

Thanks,
Yi.





[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