Viewing: ext4-export-mb-stream-allocator-variables.patch
commit 75703118588f2b23afd8c8815e5ebb768fc7a8ff
Author: Lokesh Nagappa Jaliminche <lokesh.jaliminche@seagate.com>
AuthorDate: Mon, 4 Jul 2016 14:34:20 +0530
Subject: LU-8365 ldiskfs: procfs entries for mballoc
Export mballoc streaming block allocator variables
mb_last_group and mb_last_start through procfs.
Cray-bug-id: LUS-3176
Signed-off-by: Lokesh Nagappa Jaliminche <lokesh.jaliminche@seagate.com>
Signed-off-by: Alexander Zarochentsev <c17826@cray.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I5dd00503a81c6819751c9f99b64615b497ef4e28
---
fs/ext4/ext4.h | 1 +
fs/ext4/mballoc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++
fs/ext4/sysfs.c | 2 ++
3 files changed, 57 insertions(+)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3109,6 +3109,7 @@ int ext4_fc_record_regions(struct super_block *sb, int ino,
/* mballoc.c */
extern const struct proc_ops ext4_seq_prealloc_table_fops;
+extern const struct proc_ops ext4_seq_mb_last_groups_fops;
extern const struct seq_operations ext4_mb_seq_groups_ops;
extern const struct seq_operations ext4_mb_seq_structs_summary_ops;
extern int ext4_seq_mb_stats_show(struct seq_file *seq, void *offset);
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3460,6 +3460,60 @@ static struct kmem_cache *get_groupinfo_cache(int blocksize_bits)
return cachep;
}
+#define EXT4_MB_MAX_INPUT_STRING_SIZE 32
+
+static ssize_t ext4_mb_last_groups_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;
+ unsigned int n;
+ 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;
+ for (n = 0; n < sbi->s_mb_nr_global_goals; n++)
+ WRITE_ONCE(sbi->s_mb_last_groups[n], val);
+ return cnt;
+}
+
+static int ext4_mb_seq_last_groups_seq_show(struct seq_file *m, void *v)
+{
+ struct ext4_sb_info *sbi = EXT4_SB(m->private);
+ unsigned int n;
+
+ for (n = 0; n < sbi->s_mb_nr_global_goals; n++)
+ seq_printf(m , "%u# %u\n", n,
+ READ_ONCE(sbi->s_mb_last_groups[n]));
+
+ return 0;
+}
+
+static int ext4_mb_seq_last_groups_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ext4_mb_seq_last_groups_seq_show,
+ pde_data(inode));
+}
+
+const struct proc_ops ext4_seq_mb_last_groups_fops = {
+ .proc_open = ext4_mb_seq_last_groups_open,
+ .proc_read = seq_read,
+ .proc_lseek = seq_lseek,
+ .proc_release = seq_release,
+ .proc_write = ext4_mb_last_groups_write,
+};
+
/*
* Allocate the top-level s_group_info array for the specified number
* of groups
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -603,6 +603,8 @@ int ext4_register_sysfs(struct super_block *sb)
&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_groups", S_IRUGO, sbi->s_proc,
+ &ext4_seq_mb_last_groups_fops, sb);
proc_create_single_data("mb_stats", 0444, sbi->s_proc,
ext4_seq_mb_stats_show, sb);
proc_create_seq_data("mb_structs_summary", 0444, sbi->s_proc,
--
2.48.1