From patchwork Thu Sep 6 13:16:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqiang Yang X-Patchwork-Id: 182187 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4B7212C0090 for ; Thu, 6 Sep 2012 23:52:28 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752974Ab2IFNw1 (ORCPT ); Thu, 6 Sep 2012 09:52:27 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39117 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751020Ab2IFNw0 (ORCPT ); Thu, 6 Sep 2012 09:52:26 -0400 Received: by pbbrr13 with SMTP id rr13so2536070pbb.19 for ; Thu, 06 Sep 2012 06:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=Rhfe0EC4nvOByNtpQxoRBA7yQfiWogPY75Zi67YdATI=; b=NkNTppzJGjG4NazCnzZ6XYomurNgl1HUGbWDAwe6C6GN3qDpDP38rXXdMlB7iLwr2W LbMIFE/mPf6lsMZLf22k55L2PiEn6hzAzoUh3A1jNIg9NYws2mmidSJ5/CyPPudz0oKh nREZFrO6VurjyX6ZYmbdRxN96AFJfpBeRxvDQcsJq6X50GSFEeCuNu0mPxTsKgkdUkpk i27jL1XURx0Bl2bYne0jDt8jpCwGxretlXuq425OBDCU3CpDv+VBiXcrVTdcgr1e6+bw qix1QuSDc0KfJqVJjOugUPzzdIYLslmVg3RKYHy6k1EbBq69m9tXbLz9NF+T84perf+F fcyw== Received: by 10.68.203.230 with SMTP id kt6mr4604770pbc.163.1346939546118; Thu, 06 Sep 2012 06:52:26 -0700 (PDT) Received: from localhost.localdomain ([106.3.102.60]) by mx.google.com with ESMTPS id ho7sm1387713pbc.3.2012.09.06.06.52.20 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Sep 2012 06:52:23 -0700 (PDT) From: Yongqiang Yang To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, Yongqiang Yang Subject: [PATCH 1/2 v2] ext4: check free block counters in ext4_mb_find_by_goal Date: Thu, 6 Sep 2012 21:16:54 +0800 Message-Id: <1346937415-2866-1-git-send-email-xiaoqiangnk@gmail.com> X-Mailer: git-send-email 1.7.5.1 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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)