From f2f2cc3b40e61b3e60c8f79d137f865e1e64fd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Fri, 7 Nov 2025 21:17:18 +0300 Subject: [PATCH] mdbx: add workaround for ext4 fast-commit bug. --- src/osal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/osal.c b/src/osal.c index 711a4477..ec823d32 100644 --- a/src/osal.c +++ b/src/osal.c @@ -1648,6 +1648,16 @@ int osal_fsetsize(mdbx_filehandle_t fd, const uint64_t length) { return MDBX_SUCCESS; #endif +#if defined(__linux__) || defined(__gnu_linux__) + if (globals.linux_kernel_version < 0x05110000 && globals.linux_kernel_version >= 0x050a0000) { + struct statfs statfs_info; + if (fstatfs(fd, &statfs_info)) + return errno; + if (statfs_info.f_type == 0xEF53 /* EXT4_SUPER_MAGIC */ && unlikely(fdatasync(fd))) + return errno; + } +#endif /* Linux */ + return unlikely(ftruncate(fd, length)) ? errno : MDBX_SUCCESS; #endif /* !Windows */