From patchwork Mon Jun 27 22:49:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allison Henderson X-Patchwork-Id: 102289 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 26503B6F5C for ; Tue, 28 Jun 2011 08:53:02 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754456Ab1F0Wtb (ORCPT ); Mon, 27 Jun 2011 18:49:31 -0400 Received: from e1.ny.us.ibm.com ([32.97.182.141]:57968 "EHLO e1.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755257Ab1F0Wrc (ORCPT ); Mon, 27 Jun 2011 18:47:32 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e1.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p5RMZWrY001597 for ; Mon, 27 Jun 2011 18:35:32 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p5RMlVHC141858 for ; Mon, 27 Jun 2011 18:47:31 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p5RMlU3v014671 for ; Mon, 27 Jun 2011 18:47:31 -0400 Received: from elm3c80.beaverton.ibm.com (elm3c80.beaverton.ibm.com [9.47.69.80]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p5RMlTHi014585; Mon, 27 Jun 2011 18:47:30 -0400 From: Allison Henderson To: linux-ext4@vger.kernel.org Cc: Allison Henderson Subject: [PATCH 1/2] EXT4: Punch Hole Optimizations: Skip un-needed extent lookup Date: Mon, 27 Jun 2011 15:49:50 -0700 Message-Id: <1309214991-31141-2-git-send-email-achender@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1309214991-31141-1-git-send-email-achender@linux.vnet.ibm.com> References: <1309214991-31141-1-git-send-email-achender@linux.vnet.ibm.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch optimizes the punch hole operation by skipping the tree walking code that is used by truncate. Since punch hole is done through map blocks, the path to the extent is already known in this function, so we do not need to look it up again. Signed-off-by: Allison Henderson --- v2->v3 Rebased to apply onto latest ext4 code :100644 100644 f815cc8... dc5a077... M fs/ext4/extents.c fs/ext4/extents.c | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f815cc8..dc5a077 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3497,8 +3497,27 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, ext4_ext_mark_uninitialized(ex); - err = ext4_ext_remove_space(inode, map->m_lblk, - map->m_lblk + punched_out); + ext4_ext_invalidate_cache(inode); + + err = ext4_ext_rm_leaf(handle, inode, path, + map->m_lblk, map->m_lblk + punched_out); + + if (!err && path->p_hdr->eh_entries == 0) { + /* + * Punch hole freed all of this sub tree, + * so we need to correct eh_depth + */ + err = ext4_ext_get_access(handle, inode, path); + if (err == 0) { + ext_inode_hdr(inode)->eh_depth = 0; + ext_inode_hdr(inode)->eh_max = + cpu_to_le16(ext4_ext_space_root( + inode, 0)); + + err = ext4_ext_dirty( + handle, inode, path); + } + } goto out2; }