From patchwork Wed Oct 19 02:35:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 9383513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 722846086B for ; Wed, 19 Oct 2016 02:36:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6485329853 for ; Wed, 19 Oct 2016 02:36:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58C6029857; Wed, 19 Oct 2016 02:36:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE2DB29855 for ; Wed, 19 Oct 2016 02:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756232AbcJSCgE (ORCPT ); Tue, 18 Oct 2016 22:36:04 -0400 Received: from mgwym01.jp.fujitsu.com ([211.128.242.40]:36640 "EHLO mgwym01.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756109AbcJSCgB (ORCPT ); Tue, 18 Oct 2016 22:36:01 -0400 Received: from yt-mxoi2.gw.nic.fujitsu.com (unknown [192.168.229.69]) by mgwym01.jp.fujitsu.com with smtp id 2719_4170_ff1d7714_69b2_47a2_8fa0_400f1a450f3e; Wed, 19 Oct 2016 11:35:53 +0900 Received: from m3051.s.css.fujitsu.com (m3051.s.css.fujitsu.com [10.134.21.209]) by yt-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id BB476AC009C for ; Wed, 19 Oct 2016 11:35:53 +0900 (JST) Received: from WIN-5MHF4RKU941.jp.fujitsu.com (unknown [10.124.102.163]) by m3051.s.css.fujitsu.com (Postfix) with SMTP id AB90D417 for ; Wed, 19 Oct 2016 11:35:53 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.3.2 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20150223 X-SHieldMailCheckerMailID: 560b94d2589b4b8b9de53fa0958d4b5c Message-Id: <201610190235.AA00003@WIN-5MHF4RKU941.jp.fujitsu.com> From: Tsutomu Itoh Date: Wed, 19 Oct 2016 11:35:40 +0900 To: linux-btrfs@vger.kernel.org Subject: [PATCH 3/3] btrfs-progs: send: fix handling of -c option MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 X-TM-AS-MML: disable Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When two or more -c options are specified, cannot find a suitable parent. So, output stream is bigger than correct one. [before] # btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY At subvol Snap1 At subvol Snap2 At subvol ../SnapY # ls -l /tmp/data1 -rw------- 1 root root 3153 Oct 19 10:37 /tmp/data1 # [after] # btrfs send -f /tmp/data1 -c Snap0 -c ../SnapX Snap[12] ../SnapY At subvol Snap1 At subvol Snap2 At subvol ../SnapY # ls -l /tmp/data1 -rw------- 1 root root 1492 Oct 19 10:39 /tmp/data1 # Signed-off-by: Tsutomu Itoh --- cmds-send.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmds-send.c b/cmds-send.c index 2a8a697..b93a667 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -651,6 +651,18 @@ int cmd_send(int argc, char **argv) } if (!full_send && root_id) { + ret = init_root_path(&send, subvol); + if (ret < 0) + goto out; + + ret = get_root_id(&send, + subvol_strip_mountpoint(send.root_path, subvol), + &root_id); + if (ret < 0) { + error("cannot resolve rootid for %s", subvol); + goto out; + } + ret = find_good_parent(&send, root_id, &parent_root_id); if (ret < 0) { error("parent determination failed for %lld",