From patchwork Thu Mar 25 15:24:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jing zhang X-Patchwork-Id: 48528 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 D57B5B7C98 for ; Fri, 26 Mar 2010 02:24:17 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753553Ab0CYPYP (ORCPT ); Thu, 25 Mar 2010 11:24:15 -0400 Received: from mail-iw0-f182.google.com ([209.85.223.182]:34269 "EHLO mail-iw0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753528Ab0CYPYO (ORCPT ); Thu, 25 Mar 2010 11:24:14 -0400 Received: by iwn12 with SMTP id 12so7421689iwn.21 for ; Thu, 25 Mar 2010 08:24:14 -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=ZhIiGUpPMxi3kr8Dz8eG6QR5KYma28xyzfd9hGqwIhM=; b=XxHNnsLo1vNKzF6Syn5chKoAwRJSAwIvGNRDh5UL80QEtpGogfzLt3+7SmlGbzea+S uihtNSbmVV36xa6SxspZFVxVAaF7e3HtCUt707rVo2y6eIP9QiLxX7oHCOMZCs60w54q veyYf5SgDy21+VFdma9mBWW6qCIUfInmxSm4o= 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=nrTg6xj5cAhHCBNiHGI0pVoE/wGmx9jV6azS9q0UhCxi0UAyY7U2yIvWzPF2LIP/3V f6GPvUqDZhl0K8YOm+4FNxEE2P6LFqArBZQdCJSTFLe3rJVs+Z0KA7umNirVR4YGp7Ob 31Es9CfTIh/zlhv9YwYye1V5zBCrqffyHiT40= MIME-Version: 1.0 Received: by 10.114.186.14 with SMTP id j14mr6617202waf.60.1269530653718; Thu, 25 Mar 2010 08:24:13 -0700 (PDT) Date: Thu, 25 Mar 2010 23:24:13 +0800 Message-ID: Subject: [PATCH 1/2] ext4: try to relieve ext4_mb_discard_group_preallocations() from hard work in simple way From: jing zhang To: linux-ext4 Cc: "Theodore Ts'o" , Andreas Dilger , Dave Kleikamp , "Aneesh Kumar K. V" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Jing Zhang Date: Wed Mar 25 23:15:06 2010 The function, ext4_mb_discard_group_preallocations(), works alone as hard as possible without correct understanding its caller's good thinking. And now try to relieve it in simple way. But the variable, free, may be replaced with freed. Cc: Theodore Ts'o Cc: Andreas Dilger Cc: Dave Kleikamp Cc: "Aneesh Kumar K. V" 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 +++ ext4_mm_leak/mballoc-11-1.c 2010-03-25 23:06:00.000000000 +0800 @@ -3633,7 +3633,7 @@ repeat: spin_lock(&pa->pa_lock); if (atomic_read(&pa->pa_count)) { spin_unlock(&pa->pa_lock); - busy = 1; + busy += 1; continue; } if (pa->pa_deleted) { @@ -3654,7 +3654,7 @@ repeat: } /* if we still need more blocks and some PAs were used, try again */ - if (free < needed && busy) { + if (free < needed && needed <= free + busy) { busy = 0; ext4_unlock_group(sb, group); /*