From patchwork Thu Mar 18 12:39:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jing zhang X-Patchwork-Id: 48032 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 94314B7D0A for ; Thu, 18 Mar 2010 23:39:43 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752992Ab0CRMjm (ORCPT ); Thu, 18 Mar 2010 08:39:42 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:33959 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752896Ab0CRMjl (ORCPT ); Thu, 18 Mar 2010 08:39:41 -0400 Received: by gyg8 with SMTP id 8so978093gyg.19 for ; Thu, 18 Mar 2010 05:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:cc:content-type; bh=llHqCXR0kMwzGbghyQO1qPgjIFZ0pLkKJj5eA1JgAHI=; b=i/BIYq8+wyu3hXdd1T0fld+TCY+Z2/Uhc6AwxUz9uYFFZeaW/5CndDbw4/f1P8/M30 a1ZIqIFrZCsMgOw10v+EbpNIc+5Fc0ENO1l4cffAAkvvCB2ozxq2hYbEGyZWjgJvXqZI x693L5PruhJyIjgkxX0F28sCglN+cXSFAq7IY= 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=pWAsIfFRxU16XJAs3d+N6n15AwEU6OBGxP2Hlju1GZUsdRqfIbdKVXWe6/l35W5YOU JjlKExpDFd/Cumj1MUSljdmcuLj8U/RbQwKZFBcwWpfQS3kqHq6mwIu9isAJUoqFO/g+ fjsZU6z7QwI6zyNpf+FPFzKOgkxIAaUiSRaL8= MIME-Version: 1.0 Received: by 10.101.7.14 with SMTP id k14mr4146134ani.173.1268915980279; Thu, 18 Mar 2010 05:39:40 -0700 (PDT) Date: Thu, 18 Mar 2010 20:39:40 +0800 Message-ID: Subject: [PATCH] ext4: memory leakage in ext4_discard_preallocations From: jing zhang To: linux-ext4 Cc: "Theodore Ts'o" , 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: Thu Mar 18 20:33:44 2010 When unexpected errors occur, there is memory leakage, and more. Cc: Theodore Ts'o Cc: Andreas Dilger Cc: Dave Kleikamp Signed-off-by: Jing Zhang --- -- 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 --- linux-2.6.32/fs/ext4/mballoc.c 2009-12-03 11:51:22.000000000 +0800 +++ zj/mballoc.c 2010-03-18 20:41:32.000000000 +0800 @@ -3717,6 +3717,7 @@ void ext4_discard_preallocations(struct struct list_head list; struct ext4_buddy e4b; int err; + int occurs = 0; if (!S_ISREG(inode->i_mode)) { /*BUG_ON(!list_empty(&ei->i_prealloc_list));*/ @@ -3781,6 +3782,7 @@ repeat: } spin_unlock(&ei->i_prealloc_lock); +best_efforts: list_for_each_entry_safe(pa, tmp, &list, u.pa_tmp_list) { BUG_ON(pa->pa_type != MB_INODE_PA); ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL); @@ -3811,6 +3813,12 @@ repeat: list_del(&pa->u.pa_tmp_list); call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); } + if (! list_empty(&list)) { + if (occurs++ < 2) + goto best_efforts; + else + BUG(); + } if (ac) kmem_cache_free(ext4_ac_cachep, ac); }