From patchwork Thu Nov 29 06:06:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Yang X-Patchwork-Id: 1820231 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E24AD3FC5A for ; Thu, 29 Nov 2012 06:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751344Ab2K2GGd (ORCPT ); Thu, 29 Nov 2012 01:06:33 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:53023 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751039Ab2K2GGd (ORCPT ); Thu, 29 Nov 2012 01:06:33 -0500 X-IronPort-AV: E=Sophos;i="4.83,338,1352044800"; d="scan'208,223";a="6297857" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 29 Nov 2012 14:04:45 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id qAT66VDJ031766 for ; Thu, 29 Nov 2012 14:06:31 +0800 Received: from [10.167.225.168] ([10.167.225.168]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012112914060247-152529 ; Thu, 29 Nov 2012 14:06:02 +0800 Message-ID: <50B6FB48.9060300@cn.fujitsu.com> Date: Thu, 29 Nov 2012 14:06:00 +0800 From: Chen Yang User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: send - pre-allocated file support for btrfs-send mechanism References: <1354158719-15615-1-git-send-email-chenyang.fnst@cn.fujitsu.com> In-Reply-To: <1354158719-15615-1-git-send-email-chenyang.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/29 14:06:02, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/29 14:06:02, Serialize complete at 2012/11/29 14:06:02 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From 4222aa3a32cf4db161fcbbb87ad29b714f1bfaf2 Mon Sep 17 00:00:00 2001 From: Chen Yang Date: Thu, 29 Nov 2012 13:22:09 +0800 Subject: [PATCH] Btrfs: send - pre-allocated file support for btrfs-send mechanism when send or receive a file which has pre-allocated part, the pre-allocated parts of the file will be sent as ZERO streams, and it's unnecessary. So we can improve this by skip these EMPTY parts. Signed-off-by: Cheng Yang --- this patch is based on "Btrfs: send - sparse file support for btrfs-send mechanism" --- fs/btrfs/send.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 1e1d59a..2d23184 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -3732,13 +3732,18 @@ static int send_write_or_clone(struct send_ctx *sctx, * sure to send the whole thing */ len = PAGE_CACHE_ALIGN(len); - } else { + } else if (type == BTRFS_FILE_EXTENT_REG) { bytenr = btrfs_file_extent_disk_bytenr(path->nodes[0], ei); if (bytenr == 0) { ret = 0; goto out; } len = btrfs_file_extent_num_bytes(path->nodes[0], ei); + } else if (type == BTRFS_FILE_EXTENT_PREALLOC) { + ret = 0; + goto out; + } else { + BUG(); } if (offset + len > sctx->cur_inode_size)