From patchwork Mon Jan 28 17:03:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Lyakas X-Patchwork-Id: 2057051 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 94F5240106 for ; Mon, 28 Jan 2013 17:03:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757426Ab3A1RDs (ORCPT ); Mon, 28 Jan 2013 12:03:48 -0500 Received: from mail-wg0-f46.google.com ([74.125.82.46]:39626 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756374Ab3A1RDq (ORCPT ); Mon, 28 Jan 2013 12:03:46 -0500 Received: by mail-wg0-f46.google.com with SMTP id fg15so1822831wgb.25 for ; Mon, 28 Jan 2013 09:03:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to:cc :content-type:x-gm-message-state; bh=+Vq6ooYzhFwXXfRfA506wH/rlxObla0YecMYDwWOOTs=; b=G3sWY4aownCbyVd6B5ntYhp2FcZkbxNNVo+g6lpKtT1pbavL9yQy0LIrOfwl0rKU2W FZfrR7BEFoQ5ZD9V/BZuM78SwH19O/LAJ33PMP0bhilG1jUvDfXth7Vc7rAJnD4I2dW8 BYzdjmlsu+oW1sX/9lZajfRCfiXhDzDSWwwFVrPMx5/q+HAAqgmrbE8QlAVmEOwSs8wR UOFM+/7mzF6nCq7QF0gHwf3ZWoS7wYssp+eBvLEF+RtvPc/+jpW1sPtTTiV3R648PMvc kpDv/YHVaLr5xjLc3QphepUprkAWD0PxKzolHaoKh9pYkrfMoLz696IlObh/6sL0JDQ5 cGxw== MIME-Version: 1.0 X-Received: by 10.194.172.228 with SMTP id bf4mr22719610wjc.38.1359392624722; Mon, 28 Jan 2013 09:03:44 -0800 (PST) Received: by 10.194.19.196 with HTTP; Mon, 28 Jan 2013 09:03:44 -0800 (PST) Date: Mon, 28 Jan 2013 19:03:44 +0200 Message-ID: Subject: [PATCH 1/2] V2 Avoid sending disknr==0 extents when possible From: Alex Lyakas To: linux-btrfs , Josef Bacik Cc: Jan Schmidt , Alexander Block , Arne Jansen , Chen Yang X-Gm-Message-State: ALoCoQlrXU8dLVkQNVNsARVXvOCZj8mNgXcLbdl1oicXAq0syioz/YA5U4trNpcuFGqjV2xvBCFO Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 Signed-off-by: Alex Lyakas --- fs/btrfs/send.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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,