diff options
author | Eric Sandeen <sandeen@redhat.com> | 2010-10-27 21:30:07 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2010-10-27 21:30:07 -0400 |
commit | 3e1e5f501632460184a98237d5460c521510535e (patch) | |
tree | 9bb5006c9bcb1651f9c447869f4e90deb116e6e8 /fs/ext4/mballoc.c | |
parent | 4d5476164a052e80d4ef430e368e76dbde96801f (diff) |
ext4: don't use ext4_allocation_contexts for tracing
Many tracepoints were populating an ext4_allocation_context
to pass in, but this requires a slab allocation even when
tracepoints are off. In fact, 4 of 5 of these allocations
were only for tracing. In addition, we were only using a
small fraction of the 144 bytes of this structure for this
purpose.
We can do away with all these alloc/frees of the ac and
simply pass in the bits we care about, instead.
I tested this by turning on tracing and running through
xfstests on x86_64. I did not actually do anything with
the trace output, however.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 81 |
1 files changed, 12 insertions, 69 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index ccdfec6acb75..3f62df50f483 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -3591,8 +3591,7 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac) | |||
3591 | */ | 3591 | */ |
3592 | static noinline_for_stack int | 3592 | static noinline_for_stack int |
3593 | ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | 3593 | ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, |
3594 | struct ext4_prealloc_space *pa, | 3594 | struct ext4_prealloc_space *pa) |
3595 | struct ext4_allocation_context *ac) | ||
3596 | { | 3595 | { |
3597 | struct super_block *sb = e4b->bd_sb; | 3596 | struct super_block *sb = e4b->bd_sb; |
3598 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 3597 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
@@ -3610,11 +3609,6 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
3610 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); | 3609 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); |
3611 | end = bit + pa->pa_len; | 3610 | end = bit + pa->pa_len; |
3612 | 3611 | ||
3613 | if (ac) { | ||
3614 | ac->ac_sb = sb; | ||
3615 | ac->ac_inode = pa->pa_inode; | ||
3616 | } | ||
3617 | |||
3618 | while (bit < end) { | 3612 | while (bit < end) { |
3619 | bit = mb_find_next_zero_bit(bitmap_bh->b_data, end, bit); | 3613 | bit = mb_find_next_zero_bit(bitmap_bh->b_data, end, bit); |
3620 | if (bit >= end) | 3614 | if (bit >= end) |
@@ -3625,16 +3619,9 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
3625 | (unsigned) next - bit, (unsigned) group); | 3619 | (unsigned) next - bit, (unsigned) group); |
3626 | free += next - bit; | 3620 | free += next - bit; |
3627 | 3621 | ||
3628 | if (ac) { | 3622 | trace_ext4_mballoc_discard(sb, NULL, group, bit, next - bit); |
3629 | ac->ac_b_ex.fe_group = group; | 3623 | trace_ext4_mb_release_inode_pa(sb, pa->pa_inode, pa, |
3630 | ac->ac_b_ex.fe_start = bit; | 3624 | grp_blk_start + bit, next - bit); |
3631 | ac->ac_b_ex.fe_len = next - bit; | ||
3632 | ac->ac_b_ex.fe_logical = 0; | ||
3633 | trace_ext4_mballoc_discard(ac); | ||
3634 | } | ||
3635 | |||
3636 | trace_ext4_mb_release_inode_pa(sb, ac, pa, grp_blk_start + bit, | ||
3637 | next - bit); | ||
3638 | mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); | 3625 | mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); |
3639 | bit = next + 1; | 3626 | bit = next + 1; |
3640 | } | 3627 | } |
@@ -3657,29 +3644,19 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, | |||
3657 | 3644 | ||
3658 | static noinline_for_stack int | 3645 | static noinline_for_stack int |
3659 | ext4_mb_release_group_pa(struct ext4_buddy *e4b, | 3646 | ext4_mb_release_group_pa(struct ext4_buddy *e4b, |
3660 | struct ext4_prealloc_space *pa, | 3647 | struct ext4_prealloc_space *pa) |
3661 | struct ext4_allocation_context *ac) | ||
3662 | { | 3648 | { |
3663 | struct super_block *sb = e4b->bd_sb; | 3649 | struct super_block *sb = e4b->bd_sb; |
3664 | ext4_group_t group; | 3650 | ext4_group_t group; |
3665 | ext4_grpblk_t bit; | 3651 | ext4_grpblk_t bit; |
3666 | 3652 | ||
3667 | trace_ext4_mb_release_group_pa(sb, ac, pa); | 3653 | trace_ext4_mb_release_group_pa(sb, pa); |
3668 | BUG_ON(pa->pa_deleted == 0); | 3654 | BUG_ON(pa->pa_deleted == 0); |
3669 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); | 3655 | ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); |
3670 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); | 3656 | BUG_ON(group != e4b->bd_group && pa->pa_len != 0); |
3671 | mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len); | 3657 | mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len); |
3672 | atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded); | 3658 | atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded); |
3673 | 3659 | trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len); | |
3674 | if (ac) { | ||
3675 | ac->ac_sb = sb; | ||
3676 | ac->ac_inode = NULL; | ||
3677 | ac->ac_b_ex.fe_group = group; | ||
3678 | ac->ac_b_ex.fe_start = bit; | ||
3679 | ac->ac_b_ex.fe_len = pa->pa_len; | ||
3680 | ac->ac_b_ex.fe_logical = 0; | ||
3681 | trace_ext4_mballoc_discard(ac); | ||
3682 | } | ||
3683 | 3660 | ||
3684 | return 0; | 3661 | return 0; |
3685 | } | 3662 | } |
@@ -3700,7 +3677,6 @@ ext4_mb_discard_group_preallocations(struct super_block *sb, | |||
3700 | struct ext4_group_info *grp = ext4_get_group_info(sb, group); | 3677 | struct ext4_group_info *grp = ext4_get_group_info(sb, group); |
3701 | struct buffer_head *bitmap_bh = NULL; | 3678 | struct buffer_head *bitmap_bh = NULL; |
3702 | struct ext4_prealloc_space *pa, *tmp; | 3679 | struct ext4_prealloc_space *pa, *tmp; |
3703 | struct ext4_allocation_context *ac; | ||
3704 | struct list_head list; | 3680 | struct list_head list; |
3705 | struct ext4_buddy e4b; | 3681 | struct ext4_buddy e4b; |
3706 | int err; | 3682 | int err; |
@@ -3729,9 +3705,6 @@ ext4_mb_discard_group_preallocations(struct super_block *sb, | |||
3729 | needed = EXT4_BLOCKS_PER_GROUP(sb) + 1; | 3705 | needed = EXT4_BLOCKS_PER_GROUP(sb) + 1; |
3730 | 3706 | ||
3731 | INIT_LIST_HEAD(&list); | 3707 | INIT_LIST_HEAD(&list); |
3732 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); | ||
3733 | if (ac) | ||
3734 | ac->ac_sb = sb; | ||
3735 | repeat: | 3708 | repeat: |
3736 | ext4_lock_group(sb, group); | 3709 | ext4_lock_group(sb, group); |
3737 | list_for_each_entry_safe(pa, tmp, | 3710 | list_for_each_entry_safe(pa, tmp, |
@@ -3786,9 +3759,9 @@ repeat: | |||
3786 | spin_unlock(pa->pa_obj_lock); | 3759 | spin_unlock(pa->pa_obj_lock); |
3787 | 3760 | ||
3788 | if (pa->pa_type == MB_GROUP_PA) | 3761 | if (pa->pa_type == MB_GROUP_PA) |
3789 | ext4_mb_release_group_pa(&e4b, pa, ac); | 3762 | ext4_mb_release_group_pa(&e4b, pa); |
3790 | else | 3763 | else |
3791 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); | 3764 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa); |
3792 | 3765 | ||
3793 | list_del(&pa->u.pa_tmp_list); | 3766 | list_del(&pa->u.pa_tmp_list); |
3794 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); | 3767 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); |
@@ -3796,8 +3769,6 @@ repeat: | |||
3796 | 3769 | ||
3797 | out: | 3770 | out: |
3798 | ext4_unlock_group(sb, group); | 3771 | ext4_unlock_group(sb, group); |
3799 | if (ac) | ||
3800 | kmem_cache_free(ext4_ac_cachep, ac); | ||
3801 | ext4_mb_unload_buddy(&e4b); | 3772 | ext4_mb_unload_buddy(&e4b); |
3802 | put_bh(bitmap_bh); | 3773 | put_bh(bitmap_bh); |
3803 | return free; | 3774 | return free; |
@@ -3818,7 +3789,6 @@ void ext4_discard_preallocations(struct inode *inode) | |||
3818 | struct super_block *sb = inode->i_sb; | 3789 | struct super_block *sb = inode->i_sb; |
3819 | struct buffer_head *bitmap_bh = NULL; | 3790 | struct buffer_head *bitmap_bh = NULL; |
3820 | struct ext4_prealloc_space *pa, *tmp; | 3791 | struct ext4_prealloc_space *pa, *tmp; |
3821 | struct ext4_allocation_context *ac; | ||
3822 | ext4_group_t group = 0; | 3792 | ext4_group_t group = 0; |
3823 | struct list_head list; | 3793 | struct list_head list; |
3824 | struct ext4_buddy e4b; | 3794 | struct ext4_buddy e4b; |
@@ -3834,11 +3804,6 @@ void ext4_discard_preallocations(struct inode *inode) | |||
3834 | 3804 | ||
3835 | INIT_LIST_HEAD(&list); | 3805 | INIT_LIST_HEAD(&list); |
3836 | 3806 | ||
3837 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); | ||
3838 | if (ac) { | ||
3839 | ac->ac_sb = sb; | ||
3840 | ac->ac_inode = inode; | ||
3841 | } | ||
3842 | repeat: | 3807 | repeat: |
3843 | /* first, collect all pa's in the inode */ | 3808 | /* first, collect all pa's in the inode */ |
3844 | spin_lock(&ei->i_prealloc_lock); | 3809 | spin_lock(&ei->i_prealloc_lock); |
@@ -3908,7 +3873,7 @@ repeat: | |||
3908 | 3873 | ||
3909 | ext4_lock_group(sb, group); | 3874 | ext4_lock_group(sb, group); |
3910 | list_del(&pa->pa_group_list); | 3875 | list_del(&pa->pa_group_list); |
3911 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); | 3876 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa); |
3912 | ext4_unlock_group(sb, group); | 3877 | ext4_unlock_group(sb, group); |
3913 | 3878 | ||
3914 | ext4_mb_unload_buddy(&e4b); | 3879 | ext4_mb_unload_buddy(&e4b); |
@@ -3917,8 +3882,6 @@ repeat: | |||
3917 | list_del(&pa->u.pa_tmp_list); | 3882 | list_del(&pa->u.pa_tmp_list); |
3918 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); | 3883 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); |
3919 | } | 3884 | } |
3920 | if (ac) | ||
3921 | kmem_cache_free(ext4_ac_cachep, ac); | ||
3922 | } | 3885 | } |
3923 | 3886 | ||
3924 | /* | 3887 | /* |
@@ -4116,14 +4079,10 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb, | |||
4116 | struct ext4_buddy e4b; | 4079 | struct ext4_buddy e4b; |
4117 | struct list_head discard_list; | 4080 | struct list_head discard_list; |
4118 | struct ext4_prealloc_space *pa, *tmp; | 4081 | struct ext4_prealloc_space *pa, *tmp; |
4119 | struct ext4_allocation_context *ac; | ||
4120 | 4082 | ||
4121 | mb_debug(1, "discard locality group preallocation\n"); | 4083 | mb_debug(1, "discard locality group preallocation\n"); |
4122 | 4084 | ||
4123 | INIT_LIST_HEAD(&discard_list); | 4085 | INIT_LIST_HEAD(&discard_list); |
4124 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); | ||
4125 | if (ac) | ||
4126 | ac->ac_sb = sb; | ||
4127 | 4086 | ||
4128 | spin_lock(&lg->lg_prealloc_lock); | 4087 | spin_lock(&lg->lg_prealloc_lock); |
4129 | list_for_each_entry_rcu(pa, &lg->lg_prealloc_list[order], | 4088 | list_for_each_entry_rcu(pa, &lg->lg_prealloc_list[order], |
@@ -4175,15 +4134,13 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb, | |||
4175 | } | 4134 | } |
4176 | ext4_lock_group(sb, group); | 4135 | ext4_lock_group(sb, group); |
4177 | list_del(&pa->pa_group_list); | 4136 | list_del(&pa->pa_group_list); |
4178 | ext4_mb_release_group_pa(&e4b, pa, ac); | 4137 | ext4_mb_release_group_pa(&e4b, pa); |
4179 | ext4_unlock_group(sb, group); | 4138 | ext4_unlock_group(sb, group); |
4180 | 4139 | ||
4181 | ext4_mb_unload_buddy(&e4b); | 4140 | ext4_mb_unload_buddy(&e4b); |
4182 | list_del(&pa->u.pa_tmp_list); | 4141 | list_del(&pa->u.pa_tmp_list); |
4183 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); | 4142 | call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); |
4184 | } | 4143 | } |
4185 | if (ac) | ||
4186 | kmem_cache_free(ext4_ac_cachep, ac); | ||
4187 | } | 4144 | } |
4188 | 4145 | ||
4189 | /* | 4146 | /* |
@@ -4547,7 +4504,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
4547 | { | 4504 | { |
4548 | struct buffer_head *bitmap_bh = NULL; | 4505 | struct buffer_head *bitmap_bh = NULL; |
4549 | struct super_block *sb = inode->i_sb; | 4506 | struct super_block *sb = inode->i_sb; |
4550 | struct ext4_allocation_context *ac = NULL; | ||
4551 | struct ext4_group_desc *gdp; | 4507 | struct ext4_group_desc *gdp; |
4552 | unsigned long freed = 0; | 4508 | unsigned long freed = 0; |
4553 | unsigned int overflow; | 4509 | unsigned int overflow; |
@@ -4602,12 +4558,6 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, | |||
4602 | if (!ext4_should_writeback_data(inode)) | 4558 | if (!ext4_should_writeback_data(inode)) |
4603 | flags |= EXT4_FREE_BLOCKS_METADATA; | 4559 | flags |= EXT4_FREE_BLOCKS_METADATA; |
4604 | 4560 | ||
4605 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); | ||
4606 | if (ac) { | ||
4607 | ac->ac_inode = inode; | ||
4608 | ac->ac_sb = sb; | ||
4609 | } | ||
4610 | |||
4611 | do_more: | 4561 | do_more: |
4612 | overflow = 0; | 4562 | overflow = 0; |
4613 | ext4_get_group_no_and_offset(sb, block, &block_group, &bit); | 4563 | ext4_get_group_no_and_offset(sb, block, &block_group, &bit); |
@@ -4665,12 +4615,7 @@ do_more: | |||
4665 | BUG_ON(!mb_test_bit(bit + i, bitmap_bh->b_data)); | 4615 | BUG_ON(!mb_test_bit(bit + i, bitmap_bh->b_data)); |
4666 | } | 4616 | } |
4667 | #endif | 4617 | #endif |
4668 | if (ac) { | 4618 | trace_ext4_mballoc_free(sb, inode, block_group, bit, count); |
4669 | ac->ac_b_ex.fe_group = block_group; | ||
4670 | ac->ac_b_ex.fe_start = bit; | ||
4671 | ac->ac_b_ex.fe_len = count; | ||
4672 | trace_ext4_mballoc_free(ac); | ||
4673 | } | ||
4674 | 4619 | ||
4675 | err = ext4_mb_load_buddy(sb, block_group, &e4b); | 4620 | err = ext4_mb_load_buddy(sb, block_group, &e4b); |
4676 | if (err) | 4621 | if (err) |
@@ -4741,7 +4686,5 @@ error_return: | |||
4741 | dquot_free_block(inode, freed); | 4686 | dquot_free_block(inode, freed); |
4742 | brelse(bitmap_bh); | 4687 | brelse(bitmap_bh); |
4743 | ext4_std_error(sb, err); | 4688 | ext4_std_error(sb, err); |
4744 | if (ac) | ||
4745 | kmem_cache_free(ext4_ac_cachep, ac); | ||
4746 | return; | 4689 | return; |
4747 | } | 4690 | } |