From patchwork Thu Nov 29 03:11:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Yang X-Patchwork-Id: 1820031 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 4F3243FC5A for ; Thu, 29 Nov 2012 03:50:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932503Ab2K2Dt6 (ORCPT ); Wed, 28 Nov 2012 22:49:58 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:20552 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S932465Ab2K2Dt6 (ORCPT ); Wed, 28 Nov 2012 22:49:58 -0500 X-IronPort-AV: E=Sophos;i="4.83,338,1352044800"; d="scan'208";a="6296467" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 29 Nov 2012 11:48:11 +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 qAT3CZct020428 for ; Thu, 29 Nov 2012 11:12:36 +0800 Received: from fedora.vm ([10.167.225.168]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2012112911120750-148333 ; Thu, 29 Nov 2012 11:12:07 +0800 From: Chen Yang To: linux-btrfs@vger.kernel.org Cc: Chen Yang Subject: [PATCH] Btrfs: send - sparse file support for btrfs-send mechanism Date: Thu, 29 Nov 2012 11:11:59 +0800 Message-Id: <1354158719-15615-1-git-send-email-chenyang.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.7.6 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/29 11:12:07, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/11/29 11:12:08, Serialize complete at 2012/11/29 11:12:08 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org when send/receive a sparse file, the holes of the original file will be filled with zero. The holes will be sent as ZERO streams, and it's unnecessary. So, I improved this by skipping the hole of file while sending. Signed-off-by: Cheng Yang --- fs/btrfs/send.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index e78b297..1e1d59a 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -3718,6 +3718,7 @@ static int send_write_or_clone(struct send_ctx *sctx, u64 pos = 0; u64 len; u32 l; + u64 bytenr; u8 type; ei = btrfs_item_ptr(path->nodes[0], path->slots[0], @@ -3732,6 +3733,11 @@ static int send_write_or_clone(struct send_ctx *sctx, */ len = PAGE_CACHE_ALIGN(len); } else { + 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); }