From patchwork Mon Apr 5 04:30:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jing zhang X-Patchwork-Id: 49367 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 71639B7C33 for ; Mon, 5 Apr 2010 14:30:22 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750789Ab0DEEaV (ORCPT ); Mon, 5 Apr 2010 00:30:21 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:53453 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750732Ab0DEEaU (ORCPT ); Mon, 5 Apr 2010 00:30:20 -0400 Received: by gwb19 with SMTP id 19so1030021gwb.19 for ; Sun, 04 Apr 2010 21:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:cc:content-type; bh=MN4YlTVSVHH3rf3Eh1vUB+izWOyCYcfbBWcUrpNtiS8=; b=AYqPOP9gp04AE/kFLu2fA4jV/UpKV1fs7ROgvJFi8GFsLKZJPYmSQAizwKsel9Bsa4 mEk9LrV1m+yYAJArJ3dIodbEN2FVxO9gqGeLIzwXWyyFOwe4RgXl5yXAa6thp+MranuD XT4uoN6SKS6RtaMPYRbi0AtPtv1HnIvswznB4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=vdVz7W95cof/iosKpD9DgVPpaofZBWcv3KiyG2cH6xWgqGN17/nkart84M/38EVWff Hh0PU3FaIukYVXxMKdm2+v1soSfWzDdUrGo9u88zUbejQ8rAKB402dbwey8J5eU9+Dyt IYkpTHVVZgzk6pQd/V80+ECaZkEptbzRxOnNU= MIME-Version: 1.0 Received: by 10.100.178.6 with HTTP; Sun, 4 Apr 2010 21:30:19 -0700 (PDT) Date: Mon, 5 Apr 2010 12:30:19 +0800 Received: by 10.101.209.21 with SMTP id l21mr12558837anq.114.1270441819516; Sun, 04 Apr 2010 21:30:19 -0700 (PDT) Message-ID: Subject: [PATCH] ext4: BUG_ON triggered in ext4_mb_complex_scan_group() From: jing zhang To: linux-ext4 Cc: "Theodore Ts'o" , "Aneesh Kumar K. V" , Andreas Dilger , Dave Kleikamp Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Jing Zhang Date: Mon Apr 5 12:10:50 2010 BUG_ON is triggered at [line:1762] in ext4_mb_complex_scan_group(), and fix is to change the return value of mb_find_extent() if the needed extent can not be found. The fix can also be applied to other points where mb_find_extent() is called. Cc: Theodore Ts'o Cc: Andreas Dilger Cc: Dave Kleikamp Cc: "Aneesh Kumar K. V" Signed-off-by: Jing Zhang --- fs/ext4/mballoc.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) /* FIXME dorp order completely ? */ @@ -1358,6 +1358,8 @@ static int mb_find_extent(struct ext4_buddy *e4b, int order, int block, } BUG_ON(ex->fe_start + ex->fe_len > (1 << (e4b->bd_blkbits + 3))); + if (needed > ex->fe_len) + return -ENOSPC; return ex->fe_len; } @@ -1758,7 +1760,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, break; } - mb_find_extent(e4b, 0, i, ac->ac_g_ex.fe_len, &ex); + if (0 > mb_find_extent(e4b, 0, i, ac->ac_g_ex.fe_len, &ex)) + break; BUG_ON(ex.fe_len <= 0); if (free < ex.fe_len) { ext4_grp_locked_error(sb, e4b->bd_group, -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index bba1282..fbb6899 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1321,7 +1321,7 @@ static int mb_find_extent(struct ext4_buddy *e4b, int order, int block, ex->fe_len = 0; ex->fe_start = 0; ex->fe_group = 0; - return 0; + return -ENOSPC; }