@@ -172,6 +172,14 @@ static const struct btrfs_feature runtime_features[] = {
VERSION_TO_STRING2(safe, 4,9),
VERSION_TO_STRING2(default, 5,15),
.desc = "free space tree (space_cache=v2)"
+ } , {
+ .name = "raid-stripe-tree",
+ .flag = BTRFS_RUNTIME_FEATURE_RAID_STRIPE_TREE,
+ .sysfs_name = NULL,
+ VERSION_NULL(compat),
+ VERSION_NULL(safe),
+ VERSION_NULL(default),
+ .desc = "raid stripe tree"
},
/* Keep this one last */
{
@@ -45,6 +45,7 @@
#define BTRFS_RUNTIME_FEATURE_QUOTA (1ULL << 0)
#define BTRFS_RUNTIME_FEATURE_FREE_SPACE_TREE (1ULL << 1)
+#define BTRFS_RUNTIME_FEATURE_RAID_STRIPE_TREE (1ULL << 2)
void btrfs_list_all_fs_features(u64 mask_disallowed);
void btrfs_list_all_runtime_features(u64 mask_disallowed);
@@ -88,6 +88,9 @@ struct btrfs_free_space_ctl;
/* hold the block group items. */
#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL
+/* hold the raid-stripe entries */
+#define BTRFS_RAID_STRIPE_TREE_OBJECTID 12ULL
+
/* device stats in the device tree */
#define BTRFS_DEV_STATS_OBJECTID 0ULL
@@ -969,6 +969,38 @@ fail:
return ret;
}
+static int setup_raid_stripe_tree_root(struct btrfs_fs_info *fs_info)
+{
+ struct btrfs_trans_handle *trans;
+ struct btrfs_root *stripe_root;
+ struct btrfs_key key = {
+ .objectid = BTRFS_RAID_STRIPE_TREE_OBJECTID,
+ .type = BTRFS_ROOT_ITEM_KEY,
+ };
+ int ret;
+
+ trans = btrfs_start_transaction(fs_info->tree_root, 0);
+ if (IS_ERR(trans))
+ return PTR_ERR(trans);
+
+ stripe_root = btrfs_create_tree(trans, fs_info, &key);
+ if (IS_ERR(stripe_root)) {
+ ret = PTR_ERR(stripe_root);
+ goto abort;
+ }
+ fs_info->stripe_root = stripe_root;
+ add_root_to_dirty_list(stripe_root);
+
+ ret = btrfs_commit_transaction(trans, fs_info->tree_root);
+ if (ret)
+ return ret;
+
+ return 0;
+abort:
+ btrfs_abort_transaction(trans, ret);
+ return ret;
+}
+
int BOX_MAIN(mkfs)(int argc, char **argv)
{
char *file;
@@ -1689,6 +1721,16 @@ raid_groups:
goto out;
}
}
+ if (runtime_features & BTRFS_RUNTIME_FEATURE_RAID_STRIPE_TREE) {
+ ret = setup_raid_stripe_tree_root(fs_info);
+ if (ret < 0) {
+ error("failed to initialize raid-stripe-tree: %d (%m)",
+ ret);
+ goto out;
+ }
+ }
+
+
if (bconf.verbose) {
char features_buf[64];
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- common/fsfeatures.c | 8 ++++++++ common/fsfeatures.h | 1 + kernel-shared/ctree.h | 3 +++ mkfs/main.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+)