From 56684fd5bcba9d315e8bae6fd30a1ccb0b2977fa Mon Sep 17 00:00:00 2001 From: "Aneesh Kumar K.V" Date: Wed, 9 Sep 2009 23:34:50 -0400 Subject: [PATCH] --- yaml --- r: 163677 b: refs/heads/master c: f41c0750538667b87a19c93952e5d42fcc069bd7 h: refs/heads/master i: 163675: 42060d545b26d6bcde4e2dd4e2c4fa3387d07249 v: v3 --- [refs] | 2 +- trunk/fs/ext4/mballoc.c | 39 ++++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/[refs] b/[refs] index 810ea8634025..7fde204cc630 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b6a758ec3af3ec236dbfdcf6a06b84ac8f94957e +refs/heads/master: f41c0750538667b87a19c93952e5d42fcc069bd7 diff --git a/trunk/fs/ext4/mballoc.c b/trunk/fs/ext4/mballoc.c index fed5ac699141..484c9d10c7fa 100644 --- a/trunk/fs/ext4/mballoc.c +++ b/trunk/fs/ext4/mballoc.c @@ -1034,8 +1034,26 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, * groups mapped by the page is blocked * till we are done with allocation */ +repeat_load_buddy: down_read(e4b->alloc_semp); + if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { + /* we need to check for group need init flag + * with alloc_semp held so that we can be sure + * that new blocks didn't get added to the group + * when we are loading the buddy cache + */ + up_read(e4b->alloc_semp); + /* + * we need full data about the group + * to make a good selection + */ + ret = ext4_mb_init_group(sb, group); + if (ret) + return ret; + goto repeat_load_buddy; + } + /* * the buddy cache inode stores the block bitmap * and buddy information in consecutive blocks. @@ -2012,27 +2030,6 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) if (grp->bb_free == 0) continue; - /* - * if the group is already init we check whether it is - * a good group and if not we don't load the buddy - */ - if (EXT4_MB_GRP_NEED_INIT(grp)) { - /* - * we need full data about the group - * to make a good selection - */ - err = ext4_mb_init_group(sb, group); - if (err) - goto out; - } - - /* - * If the particular group doesn't satisfy our - * criteria we continue with the next group - */ - if (!ext4_mb_good_group(ac, group, cr)) - continue; - err = ext4_mb_load_buddy(sb, group, &e4b); if (err) goto out;