btrfs-progs: mkfs: enable space_cache=v2 (free-space-tree) by default

The free space tree is a better way to track the free space and has been
tested in the wild for a long time. The backward compatibility is
sufficient, several long term kernels. On-line conversion from v1 to v2
can be done by mount, switching from v2 to v1 can be done by 'btrfs
check'.

Issue: #295
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-09-29 15:16:47 +02:00
parent 1f918def34
commit 72260bc3b9
4 changed files with 6 additions and 3 deletions

View File

@ -269,7 +269,7 @@ Enable quota support (qgroups). The qgroup accounting will be consistent,
can be used together with '--rootdir'. See also `btrfs-quota`(8).
*free-space-tree*::
(kernel support since 4.5)
(default since btrfs-progs 5.15, kernel support since 4.5)
+
Enable the free space tree (mount option space_cache=v2) for persisting the
free space cache.

View File

@ -159,7 +159,7 @@ static const struct btrfs_feature runtime_features[] = {
.sysfs_name = "free_space_tree",
VERSION_TO_STRING2(compat, 4,5),
VERSION_TO_STRING2(safe, 4,9),
VERSION_NULL(default),
VERSION_TO_STRING2(default, 5,15),
.desc = "free space tree (space_cache=v2)"
},
/* Keep this one last */

View File

@ -25,6 +25,9 @@
| BTRFS_FEATURE_INCOMPAT_NO_HOLES \
| BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
#define BTRFS_MKFS_DEFAULT_RUNTIME_FEATURES \
(BTRFS_RUNTIME_FEATURE_FREE_SPACE_TREE)
/*
* Avoid multi-device features (RAID56), mixed block groups, and zoned mode
*/

View File

@ -903,7 +903,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
int saved_optind;
char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 };
u64 features = BTRFS_MKFS_DEFAULT_FEATURES;
u64 runtime_features = 0;
u64 runtime_features = BTRFS_MKFS_DEFAULT_RUNTIME_FEATURES;
struct mkfs_allocation allocation = { 0 };
struct btrfs_mkfs_config mkfs_cfg;
enum btrfs_csum_type csum_type = BTRFS_CSUM_TYPE_CRC32;