[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d78870d1-6c40-ca8c-7740-eaf0c10ac73a@huaweicloud.com>
Date: Wed, 10 Jul 2024 14:47:31 +0800
From: Zhang Yi <yi.zhang@...weicloud.com>
To: Rohit Singh <rohitsd1409@...il.com>, linux-ext4@...r.kernel.org
Subject: Re: Updating i_disksize without acquiring i_data_sem semaphore
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.
Powered by blists - more mailing lists