On btrfs and ext4, statfs f_fsid is computed from the filesystem UUID, so a filesystem created with a known UUID must always report the same f_fsid. Userspace relies on this, for example fanotify and file handle users that identify a filesystem across mounts. Guards against f_fsid changing across kernel versions, which would break userspace that relies on it. Signed-off-by: Anand Jain --- tests/generic/902 | 38 ++++++++++++++++++++++++++++++++++++++ tests/generic/902.out | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 tests/generic/902 create mode 100644 tests/generic/902.out diff --git a/tests/generic/902 b/tests/generic/902 new file mode 100644 index 000000000000..44dd685a887b --- /dev/null +++ b/tests/generic/902 @@ -0,0 +1,38 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2026 Anand Jain . All Rights Reserved. +# +# FS QA Test No. 902 +# +# Verify that statfs f_fsid is derived from the filesystem UUID. +# Create a filesystem with a fixed UUID, mount it, and check that f_fsid +# matches the expected value. Applies only to filesystems that derive +# f_fsid from the UUID (btrfs, ext4). + +. ./common/preamble + +_begin_fstest auto quick + +_require_scratch +_require_uuid_based_fsid + +_fixed_by_fs_commit btrfs 72de4807ba84 \ + "btrfs: derive f_fsid with dev_t only when temp_fsid is active" + +_scratch_mkfs_uuid >> $seqres.full 2>&1 || _fail "mkfs failed" + +_scratch_mount + +blkid $SCRATCH_DEV >> $seqres.full +f_fsid=$(stat -f -c "%i" $SCRATCH_MNT) +expected=$(_scratch_expected_fsid) + +echo "f_fsid=$f_fsid expected=$expected" >> $seqres.full + +[[ $f_fsid == "$expected" ]] || _fail "f_fsid mismatch" + +_scratch_unmount + +echo "Silence is golden" + +_exit 0 diff --git a/tests/generic/902.out b/tests/generic/902.out new file mode 100644 index 000000000000..e20395365cb5 --- /dev/null +++ b/tests/generic/902.out @@ -0,0 +1,2 @@ +QA output created by 902 +Silence is golden -- 2.43.0