1 ext4: add delalloc debugging
3 This adds a file in /proc/fs/ext4/<dev> which when opened for reading,
4 will trigger debugging code that dumps a lot of information about
5 inodes subject to delayed allocation to the console.
7 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
9 fs/ext4/sysfs.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 1 file changed, 69 insertions(+)
12 diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
13 index 9d29723..507d33f 100644
16 @@ -371,6 +371,74 @@ static struct kobject ext4_feat = {
20 +#ifdef CONFIG_EXT4_DEBUG
21 +static void print_inode_delalloc_info(struct inode *inode)
23 + if (!EXT4_I(inode)->i_reserved_data_blocks ||
24 + !EXT4_I(inode)->i_reserved_meta_blocks)
27 + printk(KERN_DEBUG "ino %lu: %u %u\n", inode->i_ino,
28 + EXT4_I(inode)->i_reserved_data_blocks,
29 + EXT4_I(inode)->i_reserved_meta_blocks);
32 +static int debug_delalloc_show(struct seq_file *seq, void *offset)
37 +static int options_delalloc_debug_open_fs(struct inode *proc_inode,
40 + struct super_block *sb = PDE_DATA(proc_inode);
41 + struct ext4_sb_info *sbi = EXT4_SB(sb);
42 + struct inode *inode;
43 + extern spinlock_t inode_sb_list_lock;
45 + printk(KERN_DEBUG "EXT4-fs debug delalloc of %s\n", sb->s_id);
46 + printk(KERN_DEBUG "EXT4-fs: dirty clusters %lld free clusters %lld\n",
47 + percpu_counter_sum(&sbi->s_dirtyclusters_counter),
48 + percpu_counter_sum(&sbi->s_freeclusters_counter));
51 + spin_lock(&inode_sb_list_lock);
52 + if (!list_empty(&sb->s_bdi->wb.b_dirty)) {
53 + printk(KERN_DEBUG "s_bdi->wb.b_dirty list:\n");
54 + list_for_each_entry(inode, &sb->s_bdi->wb.b_dirty,
56 + print_inode_delalloc_info(inode);
59 + if (!list_empty(&sb->s_bdi->wb.b_io)) {
60 + printk(KERN_DEBUG "s_bdi->wb.b_io list:\n");
61 + list_for_each_entry(inode, &sb->s_bdi->wb.b_io,
63 + print_inode_delalloc_info(inode);
66 + if (!list_empty(&sb->s_bdi->wb.b_more_io)) {
67 + printk(KERN_DEBUG "s_bdi->wb.b_more_io list:\n");
68 + list_for_each_entry(inode, &sb->s_bdi->wb.b_more_io,
70 + print_inode_delalloc_info(inode);
73 + spin_unlock(&inode_sb_list_lock);
74 + printk(KERN_DEBUG "ext4 debug delalloc done\n");
76 + return single_open(file, debug_delalloc_show, sb);
79 +static const struct file_operations ext4_seq_delalloc_debug_fops = {
80 + .owner = THIS_MODULE,
81 + .open = options_delalloc_debug_open_fs,
83 + .llseek = seq_lseek,
84 + .release = single_release,
88 #define PROC_FILE_SHOW_DEFN(name) \
89 static int name##_open(struct inode *inode, struct file *file) \
91 @@ -398,6 +466,7 @@ static struct ext4_proc_files {
92 PROC_FILE_LIST(options),
93 PROC_FILE_LIST(es_shrinker_info),
94 PROC_FILE_LIST(mb_groups),
95 + PROC_FILE_LIST(delalloc_debug),