All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] send: Avoid sending disknr==0 and PREALLOC extents when possible V2
@ 2013-01-21 10:22 Alex Lyakas
  2013-01-21 10:27 ` [PATCH 1/2] V2 Avoid sending disknr==0 extents when possible Alex Lyakas
  2013-01-21 10:30 ` [PATCH 2/2] V2 On a diff-send, avoid sending PREALLOC extents Alex Lyakas
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Lyakas @ 2013-01-21 10:22 UTC (permalink / raw)
  To: linux-btrfs, Josef Bacik, Alexander Block, Jan Schmidt, Chen Yang
  Cc: Arne Jansen

These two patches address the issue of sending unneeded zero data for
disknr==0 and PREALLOC extents.
There is room for additional improvement for PREALLOC extents, but it
requires adding a new send command, so for now this is not addressed.

Changes in V2: no functional change; previous patchset was malformed,
so cleanup done with checkpatch.pl.

Please review and comment.

Alex Lyakas (2):
  Avoid sending disknr==0 extents when possible.
  On a diff-send, avoid sending PREALLOC extents, if the parent
    root has only PREALLOC extents on an appropriate file range.

 fs/btrfs/send.c |  184 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 178 insertions(+), 6 deletions(-)

--
1.7.9.5

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH 1/2] V2 Avoid sending disknr==0 extents when possible
@ 2013-01-28 17:03 Alex Lyakas
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Lyakas @ 2013-01-28 17:03 UTC (permalink / raw)
  To: linux-btrfs, Josef Bacik
  Cc: Jan Schmidt, Alexander Block, Arne Jansen, Chen Yang

In the following cases we do not send disknr==0 extents:
1) full send 2) new inode in a diff-send 3) when disknr==0 extents are
added to the end of an inode

Original-version-by: Chen Yang <chenyang.fnst@cn.fujitsu.com>
Signed-off-by: Alex Lyakas <alex.btrfs@zadarastorage.com>
---
 fs/btrfs/send.c |   30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 321b7fb..e23f5cf 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -3846,7 +3846,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;
+               /* No need to send a no-data extent it in this case */
+               ret = (left_disknr == 0) ? 1 : 0;
                goto out;
        }

@@ -3872,7 +3873,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;
+                       /* No need to send a no-data extent it in this case */
+                       ret = (left_disknr == 0) ? 1 : 0;
                        goto out;
                }

@@ -3953,6 +3955,30 @@ static int process_extent(struct send_ctx *sctx,
                        ret = 0;
                        goto out;
                }
+       } else {
+               struct extent_buffer *eb;
+               struct btrfs_file_extent_item *ei;
+               u8 extent_type;
+               u64 extent_disknr;
+
+               eb = path->nodes[0];
+               ei = btrfs_item_ptr(eb, path->slots[0],
+                               struct btrfs_file_extent_item);
+
+               extent_type = btrfs_file_extent_type(eb, ei);
+               extent_disknr = btrfs_file_extent_disk_bytenr(eb, ei);
+               if (extent_type == BTRFS_FILE_EXTENT_REG &&
+                       extent_disknr == 0) {
+                       /*
+                        * This is disknr=0 extent in a full-send or a
+                        * new inode in a diff-send. Since we will
+                        * send truncate command in finish_inode_if_needed
+                        * anyways, the inode size will be correct,
+                        * and we don't have to send all-zero data.
+                        */
+                       ret = 0;
+                       goto out;
+               }
        }

        ret = find_extent_clone(sctx, path, key->objectid, key->offset,
--
1.7.9.5

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

end of thread, other threads:[~2013-01-28 17:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-21 10:22 [PATCH 0/2] send: Avoid sending disknr==0 and PREALLOC extents when possible V2 Alex Lyakas
2013-01-21 10:27 ` [PATCH 1/2] V2 Avoid sending disknr==0 extents when possible Alex Lyakas
2013-01-24 15:48   ` Josef Bacik
2013-01-21 10:30 ` [PATCH 2/2] V2 On a diff-send, avoid sending PREALLOC extents Alex Lyakas
  -- strict thread matches above, loose matches on Subject: below --
2013-01-28 17:03 [PATCH 1/2] V2 Avoid sending disknr==0 extents when possible Alex Lyakas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.