]> 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>
Sun, 8 Nov 2026 06:08:58 +0000 (01:08 -0500)
commite34929a04b50ed8cfe3cc37b7a9f96a886a7947f
tree4006d94a14c07b6198e2cfde7412861e26cf3606
parent72146a65d0b77836a51e13e37122ea2f05ed90b1
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