Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95057
b: refs/heads/master
c: c83617d
h: refs/heads/master
i:
  95055: 391932d
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Theodore Ts'o committed Apr 30, 2008
1 parent ae75211 commit 0e970f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3dcf54515aa4981a647ad74859199032965193a5
refs/heads/master: c83617db76353ff30e825874be2c15c185b95759
29 changes: 15 additions & 14 deletions trunk/fs/ext4/mballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3730,9 +3730,9 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac)
*/
static noinline_for_stack int
ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
struct ext4_prealloc_space *pa)
struct ext4_prealloc_space *pa,
struct ext4_allocation_context *ac)
{
struct ext4_allocation_context *ac;
struct super_block *sb = e4b->bd_sb;
struct ext4_sb_info *sbi = EXT4_SB(sb);
unsigned long end;
Expand All @@ -3748,8 +3748,6 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
end = bit + pa->pa_len;

ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);

if (ac) {
ac->ac_sb = sb;
ac->ac_inode = pa->pa_inode;
Expand Down Expand Up @@ -3794,23 +3792,19 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
*/
}
atomic_add(free, &sbi->s_mb_discarded);
if (ac)
kmem_cache_free(ext4_ac_cachep, ac);

return err;
}

static noinline_for_stack int
ext4_mb_release_group_pa(struct ext4_buddy *e4b,
struct ext4_prealloc_space *pa)
struct ext4_prealloc_space *pa,
struct ext4_allocation_context *ac)
{
struct ext4_allocation_context *ac;
struct super_block *sb = e4b->bd_sb;
ext4_group_t group;
ext4_grpblk_t bit;

ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);

if (ac)
ac->ac_op = EXT4_MB_HISTORY_DISCARD;

Expand All @@ -3828,7 +3822,6 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
ac->ac_b_ex.fe_len = pa->pa_len;
ac->ac_b_ex.fe_logical = 0;
ext4_mb_store_history(ac);
kmem_cache_free(ext4_ac_cachep, ac);
}

return 0;
Expand All @@ -3850,6 +3843,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
struct ext4_group_info *grp = ext4_get_group_info(sb, group);
struct buffer_head *bitmap_bh = NULL;
struct ext4_prealloc_space *pa, *tmp;
struct ext4_allocation_context *ac;
struct list_head list;
struct ext4_buddy e4b;
int err;
Expand Down Expand Up @@ -3877,6 +3871,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
grp = ext4_get_group_info(sb, group);
INIT_LIST_HEAD(&list);

ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
repeat:
ext4_lock_group(sb, group);
list_for_each_entry_safe(pa, tmp,
Expand Down Expand Up @@ -3931,16 +3926,18 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
spin_unlock(pa->pa_obj_lock);

if (pa->pa_linear)
ext4_mb_release_group_pa(&e4b, pa);
ext4_mb_release_group_pa(&e4b, pa, ac);
else
ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa);
ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac);

list_del(&pa->u.pa_tmp_list);
call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback);
}

out:
ext4_unlock_group(sb, group);
if (ac)
kmem_cache_free(ext4_ac_cachep, ac);
ext4_mb_release_desc(&e4b);
put_bh(bitmap_bh);
return free;
Expand All @@ -3961,6 +3958,7 @@ void ext4_mb_discard_inode_preallocations(struct inode *inode)
struct super_block *sb = inode->i_sb;
struct buffer_head *bitmap_bh = NULL;
struct ext4_prealloc_space *pa, *tmp;
struct ext4_allocation_context *ac;
ext4_group_t group = 0;
struct list_head list;
struct ext4_buddy e4b;
Expand All @@ -3975,6 +3973,7 @@ void ext4_mb_discard_inode_preallocations(struct inode *inode)

INIT_LIST_HEAD(&list);

ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
repeat:
/* first, collect all pa's in the inode */
spin_lock(&ei->i_prealloc_lock);
Expand Down Expand Up @@ -4039,7 +4038,7 @@ void ext4_mb_discard_inode_preallocations(struct inode *inode)

ext4_lock_group(sb, group);
list_del(&pa->pa_group_list);
ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa);
ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac);
ext4_unlock_group(sb, group);

ext4_mb_release_desc(&e4b);
Expand All @@ -4048,6 +4047,8 @@ void ext4_mb_discard_inode_preallocations(struct inode *inode)
list_del(&pa->u.pa_tmp_list);
call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback);
}
if (ac)
kmem_cache_free(ext4_ac_cachep, ac);
}

/*
Expand Down

0 comments on commit 0e970f9

Please sign in to comment.