Re: [PATCH v3] fat: make rename recovery safe after metadata write errors

From: OGAWA Hirofumi

Date: Fri Oct 16 2026 - 10:02:21 EST


Krystian Kaniewski <krystianmkaniewski@xxxxxxxxx> writes:

> On 10/15/26 20:54, OGAWA Hirofumi wrote:
>
>>> + } else if (!rollback_err) {
>>> + /* Read the entry block again if a failed write invalidated it. */
>>> + rollback_err = bh_read(sinfo.bh, 0);
>>
>> Why do this read the bh from on disk?
>>
>
> The bh_read(sinfo.bh, 0) is needed because a failed inode-position write clears BH_Uptodate. fat_remove_entries() modifies and dirties that retained buffer directly, which otherwise triggers the warning. Reading it first refreshes the whole block. If the read fails, the buffer is left untouched.
>
> The same reasoning applies to both the VFAT and MS-DOS paths.

If sinfo.bh is required to read because of failure of I/O error, I guess
the bh will fail to write again. I think we should give up to rollback
in that case.

Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>