]> git.hungrycats.org Git - linux/commit
btrfs: remove runtime tweakable feature sysfs interface
authorQu Wenruo <wqu@suse.com>
Fri, 21 Aug 2026 10:12:10 +0000 (19:42 +0930)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Sep 2026 11:23:36 +0000 (13:23 +0200)
commitc8febd585c5124ec96d9346584b79c57e2def261
tree690c564ee1ae87ef7b8d4ad4123d2a406b6ff5cf
parentddfce12cf94208160df06449025a6e847c2ea8f6
btrfs: remove runtime tweakable feature sysfs interface

There are 2 features that are marked runtime tweakable inside
/sys/fs/btrfs/features/

- acl
  Which is a mount option, and it will not show up in
  /sys/fs/btrfs/<fsid>/features/ directory anyway.

- extended_iref
  This feature can only be enabled, but not disabled at runtime.
  Furthermore it's already the default behavior since 3.12.

  So it means this feature is always enabled and cannot be disabled for
  modern btrfs.

So there is no need to maintain the ability to modify btrfs' runtime
features through sysfs.

And furthermore, the existing btrfs_feature_attr_store() is race-prone,
it relies on fs_info->transaction_kthread, but our sysfs interfaces are
enabled before transaction_kthread.

Meaning at mount time a sysfs write can trigger NULL pointer dereference
if the transaction_kthread is not yet initialized.
The opposite is also possible during unmount.

Thankfully that race is not possible in the real world, as the only
supported feature is already enabled.

But it also means we do not really need to keep the race-prone
infrastructure, so just remove it completely, and make the per-module
and per-mount features files to be completely read-only.

Even with the sysfs tweakable features removed, we can still enable
extended_iref feature through ioctl.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/sysfs.c