diff options
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index e72c72a0b807..7f6fc41a2dde 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -3555,8 +3555,11 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac, | |||
3555 | spin_unlock(&pa->pa_lock); | 3555 | spin_unlock(&pa->pa_lock); |
3556 | 3556 | ||
3557 | grp_blk = pa->pa_pstart; | 3557 | grp_blk = pa->pa_pstart; |
3558 | /* If linear, pa_pstart may be in the next group when pa is used up */ | 3558 | /* |
3559 | 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) | ||
3560 | grp_blk--; | 3563 | grp_blk--; |
3561 | 3564 | ||
3562 | ext4_get_group_no_and_offset(sb, grp_blk, &grp, NULL); | 3565 | ext4_get_group_no_and_offset(sb, grp_blk, &grp, NULL); |
@@ -3651,7 +3654,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac) | |||
3651 | INIT_LIST_HEAD(&pa->pa_inode_list); | 3654 | INIT_LIST_HEAD(&pa->pa_inode_list); |
3652 | INIT_LIST_HEAD(&pa->pa_group_list); | 3655 | INIT_LIST_HEAD(&pa->pa_group_list); |
3653 | pa->pa_deleted = 0; | 3656 | pa->pa_deleted = 0; |
3654 | pa->pa_linear = 0; | 3657 | pa->pa_type = MB_INODE_PA; |
3655 | 3658 | ||
3656 | 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, |
3657 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); | 3660 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); |
@@ -3714,7 +3717,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac) | |||
3714 | INIT_LIST_HEAD(&pa->pa_inode_list); | 3717 | INIT_LIST_HEAD(&pa->pa_inode_list); |
3715 | INIT_LIST_HEAD(&pa->pa_group_list); | 3718 | INIT_LIST_HEAD(&pa->pa_group_list); |
3716 | pa->pa_deleted = 0; | 3719 | pa->pa_deleted = 0; |
3717 | pa->pa_linear = 1; | 3720 | pa->pa_type = MB_GROUP_PA; |
3718 | 3721 | ||
3719 | 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, |
3720 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); | 3723 | pa->pa_pstart, pa->pa_len, pa->pa_lstart); |
@@ -3968,7 +3971,7 @@ repeat: | |||
3968 | list_del_rcu(&pa->pa_inode_list); | 3971 | list_del_rcu(&pa->pa_inode_list); |
3969 | spin_unlock(pa->pa_obj_lock); | 3972 | spin_unlock(pa->pa_obj_lock); |
3970 | 3973 | ||
3971 | if (pa->pa_linear) | 3974 | if (pa->pa_type == MB_GROUP_PA) |
3972 | ext4_mb_release_group_pa(&e4b, pa, ac); | 3975 | ext4_mb_release_group_pa(&e4b, pa, ac); |
3973 | else | 3976 | else |
3974 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); | 3977 | ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac); |
@@ -4068,7 +4071,7 @@ repeat: | |||
4068 | spin_unlock(&ei->i_prealloc_lock); | 4071 | spin_unlock(&ei->i_prealloc_lock); |
4069 | 4072 | ||
4070 | 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) { |
4071 | BUG_ON(pa->pa_linear != 0); | 4074 | BUG_ON(pa->pa_type != MB_INODE_PA); |
4072 | 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); |
4073 | 4076 | ||
4074 | err = ext4_mb_load_buddy(sb, group, &e4b); | 4077 | err = ext4_mb_load_buddy(sb, group, &e4b); |
@@ -4320,7 +4323,7 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb, | |||
4320 | continue; | 4323 | continue; |
4321 | } | 4324 | } |
4322 | /* only lg prealloc space */ | 4325 | /* only lg prealloc space */ |
4323 | BUG_ON(!pa->pa_linear); | 4326 | BUG_ON(pa->pa_type != MB_GROUP_PA); |
4324 | 4327 | ||
4325 | /* seems this one can be freed ... */ | 4328 | /* seems this one can be freed ... */ |
4326 | pa->pa_deleted = 1; | 4329 | pa->pa_deleted = 1; |
@@ -4426,7 +4429,7 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac) | |||
4426 | { | 4429 | { |
4427 | struct ext4_prealloc_space *pa = ac->ac_pa; | 4430 | struct ext4_prealloc_space *pa = ac->ac_pa; |
4428 | if (pa) { | 4431 | if (pa) { |
4429 | if (pa->pa_linear) { | 4432 | if (pa->pa_type == MB_GROUP_PA) { |
4430 | /* see comment in ext4_mb_use_group_pa() */ | 4433 | /* see comment in ext4_mb_use_group_pa() */ |
4431 | spin_lock(&pa->pa_lock); | 4434 | spin_lock(&pa->pa_lock); |
4432 | pa->pa_pstart += ac->ac_b_ex.fe_len; | 4435 | pa->pa_pstart += ac->ac_b_ex.fe_len; |
@@ -4446,7 +4449,7 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac) | |||
4446 | * doesn't grow big. We need to release | 4449 | * doesn't grow big. We need to release |
4447 | * alloc_semp before calling ext4_mb_add_n_trim() | 4450 | * alloc_semp before calling ext4_mb_add_n_trim() |
4448 | */ | 4451 | */ |
4449 | if (pa->pa_linear && likely(pa->pa_free)) { | 4452 | if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) { |
4450 | spin_lock(pa->pa_obj_lock); | 4453 | spin_lock(pa->pa_obj_lock); |
4451 | list_del_rcu(&pa->pa_inode_list); | 4454 | list_del_rcu(&pa->pa_inode_list); |
4452 | spin_unlock(pa->pa_obj_lock); | 4455 | spin_unlock(pa->pa_obj_lock); |