linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: send - sparse file support for btrfs-send mechanism
@ 2012-11-29  3:11 Chen Yang
  2012-11-29  6:06 ` [PATCH] Btrfs: send - pre-allocated " Chen Yang
  2012-11-29  8:54 ` [PATCH] Btrfs: send - sparse " Alexander Block
  0 siblings, 2 replies; 7+ messages in thread
From: Chen Yang @ 2012-11-29  3:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Chen Yang

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 <chenyang.fnst@cn.fujitsu.com>
---
 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);
 	}
 
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-01-08 20:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-29  3:11 [PATCH] Btrfs: send - sparse file support for btrfs-send mechanism Chen Yang
2012-11-29  6:06 ` [PATCH] Btrfs: send - pre-allocated " Chen Yang
2012-11-29  8:55   ` Alexander Block
2012-12-01 18:39     ` Alex Lyakas
2012-11-29  8:54 ` [PATCH] Btrfs: send - sparse " Alexander Block
2013-01-08 16:06   ` Alex Lyakas
2013-01-08 20:11     ` Alex Lyakas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).