From: Anand Suveer Jain <asj@kernel.org>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Cc: dwmw2@infradead.org, thiago.macieira@intel.com, dave.hansen@intel.com
Subject: Re: [PATCH] btrfs: derive f_fsid with dev_t only when temp_fsid is active
Date: Mon, 14 Sep 2026 11:42:51 +0800 [thread overview]
Message-ID: <0691a903-cc82-4ad7-8264-cddbf146d00e@kernel.org> (raw)
In-Reply-To: <16069a6fc651168bfcd2394d6e57ce63a50231ed.1789235482.git.asj@kernel.org>
This issue and its current fix (below) have been on my mind, as I wasn't
fully satisfied with the approach even though it works.
Now, I think I have a better idea.
The core issue isn't that the new f_fsid derivation is wrong (recap:
f_fsid derivation changed from f(UUID) to f(UUID + dev_t)). Rather, the
problem is that f_fsid changes unexpectedly after an upgrade.
So we need to address the upgrade behavior, not how f_fsid itself is
derived.
My new proposed solution:
. Put the new f_fsid derivation behind a compile-time config flag (an
incompat/opt-in flag).
. For stable kernels, this flag will keep the new f_fsid derivation
disabled by default.
The only drawback I see with this approach is that it adds yet another
incompat flag, making the incompat feature list even longer.
Please let me know what you think. I can send out v2 with these changes
on Tuesday.
Thanks, Anand
On 13/9/26 02:06, Anand Jain wrote:
> Commit c2a74ed0494c ("btrfs: derive f_fsid from on-disk fsid and dev_t")
> mixed dev_t into f_fsid for all single-device setups to avoid f_fsid
> collisions with cloned filesystems.
>
> However, doing this unconditionally breaks backward compatibility.
> statfs(2) f_fsid changes after a kernel upgrade, and also can shift
> across reboots or dev re-attaches as dev_t values change.
>
> Fix this by only mixing dev_t when temp_fsid is active.
> This means for non-temp_fsid setups or the original mount, we use the
> old method of deriving fsid based on the UUID.
>
> So in the case of a cloned Btrfs filesystem, we won't be able to
> maintain the same fsid across mount recycle if the mount order
> changes.
>
> Fixes: c2a74ed0494c ("btrfs: derive f_fsid from on-disk fsid and dev_t")
> Reported-by: Dave Hansen <dave.hansen@intel.com>
> Closes: https://lore.kernel.org/linux-btrfs/be0c08f5-2f31-40f5-8a3b-f2f58b3e00ff@intel.com
> Signed-off-by: Anand Jain <asj@kernel.org>
> ---
> Dave (Hansen), I wonder if you could verify whether this fixes the issue
> on your end. I have run some limited test cases from fstests as of now,
> and they passed.
>
> fs/btrfs/super.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 464129b1b0d4..ddb620ac241b 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1836,8 +1836,12 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
> f_fsid.val[0] ^= btrfs_root_id(BTRFS_I(d_inode(dentry))->root) >> 32;
> f_fsid.val[1] ^= btrfs_root_id(BTRFS_I(d_inode(dentry))->root);
>
> - /* Hash dev_t to avoid f_fsid collision with cloned filesystems. */
> - if (fs_info->fs_devices->total_devices == 1) {
> + /*
> + * Hash dev_t to avoid f_fsid collisions with cloned filesystems.
> + * Only do this when a clone is present so the original filesystem
> + * (mounted first) maintains backward-compatible f_fsid behavior.
> + */
> + if (fs_info->fs_devices->temp_fsid) {
> __kernel_fsid_t dev_fsid =
> u64_to_fsid(huge_encode_dev(fs_info->fs_devices->latest_dev->bdev->bd_dev));
>
next prev parent reply other threads:[~2026-09-14 3:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 18:06 [PATCH] btrfs: derive f_fsid with dev_t only when temp_fsid is active Anand Jain
2026-09-12 21:58 ` Dave Hansen
2026-09-13 1:05 ` Anand Suveer Jain
2026-09-13 1:13 ` Dave Hansen
2026-09-13 2:43 ` Anand Suveer Jain
2026-09-14 3:42 ` Anand Suveer Jain [this message]
2026-09-14 5:28 ` David Woodhouse
2026-09-14 8:28 ` Anand Suveer Jain
2026-09-14 10:47 ` David Woodhouse
2026-09-14 12:28 ` Anand Suveer Jain
2026-09-14 16:41 ` David Sterba
2026-09-14 16:39 ` David Sterba
2026-09-14 16:46 ` David Sterba
2026-09-18 8:59 ` Anand Suveer Jain
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=0691a903-cc82-4ad7-8264-cddbf146d00e@kernel.org \
--to=asj@kernel.org \
--cc=dave.hansen@intel.com \
--cc=dsterba@suse.cz \
--cc=dwmw2@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=thiago.macieira@intel.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