Whamcloud - gitweb
LU-13004 modules: replace lnet_kiov_t with struct bio_vec
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel7.6 / ext4-export-mb-stream-allocator-variables.patch
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_
6         return cachep;
7  }
8
9 +#define EXT4_MB_MAX_INPUT_STRING_SIZE 32
10 +
11 +static ssize_t ext4_mb_last_group_write(struct file *file,
12 +                                       const char __user *buf,
13 +                                       size_t cnt, loff_t *pos)
14 +{
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);
18 +       unsigned long val;
19 +       char *end;
20 +
21 +       if (cnt > EXT4_MB_MAX_INPUT_STRING_SIZE)
22 +               return -EINVAL;
23 +       if (copy_from_user(dummy, buf, cnt))
24 +               return -EFAULT;
25 +       dummy[cnt] = '\0';
26 +       val = simple_strtoul(dummy, &end, 0);
27 +       if (dummy == end)
28 +               return -EINVAL;
29 +       if (val >= ext4_get_groups_count(sb))
30 +               return -ERANGE;
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);
35 +       return cnt;
36 +}
37 +
38 +static int ext4_mb_seq_last_group_seq_show(struct seq_file *m, void *v)
39 +{
40 +       struct ext4_sb_info *sbi = EXT4_SB(m->private);
41 +
42 +       seq_printf(m , "%ld\n", sbi->s_mb_last_group);
43 +       return 0;
44 +}
45 +
46 +static int ext4_mb_seq_last_group_open(struct inode *inode, struct file *file)
47 +{
48 +       return single_open(file, ext4_mb_seq_last_group_seq_show, PDE_DATA(inode));
49 +}
50 +
51 +static const struct file_operations ext4_mb_seq_last_group_fops = {
52 +       .owner         = THIS_MODULE,
53 +       .open          = ext4_mb_seq_last_group_open,
54 +       .read          = seq_read,
55 +       .llseek        = seq_lseek,
56 +       .release       = seq_release,
57 +       .write         = ext4_mb_last_group_write,
58 +};
59 +
60 +static int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v)
61 +{
62 +       struct ext4_sb_info *sbi = EXT4_SB(m->private);
63 +
64 +       seq_printf(m , "%ld\n", sbi->s_mb_last_start);
65 +       return 0;
66 +}
67 +
68 +static int ext4_mb_seq_last_start_open(struct inode *inode, struct file *file)
69 +{
70 +       return single_open(file, ext4_mb_seq_last_start_seq_show, PDE_DATA(inode));
71 +}
72 +static const struct file_operations ext4_mb_seq_last_start_fops = {
73 +       .owner         = THIS_MODULE,
74 +       .open          = ext4_mb_seq_last_start_open,
75 +       .read          = seq_read,
76 +       .llseek        = seq_lseek,
77 +       .release       = seq_release,
78 +};
79 +
80  /*
81   * Allocate the top-level s_group_info array for the specified number
82   * of groups
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 |
85                                  S_IWUSR, sbi->s_proc,
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);
92         }
93
94         return 0;
95 @@ -2835,6 +2911,8 @@ int ext4_mb_release(struct super_block *
96
97         if (sbi->s_proc) {
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);
102         }
103