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

From: Andrew Morton

Date: Tue Oct 13 2026 - 19:00:39 EST


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?


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 */
_