public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
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: File permissions are not persisted after creating hard link if system crashes
Date: Tue, 3 Mar 2026 19:08:14 +0000	[thread overview]
Message-ID: <CAL3q7H7frAhNt+KVk7KwKS_1SWnka--xWQTaOJX+KLJuHqnOEA@mail.gmail.com> (raw)
In-Reply-To: <2d514275-d2dc-4c0b-a7bd-3adf9415711b@gmail.com>

On Tue, Mar 3, 2026 at 4:47 PM Vyacheslav Kovalevsky
<slava.kovalevskiy.2014@gmail.com> wrote:
>
> Detailed description
> ====================
>
> Hello, there seems to be an issue with btrfs crash behavior:
>
> 1. Create and sync a new file.
> 2. Open the file and change permissions.
> 3. Sync the file.
> 4. Create new hard link to file.
> 5. Sync the root directory.
>
> After crash the file will have old (original) permissions, though the
> changes were synced.

For this test to pass you'll need the patch I sent for another report
you made before:

https://lore.kernel.org/linux-btrfs/af8c15fa-4e41-4bb2-885c-0bc4e97532a6@gmail.com/

The patch is: https://lore.kernel.org/linux-btrfs/1c66bd7efe749cd3b421fc3dff5ef646dda8c7aa.1771350720.git.fdmanana@suse.com/

It's not in any released kernel yet (not even in Linus' master
branch), only in the for-next github branch:
https://github.com/btrfs/linux/commits/for-next/

Whenever you have new things to report, try to see if every patch I
pointed you to in previous reports is applied in the kernel you are
testing.

Thanks.

>
>
> 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 file_fd0;
>    int file_fd1;
>    int root_fd;
>
>    status = creat("file1", S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
>    printf("CREAT: %d\n", status);
>    file_fd0 = status;
>
>    status = close(file_fd0);
>    printf("CLOSE: %d\n", status);
>
>    sync();
>
>    status = open("file1", O_RDONLY);
>    printf("OPEN: %d\n", status);
>    file_fd1 = status;
>
>    status = fchmod(file_fd1, S_IRWXU | S_IRWXG | S_IRWXO);
>    printf("FCHMOD: %d\n", status);
>
>    status = fsync(file_fd1);
>    printf("FSYNC: %d\n", status);
>
>    status = link("file1", "file2");
>    printf("LINK: %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 file `file1` / `file2` has old permissions (0751 instead
> of 0777)
> ```
>
> 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 file permissions were not persisted.
>
>

      reply	other threads:[~2026-03-03 19:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 16:41 File permissions are not persisted after creating hard link if system crashes Vyacheslav Kovalevsky
2026-03-03 19:08 ` 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=CAL3q7H7frAhNt+KVk7KwKS_1SWnka--xWQTaOJX+KLJuHqnOEA@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