1 Index: linux-3.10.0-327.10.1.el7.x86_64/fs/ext4/mballoc.c
2 ===================================================================
3 --- linux-3.10.0-327.10.1.el7.x86_64.orig/fs/ext4/mballoc.c
4 +++ linux-3.10.0-327.10.1.el7.x86_64/fs/ext4/mballoc.c
5 @@ -2435,6 +2435,77 @@ static struct kmem_cache *get_groupinfo_
9 +#define EXT4_MB_MAX_INPUT_STRING_SIZE 32
11 +static ssize_t ext4_mb_last_group_write(struct file *file,
12 + const char __user *buf,
13 + size_t cnt, loff_t *pos)
15 + char dummy[EXT4_MB_MAX_INPUT_STRING_SIZE + 1];
16 + struct super_block *sb = PDE_DATA(file_inode(file));
17 + struct ext4_sb_info *sbi = EXT4_SB(sb);
21 + if (cnt > EXT4_MB_MAX_INPUT_STRING_SIZE)
23 + if (copy_from_user(dummy, buf, cnt))
26 + val = simple_strtoul(dummy, &end, 0);
29 + if (val >= ext4_get_groups_count(sb))
31 + spin_lock(&sbi->s_md_lock);
32 + sbi->s_mb_last_group = val;
33 + sbi->s_mb_last_start = 0;
34 + spin_unlock(&sbi->s_md_lock);
38 +static int ext4_mb_seq_last_group_seq_show(struct seq_file *m, void *v)
40 + struct ext4_sb_info *sbi = EXT4_SB(m->private);
42 + seq_printf(m , "%ld\n", sbi->s_mb_last_group);
46 +static int ext4_mb_seq_last_group_open(struct inode *inode, struct file *file)
48 + return single_open(file, ext4_mb_seq_last_group_seq_show, PDE_DATA(inode));
51 +static const struct file_operations ext4_mb_seq_last_group_fops = {
52 + .owner = THIS_MODULE,
53 + .open = ext4_mb_seq_last_group_open,
55 + .llseek = seq_lseek,
56 + .release = seq_release,
57 + .write = ext4_mb_last_group_write,
60 +static int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v)
62 + struct ext4_sb_info *sbi = EXT4_SB(m->private);
64 + seq_printf(m , "%ld\n", sbi->s_mb_last_start);
68 +static int ext4_mb_seq_last_start_open(struct inode *inode, struct file *file)
70 + return single_open(file, ext4_mb_seq_last_start_seq_show, PDE_DATA(inode));
72 +static const struct file_operations ext4_mb_seq_last_start_fops = {
73 + .owner = THIS_MODULE,
74 + .open = ext4_mb_seq_last_start_open,
76 + .llseek = seq_lseek,
77 + .release = seq_release,
81 * Allocate the top-level s_group_info array for the specified number
83 @@ -2790,6 +2861,11 @@ int ext4_mb_init(struct super_block *sb)
84 proc_create_data(EXT4_MB_PREALLOC_TABLE, S_IFREG | S_IRUGO |
86 &ext4_mb_prealloc_seq_fops, sb);
87 + proc_create_data("mb_last_group", S_IFREG | S_IRUGO |
88 + S_IWUSR, sbi->s_proc,
89 + &ext4_mb_seq_last_group_fops, sb);
90 + proc_create_data("mb_last_start", S_IFREG | S_IRUGO,
91 + sbi->s_proc, &ext4_mb_seq_last_start_fops, sb);
95 @@ -2835,6 +2911,8 @@ int ext4_mb_release(struct super_block *
98 remove_proc_entry("mb_groups", sbi->s_proc);
99 + remove_proc_entry("mb_last_group", sbi->s_proc);
100 + remove_proc_entry("mb_last_start", sbi->s_proc);
101 remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_proc);