diff options
| author | Theodore Ts'o <tytso@mit.edu> | 2008-09-23 09:18:24 -0400 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2008-09-23 09:18:24 -0400 |
| commit | 9f6200bbfc962d8f926278cf5d5ddb90a228c322 (patch) | |
| tree | 86cf42e4f1fff753a38c64d49971efd04bfdd5f9 | |
| parent | f702ba0fd7d50b5f5f5aea5317875a10d40b869f (diff) | |
ext4: move /proc setup and teardown out of mballoc.c
...and into the core setup/teardown code in fs/ext4/super.c so that
other parts of ext4 can define tuning parameters.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
| -rw-r--r-- | fs/ext4/ext4.h | 2 | ||||
| -rw-r--r-- | fs/ext4/ext4_sb.h | 2 | ||||
| -rw-r--r-- | fs/ext4/mballoc.c | 76 | ||||
| -rw-r--r-- | fs/ext4/mballoc.h | 1 | ||||
| -rw-r--r-- | fs/ext4/super.c | 17 |
5 files changed, 42 insertions, 56 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 50a4846c7e71..b9c9371d8164 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
| @@ -955,6 +955,8 @@ ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no) | |||
| 955 | void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, | 955 | void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, |
| 956 | unsigned long *blockgrpp, ext4_grpblk_t *offsetp); | 956 | unsigned long *blockgrpp, ext4_grpblk_t *offsetp); |
| 957 | 957 | ||
| 958 | extern struct proc_dir_entry *ext4_proc_root; | ||
| 959 | |||
| 958 | /* | 960 | /* |
| 959 | * Function prototypes | 961 | * Function prototypes |
| 960 | */ | 962 | */ |
diff --git a/fs/ext4/ext4_sb.h b/fs/ext4/ext4_sb.h index a5577e0ccd3b..95e046e77cb1 100644 --- a/fs/ext4/ext4_sb.h +++ b/fs/ext4/ext4_sb.h | |||
| @@ -61,6 +61,7 @@ struct ext4_sb_info { | |||
| 61 | struct percpu_counter s_dirs_counter; | 61 | struct percpu_counter s_dirs_counter; |
| 62 | struct percpu_counter s_dirtyblocks_counter; | 62 | struct percpu_counter s_dirtyblocks_counter; |
| 63 | struct blockgroup_lock s_blockgroup_lock; | 63 | struct blockgroup_lock s_blockgroup_lock; |
| 64 | struct proc_dir_entry *s_proc; | ||
| 64 | 65 | ||
| 65 | /* root of the per fs reservation window tree */ | 66 | /* root of the per fs reservation window tree */ |
| 66 | spinlock_t s_rsv_window_lock; | 67 | spinlock_t s_rsv_window_lock; |
| @@ -122,7 +123,6 @@ struct ext4_sb_info { | |||
| 122 | int s_mb_history_cur; | 123 | int s_mb_history_cur; |
| 123 | int s_mb_history_max; | 124 | int s_mb_history_max; |
| 124 | int s_mb_history_num; | 125 | int s_mb_history_num; |
| 125 | struct proc_dir_entry *s_mb_proc; | ||
| 126 | spinlock_t s_mb_history_lock; | 126 | spinlock_t s_mb_history_lock; |
| 127 | int s_mb_history_filter; | 127 | int s_mb_history_filter; |
| 128 | 128 | ||
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 14ebd572bea8..842d4017006e 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
| @@ -2170,9 +2170,10 @@ static void ext4_mb_history_release(struct super_block *sb) | |||
| 2170 | { | 2170 | { |
| 2171 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2171 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 2172 | 2172 | ||
| 2173 | remove_proc_entry("mb_groups", sbi->s_mb_proc); | 2173 | if (sbi->s_proc != NULL) { |
| 2174 | remove_proc_entry("mb_history", sbi->s_mb_proc); | 2174 | remove_proc_entry("mb_groups", sbi->s_proc); |
| 2175 | 2175 | remove_proc_entry("mb_history", sbi->s_proc); | |
| 2176 | } | ||
| 2176 | kfree(sbi->s_mb_history); | 2177 | kfree(sbi->s_mb_history); |
| 2177 | } | 2178 | } |
| 2178 | 2179 | ||
| @@ -2181,10 +2182,10 @@ static void ext4_mb_history_init(struct super_block *sb) | |||
| 2181 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2182 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 2182 | int i; | 2183 | int i; |
| 2183 | 2184 | ||
| 2184 | if (sbi->s_mb_proc != NULL) { | 2185 | if (sbi->s_proc != NULL) { |
| 2185 | proc_create_data("mb_history", S_IRUGO, sbi->s_mb_proc, | 2186 | proc_create_data("mb_history", S_IRUGO, sbi->s_proc, |
| 2186 | &ext4_mb_seq_history_fops, sb); | 2187 | &ext4_mb_seq_history_fops, sb); |
| 2187 | proc_create_data("mb_groups", S_IRUGO, sbi->s_mb_proc, | 2188 | proc_create_data("mb_groups", S_IRUGO, sbi->s_proc, |
| 2188 | &ext4_mb_seq_groups_fops, sb); | 2189 | &ext4_mb_seq_groups_fops, sb); |
| 2189 | } | 2190 | } |
| 2190 | 2191 | ||
| @@ -2720,8 +2721,6 @@ ext4_mb_free_committed_blocks(struct super_block *sb) | |||
| 2720 | #define EXT4_MB_STREAM_REQ "stream_req" | 2721 | #define EXT4_MB_STREAM_REQ "stream_req" |
| 2721 | #define EXT4_MB_GROUP_PREALLOC "group_prealloc" | 2722 | #define EXT4_MB_GROUP_PREALLOC "group_prealloc" |
| 2722 | 2723 | ||
| 2723 | |||
| 2724 | |||
| 2725 | #define MB_PROC_FOPS(name) \ | 2724 | #define MB_PROC_FOPS(name) \ |
| 2726 | static int ext4_mb_##name##_proc_show(struct seq_file *m, void *v) \ | 2725 | static int ext4_mb_##name##_proc_show(struct seq_file *m, void *v) \ |
| 2727 | { \ | 2726 | { \ |
| @@ -2771,7 +2770,7 @@ MB_PROC_FOPS(group_prealloc); | |||
| 2771 | 2770 | ||
| 2772 | #define MB_PROC_HANDLER(name, var) \ | 2771 | #define MB_PROC_HANDLER(name, var) \ |
| 2773 | do { \ | 2772 | do { \ |
| 2774 | proc = proc_create_data(name, mode, sbi->s_mb_proc, \ | 2773 | proc = proc_create_data(name, mode, sbi->s_proc, \ |
| 2775 | &ext4_mb_##var##_proc_fops, sbi); \ | 2774 | &ext4_mb_##var##_proc_fops, sbi); \ |
| 2776 | if (proc == NULL) { \ | 2775 | if (proc == NULL) { \ |
| 2777 | printk(KERN_ERR "EXT4-fs: can't to create %s\n", name); \ | 2776 | printk(KERN_ERR "EXT4-fs: can't to create %s\n", name); \ |
| @@ -2784,20 +2783,9 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb) | |||
| 2784 | mode_t mode = S_IFREG | S_IRUGO | S_IWUSR; | 2783 | mode_t mode = S_IFREG | S_IRUGO | S_IWUSR; |
| 2785 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2784 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 2786 | struct proc_dir_entry *proc; | 2785 | struct proc_dir_entry *proc; |
| 2787 | char devname[BDEVNAME_SIZE], *p; | ||
| 2788 | 2786 | ||
| 2789 | if (proc_root_ext4 == NULL) { | 2787 | if (sbi->s_proc == NULL) |
| 2790 | sbi->s_mb_proc = NULL; | ||
| 2791 | return -EINVAL; | 2788 | return -EINVAL; |
| 2792 | } | ||
| 2793 | bdevname(sb->s_bdev, devname); | ||
| 2794 | p = devname; | ||
| 2795 | while ((p = strchr(p, '/'))) | ||
| 2796 | *p = '!'; | ||
| 2797 | |||
| 2798 | sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); | ||
| 2799 | if (!sbi->s_mb_proc) | ||
| 2800 | goto err_create_dir; | ||
| 2801 | 2789 | ||
| 2802 | MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); | 2790 | MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); |
| 2803 | MB_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, max_to_scan); | 2791 | MB_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, max_to_scan); |
| @@ -2805,43 +2793,31 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb) | |||
| 2805 | MB_PROC_HANDLER(EXT4_MB_ORDER2_REQ, order2_reqs); | 2793 | MB_PROC_HANDLER(EXT4_MB_ORDER2_REQ, order2_reqs); |
| 2806 | MB_PROC_HANDLER(EXT4_MB_STREAM_REQ, stream_request); | 2794 | MB_PROC_HANDLER(EXT4_MB_STREAM_REQ, stream_request); |
| 2807 | MB_PROC_HANDLER(EXT4_MB_GROUP_PREALLOC, group_prealloc); | 2795 | MB_PROC_HANDLER(EXT4_MB_GROUP_PREALLOC, group_prealloc); |
| 2808 | |||
| 2809 | return 0; | 2796 | return 0; |
| 2810 | 2797 | ||
| 2811 | err_out: | 2798 | err_out: |
| 2812 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); | 2799 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_proc); |
| 2813 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); | 2800 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_proc); |
| 2814 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); | 2801 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_proc); |
| 2815 | remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_mb_proc); | 2802 | remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc); |
| 2816 | remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_mb_proc); | 2803 | remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc); |
| 2817 | remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_mb_proc); | 2804 | remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc); |
| 2818 | remove_proc_entry(devname, proc_root_ext4); | ||
| 2819 | sbi->s_mb_proc = NULL; | ||
| 2820 | err_create_dir: | ||
| 2821 | printk(KERN_ERR "EXT4-fs: Unable to create %s\n", devname); | ||
| 2822 | |||
| 2823 | return -ENOMEM; | 2805 | return -ENOMEM; |
| 2824 | } | 2806 | } |
| 2825 | 2807 | ||
| 2826 | static int ext4_mb_destroy_per_dev_proc(struct super_block *sb) | 2808 | static int ext4_mb_destroy_per_dev_proc(struct super_block *sb) |
| 2827 | { | 2809 | { |
| 2828 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 2810 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
| 2829 | char devname[BDEVNAME_SIZE], *p; | ||
| 2830 | 2811 | ||
| 2831 | if (sbi->s_mb_proc == NULL) | 2812 | if (sbi->s_proc == NULL) |
| 2832 | return -EINVAL; | 2813 | return -EINVAL; |
| 2833 | 2814 | ||
| 2834 | bdevname(sb->s_bdev, devname); | 2815 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_proc); |
| 2835 | p = devname; | 2816 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_proc); |
| 2836 | while ((p = strchr(p, '/'))) | 2817 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_proc); |
| 2837 | *p = '!'; | 2818 | remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc); |
| 2838 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); | 2819 | remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc); |
| 2839 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); | 2820 | remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc); |
| 2840 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); | ||
| 2841 | remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_mb_proc); | ||
| 2842 | remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_mb_proc); | ||
| 2843 | remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_mb_proc); | ||
| 2844 | remove_proc_entry(devname, proc_root_ext4); | ||
| 2845 | 2821 | ||
| 2846 | return 0; | 2822 | return 0; |
| 2847 | } | 2823 | } |
| @@ -2863,11 +2839,6 @@ int __init init_ext4_mballoc(void) | |||
| 2863 | kmem_cache_destroy(ext4_pspace_cachep); | 2839 | kmem_cache_destroy(ext4_pspace_cachep); |
| 2864 | return -ENOMEM; | 2840 | return -ENOMEM; |
| 2865 | } | 2841 | } |
| 2866 | #ifdef CONFIG_PROC_FS | ||
| 2867 | proc_root_ext4 = proc_mkdir("fs/ext4", NULL); | ||
| 2868 | if (proc_root_ext4 == NULL) | ||
| 2869 | printk(KERN_ERR "EXT4-fs: Unable to create fs/ext4\n"); | ||
| 2870 | #endif | ||
| 2871 | return 0; | 2842 | return 0; |
| 2872 | } | 2843 | } |
| 2873 | 2844 | ||
| @@ -2876,9 +2847,6 @@ void exit_ext4_mballoc(void) | |||
| 2876 | /* XXX: synchronize_rcu(); */ | 2847 | /* XXX: synchronize_rcu(); */ |
| 2877 | kmem_cache_destroy(ext4_pspace_cachep); | 2848 | kmem_cache_destroy(ext4_pspace_cachep); |
| 2878 | kmem_cache_destroy(ext4_ac_cachep); | 2849 | kmem_cache_destroy(ext4_ac_cachep); |
| 2879 | #ifdef CONFIG_PROC_FS | ||
| 2880 | remove_proc_entry("fs/ext4", NULL); | ||
| 2881 | #endif | ||
| 2882 | } | 2850 | } |
| 2883 | 2851 | ||
| 2884 | 2852 | ||
diff --git a/fs/ext4/mballoc.h b/fs/ext4/mballoc.h index c7c9906c2a75..b3b4828f8b89 100644 --- a/fs/ext4/mballoc.h +++ b/fs/ext4/mballoc.h | |||
| @@ -257,7 +257,6 @@ static void ext4_mb_store_history(struct ext4_allocation_context *ac); | |||
| 257 | 257 | ||
| 258 | #define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1) | 258 | #define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1) |
| 259 | 259 | ||
| 260 | static struct proc_dir_entry *proc_root_ext4; | ||
| 261 | struct buffer_head *read_block_bitmap(struct super_block *, ext4_group_t); | 260 | struct buffer_head *read_block_bitmap(struct super_block *, ext4_group_t); |
| 262 | 261 | ||
| 263 | static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, | 262 | static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index fb5766e2bffe..7feeec6f7c39 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include <linux/namei.h> | 34 | #include <linux/namei.h> |
| 35 | #include <linux/quotaops.h> | 35 | #include <linux/quotaops.h> |
| 36 | #include <linux/seq_file.h> | 36 | #include <linux/seq_file.h> |
| 37 | #include <linux/proc_fs.h> | ||
| 37 | #include <linux/log2.h> | 38 | #include <linux/log2.h> |
| 38 | #include <linux/crc16.h> | 39 | #include <linux/crc16.h> |
| 39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
| @@ -45,6 +46,8 @@ | |||
| 45 | #include "namei.h" | 46 | #include "namei.h" |
| 46 | #include "group.h" | 47 | #include "group.h" |
| 47 | 48 | ||
| 49 | struct proc_dir_entry *ext4_proc_root; | ||
| 50 | |||
| 48 | static int ext4_load_journal(struct super_block *, struct ext4_super_block *, | 51 | static int ext4_load_journal(struct super_block *, struct ext4_super_block *, |
| 49 | unsigned long journal_devnum); | 52 | unsigned long journal_devnum); |
| 50 | static int ext4_create_journal(struct super_block *, struct ext4_super_block *, | 53 | static int ext4_create_journal(struct super_block *, struct ext4_super_block *, |
| @@ -512,6 +515,8 @@ static void ext4_put_super(struct super_block *sb) | |||
| 512 | mark_buffer_dirty(sbi->s_sbh); | 515 | mark_buffer_dirty(sbi->s_sbh); |
| 513 | ext4_commit_super(sb, es, 1); | 516 | ext4_commit_super(sb, es, 1); |
| 514 | } | 517 | } |
| 518 | if (sbi->s_proc) | ||
| 519 | remove_proc_entry(sb->s_id, ext4_proc_root); | ||
| 515 | 520 | ||
| 516 | for (i = 0; i < sbi->s_gdb_count; i++) | 521 | for (i = 0; i < sbi->s_gdb_count; i++) |
| 517 | brelse(sbi->s_group_desc[i]); | 522 | brelse(sbi->s_group_desc[i]); |
| @@ -1916,6 +1921,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1916 | unsigned long journal_devnum = 0; | 1921 | unsigned long journal_devnum = 0; |
| 1917 | unsigned long def_mount_opts; | 1922 | unsigned long def_mount_opts; |
| 1918 | struct inode *root; | 1923 | struct inode *root; |
| 1924 | char *cp; | ||
| 1919 | int ret = -EINVAL; | 1925 | int ret = -EINVAL; |
| 1920 | int blocksize; | 1926 | int blocksize; |
| 1921 | int db_count; | 1927 | int db_count; |
| @@ -1936,6 +1942,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1936 | 1942 | ||
| 1937 | unlock_kernel(); | 1943 | unlock_kernel(); |
| 1938 | 1944 | ||
| 1945 | /* Cleanup superblock name */ | ||
| 1946 | for (cp = sb->s_id; (cp = strchr(cp, '/'));) | ||
| 1947 | *cp = '!'; | ||
| 1948 | |||
| 1939 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); | 1949 | blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE); |
| 1940 | if (!blocksize) { | 1950 | if (!blocksize) { |
| 1941 | printk(KERN_ERR "EXT4-fs: unable to set blocksize\n"); | 1951 | printk(KERN_ERR "EXT4-fs: unable to set blocksize\n"); |
| @@ -2221,6 +2231,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 2221 | goto failed_mount; | 2231 | goto failed_mount; |
| 2222 | } | 2232 | } |
| 2223 | 2233 | ||
| 2234 | if (ext4_proc_root) | ||
| 2235 | sbi->s_proc = proc_mkdir(sb->s_id, ext4_proc_root); | ||
| 2236 | |||
| 2224 | bgl_lock_init(&sbi->s_blockgroup_lock); | 2237 | bgl_lock_init(&sbi->s_blockgroup_lock); |
| 2225 | 2238 | ||
| 2226 | for (i = 0; i < db_count; i++) { | 2239 | for (i = 0; i < db_count; i++) { |
| @@ -2500,6 +2513,8 @@ failed_mount2: | |||
| 2500 | brelse(sbi->s_group_desc[i]); | 2513 | brelse(sbi->s_group_desc[i]); |
| 2501 | kfree(sbi->s_group_desc); | 2514 | kfree(sbi->s_group_desc); |
| 2502 | failed_mount: | 2515 | failed_mount: |
| 2516 | if (sbi->s_proc) | ||
| 2517 | remove_proc_entry(sb->s_id, ext4_proc_root); | ||
| 2503 | #ifdef CONFIG_QUOTA | 2518 | #ifdef CONFIG_QUOTA |
| 2504 | for (i = 0; i < MAXQUOTAS; i++) | 2519 | for (i = 0; i < MAXQUOTAS; i++) |
| 2505 | kfree(sbi->s_qf_names[i]); | 2520 | kfree(sbi->s_qf_names[i]); |
| @@ -3538,6 +3553,7 @@ static int __init init_ext4_fs(void) | |||
| 3538 | { | 3553 | { |
| 3539 | int err; | 3554 | int err; |
| 3540 | 3555 | ||
| 3556 | ext4_proc_root = proc_mkdir("fs/ext4", NULL); | ||
| 3541 | err = init_ext4_mballoc(); | 3557 | err = init_ext4_mballoc(); |
| 3542 | if (err) | 3558 | if (err) |
| 3543 | return err; | 3559 | return err; |
| @@ -3567,6 +3583,7 @@ static void __exit exit_ext4_fs(void) | |||
| 3567 | destroy_inodecache(); | 3583 | destroy_inodecache(); |
| 3568 | exit_ext4_xattr(); | 3584 | exit_ext4_xattr(); |
| 3569 | exit_ext4_mballoc(); | 3585 | exit_ext4_mballoc(); |
| 3586 | remove_proc_entry("fs/ext4", NULL); | ||
| 3570 | } | 3587 | } |
| 3571 | 3588 | ||
| 3572 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); | 3589 | MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); |
