3 fs/ext4/mballoc.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 fs/ext4/sysfs.c | 4 +++
5 3 files changed, 64 insertions(+)
9 @@ -2808,6 +2808,8 @@ extern void ext4_end_bitmap_read(struct
11 extern const struct proc_ops ext4_seq_prealloc_table_fops;
12 extern const struct seq_operations ext4_mb_seq_groups_ops;
13 +extern const struct proc_ops ext4_seq_mb_last_group_fops;
14 +extern int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v);
15 extern long ext4_mb_stats;
16 extern long ext4_mb_max_to_scan;
17 extern int ext4_mb_init(struct super_block *);
18 --- a/fs/ext4/mballoc.c
19 +++ b/fs/ext4/mballoc.c
20 @@ -2574,6 +2574,64 @@ static struct kmem_cache *get_groupinfo_
24 +#define EXT4_MB_MAX_INPUT_STRING_SIZE 32
26 +static ssize_t ext4_mb_last_group_write(struct file *file,
27 + const char __user *buf,
28 + size_t cnt, loff_t *pos)
30 + char dummy[EXT4_MB_MAX_INPUT_STRING_SIZE + 1];
31 + struct super_block *sb = PDE_DATA(file_inode(file));
32 + struct ext4_sb_info *sbi = EXT4_SB(sb);
36 + if (cnt > EXT4_MB_MAX_INPUT_STRING_SIZE)
38 + if (copy_from_user(dummy, buf, cnt))
41 + val = simple_strtoul(dummy, &end, 0);
44 + if (val >= ext4_get_groups_count(sb))
46 + spin_lock(&sbi->s_md_lock);
47 + sbi->s_mb_last_group = val;
48 + sbi->s_mb_last_start = 0;
49 + spin_unlock(&sbi->s_md_lock);
53 +static int ext4_mb_seq_last_group_seq_show(struct seq_file *m, void *v)
55 + struct ext4_sb_info *sbi = EXT4_SB(m->private);
57 + seq_printf(m , "%ld\n", sbi->s_mb_last_group);
61 +static int ext4_mb_seq_last_group_open(struct inode *inode, struct file *file)
63 + return single_open(file, ext4_mb_seq_last_group_seq_show, PDE_DATA(inode));
66 +const struct proc_ops ext4_seq_mb_last_group_fops = {
67 + .proc_open = ext4_mb_seq_last_group_open,
68 + .proc_read = seq_read,
69 + .proc_lseek = seq_lseek,
70 + .proc_release = seq_release,
71 + .proc_write = ext4_mb_last_group_write,
74 +int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v)
76 + struct ext4_sb_info *sbi = EXT4_SB(m->private);
78 + seq_printf(m , "%ld\n", sbi->s_mb_last_start);
83 * Allocate the top-level s_group_info array for the specified number
87 @@ -524,6 +524,10 @@ int ext4_register_sysfs(struct super_blo
88 &ext4_mb_seq_groups_ops, sb);
89 proc_create_data("prealloc_table", S_IRUGO, sbi->s_proc,
90 &ext4_seq_prealloc_table_fops, sb);
91 + proc_create_data("mb_last_group", S_IRUGO, sbi->s_proc,
92 + &ext4_seq_mb_last_group_fops, sb);
93 + proc_create_single_data("mb_last_start", S_IRUGO, sbi->s_proc,
94 + ext4_mb_seq_last_start_seq_show, sb);