From patchwork Sat Apr 29 21:54:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 9705955 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 5160A602BF for ; Sat, 29 Apr 2017 21:54:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40E1528210 for ; Sat, 29 Apr 2017 21:54:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3270828355; Sat, 29 Apr 2017 21:54:26 +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 B058F28210 for ; Sat, 29 Apr 2017 21:54:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1167018AbdD2VyW (ORCPT ); Sat, 29 Apr 2017 17:54:22 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:32930 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936774AbdD2VyU (ORCPT ); Sat, 29 Apr 2017 17:54:20 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 89D0144542; Sat, 29 Apr 2017 23:54:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id cuxAVwYSFBFG; Sat, 29 Apr 2017 23:54:16 +0200 (CEST) From: Christian Brauner To: nazar@mokrynskyi.com, lakshmipathi.g@gmail.com, dsterba@suse.cz, linux-btrfs@vger.kernel.org Cc: Christian Brauner Subject: [PATCH 1/1] btrfs-progs: send: fail on first -ENODATA only Date: Sat, 29 Apr 2017 23:54:05 +0200 Message-Id: <20170429215405.1123-2-christian.brauner@ubuntu.com> In-Reply-To: <20170429215405.1123-1-christian.brauner@ubuntu.com> References: <20170429215405.1123-1-christian.brauner@ubuntu.com> 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 Returning -ENODATA is only considered invalid on the first run of the loop. Signed-off-by: Christian Brauner --- cmds-receive.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cmds-receive.c b/cmds-receive.c index b59f00e4..72e9c8f3 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -1091,6 +1091,7 @@ static int do_receive(struct btrfs_receive *rctx, const char *tomnt, char *dest_dir_full_path; char root_subvol_path[PATH_MAX]; int end = 0; + int iterations = 0; dest_dir_full_path = realpath(tomnt, NULL); if (!dest_dir_full_path) { @@ -1198,13 +1199,18 @@ static int do_receive(struct btrfs_receive *rctx, const char *tomnt, rctx, rctx->honor_end_cmd, max_errors); - if (ret < 0 && ret == -ENODATA) { + if (ret < 0) { + if (ret != -ENODATA) + goto out; + /* Empty stream is invalid */ - error("empty stream is not considered valid"); - ret = -EINVAL; - goto out; - } else if (ret < 0) { - goto out; + if (iterations == 0) { + error("empty stream is not considered valid"); + ret = -EINVAL; + goto out; + } + + ret = 1; } if (ret > 0) end = 1; @@ -1213,6 +1219,8 @@ static int do_receive(struct btrfs_receive *rctx, const char *tomnt, ret = finish_subvol(rctx); if (ret < 0) goto out; + + iterations++; } ret = 0;