Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: zoned: show statistics about zoned filesystems in mountstats

Add statistics output to /proc/<pid>/mountstats for zoned BTRFS, similar
to the zoned statistics from XFS in mountstats.

The output for /proc/<pid>/mountstats on an example filesystem will be as
follows:

device /dev/vda mounted on /mnt with fstype btrfs
zoned statistics:
active block-groups: 7
reclaimable: 0
unused: 5
need reclaim: false
data relocation block-group: 1342177280
active zones:
start: 1073741824, wp: 268419072 used: 0, reserved: 268419072, unusable: 0
start: 1342177280, wp: 0 used: 0, reserved: 0, unusable: 0
start: 1610612736, wp: 49152 used: 16384, reserved: 16384, unusable: 16384
start: 1879048192, wp: 950272 used: 131072, reserved: 622592, unusable: 196608
start: 2147483648, wp: 212238336 used: 0, reserved: 212238336, unusable: 0
start: 2415919104, wp: 0 used: 0, reserved: 0, unusable: 0
start: 2684354560, wp: 0 used: 0, reserved: 0, unusable: 0

Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Johannes Thumshirn and committed by
David Sterba
6a5ac228 68d4ece9

+75
+13
fs/btrfs/super.c
··· 2483 2483 } 2484 2484 #endif 2485 2485 2486 + static int btrfs_show_stats(struct seq_file *seq, struct dentry *root) 2487 + { 2488 + struct btrfs_fs_info *fs_info = btrfs_sb(root->d_sb); 2489 + 2490 + if (btrfs_is_zoned(fs_info)) { 2491 + btrfs_show_zoned_stats(fs_info, seq); 2492 + return 0; 2493 + } 2494 + 2495 + return 0; 2496 + } 2497 + 2486 2498 static const struct super_operations btrfs_super_ops = { 2487 2499 .drop_inode = btrfs_drop_inode, 2488 2500 .evict_inode = btrfs_evict_inode, ··· 2510 2498 .unfreeze_fs = btrfs_unfreeze, 2511 2499 .nr_cached_objects = btrfs_nr_cached_objects, 2512 2500 .free_cached_objects = btrfs_free_cached_objects, 2501 + .show_stats = btrfs_show_stats, 2513 2502 #ifdef CONFIG_BTRFS_EXPERIMENTAL 2514 2503 .remove_bdev = btrfs_remove_bdev, 2515 2504 .shutdown = btrfs_shutdown,
+54
fs/btrfs/zoned.c
··· 2984 2984 2985 2985 return 0; 2986 2986 } 2987 + 2988 + void btrfs_show_zoned_stats(struct btrfs_fs_info *fs_info, struct seq_file *seq) 2989 + { 2990 + struct btrfs_block_group *bg; 2991 + u64 data_reloc_bg; 2992 + u64 treelog_bg; 2993 + 2994 + seq_puts(seq, "\n zoned statistics:\n"); 2995 + 2996 + spin_lock(&fs_info->zone_active_bgs_lock); 2997 + seq_printf(seq, "\tactive block-groups: %zu\n", 2998 + list_count_nodes(&fs_info->zone_active_bgs)); 2999 + spin_unlock(&fs_info->zone_active_bgs_lock); 3000 + 3001 + spin_lock(&fs_info->unused_bgs_lock); 3002 + seq_printf(seq, "\t reclaimable: %zu\n", 3003 + list_count_nodes(&fs_info->reclaim_bgs)); 3004 + seq_printf(seq, "\t unused: %zu\n", list_count_nodes(&fs_info->unused_bgs)); 3005 + spin_unlock(&fs_info->unused_bgs_lock); 3006 + 3007 + seq_printf(seq,"\t need reclaim: %s\n", 3008 + str_true_false(btrfs_zoned_should_reclaim(fs_info))); 3009 + 3010 + data_reloc_bg = data_race(fs_info->data_reloc_bg); 3011 + if (data_reloc_bg) 3012 + seq_printf(seq, "\tdata relocation block-group: %llu\n", 3013 + data_reloc_bg); 3014 + treelog_bg = data_race(fs_info->treelog_bg); 3015 + if (treelog_bg) 3016 + seq_printf(seq, "\ttree-log block-group: %llu\n", treelog_bg); 3017 + 3018 + spin_lock(&fs_info->zone_active_bgs_lock); 3019 + seq_puts(seq, "\tactive zones:\n"); 3020 + list_for_each_entry(bg, &fs_info->zone_active_bgs, active_bg_list) { 3021 + u64 start; 3022 + u64 alloc_offset; 3023 + u64 used; 3024 + u64 reserved; 3025 + u64 zone_unusable; 3026 + 3027 + spin_lock(&bg->lock); 3028 + start = bg->start; 3029 + alloc_offset = bg->alloc_offset; 3030 + used = bg->used; 3031 + reserved = bg->reserved; 3032 + zone_unusable = bg->zone_unusable; 3033 + spin_unlock(&bg->lock); 3034 + 3035 + seq_printf(seq, 3036 + "\t start: %llu, wp: %llu used: %llu, reserved: %llu, unusable: %llu\n", 3037 + start, alloc_offset, used, reserved, zone_unusable); 3038 + } 3039 + spin_unlock(&fs_info->zone_active_bgs_lock); 3040 + }
+8
fs/btrfs/zoned.h
··· 10 10 #include <linux/errno.h> 11 11 #include <linux/spinlock.h> 12 12 #include <linux/mutex.h> 13 + #include <linux/seq_file.h> 13 14 #include "messages.h" 14 15 #include "volumes.h" 15 16 #include "disk-io.h" ··· 97 96 int btrfs_zoned_activate_one_bg(struct btrfs_space_info *space_info, bool do_finish); 98 97 void btrfs_check_active_zone_reservation(struct btrfs_fs_info *fs_info); 99 98 int btrfs_reset_unused_block_groups(struct btrfs_space_info *space_info, u64 num_bytes); 99 + void btrfs_show_zoned_stats(struct btrfs_fs_info *fs_info, struct seq_file *seq); 100 + 100 101 #else /* CONFIG_BLK_DEV_ZONED */ 101 102 102 103 static inline int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) ··· 274 271 275 272 static inline int btrfs_reset_unused_block_groups(struct btrfs_space_info *space_info, 276 273 u64 num_bytes) 274 + { 275 + return 0; 276 + } 277 + 278 + static inline int btrfs_show_zoned_stats(struct btrfs_fs_info *fs_info, struct seq_file *seq) 277 279 { 278 280 return 0; 279 281 }