diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-09-23 18:07:35 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-09-23 18:07:35 -0400 |
commit | 5e8814f2f74f53d58aa5679bf32b38a7940033fe (patch) | |
tree | 05f70d1d57d20111a57cd35fb971e36f836d24e8 /fs/ext4/mballoc.c | |
parent | 9f6200bbfc962d8f926278cf5d5ddb90a228c322 (diff) |
ext4: Combine proc file handling into a single set of functions
Previously mballoc created a separate set of functions for each proc
file. This combines the tunables into a single set of functions which
gets used for all of the per-superblock proc files, saving
approximately 2k of compiled object code.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 69 |
1 files changed, 6 insertions, 63 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 842d4017006e..b9118bb29939 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2721,63 +2721,6 @@ ext4_mb_free_committed_blocks(struct super_block *sb) | |||
2721 | #define EXT4_MB_STREAM_REQ "stream_req" | 2721 | #define EXT4_MB_STREAM_REQ "stream_req" |
2722 | #define EXT4_MB_GROUP_PREALLOC "group_prealloc" | 2722 | #define EXT4_MB_GROUP_PREALLOC "group_prealloc" |
2723 | 2723 | ||
2724 | #define MB_PROC_FOPS(name) \ | ||
2725 | static int ext4_mb_##name##_proc_show(struct seq_file *m, void *v) \ | ||
2726 | { \ | ||
2727 | struct ext4_sb_info *sbi = m->private; \ | ||
2728 | \ | ||
2729 | seq_printf(m, "%ld\n", sbi->s_mb_##name); \ | ||
2730 | return 0; \ | ||
2731 | } \ | ||
2732 | \ | ||
2733 | static int ext4_mb_##name##_proc_open(struct inode *inode, struct file *file)\ | ||
2734 | { \ | ||
2735 | return single_open(file, ext4_mb_##name##_proc_show, PDE(inode)->data);\ | ||
2736 | } \ | ||
2737 | \ | ||
2738 | static ssize_t ext4_mb_##name##_proc_write(struct file *file, \ | ||
2739 | const char __user *buf, size_t cnt, loff_t *ppos) \ | ||
2740 | { \ | ||
2741 | struct ext4_sb_info *sbi = PDE(file->f_path.dentry->d_inode)->data;\ | ||
2742 | char str[32]; \ | ||
2743 | long value; \ | ||
2744 | if (cnt >= sizeof(str)) \ | ||
2745 | return -EINVAL; \ | ||
2746 | if (copy_from_user(str, buf, cnt)) \ | ||
2747 | return -EFAULT; \ | ||
2748 | value = simple_strtol(str, NULL, 0); \ | ||
2749 | if (value <= 0) \ | ||
2750 | return -ERANGE; \ | ||
2751 | sbi->s_mb_##name = value; \ | ||
2752 | return cnt; \ | ||
2753 | } \ | ||
2754 | \ | ||
2755 | static const struct file_operations ext4_mb_##name##_proc_fops = { \ | ||
2756 | .owner = THIS_MODULE, \ | ||
2757 | .open = ext4_mb_##name##_proc_open, \ | ||
2758 | .read = seq_read, \ | ||
2759 | .llseek = seq_lseek, \ | ||
2760 | .release = single_release, \ | ||
2761 | .write = ext4_mb_##name##_proc_write, \ | ||
2762 | }; | ||
2763 | |||
2764 | MB_PROC_FOPS(stats); | ||
2765 | MB_PROC_FOPS(max_to_scan); | ||
2766 | MB_PROC_FOPS(min_to_scan); | ||
2767 | MB_PROC_FOPS(order2_reqs); | ||
2768 | MB_PROC_FOPS(stream_request); | ||
2769 | MB_PROC_FOPS(group_prealloc); | ||
2770 | |||
2771 | #define MB_PROC_HANDLER(name, var) \ | ||
2772 | do { \ | ||
2773 | proc = proc_create_data(name, mode, sbi->s_proc, \ | ||
2774 | &ext4_mb_##var##_proc_fops, sbi); \ | ||
2775 | if (proc == NULL) { \ | ||
2776 | printk(KERN_ERR "EXT4-fs: can't to create %s\n", name); \ | ||
2777 | goto err_out; \ | ||
2778 | } \ | ||
2779 | } while (0) | ||
2780 | |||
2781 | static int ext4_mb_init_per_dev_proc(struct super_block *sb) | 2724 | static int ext4_mb_init_per_dev_proc(struct super_block *sb) |
2782 | { | 2725 | { |
2783 | mode_t mode = S_IFREG | S_IRUGO | S_IWUSR; | 2726 | mode_t mode = S_IFREG | S_IRUGO | S_IWUSR; |
@@ -2787,12 +2730,12 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb) | |||
2787 | if (sbi->s_proc == NULL) | 2730 | if (sbi->s_proc == NULL) |
2788 | return -EINVAL; | 2731 | return -EINVAL; |
2789 | 2732 | ||
2790 | MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); | 2733 | EXT4_PROC_HANDLER(EXT4_MB_STATS_NAME, mb_stats); |
2791 | MB_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, max_to_scan); | 2734 | EXT4_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, mb_max_to_scan); |
2792 | MB_PROC_HANDLER(EXT4_MB_MIN_TO_SCAN_NAME, min_to_scan); | 2735 | EXT4_PROC_HANDLER(EXT4_MB_MIN_TO_SCAN_NAME, mb_min_to_scan); |
2793 | MB_PROC_HANDLER(EXT4_MB_ORDER2_REQ, order2_reqs); | 2736 | EXT4_PROC_HANDLER(EXT4_MB_ORDER2_REQ, mb_order2_reqs); |
2794 | MB_PROC_HANDLER(EXT4_MB_STREAM_REQ, stream_request); | 2737 | EXT4_PROC_HANDLER(EXT4_MB_STREAM_REQ, mb_stream_request); |
2795 | MB_PROC_HANDLER(EXT4_MB_GROUP_PREALLOC, group_prealloc); | 2738 | EXT4_PROC_HANDLER(EXT4_MB_GROUP_PREALLOC, mb_group_prealloc); |
2796 | return 0; | 2739 | return 0; |
2797 | 2740 | ||
2798 | err_out: | 2741 | err_out: |