# function: detect_mixed_bg
# parameter: path to a mounted filesystem
# check if the filesystem contains mixed block groups,
# simple test is to read 'btrfs fi df',
# (we could look for /sys/sfs/btrfs/UUID/allocation/mixed if we know
# the UUID)
btrfs filesystem df "$1" | grep -q "Data+Metadata"
Normally the data and metadata block groups are isolated. The mixed mode will remove the isolation and store both types in the same block group type. This helps to utilize the free space regardless of the purpose and is suitable for small devices. The separate allocation of block groups leads to a situation where the space is reserved for the other block group type, is not available for allocation and can lead to ENOSPC state.
The recommended size for the mixed mode is for filesystems less than 1GiB. The soft recommendation is to use it for filesystems smaller than 5GiB. The mixed mode may lead to degraded performance on larger filesystems, but is otherwise usable, even on multiple devices.
The nodesize and sectorsize must be equal, and the block group types must match.
Note: versions up to 4.2.x forced the mixed mode for devices smaller than 1GiB. This has been removed in 4.3+ as it caused some usability issues.