Whamcloud - gitweb
LU-13783 ldiskfs: Add support for mainline 5.8 kernel
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / linux-5.8 / ext4-export-mb-stream-allocator-variables.patch
diff --git a/ldiskfs/kernel_patches/patches/linux-5.8/ext4-export-mb-stream-allocator-variables.patch b/ldiskfs/kernel_patches/patches/linux-5.8/ext4-export-mb-stream-allocator-variables.patch
new file mode 100644 (file)
index 0000000..7ab4fff
--- /dev/null
@@ -0,0 +1,97 @@
+---
+ fs/ext4/ext4.h    |    2 +
+ fs/ext4/mballoc.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ fs/ext4/sysfs.c   |    4 +++
+ 3 files changed, 64 insertions(+)
+
+--- a/fs/ext4/ext4.h
++++ b/fs/ext4/ext4.h
+@@ -2808,6 +2808,8 @@ extern void ext4_end_bitmap_read(struct
+ /* mballoc.c */
+ extern const struct proc_ops ext4_seq_prealloc_table_fops;
+ extern const struct seq_operations ext4_mb_seq_groups_ops;
++extern const struct proc_ops ext4_seq_mb_last_group_fops;
++extern int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v);
+ extern long ext4_mb_stats;
+ extern long ext4_mb_max_to_scan;
+ extern int ext4_mb_init(struct super_block *);
+--- a/fs/ext4/mballoc.c
++++ b/fs/ext4/mballoc.c
+@@ -2574,6 +2574,64 @@ static struct kmem_cache *get_groupinfo_
+       return cachep;
+ }
++#define EXT4_MB_MAX_INPUT_STRING_SIZE 32
++
++static ssize_t ext4_mb_last_group_write(struct file *file,
++                                      const char __user *buf,
++                                      size_t cnt, loff_t *pos)
++{
++      char dummy[EXT4_MB_MAX_INPUT_STRING_SIZE + 1];
++      struct super_block *sb = PDE_DATA(file_inode(file));
++      struct ext4_sb_info *sbi = EXT4_SB(sb);
++      unsigned long val;
++      char *end;
++
++      if (cnt > EXT4_MB_MAX_INPUT_STRING_SIZE)
++              return -EINVAL;
++      if (copy_from_user(dummy, buf, cnt))
++              return -EFAULT;
++      dummy[cnt] = '\0';
++      val = simple_strtoul(dummy, &end, 0);
++      if (dummy == end)
++              return -EINVAL;
++      if (val >= ext4_get_groups_count(sb))
++              return -ERANGE;
++      spin_lock(&sbi->s_md_lock);
++      sbi->s_mb_last_group = val;
++      sbi->s_mb_last_start = 0;
++      spin_unlock(&sbi->s_md_lock);
++      return cnt;
++}
++
++static int ext4_mb_seq_last_group_seq_show(struct seq_file *m, void *v)
++{
++      struct ext4_sb_info *sbi = EXT4_SB(m->private);
++
++      seq_printf(m , "%ld\n", sbi->s_mb_last_group);
++      return 0;
++}
++
++static int ext4_mb_seq_last_group_open(struct inode *inode, struct file *file)
++{
++      return single_open(file, ext4_mb_seq_last_group_seq_show, PDE_DATA(inode));
++}
++
++const struct proc_ops ext4_seq_mb_last_group_fops = {
++      .proc_open      = ext4_mb_seq_last_group_open,
++      .proc_read      = seq_read,
++      .proc_lseek     = seq_lseek,
++      .proc_release   = seq_release,
++      .proc_write     = ext4_mb_last_group_write,
++};
++
++int ext4_mb_seq_last_start_seq_show(struct seq_file *m, void *v)
++{
++      struct ext4_sb_info *sbi = EXT4_SB(m->private);
++
++      seq_printf(m , "%ld\n", sbi->s_mb_last_start);
++      return 0;
++}
++
+ /*
+  * Allocate the top-level s_group_info array for the specified number
+  * of groups
+--- a/fs/ext4/sysfs.c
++++ b/fs/ext4/sysfs.c
+@@ -524,6 +524,10 @@ int ext4_register_sysfs(struct super_blo
+                               &ext4_mb_seq_groups_ops, sb);
+               proc_create_data("prealloc_table", S_IRUGO, sbi->s_proc,
+                               &ext4_seq_prealloc_table_fops, sb);
++              proc_create_data("mb_last_group", S_IRUGO, sbi->s_proc,
++                              &ext4_seq_mb_last_group_fops, sb);
++              proc_create_single_data("mb_last_start", S_IRUGO, sbi->s_proc,
++                              ext4_mb_seq_last_start_seq_show, sb);
+       }
+       return 0;
+ }