From patchwork Thu Jul 25 23:42:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 261989 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 291BB2C00B3 for ; Fri, 26 Jul 2013 09:42:22 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755070Ab3GYXmV (ORCPT ); Thu, 25 Jul 2013 19:42:21 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:53882 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755903Ab3GYXmU (ORCPT ); Thu, 25 Jul 2013 19:42:20 -0400 Received: by mail-pa0-f43.google.com with SMTP id hz10so1590697pad.2 for ; Thu, 25 Jul 2013 16:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=F40gqvYMr3JsgMFi497UTPNpXw4Qv3SpN/cpZNeVC9o=; b=Ti2O3JhLl/YDhDQBkm21uJlglPZ+LuAnIoxAyOTFzU6z2m7eWSX228ACByNm/71WHD ZxAnqEXtUkKrKK3PMEmOisLtwwsOnWcWgBB+i/lVkBgDjxxkdTSWDSncbYUhG4LWhk6+ DLpKGKufk/OHdc21EL8ypbsUFPqIeQ6ozgfbG7xsqBFbCcS8MVY6ofOuv9Isyde4K5cO YcO4b3G4L7TOBXV5rLVsLM8oL+k2sQ7y4q+GmkAdn3KPzx9DpV61NFyWXK7adLAUQb8E iGrLIuDW+0pP8BbU0ij9QKoP5cME9pbVcKsi02ts7Y0McWIClcW6S0jK9B2FOgKf7EB2 wELA== X-Received: by 10.66.253.4 with SMTP id zw4mr37088027pac.119.1374795740257; Thu, 25 Jul 2013 16:42:20 -0700 (PDT) Received: from lz-devel.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPSA id y6sm56432190pbl.23.2013.07.25.16.42.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 25 Jul 2013 16:42:19 -0700 (PDT) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Jan Kara , Zheng Liu Subject: [PATCH v2] ext4: remove the entry from es tree when bigalloc is enabled Date: Fri, 26 Jul 2013 07:42:06 +0800 Message-Id: <1374795726-28859-1-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.9.7 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Jan Kara Now in ext4_da_page_release_reservation() we remove the entry from es tree if to_release != 0. But there are two issues. One is that it is wrong when blocksize != pagesize, another is that we don't need to do this if ->s_cluster_ratio == 1 because we will remove the entry in ext4_truncate/ext4_punch_hole. Here we need to do this just because when ->s_cluster_ratio > 1 we will determine whether we can release the reserved space according to ext4_find_delalloc_cluster(). This commit tries to fix these problems. Now we remove the entry from es tree only if ->s_cluster_ratio > 1. Signed-off-by: Jan Kara Signed-off-by: Zheng Liu --- v2: * fix a typo in comment. fs/ext4/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index ba33c67..2cc97a4 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1387,7 +1387,15 @@ static void ext4_da_page_release_reservation(struct page *page, curr_off = next_off; } while ((bh = bh->b_this_page) != head); - if (to_release) { + /* + * Here we need to remove the entry from es tree because when bigalloc + * is enabled we need to determine whether we can release the reserved + * space according to the result of ext4_find_delalloc_cluster(). + * + * If bigalloc is disabled, we don't need to do this here because these + * entries in es tree will be removed in ext4_truncate/ext4_punch_hole. + */ + if (sbi->s_cluster_ratio > 1 && to_release) { lblk = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); ext4_es_remove_extent(inode, lblk, to_release); }