From patchwork Tue Oct 13 02:20:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 7381071 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 015CA9F731 for ; Tue, 13 Oct 2015 02:20:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F3992066D for ; Tue, 13 Oct 2015 02:20:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54F0820629 for ; Tue, 13 Oct 2015 02:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932340AbbJMCUn (ORCPT ); Mon, 12 Oct 2015 22:20:43 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:64609 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932319AbbJMCUl (ORCPT ); Mon, 12 Oct 2015 22:20:41 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="101760909" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by heian.cn.fujitsu.com with ESMTP; 13 Oct 2015 10:23:06 +0800 Received: from localhost.localdomain (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t9D2K1QJ012662 for ; Tue, 13 Oct 2015 10:20:12 +0800 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v3 19/21] btrfs: Avoid truncate tailing page if fallocate range doesn't exceed inode size Date: Tue, 13 Oct 2015 10:20:25 +0800 Message-Id: <1444702827-18169-20-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1444702827-18169-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1444702827-18169-1-git-send-email-quwenruo@cn.fujitsu.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Current code will always truncate tailing page if its alloc_start is smaller than inode size. This behavior will cause a lot of unneeded COW page size extent. This patch will avoid such problem. Signed-off-by: Qu Wenruo --- v2: Newly introduced v3: None --- fs/btrfs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 35bfabf..e59b123 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2640,7 +2640,7 @@ static long btrfs_fallocate(struct file *file, int mode, alloc_start); if (ret) goto out; - } else { + } else if (offset + len > inode->i_size) { /* * If we are fallocating from the end of the file onward we * need to zero out the end of the page if i_size lands in the