|
9 | 9 | #include <linux/spinlock.h>
|
10 | 10 | #include <linux/completion.h>
|
11 | 11 | #include <linux/bug.h>
|
| 12 | +#include <linux/list.h> |
12 | 13 | #include <crypto/hash.h>
|
13 | 14 | #include "messages.h"
|
14 | 15 | #include "ctree.h"
|
@@ -778,6 +779,45 @@ static ssize_t btrfs_chunk_size_store(struct kobject *kobj,
|
778 | 779 | return len;
|
779 | 780 | }
|
780 | 781 |
|
| 782 | +static ssize_t btrfs_size_classes_show(struct kobject *kobj, |
| 783 | + struct kobj_attribute *a, char *buf) |
| 784 | +{ |
| 785 | + struct btrfs_space_info *sinfo = to_space_info(kobj); |
| 786 | + struct btrfs_block_group *bg; |
| 787 | + u32 none = 0; |
| 788 | + u32 small = 0; |
| 789 | + u32 medium = 0; |
| 790 | + u32 large = 0; |
| 791 | + |
| 792 | + for (int i = 0; i < BTRFS_NR_RAID_TYPES; ++i) { |
| 793 | + down_read(&sinfo->groups_sem); |
| 794 | + list_for_each_entry(bg, &sinfo->block_groups[i], list) { |
| 795 | + if (!btrfs_block_group_should_use_size_class(bg)) |
| 796 | + continue; |
| 797 | + switch (bg->size_class) { |
| 798 | + case BTRFS_BG_SZ_NONE: |
| 799 | + none++; |
| 800 | + break; |
| 801 | + case BTRFS_BG_SZ_SMALL: |
| 802 | + small++; |
| 803 | + break; |
| 804 | + case BTRFS_BG_SZ_MEDIUM: |
| 805 | + medium++; |
| 806 | + break; |
| 807 | + case BTRFS_BG_SZ_LARGE: |
| 808 | + large++; |
| 809 | + break; |
| 810 | + } |
| 811 | + } |
| 812 | + up_read(&sinfo->groups_sem); |
| 813 | + } |
| 814 | + return sysfs_emit(buf, "none %u\n" |
| 815 | + "small %u\n" |
| 816 | + "medium %u\n" |
| 817 | + "large %u\n", |
| 818 | + none, small, medium, large); |
| 819 | +} |
| 820 | + |
781 | 821 | #ifdef CONFIG_BTRFS_DEBUG
|
782 | 822 | /*
|
783 | 823 | * Request chunk allocation with current chunk size.
|
@@ -835,6 +875,7 @@ SPACE_INFO_ATTR(bytes_zone_unusable);
|
835 | 875 | SPACE_INFO_ATTR(disk_used);
|
836 | 876 | SPACE_INFO_ATTR(disk_total);
|
837 | 877 | BTRFS_ATTR_RW(space_info, chunk_size, btrfs_chunk_size_show, btrfs_chunk_size_store);
|
| 878 | +BTRFS_ATTR(space_info, size_classes, btrfs_size_classes_show); |
838 | 879 |
|
839 | 880 | static ssize_t btrfs_sinfo_bg_reclaim_threshold_show(struct kobject *kobj,
|
840 | 881 | struct kobj_attribute *a,
|
@@ -887,6 +928,7 @@ static struct attribute *space_info_attrs[] = {
|
887 | 928 | BTRFS_ATTR_PTR(space_info, disk_total),
|
888 | 929 | BTRFS_ATTR_PTR(space_info, bg_reclaim_threshold),
|
889 | 930 | BTRFS_ATTR_PTR(space_info, chunk_size),
|
| 931 | + BTRFS_ATTR_PTR(space_info, size_classes), |
890 | 932 | #ifdef CONFIG_BTRFS_DEBUG
|
891 | 933 | BTRFS_ATTR_PTR(space_info, force_chunk_alloc),
|
892 | 934 | #endif
|
|
0 commit comments