Re: [PATCH v2] fat: roll back the new entry when create/mkdir fails to build the inode

From: OGAWA Hirofumi

Date: Wed Oct 14 2026 - 00:04:51 EST


Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> writes:

> On Mon, 12 Oct 2026 21:20:06 +0800 zhoumin <teczm@xxxxxxxxxxx> wrote:
>
>> vfat_create(), vfat_mkdir(), msdos_create() and msdos_mkdir() add the
>> on-disk entry before calling fat_build_inode() to set up the VFS
>> inode. If fat_build_inode() fails, the error is returned but the
>> entry stays on disk and the file or directory shows up after remount.
>>
>> Remove the entry in that case. For mkdir, also free the directory
>> cluster and decrement the parent's link count.
>
> MODPOST Module.symvers
> ERROR: modpost: fs/fat/msdos.ko: symbol '_fat_msg' undefined!
> make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1
> make[1]: *** [/usr/src/25/Makefile:2159: modpost] Error 2
> make: *** [Makefile:248: __sub-make] Error 2
> **FAILED**
>
> Easy fixup, but I'm surprised this hasn't already been encountered - is
> something funny going on?

Ouch. Thank you. fat_msg() was not used in msdos.ko or vfat.ko until now
(only in fat.ko). So your patch is right.

> From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Subject: fat-roll-back-the-new-entry-when-create-mkdir-fails-to-build-the-inode-fix
> Date: Tue Oct 13 03:50:35 PM PDT 2026
>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
> Cc: zhoumin <teczm@xxxxxxxxxxx>
> ---
>
> fs/fat/misc.c | 1 +
> 1 file changed, 1 insertion(+)
>
> --- a/fs/fat/misc.c~fat-roll-back-the-new-entry-when-create-mkdir-fails-to-build-the-inode-fix
> +++ a/fs/fat/misc.c
> @@ -62,6 +62,7 @@ void _fat_msg(struct super_block *sb, co
> _printk(FAT_PRINTK_PREFIX "%pV\n", level, sb->s_id, &vaf);
> va_end(args);
> }
> +EXPORT_SYMBOL_GPL(_fat_msg);
>
> /* Flushes the number of free clusters on FAT32 */
> /* XXX: Need to write one per FSINFO block. Currently only writes 1 */
> _
>

--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>