From: Vyacheslav Kovalevsky <slava.kovalevskiy.2014@gmail.com>
To: Filipe Manana <fdmanana@kernel.org>
Cc: clm@fb.com, dsterba@suse.com, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: Directory is not persisted after writing to the file within directory if system crashes
Date: Sat, 25 Oct 2025 12:49:42 +0300 [thread overview]
Message-ID: <d039a3c8-c4f7-487c-a848-2a26ea26f77d@gmail.com> (raw)
In-Reply-To: <CAL3q7H5ggWXdptoGH9Bmk-hc2CMBLz-YmC1A8U-hx9q=ZZ0BHw@mail.gmail.com>
On 24/10/2025 19:17, Filipe Manana wrote:
> I converted that to a test case for fstests and couldn't reproduce,
> "dir", "file1" and "dir/file2" exist after the power failure.
>
> The conversion for fstests:
>
> #! /bin/bash
> # SPDX-License-Identifier: GPL-2.0
> # Copyright (c) 2025 SUSE S.A. All Rights Reserved.
> #
> # FS QA Test 780
> #
> # what am I here for?
> #
> . ./common/preamble
> _begin_fstest auto quick log
>
> _cleanup()
> {
> _cleanup_flakey
> cd /
> rm -r -f $tmp.*
> }
>
> . ./common/filter
> . ./common/dmflakey
>
> _require_scratch
> _require_dm_target flakey
>
> rm -f $seqres.full
> On 24/10/2025 19:17, Filipe Manana wrote:
> _scratch_mkfs >>$seqres.full 2>&1 || _fail "mkfs failed"
> _require_metadata_journaling $SCRATCH_DEV
> _init_flakey
> _mount_flakey
>
> touch $SCRATCH_MNT/file1
>
> _scratch_sync
>
> mkdir $SCRATCH_MNT/dir
> echo -n "hello world" > $SCRATCH_MNT/file1
> ln $SCRATCH_MNT/file1 $SCRATCH_MNT/dir/file2
>
> $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/
>
> # Simulate a power failure and then mount again the filesystem to replay the
> # journal/log.
> _flakey_drop_and_remount
>
> ls -R $SCRATCH_MNT/ | _filter_scratch
>
> _unmount_flakey
>
> # success, all done
> _exit 0
I think the line with `echo` may not be the correct translation:
> echo -n "hello world" > $SCRATCH_MNT/file1
In the original test, the file was opened with `O_SYNC` flag, if you
remove it, the directory will be there when the system crashes. I also
forgot to close the file after the `creat` call in the original test,
may be important as well.
The test itself is quite weird (why would `dir` be gone after seemingly
unrelated operation?), any detail can matter.
Please run the original test with a real system crash. I will also
double check everything on my side.
next prev parent reply other threads:[~2025-10-25 9:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 15:19 Directory is not persisted after writing to the file within directory if system crashes Vyacheslav Kovalevsky
2025-10-24 16:17 ` Filipe Manana
2025-10-25 9:49 ` Vyacheslav Kovalevsky [this message]
2025-10-25 23:40 ` Chris Murphy
2025-10-26 9:04 ` Filipe Manana
2025-10-27 7:19 ` Christoph Hellwig
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=d039a3c8-c4f7-487c-a848-2a26ea26f77d@gmail.com \
--to=slava.kovalevskiy.2014@gmail.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=fdmanana@kernel.org \
--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