0xStubs

System Administration, Reconfigurable Computing and Other Random Topics

Figuring out the used space_cache version of a btrfs file system

Btrfs contains different implementations of a free space cache. The default currently is space_cache=v1. A newer tree-based cache can be activated by the mount option space_cache=v2. As soon as the new version has been used once, it will automatically be used for any future mount. But how do you figure out which version your file system is actually using?

There are multiple ways to determine the used space cache version. The easiest one is to just mount the file system and look into the kernel log. If the default space cache v1 is used, it will say something like

BTRFS info (device yourdevice): disk space caching is enabled

However, if it already has been configured to use the new space cache v2, it will say something like

BTRFS info (device yourdevice): using free space tree

One can also determine the used space cache version without mounting the file system by peeking into the superblock:

btrfs inspect-internal dump-super /dev/yourdev

If the file system already uses space_cache=v2, the compat_ro_flags will contain the flag FREE_SPACE_TREE.

For completeness: When playing with space_cache=v2, be aware of the risks (see the remarks on the space_cache mount option in btrfs(5)).

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha loading...