From: Anand Suveer Jain <asj@kernel.org>
To: dsterba@suse.cz, Anand Suveer Jain <asj@kernel.org>
Cc: Dave Hansen <dave.hansen@intel.com>,
sashal@kernel.org, linux-btrfs@vger.kernel.org,
David Woodhouse <dwmw2@infradead.org>,
David Sterba <dsterba@suse.com>,
"Macieira, Thiago" <thiago.macieira@intel.com>
Subject: Re: [PATCH 1/3] btrfs: derive f_fsid from on-disk fsuuid and dev_t
Date: Sat, 12 Sep 2026 18:19:21 +0800 [thread overview]
Message-ID: <d0bd13fa-9126-4efd-9166-ed6c1c08c24d@kernel.org> (raw)
In-Reply-To: <20260911172313.GA54722@twin.jikos.cz>
On 12/9/26 01:23, David Sterba wrote:
> On Fri, Sep 11, 2026 at 10:51:16PM +0800, Anand Suveer Jain wrote:
>> On 11/9/26 20:32, Dave Hansen wrote:
>>> On 2/26/26 06:27, Anand Jain wrote:
>>>> Currently, f_fsid depends on fs_devices->fsid. For cloned devices, this
>>>> value is dynamic and fluctuates across mount cycles. This inconsistency
>>>> breaks persistence for subsystems like IMA.
>>>>
>>>> Switch to a stable derivation using the persistent on-disk fsuuid +
>>>> root id + devt of the block device for the single device filesystem.
>>>> This is consistent as long as the device remains unchanged/replace
>>>> (excludes btrfs device replace secnario for now).
>>>
>>> This commit evidently hit 7.2 and is causing end users some real pain.
>>> Real software uses the FSID to encrypt/decrypt their VPN key files:
>>>
>>> https://github.com/NetworkManager/NetworkManager-openconnect/
>>>
>>> When this gets applied, those users suddenly can't connect to their VPN
>>> any more. Having a stable derivation does seem like a good idea, of
>>> course. Is there any way to make this transition without breaking
>>> existing userspace and existing users?
>>>
>>> It looks like this is also getting -stable backports.
>>
>> I wish I had more clarity on how OpenConnect uses the FSID before I
>> comment. Do you know? Can you shed some light on this?
>>
>>
>> Also, a couple of quick checks:
>>
>> Is the underlying device MAJ:MIN changing before and after the upgrade?
>>
>> Are the original and cloned Btrfs filesystems mounted simultaneously?
>>
>> Patch v3 (1/2) keeps the FSID persistent from the on-disk superblock and
>> stops exposing the internal random FSID. However, if OpenConnect relies
>> on statfs.f_fsid, patch v3 (2/2) now derives f_fsid from the underlying
>> MAJ:MIN.
>
> You've sent the fsid patches [1] to fix some IMA and fanotify problems,
> so I guess there's a use case. This report shows a clear breakage in a
> different use case, I'm thinking about a quick revert as it seems to
> have worse consequences. A fix to make both work would be good but I
> can't estimate when it'll be ready so for now I'd go for a revert and
> then forward it to 7.2 stable tree.
>
> [1] https://lore.kernel.org/linux-btrfs/cover.1772095546.git.asj@kernel.org/
Dave,
I'm currently testing the changes below, which limit the new fsid
behavior (deriving it from dev_t) strictly to cloned Btrfs.
If all goes well, I'll post the patch or will update how it goes
by EOD . Thanks!
------------
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-12 10:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 14:23 [PATCH 0/3] fix s_uuid and f_fsid consistency for cloned filesystems Anand Jain
2026-02-26 14:27 ` [PATCH 1/3] btrfs: derive f_fsid from on-disk fsuuid and dev_t Anand Jain
2026-09-11 12:32 ` Dave Hansen
2026-09-11 14:51 ` Anand Suveer Jain
2026-09-11 16:07 ` Thiago Macieira
2026-09-11 18:12 ` David Woodhouse
2026-09-12 10:10 ` Anand Suveer Jain
2026-09-11 17:23 ` David Sterba
2026-09-12 10:19 ` Anand Suveer Jain [this message]
2026-09-14 13:14 ` David Sterba
2026-09-15 16:11 ` Anand Suveer Jain
2026-02-26 14:27 ` [PATCH 2/3] btrfs: use on-disk uuid for s_uuid in temp_fsid mounts Anand Jain
2026-03-04 13:28 ` [PATCH 0/3] fix s_uuid and f_fsid consistency for cloned filesystems Christoph Hellwig
2026-03-05 9:32 ` Anand Jain
2026-03-05 14:21 ` Christoph Hellwig
2026-03-22 20:31 ` Theodore Tso
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=d0bd13fa-9126-4efd-9166-ed6c1c08c24d@kernel.org \
--to=asj@kernel.org \
--cc=dave.hansen@intel.com \
--cc=dsterba@suse.com \
--cc=dsterba@suse.cz \
--cc=dwmw2@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=sashal@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;
as well as URLs for NNTP newsgroup(s).