From patchwork Wed Jun 29 00:57:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dong X-Patchwork-Id: 102502 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 4CAD3B6F5C for ; Wed, 29 Jun 2011 10:58:04 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750974Ab1F2A6B (ORCPT ); Tue, 28 Jun 2011 20:58:01 -0400 Received: from mail-iw0-f174.google.com ([209.85.214.174]:47994 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750821Ab1F2A6B (ORCPT ); Tue, 28 Jun 2011 20:58:01 -0400 Received: by iwn6 with SMTP id 6so619727iwn.19 for ; Tue, 28 Jun 2011 17:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=8WftAKKF+AWsvVNaYEsfCXcEd/KbR2tV82row1+eBwo=; b=xe9cJUY8Ps1/z8kEzSjZEyIyW+fxOOzBh31yy++i/NAXkIbRt70aOjXbeZFTdmMJud iyBL8k7saTiwhb28aSfERh3G3OodKaemMjnAfnMrrmUbdkn9hRbuqSJQrlOCDyJ1Ptbd t3uu5zWgVD7fUMVFfUmbBudB9ptM+iQSev7uQ= Received: by 10.231.167.197 with SMTP id r5mr163324iby.70.1309309080511; Tue, 28 Jun 2011 17:58:00 -0700 (PDT) Received: from localhost.localdomain ([114.251.86.0]) by mx.google.com with ESMTPS id w11sm335749ibw.41.2011.06.28.17.57.58 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Jun 2011 17:57:59 -0700 (PDT) From: Robin Dong To: linux-ext4@vger.kernel.org Cc: Robin Dong Subject: [PATCH v3] ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT Date: Wed, 29 Jun 2011 08:57:51 +0800 Message-Id: <1309309071-2244-1-git-send-email-sanbai@taobao.com> X-Mailer: git-send-email 1.7.1 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch avoids an extraneous lookup of the extent cache in ext4_ext_map_blocks() when the flag EXT4_GET_BLOCKS_PUNCH_OUT_EXT is absent. The existing logic was performing the lookup but not making use of the result. The patch simply reverses the order of evaluation in the condition. Since ext4_ext_in_cache() does not initialize newex on misses, bypassing its invocation does not introduce any new issue in this regard. Signed-off-by: Robin Dong Reviewed-by: Lukas Czerner Reviewed-by: Eric Gouriou Acked-by: LiuQi --- fs/ext4/extents.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index eb63c7b..fed2633 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3358,8 +3358,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags); /* check in cache */ - if (ext4_ext_in_cache(inode, map->m_lblk, &newex) && - ((flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) == 0)) { + if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) && + ext4_ext_in_cache(inode, map->m_lblk, &newex)) { if (!newex.ee_start_lo && !newex.ee_start_hi) { if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { /*