From: Yongqiang Yang Subject: [PATCH 1/2] ext4: check free block counters in ext4_mb_find_by_goal Date: Sun, 2 Sep 2012 17:45:08 +0800 Message-ID: <1346579109-25016-1-git-send-email-xiaoqiangnk@gmail.com> Cc: tytso@mit.edu, Yongqiang Yang To: linux-ext4@vger.kernel.org Return-path: Received: from mail-pz0-f46.google.com ([209.85.210.46]:49383 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063Ab2IBKUd (ORCPT ); Sun, 2 Sep 2012 06:20:33 -0400 Received: by dady13 with SMTP id y13so3013380dad.19 for ; Sun, 02 Sep 2012 03:20:33 -0700 (PDT) Sender: linux-ext4-owner@vger.kernel.org List-ID: Free block counters should be checked before doing allocation. Signed-off-by: Yongqiang Yang --- fs/ext4/mballoc.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 6873571..5d4c21a 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1659,10 +1659,13 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, int max; int err; struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); + struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group); struct ext4_free_extent ex; if (!(ac->ac_flags & EXT4_MB_HINT_TRY_GOAL)) return 0; + if (grp->bb_free == 0) + return 0; err = ext4_mb_load_buddy(ac->ac_sb, group, e4b); if (err) -- 1.7.5.1