Error loading journal when using ext4 with fast_commit and calling fsync on unlinked file inside directory (if system crashes)

From: Slava0135 <hidden>
Date: 2026-08-24 11:53:15
Also in: lkml

Detailed description
====================

Hello, there seems to be an issue with ext4 (fast_commit) crash behavior:

1. Create a new directory and a new file inside the directory.
2. Sync filesystem.
3. Open file.
4. Unlink file.
5. Fsync file.

After system crash (e.g. power failure) mounting file system results in
error (`Structure needs cleaning` / `error loading journal`).


System info
===========

Linux version 7.2 & 6.17.0-29-generic (Ubuntu 25.10)


How to reproduce
================

Test:
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

int main() {
  int status;
  int fd;

  status = mkdir("dir", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  printf("MKDIR: %d\n", status);

  status = creat("dir/file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
  printf("CREAT: %d\n", status);
  close(status);

  sync();

  status = open("dir/file", O_WRONLY);
  printf("OPEN: %d\n", status);
  fd = status;

  status = unlink("dir/file");
  printf("UNLINK: %d\n", status);

  status = fsync(fd);
  printf("FSYNC: %d\n", status);
}
// system crashes!
mount:
root@ubuntu:~# mount /dev/vdb /mnt/fstest/
mount: /mnt/fstest: mount() failed: Structure needs cleaning.
       dmesg(1) may have more information after failed mount system call.
dmesg:
[   27.437203] JBD2: journal recovery failed
[   27.437206] EXT4-fs (vdb): error loading journal
Steps:

1. Create and mount a new ext4 filesystem with `fast_commit` option.
2. Change directory to root of the filesystem and run the compiled test.
3. Cause hard system crash (e.g. QEMU `system_reset` command).
4. Remount filesystem after crash.
5. Observe that mount fails.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help