From: Filipe Manana <fdmanana@kernel.org>
To: Vyacheslav Kovalevsky <slava.kovalevskiy.2014@gmail.com>
Cc: clm@fb.com, dsterba@suse.com, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: 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 17:22:47 +0000 [thread overview]
Message-ID: <CAL3q7H6a+C43SjrfqR2g_zu6pJ1e_rO3=XexkZzxn_qejRHaOg@mail.gmail.com> (raw)
In-Reply-To: <182055fa-e9ce-4089-9f5f-4b8a23e8dd91@gmail.com>
On Tue, Mar 3, 2026 at 1:32 PM Vyacheslav Kovalevsky
<slava.kovalevskiy.2014@gmail.com> wrote:
>
> 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).
It doesn't need to be a symlink, a regular file is enough.
Fix here: https://lore.kernel.org/linux-btrfs/9a367f025abf4ea19c96aead75d206e129b2c56e.1772558089.git.fdmanana@suse.com/
Btw, I think you may have sent a message with one of the longest subjects ever.
Thanks.
> 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.
>
>
prev parent reply other threads:[~2026-03-03 17:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 13:30 Directory is not persisted after removing another directory and creating a hard linked symlink with the same name if system crashes Vyacheslav Kovalevsky
2026-03-03 17:22 ` Filipe Manana [this message]
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='CAL3q7H6a+C43SjrfqR2g_zu6pJ1e_rO3=XexkZzxn_qejRHaOg@mail.gmail.com' \
--to=fdmanana@kernel.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slava.kovalevskiy.2014@gmail.com \
/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