Message ID | f4679fa21b8b55e467c653ae7f0efb64e27044ad.1742364593.git.naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | btrfs: zoned: split out space_info for dedicated block groups | expand |
On 19.03.25 07:17, Naohiro Aota wrote: > diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c > index 53eea3cd2bf3..3c775c76e2af 100644 > --- a/fs/btrfs/space-info.c > +++ b/fs/btrfs/space-info.c > @@ -280,6 +280,18 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags) > > ret = btrfs_sysfs_add_space_info_type(info, reloc); > ASSERT(!ret); > + } else if (flags & BTRFS_BLOCK_GROUP_METADATA) { > + struct btrfs_space_info *treelog = kzalloc(sizeof(*treelog), GFP_NOFS); > + > + if (!treelog) > + return -ENOMEM; > + init_space_info(info, treelog, flags); > + space_info->sub_group[SUB_GROUP_METADATA_TREELOG] = treelog; > + treelog->parent = space_info; > + treelog->subgroup_id = SUB_GROUP_METADATA_TREELOG; > + > + ret = btrfs_sysfs_add_space_info_type(info, treelog); > + ASSERT(!ret); > } > } > Same comment as for the previous one.
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 53eea3cd2bf3..3c775c76e2af 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -280,6 +280,18 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags) ret = btrfs_sysfs_add_space_info_type(info, reloc); ASSERT(!ret); + } else if (flags & BTRFS_BLOCK_GROUP_METADATA) { + struct btrfs_space_info *treelog = kzalloc(sizeof(*treelog), GFP_NOFS); + + if (!treelog) + return -ENOMEM; + init_space_info(info, treelog, flags); + space_info->sub_group[SUB_GROUP_METADATA_TREELOG] = treelog; + treelog->parent = space_info; + treelog->subgroup_id = SUB_GROUP_METADATA_TREELOG; + + ret = btrfs_sysfs_add_space_info_type(info, treelog); + ASSERT(!ret); } } diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index 64641885babd..1aadf88e5789 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -100,6 +100,7 @@ enum btrfs_flush_state { enum btrfs_space_info_sub_group { SUB_GROUP_DATA_RELOC = 0, + SUB_GROUP_METADATA_TREELOG = 0, SUB_GROUP_PRIMARY = -1, }; #define BTRFS_SPACE_INFO_SUB_GROUP_MAX 1 diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 92caa5d09e2f..fba31e2354e5 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1938,7 +1938,15 @@ static const char *alloc_name(struct btrfs_space_info *space_info) case BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA: return "mixed"; case BTRFS_BLOCK_GROUP_METADATA: - return "metadata"; + switch (space_info->subgroup_id) { + case SUB_GROUP_PRIMARY: + return "metadata"; + case SUB_GROUP_METADATA_TREELOG: + return "metadata-treelog"; + default: + WARN_ON_ONCE(1); + return "metadata (unknown sub-group)"; + } case BTRFS_BLOCK_GROUP_DATA: switch (space_info->subgroup_id) { case SUB_GROUP_PRIMARY:
This commit introduces the tree-log sub-space_info, which is sub-space of metadata space_info and dedicated for tree-log node allocation. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- fs/btrfs/space-info.c | 12 ++++++++++++ fs/btrfs/space-info.h | 1 + fs/btrfs/sysfs.c | 10 +++++++++- 3 files changed, 22 insertions(+), 1 deletion(-)