]> git.hungrycats.org Git - linux/commit
btrfs: change the DEV_ITEM 'type' field via sysfs
authorKai Krakow <kai@kaishome.de>
Fri, 10 Jul 2026 22:25:21 +0000 (00:25 +0200)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:06:49 +0000 (21:06 -0500)
commitab7714e82aea77d30ef03f5e53637a4bc09cd4d2
tree83077c56a58c0ca7ee3b4861fc9d3a4a9e8600ee
parent5b2a729b5cdc1ef1722824ec96fe5547ad5ab57c
btrfs: change the DEV_ITEM 'type' field via sysfs

Known limitations:

- Device replace does not copy the allocation hint to the target
  device. Users must reapply it after replacement.
- The sysfs update is not serialized with chunk allocation through
  chunk_mutex, so an allocation concurrent with an update may observe
  either value.

A future revision should replace the type field with dedicated
transactional structures. Transactions should not be triggered directly
from sysfs writes, see:

https://lore.kernel.org/linux-btrfs/20251213200920.1808679-1-kai@kaishome.de/

v2:
- Adds a check to prevent modification while the file system is still
  mounting.

v3:
- Accept only valid allocation hint types

v4:
- Document the device replace and chunk allocation synchronization
  limitations of the current type-based interface.

Link: https://github.com/kakra/linux/pull/36#issuecomment-3406301805
Reported-by: Eli Venter <eli@genedx.com>
Co-authored-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: Kai Krakow <kai@kaishome.de>
fs/btrfs/sysfs.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h