From: Vyacheslav Kovalevsky <slava.kovalevskiy.2014@gmail.com>
To: clm@fb.com, dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Directory is not persisted after removing another directory and creating a hard linked symlink with the same name if system crashes
Date: Tue, 3 Mar 2026 16:30:09 +0300 [thread overview]
Message-ID: <182055fa-e9ce-4089-9f5f-4b8a23e8dd91@gmail.com> (raw)
Detailed description
====================
Hello, there seems to be an issue with btrfs crash behavior:
1. Create new directory `foo`, sync, then remove the directory.
2. Create new directories `dir1` and `dir2`.
3. Create new symlink named `foo` (NOTE: must have the same name as the
removed directory).
4. Create new (hard) link to the symlink inside `dir2` (NOTE: this is
also important).
5. Sync directory `dir2`.
6. Sync root directory.
Directory `dir1` will be missing even though it was synced in the last step.
System info
===========
Linux version 7.0-rc2, also tested on 6.19.2
How to reproduce
================
```
#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 dir_fd;
int root_fd;
status = mkdir("foo", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
printf("MKDIR: %d\n", status);
sync();
status = rmdir("foo");
printf("RMDIR: %d\n", status);
status = mkdir("dir1", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
printf("MKDIR: %d\n", status);
status = mkdir("dir2", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
printf("MKDIR: %d\n", status);
status = symlink("bar", "foo");
printf("SYMLINK: %d\n", status);
status = link("foo", "dir2/link");
printf("LINK: %d\n", status);
status = open("dir2", O_RDONLY);
printf("OPEN: %d\n", status);
dir_fd = status;
status = fsync(dir_fd);
printf("FSYNC: %d\n", status);
status = open(".", O_RDONLY);
printf("OPEN: %d\n", status);
root_fd = status;
status = fsync(root_fd);
printf("FSYNC: %d\n", status);
}
// after crash `dir1` is missing
```
Steps:
1. Create and mount new btrfs file system in default configuration.
2. Change directory to root of the file system and run the compiled test.
3. Cause hard system crash (e.g. QEMU `system_reset` command).
4. Remount file system after crash.
5. Observe that directory `dir1` is missing.
next reply other threads:[~2026-03-03 13:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 13:30 Vyacheslav Kovalevsky [this message]
2026-03-03 17:22 ` Directory is not persisted after removing another directory and creating a hard linked symlink with the same name if system crashes Filipe Manana
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=182055fa-e9ce-4089-9f5f-4b8a23e8dd91@gmail.com \
--to=slava.kovalevskiy.2014@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox