From patchwork Mon Mar 31 13:52:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 3914081 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 410E29F357 for ; Mon, 31 Mar 2014 12:52:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4CCF32039C for ; Mon, 31 Mar 2014 12:52:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DB8020386 for ; Mon, 31 Mar 2014 12:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753217AbaCaMw3 (ORCPT ); Mon, 31 Mar 2014 08:52:29 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:53223 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753184AbaCaMw1 (ORCPT ); Mon, 31 Mar 2014 08:52:27 -0400 Received: by mail-wi0-f179.google.com with SMTP id z2so1477218wiv.6 for ; Mon, 31 Mar 2014 05:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=1Bq3fCje3K/htShKt9a/6St0W8TUpW0aAjwDbjHfjKc=; b=aAp/Y82lKg2MheLE3rb9kBMFAioeeeabLBCoxVqdqVlAtjjrfPV32zspC6vf5ObYHA 0trIiruIbvysXXnfJ4y+8socODA5ssdIpAjC7/tpDgWgo3fL6KvrwQQQmuO9/SpYjGrU JdAYUxktxd+hDrjAzo5pe7DOe4qxZE76zKgCYWoDGSs1nJgrbAeUxpMyVuhcg2WXwg1X ZgzsmZPLPPkH7zhRUN4H+BGPUip5ceN62z8UfvyChq2T1Dk5ZzOJWFg5ClFi7xgCV3PT t+rTgynN96VPAzj1K1SupxfoOiXcVt5K8ExborM0uxO3WtSIl7JfTMQKLVWjf4F7Ri9f VPfw== X-Received: by 10.180.231.39 with SMTP id td7mr5087617wic.14.1396270346634; Mon, 31 Mar 2014 05:52:26 -0700 (PDT) Received: from debian-vm3.lan (bl9-168-27.dsl.telepac.pt. [85.242.168.27]) by mx.google.com with ESMTPSA id jd2sm26533670wic.9.2014.03.31.05.52.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 05:52:25 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH] Btrfs: send, build path string only once in send_hole Date: Mon, 31 Mar 2014 14:52:14 +0100 Message-Id: <1396273934-15888-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's no point building the path string in each iteration of the send_hole loop, as it produces always the same string. Signed-off-by: Filipe David Borba Manana --- fs/btrfs/send.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 281ab2c..c81e0d9 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4410,6 +4410,9 @@ static int send_hole(struct send_ctx *sctx, u64 end) p = fs_path_alloc(); if (!p) return -ENOMEM; + ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); + if (ret < 0) + goto tlv_put_failure; memset(sctx->read_buf, 0, BTRFS_SEND_READ_SIZE); while (offset < end) { len = min_t(u64, end - offset, BTRFS_SEND_READ_SIZE); @@ -4417,9 +4420,6 @@ static int send_hole(struct send_ctx *sctx, u64 end) ret = begin_cmd(sctx, BTRFS_SEND_C_WRITE); if (ret < 0) break; - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); - if (ret < 0) - break; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset); TLV_PUT(sctx, BTRFS_SEND_A_DATA, sctx->read_buf, len);