From patchwork Mon Jan 21 10:27:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Lyakas X-Patchwork-Id: 2010581 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 0BA893FD1A for ; Mon, 21 Jan 2013 10:27:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752947Ab3AUK1Z (ORCPT ); Mon, 21 Jan 2013 05:27:25 -0500 Received: from mail-we0-f177.google.com ([74.125.82.177]:52068 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752937Ab3AUK1Y (ORCPT ); Mon, 21 Jan 2013 05:27:24 -0500 Received: by mail-we0-f177.google.com with SMTP id d7so248520wer.22 for ; Mon, 21 Jan 2013 02:27:22 -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=xGrFcaB1szUbIS8rdb/8KhxJlBi4tyj4pSx9nje+NH4=; b=naEMEwIcscafrTCyW+NpjuqT5K0Zf8a2iaGVmsR9CsldFfWSDqmoOyFY+DkBfNCCUg RL6YlowsZQvA/Bv7/4svXt11xRplN4mitUSFq8MqXSMnw5Cw4I/Y/DH5yxwjeP2t6Pba c6F91MdUSs50lnZnvdanBG8mhQ6yJZ1qpkGZQTk8TiY+4PqPSDVVJ+ZTWhh19LgmByKI +sDyAavuKv0cHoQI7h2csj1/OeezXJRHGyoFFtUI1TWQ1GgAkDHb4hETPkm3B3rrrFqz gluBxbN2YN+D9UUolJy8RO2R6q6UM6Mm6TVIiNFWfjhK2xsOvNQ1FQiXjew81BwqYx93 TkvQ== MIME-Version: 1.0 X-Received: by 10.180.78.137 with SMTP id b9mr14391530wix.30.1358764042358; Mon, 21 Jan 2013 02:27:22 -0800 (PST) Received: by 10.194.23.3 with HTTP; Mon, 21 Jan 2013 02:27:22 -0800 (PST) Date: Mon, 21 Jan 2013 12:27:22 +0200 Message-ID: Subject: [PATCH 1/2] V2 Avoid sending disknr==0 extents when possible. From: Alex Lyakas To: linux-btrfs , Josef Bacik , Alexander Block , Jan Schmidt , Chen Yang Cc: Arne Jansen X-Gm-Message-State: ALoCoQkM6kF1OksqHY7TOcNifxOKZfZMGBA4JeBjeyz2ubOS4cP7pHmsFO1175NRtFkM4k6+5I+i 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 5445454..bdef966 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -3844,7 +3844,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; } @@ -3870,7 +3871,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; } @@ -3951,6 +3953,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,