Whamcloud - gitweb
LU-12477 ldiskfs: drop SUSE kernel 4.4 and earlier
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / suse15 / ext4-export-mb-stream-allocator-variables.patch
1 Index: linux-4.4/fs/ext4/mballoc.c
2 ===================================================================
3 --- linux-4.4.orig/fs/ext4/mballoc.c
4 +++ linux-4.4/fs/ext4/mballoc.c
5 @@ -2483,6 +2483,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 +const struct file_operations ext4_seq_mb_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 +const struct file_operations ext4_seq_mb_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 Index: linux-4.4/fs/ext4/ext4.h
84 ===================================================================
85 --- linux-4.4.orig/fs/ext4/ext4.h
86 +++ linux-4.4/fs/ext4/ext4.h
87 @@ -2595,6 +2595,8 @@ extern void ext4_end_bitmap_read(struct
88  /* mballoc.c */
89  extern const struct file_operations ext4_seq_prealloc_table_fops;
90  extern const struct file_operations ext4_seq_mb_groups_fops;
91 +extern const struct file_operations ext4_seq_mb_last_group_fops;
92 +extern const struct file_operations ext4_seq_mb_last_start_fops;
93  extern long ext4_mb_stats;
94  extern long ext4_mb_max_to_scan;
95  extern int ext4_mb_init(struct super_block *);
96 Index: linux-4.4/fs/ext4/sysfs.c
97 ===================================================================
98 --- linux-4.4.orig/fs/ext4/sysfs.c
99 +++ linux-4.4/fs/ext4/sysfs.c
100 @@ -396,6 +396,8 @@ static struct ext4_proc_files {
101         PROC_FILE_LIST(es_shrinker_info),
102         PROC_FILE_LIST(mb_groups),
103         PROC_FILE_LIST(prealloc_table),
104 +       PROC_FILE_LIST(mb_last_group),
105 +       PROC_FILE_LIST(mb_last_start),
106         { NULL, NULL },
107  };
108