* [PATCH] Btrfs: fix send to deal with sparse files properly V2
@ 2013-08-22 15:47 Josef Bacik
2013-08-30 2:15 ` Wang Shilong
0 siblings, 1 reply; 3+ messages in thread
From: Josef Bacik @ 2013-08-22 15:47 UTC (permalink / raw)
To: linux-btrfs
Send was just sending everything it found, even if the extent was a hole. This
is unpleasant for users, so just skip holes when we are sending. This will also
skip sending prealloc extents since the send spec doesn't have a prealloc
command. Eventually we will add a prealloc command and rev the send version so
we can send down the prealloc info. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
V1->V2: fix where we were skipping holes that needed to be written because we
punched a hole between the original snapshot and the send snapshot.
fs/btrfs/send.c | 34 +++++++++++++++++++++++++++++++---
1 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index db7da68..cbe92da 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -3920,7 +3920,8 @@ static int is_extent_unchanged(struct send_ctx *sctx,
btrfs_item_key_to_cpu(eb, &found_key, slot);
if (found_key.objectid != key.objectid ||
found_key.type != key.type) {
- ret = 0;
+ /* If we're a hole then just pretend nothing changed */
+ ret = (left_disknr) ? 0 : 1;
goto out;
}
@@ -3946,7 +3947,8 @@ static int is_extent_unchanged(struct send_ctx *sctx,
* This may only happen on the first iteration.
*/
if (found_key.offset + right_len <= ekey->offset) {
- ret = 0;
+ /* If we're a hole just pretend nothing changed */
+ ret = (left_disknr) ? 0 : 1;
goto out;
}
@@ -4011,8 +4013,8 @@ static int process_extent(struct send_ctx *sctx,
struct btrfs_path *path,
struct btrfs_key *key)
{
- int ret = 0;
struct clone_root *found_clone = NULL;
+ int ret = 0;
if (S_ISLNK(sctx->cur_inode_mode))
return 0;
@@ -4025,6 +4027,32 @@ static int process_extent(struct send_ctx *sctx,
ret = 0;
goto out;
}
+ } else {
+ struct btrfs_file_extent_item *ei;
+ u8 type;
+
+ ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
+ struct btrfs_file_extent_item);
+ type = btrfs_file_extent_type(path->nodes[0], ei);
+ if (type == BTRFS_FILE_EXTENT_PREALLOC ||
+ type == BTRFS_FILE_EXTENT_REG) {
+ /*
+ * The send spec does not have a prealloc command yet,
+ * so just leave a hole for prealloc'ed extents until
+ * we have enough commands queued up to justify rev'ing
+ * the send spec.
+ */
+ if (type == BTRFS_FILE_EXTENT_PREALLOC) {
+ ret = 0;
+ goto out;
+ }
+
+ /* Have a hole, just skip it. */
+ if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0) {
+ ret = 0;
+ goto out;
+ }
+ }
}
ret = find_extent_clone(sctx, path, key->objectid, key->offset,
--
1.7.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: fix send to deal with sparse files properly V2
2013-08-22 15:47 [PATCH] Btrfs: fix send to deal with sparse files properly V2 Josef Bacik
@ 2013-08-30 2:15 ` Wang Shilong
2013-08-30 12:24 ` Josef Bacik
0 siblings, 1 reply; 3+ messages in thread
From: Wang Shilong @ 2013-08-30 2:15 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs
On 08/22/2013 11:47 PM, Josef Bacik wrote:
please use checkpatch.pl to check coding styles before sending patches:
WARNING: line over 80 characters
#86: FILE: fs/btrfs/send.c:4051:
+ if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0) {
total: 0 errors, 1 warnings, 59 lines checked
Thanks,
Wang
> Send was just sending everything it found, even if the extent was a hole. This
> is unpleasant for users, so just skip holes when we are sending. This will also
> skip sending prealloc extents since the send spec doesn't have a prealloc
> command. Eventually we will add a prealloc command and rev the send version so
> we can send down the prealloc info. Thanks,
>
> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
> ---
> V1->V2: fix where we were skipping holes that needed to be written because we
> punched a hole between the original snapshot and the send snapshot.
>
> fs/btrfs/send.c | 34 +++++++++++++++++++++++++++++++---
> 1 files changed, 31 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index db7da68..cbe92da 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -3920,7 +3920,8 @@ static int is_extent_unchanged(struct send_ctx *sctx,
> btrfs_item_key_to_cpu(eb, &found_key, slot);
> if (found_key.objectid != key.objectid ||
> found_key.type != key.type) {
> - ret = 0;
> + /* If we're a hole then just pretend nothing changed */
> + ret = (left_disknr) ? 0 : 1;
> goto out;
> }
>
> @@ -3946,7 +3947,8 @@ static int is_extent_unchanged(struct send_ctx *sctx,
> * This may only happen on the first iteration.
> */
> if (found_key.offset + right_len <= ekey->offset) {
> - ret = 0;
> + /* If we're a hole just pretend nothing changed */
> + ret = (left_disknr) ? 0 : 1;
> goto out;
> }
>
> @@ -4011,8 +4013,8 @@ static int process_extent(struct send_ctx *sctx,
> struct btrfs_path *path,
> struct btrfs_key *key)
> {
> - int ret = 0;
> struct clone_root *found_clone = NULL;
> + int ret = 0;
>
> if (S_ISLNK(sctx->cur_inode_mode))
> return 0;
> @@ -4025,6 +4027,32 @@ static int process_extent(struct send_ctx *sctx,
> ret = 0;
> goto out;
> }
> + } else {
> + struct btrfs_file_extent_item *ei;
> + u8 type;
> +
> + ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
> + struct btrfs_file_extent_item);
> + type = btrfs_file_extent_type(path->nodes[0], ei);
> + if (type == BTRFS_FILE_EXTENT_PREALLOC ||
> + type == BTRFS_FILE_EXTENT_REG) {
> + /*
> + * The send spec does not have a prealloc command yet,
> + * so just leave a hole for prealloc'ed extents until
> + * we have enough commands queued up to justify rev'ing
> + * the send spec.
> + */
> + if (type == BTRFS_FILE_EXTENT_PREALLOC) {
> + ret = 0;
> + goto out;
> + }
> +
> + /* Have a hole, just skip it. */
> + if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0) {
> + ret = 0;
> + goto out;
> + }
> + }
> }
>
> ret = find_extent_clone(sctx, path, key->objectid, key->offset,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: fix send to deal with sparse files properly V2
2013-08-30 2:15 ` Wang Shilong
@ 2013-08-30 12:24 ` Josef Bacik
0 siblings, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2013-08-30 12:24 UTC (permalink / raw)
To: Wang Shilong; +Cc: Josef Bacik, linux-btrfs
On Fri, Aug 30, 2013 at 10:15:27AM +0800, Wang Shilong wrote:
> On 08/22/2013 11:47 PM, Josef Bacik wrote:
>
> please use checkpatch.pl to check coding styles before sending patches:
>
> WARNING: line over 80 characters
> #86: FILE: fs/btrfs/send.c:4051:
> + if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0) {
>
> total: 0 errors, 1 warnings, 59 lines checked
>
Yeah I did that on purpose, thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-30 12:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-22 15:47 [PATCH] Btrfs: fix send to deal with sparse files properly V2 Josef Bacik
2013-08-30 2:15 ` Wang Shilong
2013-08-30 12:24 ` Josef Bacik
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).