diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-01 13:57:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-01 13:57:49 -0400 |
commit | 395d73413c5656c6d7706ae91dcb441f9b7e3074 (patch) | |
tree | 7fadabe996f70d7918583fa2312d4fad19397fcb /fs/ext4/mballoc.c | |
parent | c226fd659fa7b6a7b038df5ae6856a68514bacde (diff) | |
parent | 06705bff9114531a997a7d0c2520bea0f2927410 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (33 commits)
ext4: Regularize mount options
ext4: fix locking typo in mballoc which could cause soft lockup hangs
ext4: fix typo which causes a memory leak on error path
jbd2: Update locking coments
ext4: Rename pa_linear to pa_type
ext4: add checks of block references for non-extent inodes
ext4: Check for an valid i_mode when reading the inode from disk
ext4: Use WRITE_SYNC for commits which are caused by fsync()
ext4: Add auto_da_alloc mount option
ext4: Use struct flex_groups to calculate get_orlov_stats()
ext4: Use atomic_t's in struct flex_groups
ext4: remove /proc tuning knobs
ext4: Add sysfs support
ext4: Track lifetime disk writes
ext4: Fix discard of inode prealloc space with delayed allocation.
ext4: Automatically allocate delay allocated blocks on rename
ext4: Automatically allocate delay allocated blocks on close
ext4: add EXT4_IOC_ALLOC_DA_BLKS ioctl
ext4: Simplify delalloc code by removing mpage_da_writepages()
ext4: Save stack space by removing fake buffer heads
...
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 158 |
1 files changed, 53 insertions, 105 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index b038188bd039..f871677a7984 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -46,22 +46,23 @@ | |||
46 | * The allocation request involve request for multiple number of blocks | 46 | * The allocation request involve request for multiple number of blocks |
47 | * near to the goal(block) value specified. | 47 | * near to the goal(block) value specified. |
48 | * | 48 | * |
49 | * During initialization phase of the allocator we decide to use the group | 49 | * During initialization phase of the allocator we decide to use the |
50 | * preallocation or inode preallocation depending on the size file. The | 50 | * group preallocation or inode preallocation depending on the size of |
51 | * size of the file could be the resulting file size we would have after | 51 | * the file. The size of the file could be the resulting file size we |
52 | * allocation or the current file size which ever is larger. If the size is | 52 | * would have after allocation, or the current file size, which ever |
53 | * less that sbi->s_mb_stream_request we select the group | 53 | * is larger. If the size is less than sbi->s_mb_stream_request we |
54 | * preallocation. The default value of s_mb_stream_request is 16 | 54 | * select to use the group preallocation. The default value of |
55 | * blocks. This can also be tuned via | 55 | * s_mb_stream_request is 16 blocks. This can also be tuned via |
56 | * /proc/fs/ext4/<partition>/stream_req. The value is represented in terms | 56 | * /sys/fs/ext4/<partition>/mb_stream_req. The value is represented in |
57 | * of number of blocks. | 57 | * terms of number of blocks. |
58 | * | 58 | * |
59 | * The main motivation for having small file use group preallocation is to | 59 | * The main motivation for having small file use group preallocation is to |
60 | * ensure that we have small file closer in the disk. | 60 | * ensure that we have small files closer together on the disk. |
61 | * | 61 | * |
62 | * First stage the allocator looks at the inode prealloc list | 62 | * First stage the allocator looks at the inode prealloc list, |
63 | * ext4_inode_info->i_prealloc_list contain list of prealloc spaces for | 63 | * ext4_inode_info->i_prealloc_list, which contains list of prealloc |
64 | * this particular inode. The inode prealloc space is represented as: | 64 | * spaces for this particular inode. The inode prealloc space is |
65 | * represented as: | ||
65 | * | 66 | * |
66 | * pa_lstart -> the logical start block for this prealloc space | 67 | * pa_lstart -> the logical start block for this prealloc space |
67 | * pa_pstart -> the physical start block for this prealloc space | 68 | * pa_pstart -> the physical start block for this prealloc space |
@@ -121,29 +122,29 @@ | |||
121 | * list. In case of inode preallocation we follow a list of heuristics | 122 | * list. In case of inode preallocation we follow a list of heuristics |
122 | * based on file size. This can be found in ext4_mb_normalize_request. If | 123 | * based on file size. This can be found in ext4_mb_normalize_request. If |
123 | * we are doing a group prealloc we try to normalize the request to | 124 | * we are doing a group prealloc we try to normalize the request to |
124 | * sbi->s_mb_group_prealloc. Default value of s_mb_group_prealloc is set to | 125 | * sbi->s_mb_group_prealloc. Default value of s_mb_group_prealloc is |
125 | * 512 blocks. This can be tuned via | 126 | * 512 blocks. This can be tuned via |
126 | * /proc/fs/ext4/<partition/group_prealloc. The value is represented in | 127 | * /sys/fs/ext4/<partition/mb_group_prealloc. The value is represented in |
127 | * terms of number of blocks. If we have mounted the file system with -O | 128 | * terms of number of blocks. If we have mounted the file system with -O |
128 | * stripe=<value> option the group prealloc request is normalized to the | 129 | * stripe=<value> option the group prealloc request is normalized to the |
129 | * stripe value (sbi->s_stripe) | 130 | * stripe value (sbi->s_stripe) |
130 | * | 131 | * |
131 | * The regular allocator(using the buddy cache) support few tunables. | 132 | * The regular allocator(using the buddy cache) supports few tunables. |
132 | * | 133 | * |
133 | * /proc/fs/ext4/<partition>/min_to_scan | 134 | * /sys/fs/ext4/<partition>/mb_min_to_scan |
134 | * /proc/fs/ext4/<partition>/max_to_scan | 135 | * /sys/fs/ext4/<partition>/mb_max_to_scan |
135 | * /proc/fs/ext4/<partition>/order2_req | 136 | * /sys/fs/ext4/<partition>/mb_order2_req |
136 | * | 137 | * |
137 | * The regular allocator use buddy scan only if the request len is power of | 138 | * The regular allocator uses buddy scan only if the request len is power of |
138 | * 2 blocks and the order of allocation is >= sbi->s_mb_order2_reqs. The | 139 | * 2 blocks and the order of allocation is >= sbi->s_mb_order2_reqs. The |
139 | * value of s_mb_order2_reqs can be tuned via | 140 | * value of s_mb_order2_reqs can be tuned via |
140 | * /proc/fs/ext4/<partition>/order2_req. If the request len is equal to | 141 | * /sys/fs/ext4/<partition>/mb_order2_req. If the request len is equal to |
141 | * stripe size (sbi->s_stripe), we try to search for contigous block in | 142 | * stripe size (sbi->s_stripe), we try to search for contigous block in |
142 | * stripe size. This should result in better allocation on RAID setup. If | 143 | * stripe size. This should result in better allocation on RAID setups. If |
143 | * not we search in the specific group using bitmap for best extents. The | 144 | * not, we search in the specific group using bitmap for best extents. The |
144 | * tunable min_to_scan and max_to_scan controll the behaviour here. | 145 | * tunable min_to_scan and max_to_scan control the behaviour here. |
145 | * min_to_scan indicate how long the mballoc __must__ look for a best | 146 | * min_to_scan indicate how long the mballoc __must__ look for a best |
146 | * extent and max_to_scanindicate how long the mballoc __can__ look for a | 147 | * extent and max_to_scan indicates how long the mballoc __can__ look for a |
147 | * best extent in the found extents. Searching for the blocks starts with | 148 | * best extent in the found extents. Searching for the blocks starts with |
148 | * the group specified as the goal value in allocation context via | 149 | * the group specified as the goal value in allocation context via |
149 | * ac_g_ex. Each group is first checked based on the criteria whether it | 150 | * ac_g_ex. Each group is first checked based on the criteria whether it |
@@ -337,8 +338,6 @@ static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, | |||
337 | ext4_group_t group); | 338 | ext4_group_t group); |
338 | static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, | 339 | static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, |
339 | ext4_group_t group); | 340 | ext4_group_t group); |
340 | static int ext4_mb_init_per_dev_proc(struct super_block *sb); | ||
341 | static int ext4_mb_destroy_per_dev_proc(struct super_block *sb); | ||
342 | static void release_blocks_on_commit(journal_t *journal, transaction_t *txn); | 341 | static void release_blocks_on_commit(journal_t *journal, transaction_t *txn); |
343 | 342 | ||
344 | 343 | ||
@@ -1726,6 +1725,7 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac, | |||
1726 | { | 1725 | { |
1727 | unsigned free, fragments; | 1726 | unsigned free, fragments; |
1728 | unsigned i, bits; | 1727 | unsigned i, bits; |
1728 | int flex_size = ext4_flex_bg_size(EXT4_SB(ac->ac_sb)); | ||
1729 | struct ext4_group_desc *desc; | 1729 | struct ext4_group_desc *desc; |
1730 | struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group); | 1730 | struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group); |
1731 | 1731 | ||
@@ -1747,6 +1747,12 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac, | |||
1747 | if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) | 1747 | if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) |
1748 | return 0; | 1748 | return 0; |
1749 | 1749 | ||
1750 | /* Avoid using the first bg of a flexgroup for data files */ | ||
1751 | if ((ac->ac_flags & EXT4_MB_HINT_DATA) && | ||
1752 | (flex_size >= EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME) && | ||
1753 | ((group % flex_size) == 0)) | ||
1754 | return 0; | ||
1755 | |||
1750 | bits = ac->ac_sb->s_blocksize_bits + 1; | 1756 | bits = ac->ac_sb->s_blocksize_bits + 1; |
1751 | for (i = ac->ac_2order; i <= bits; i++) | 1757 | for (i = ac->ac_2order; i <= bits; i++) |
1752 | if (grp->bb_counters[i] > 0) | 1758 | if (grp->bb_counters[i] > 0) |
@@ -1971,7 +1977,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) | |||
1971 | /* | 1977 | /* |
1972 | * We search using buddy data only if the order of the request | 1978 | * We search using buddy data only if the order of the request |
1973 | * is greater than equal to the sbi_s_mb_order2_reqs | 1979 | * is greater than equal to the sbi_s_mb_order2_reqs |
1974 | * You can tune it via /proc/fs/ext4/<partition>/order2_req | 1980 | * You can tune it via /sys/fs/ext4/<partition>/mb_order2_req |
1975 | */ | 1981 | */ |
1976 | if (i >= sbi->s_mb_order2_reqs) { | 1982 | if (i >= sbi->s_mb_order2_reqs) { |
1977 | /* | 1983 | /* |
@@ -2693,7 +2699,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery) | |||
2693 | i = (sb->s_blocksize_bits + 2) * sizeof(unsigned int); | 2699 | i = (sb->s_blocksize_bits + 2) * sizeof(unsigned int); |
2694 | sbi->s_mb_maxs = kmalloc(i, GFP_KERNEL); | 2700 | sbi->s_mb_maxs = kmalloc(i, GFP_KERNEL); |
2695 | if (sbi->s_mb_maxs == NULL) { | 2701 | if (sbi->s_mb_maxs == NULL) { |
2696 | kfree(sbi->s_mb_maxs); | 2702 | kfree(sbi->s_mb_offsets); |
2697 | return -ENOMEM; | 2703 | return -ENOMEM; |
2698 | } | 2704 | } |
2699 | 2705 | ||
@@ -2746,7 +2752,6 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery) | |||
2746 | spin_lock_init(&lg->lg_prealloc_lock); | 2752 | spin_lock_init(&lg->lg_prealloc_lock); |
2747 | } | 2753 | } |
2748 | 2754 | ||
2749 | ext4_mb_init_per_dev_proc(sb); | ||
2750 | ext4_mb_history_init(sb); | 2755 | ext4_mb_history_init(sb); |
2751 | 2756 | ||
2752 | if (sbi->s_journal) | 2757 | if (sbi->s_journal) |
@@ -2829,7 +2834,6 @@ int ext4_mb_release(struct super_block *sb) | |||
2829 | 2834 | ||
2830 | free_percpu(sbi->s_locality_groups); | 2835 | free_percpu(sbi->s_locality_groups); |
2831 | ext4_mb_history_release(sb); | 2836 | ext4_mb_history_release(sb); |
2832 | ext4_mb_destroy_per_dev_proc(sb); | ||
2833 | 2837 | ||
2834 | return 0; | 2838 | return 0; |
2835 | } | 2839 | } |
@@ -2890,62 +2894,6 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) | |||
2890 | mb_debug("freed %u blocks in %u structures\n", count, count2); | 2894 | mb_debug("freed %u blocks in %u structures\n", count, count2); |
2891 | } | 2895 | } |
2892 | 2896 | ||
2893 | #define EXT4_MB_STATS_NAME "stats" | ||
2894 | #define EXT4_MB_MAX_TO_SCAN_NAME "max_to_scan" | ||
2895 | #define EXT4_MB_MIN_TO_SCAN_NAME "min_to_scan" | ||
2896 | #define EXT4_MB_ORDER2_REQ "order2_req" | ||
2897 | #define EXT4_MB_STREAM_REQ "stream_req" | ||
2898 | #define EXT4_MB_GROUP_PREALLOC "group_prealloc" | ||
2899 | |||
2900 | static int ext4_mb_init_per_dev_proc(struct super_block *sb) | ||
2901 | { | ||
2902 | #ifdef CONFIG_PROC_FS | ||
2903 | mode_t mode = S_IFREG | S_IRUGO | S_IWUSR; | ||
2904 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
2905 | struct proc_dir_entry *proc; | ||
2906 | |||
2907 | if (sbi->s_proc == NULL) | ||
2908 | return -EINVAL; | ||
2909 | |||
2910 | EXT4_PROC_HANDLER(EXT4_MB_STATS_NAME, mb_stats); | ||
2911 | EXT4_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, mb_max_to_scan); | ||
2912 | EXT4_PROC_HANDLER(EXT4_MB_MIN_TO_SCAN_NAME, mb_min_to_scan); | ||
2913 | EXT4_PROC_HANDLER(EXT4_MB_ORDER2_REQ, mb_order2_reqs); | ||
2914 | EXT4_PROC_HANDLER(EXT4_MB_STREAM_REQ, mb_stream_request); | ||
2915 | EXT4_PROC_HANDLER(EXT4_MB_GROUP_PREALLOC, mb_group_prealloc); | ||
2916 | return 0; | ||
2917 | |||
2918 | err_out: | ||
2919 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_proc); | ||
2920 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_proc); | ||
2921 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_proc); | ||
2922 | remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc); | ||
2923 | remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc); | ||
2924 | remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc); | ||
2925 | return -ENOMEM; | ||
2926 | #else | ||
2927 | return 0; | ||
2928 | #endif | ||
2929 | } | ||
2930 | |||
2931 | static int ext4_mb_destroy_per_dev_proc(struct super_block *sb) | ||
2932 | { | ||
2933 | #ifdef CONFIG_PROC_FS | ||
2934 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
2935 | |||
2936 | if (sbi->s_proc == NULL) | ||
2937 | return -EINVAL; | ||
2938 | |||
2939 | remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_proc); | ||
2940 | remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_proc); | ||
2941 | remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_proc); | ||
2942 | remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc); | ||
2943 | remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc); | ||
2944 | remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc); | ||
2945 | #endif | ||
2946 | return 0; | ||
2947 | } | ||
2948 | |||
2949 | int __init init_ext4_mballoc(void) | 2897 | int __init init_ext4_mballoc(void) |
2950 | { | 2898 | { |
2951 | ext4_pspace_cachep = | 2899 | ext4_pspace_cachep = |
@@ -3096,9 +3044,8 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
3096 | if (sbi->s_log_groups_per_flex) { | 3044 | if (sbi->s_log_groups_per_flex) { |
3097 | ext4_group_t flex_group = ext4_flex_group(sbi, | 3045 | ext4_group_t flex_group = ext4_flex_group(sbi, |
3098 | ac->ac_b_ex.fe_group); | 3046 | ac->ac_b_ex.fe_group); |
3099 | spin_lock(sb_bgl_lock(sbi, flex_group)); | 3047 | atomic_sub(ac->ac_b_ex.fe_len, |
3100 | sbi->s_flex_groups[flex_group].free_blocks -= ac->ac_b_ex.fe_len; | 3048 | &sbi->s_flex_groups[flex_group].free_blocks); |
3101 | spin_unlock(sb_bgl_lock(sbi, flex_group)); | ||
3102 | } | 3049 | } |
3103 | 3050 | ||
3104 | err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh); | 3051 | err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh); |
@@ -3116,7 +3063,7 @@ out_err: | |||
3116 | * here we normalize request for locality group | 3063 | * here we normalize request for locality group |
3117 | * Group request are normalized to s_strip size if we set the same via mount | 3064 | * Group request are normalized to s_strip size if we set the same via mount |
3118 | * option. If not we set it to s_mb_group_prealloc which can be configured via | 3065 | * option. If not we set it to s_mb_group_prealloc which can be configured via |
3119 | * /proc/fs/ext4/<partition>/group_prealloc | 3066 | * /sys/fs/ext4/<partition>/mb_group_prealloc |
3120 | * | 3067 | * |
3121 | * XXX: should we try to preallocate more than the group has now? | 3068 | * XXX: should we try to preallocate more than the group has now? |
3122 | */ | 3069 | */ |
@@ -3608,8 +3555,11 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac, | |||
3608 | spin_unlock(&pa->pa_lock); | 3555 | spin_unlock(&pa->pa_lock); |
3609 | 3556 | ||
3610 | grp_blk = pa->pa_pstart; | 3557 | grp_blk = pa->pa_pstart; |
3611 | /* If linear, pa_pstart may be in the next group when pa is used up */ | 3558 | /* |
3612 | if (pa->pa_linear) | 3559 | * If doing group-based preallocation, pa_pstart may be in the |
3560 | * next group when pa is used up | ||
3561 | */ | ||
3562 | if (pa->pa_type == MB_GROUP_PA) | ||
3613 | grp_blk--; | 3563 | grp_blk--; |
3614 | 3564 | ||
3615 | ext4_get_group_no_and_offset(sb, grp_blk, &grp, NULL); | 3565 | ext4_get_group_no_and_offset(sb, grp_blk, &grp, NULL); |
@@ -3704,7 +3654,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) | |||
3704 | INIT_LIST_HEAD(&pa->pa_inode_list); | 3654 | INIT_LIST_HEAD(&pa->pa_inode_list); |
3705 | INIT_LIST_HEAD(&pa->pa_group_list); | 3655 | INIT_LIST_HEAD(&pa->pa_group_list); |
3706 | pa->pa_deleted = 0; | 3656 | pa->pa_deleted = 0; |
3707 | pa->pa_linear = 0; | 3657 | pa->pa_type = MB_INODE_PA; |
3708 | 3658 | ||
3709 | mb_debug("new inode pa %p: %llu/%u for %u\n", pa, | 3659 | mb_debug("new inode pa %p: %llu/%u for %u\n", pa, |
3710 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); | 3660 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); |
@@ -3767,7 +3717,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac) | |||
3767 | INIT_LIST_HEAD(&pa->pa_inode_list); | 3717 | INIT_LIST_HEAD(&pa->pa_inode_list); |
3768 | INIT_LIST_HEAD(&pa->pa_group_list); | 3718 | INIT_LIST_HEAD(&pa->pa_group_list); |
3769 | pa->pa_deleted = 0; | 3719 | pa->pa_deleted = 0; |
3770 | pa->pa_linear = 1; | 3720 | pa->pa_type = MB_GROUP_PA; |
3771 | 3721 | ||
3772 | mb_debug("new group pa %p: %llu/%u for %u\n", pa, | 3722 | mb_debug("new group pa %p: %llu/%u for %u\n", pa, |
3773 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); | 3723 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); |
@@ -4021,7 +3971,7 @@ repeat: | |||
4021 | list_del_rcu(&pa->pa_inode_list); | 3971 | list_del_rcu(&pa->pa_inode_list); |
4022 | spin_unlock(pa->pa_obj_lock); | 3972 | spin_unlock(pa->pa_obj_lock); |
4023 | 3973 | ||
4024 | if (pa->pa_linear) | 3974 | if (pa->pa_type == MB_GROUP_PA) |
4025 | ext4_mb_release_group_pa(&e4b, pa, ac); | 3975 | ext4_mb_release_group_pa(&e4b, pa, ac); |
4026 | else | 3976 | else |
4027 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); | 3977 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); |
@@ -4121,7 +4071,7 @@ repeat: | |||
4121 | spin_unlock(&ei->i_prealloc_lock); | 4071 | spin_unlock(&ei->i_prealloc_lock); |
4122 | 4072 | ||
4123 | list_for_each_entry_safe(pa, tmp, &list, u.pa_tmp_list) { | 4073 | list_for_each_entry_safe(pa, tmp, &list, u.pa_tmp_list) { |
4124 | BUG_ON(pa->pa_linear != 0); | 4074 | BUG_ON(pa->pa_type != MB_INODE_PA); |
4125 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL); | 4075 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL); |
4126 | 4076 | ||
4127 | err = ext4_mb_load_buddy(sb, group, &e4b); | 4077 | err = ext4_mb_load_buddy(sb, group, &e4b); |
@@ -4232,7 +4182,7 @@ static inline void ext4_mb_show_ac(struct ext4_allocation_context *ac) | |||
4232 | * file is determined by the current size or the resulting size after | 4182 | * file is determined by the current size or the resulting size after |
4233 | * allocation which ever is larger | 4183 | * allocation which ever is larger |
4234 | * | 4184 | * |
4235 | * One can tune this size via /proc/fs/ext4/<partition>/stream_req | 4185 | * One can tune this size via /sys/fs/ext4/<partition>/mb_stream_req |
4236 | */ | 4186 | */ |
4237 | static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) | 4187 | static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) |
4238 | { | 4188 | { |
@@ -4373,7 +4323,7 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb, | |||
4373 | continue; | 4323 | continue; |
4374 | } | 4324 | } |
4375 | /* only lg prealloc space */ | 4325 | /* only lg prealloc space */ |
4376 | BUG_ON(!pa->pa_linear); | 4326 | BUG_ON(pa->pa_type != MB_GROUP_PA); |
4377 | 4327 | ||
4378 | /* seems this one can be freed ... */ | 4328 | /* seems this one can be freed ... */ |
4379 | pa->pa_deleted = 1; | 4329 | pa->pa_deleted = 1; |
@@ -4442,7 +4392,7 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac) | |||
4442 | pa_inode_list) { | 4392 | pa_inode_list) { |
4443 | spin_lock(&tmp_pa->pa_lock); | 4393 | spin_lock(&tmp_pa->pa_lock); |
4444 | if (tmp_pa->pa_deleted) { | 4394 | if (tmp_pa->pa_deleted) { |
4445 | spin_unlock(&pa->pa_lock); | 4395 | spin_unlock(&tmp_pa->pa_lock); |
4446 | continue; | 4396 | continue; |
4447 | } | 4397 | } |
4448 | if (!added && pa->pa_free < tmp_pa->pa_free) { | 4398 | if (!added && pa->pa_free < tmp_pa->pa_free) { |
@@ -4479,7 +4429,7 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac) | |||
4479 | { | 4429 | { |
4480 | struct ext4_prealloc_space *pa = ac->ac_pa; | 4430 | struct ext4_prealloc_space *pa = ac->ac_pa; |
4481 | if (pa) { | 4431 | if (pa) { |
4482 | if (pa->pa_linear) { | 4432 | if (pa->pa_type == MB_GROUP_PA) { |
4483 | /* see comment in ext4_mb_use_group_pa() */ | 4433 | /* see comment in ext4_mb_use_group_pa() */ |
4484 | spin_lock(&pa->pa_lock); | 4434 | spin_lock(&pa->pa_lock); |
4485 | pa->pa_pstart += ac->ac_b_ex.fe_len; | 4435 | pa->pa_pstart += ac->ac_b_ex.fe_len; |
@@ -4499,7 +4449,7 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac) | |||
4499 | * doesn't grow big. We need to release | 4449 | * doesn't grow big. We need to release |
4500 | * alloc_semp before calling ext4_mb_add_n_trim() | 4450 | * alloc_semp before calling ext4_mb_add_n_trim() |
4501 | */ | 4451 | */ |
4502 | if (pa->pa_linear && likely(pa->pa_free)) { | 4452 | if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) { |
4503 | spin_lock(pa->pa_obj_lock); | 4453 | spin_lock(pa->pa_obj_lock); |
4504 | list_del_rcu(&pa->pa_inode_list); | 4454 | list_del_rcu(&pa->pa_inode_list); |
4505 | spin_unlock(pa->pa_obj_lock); | 4455 | spin_unlock(pa->pa_obj_lock); |
@@ -4936,9 +4886,7 @@ do_more: | |||
4936 | 4886 | ||
4937 | if (sbi->s_log_groups_per_flex) { | 4887 | if (sbi->s_log_groups_per_flex) { |
4938 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); | 4888 | ext4_group_t flex_group = ext4_flex_group(sbi, block_group); |
4939 | spin_lock(sb_bgl_lock(sbi, flex_group)); | 4889 | atomic_add(count, &sbi->s_flex_groups[flex_group].free_blocks); |
4940 | sbi->s_flex_groups[flex_group].free_blocks += count; | ||
4941 | spin_unlock(sb_bgl_lock(sbi, flex_group)); | ||
4942 | } | 4890 | } |
4943 | 4891 | ||
4944 | ext4_mb_release_desc(&e4b); | 4892 | ext4_mb_release_desc(&e4b); |