From: Christian Brauner <christian.brauner@canonical.com>
To: "Lakshmipathi.G" <lakshmipathi.g@gmail.com>
Cc: Christian Brauner <christian.brauner@ubuntu.com>,
dsterba@suse.cz, btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 1/2 v2] btrfs-progs: fix btrfs send & receive with -e flag
Date: Fri, 28 Apr 2017 11:55:31 +0200 [thread overview]
Message-ID: <20170428095530.yw74untb34oawlm2@mailbox.org> (raw)
In-Reply-To: <CAKuJGC9hJSKnHrXPr2EvEktjHf-=OxJkhzzZbeFfB6OUYSdyJQ@mail.gmail.com>
Hi,
On Fri, Apr 28, 2017 at 02:55:31PM +0530, Lakshmipathi.G wrote:
> Seems like user reported an issue with this patch. please check
> https://bugzilla.kernel.org/show_bug.cgi?id=195597
I can take a look. What I'm wondering about is why it fails only in the HDD
to SSD case. If -ENODATA is returned with this patch it should mean that there
was no header data. So is the user sure that this doesn't indicate a valid
error?
Christian
>
> ----
> Cheers,
> Lakshmipathi.G
>
>
> On Tue, Apr 4, 2017 at 1:51 AM, Christian Brauner <
> christian.brauner@ubuntu.com> wrote:
> > The old check here tried to ensure that empty streams are not considered
> valid.
> > The old check however, will always fail when only one run through the
> while(1)
> > loop is needed and honor_end_cmd is set. So this:
> >
> > btrfs send /some/subvol | btrfs receive -e /some/
> >
> > will consistently fail because -e causes honor_cmd_to be set and
> > btrfs_read_and_process_send_stream() to correctly return 1. So the
> command will
> > be successful but btrfs receive will error out because the send - receive
> > concluded in one run through the while(1) loop.
> >
> > If we want to exclude empty streams we need a way to tell the difference
> between
> > btrfs_read_and_process_send_stream() returning 1 because read_buf() did
> not
> > detect any data and read_and_process_cmd() returning 1 because
> honor_end_cmd was
> > set. Without introducing too many changes the best way to me seems to have
> > btrfs_read_and_process_send_stream() return -ENODATA in the first case.
> The rest
> > stays the same. We can then check for -ENODATA in do_receive() and report
> a
> > proper error in this case. This should also be backwards compatible to
> previous
> > versions of btrfs receive. They will fail on empty streams because a
> negative
> > value is returned. The only thing that they will lack is a nice error
> message.
> >
> > Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> > ---
> > Changelog: 2017-04-03
> > - no changes
> > ---
> > cmds-receive.c | 13 +++++--------
> > send-stream.c | 2 +-
> > 2 files changed, 6 insertions(+), 9 deletions(-)
> >
> > diff --git a/cmds-receive.c b/cmds-receive.c
> > index 6cf22637..b59f00e4 100644
> > --- a/cmds-receive.c
> > +++ b/cmds-receive.c
> > @@ -1091,7 +1091,6 @@ 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 count;
> >
> > dest_dir_full_path = realpath(tomnt, NULL);
> > if (!dest_dir_full_path) {
> > @@ -1186,7 +1185,6 @@ static int do_receive(struct btrfs_receive *rctx,
> const char *tomnt,
> > if (ret < 0)
> > goto out;
> >
> > - count = 0;
> > while (!end) {
> > if (rctx->cached_capabilities_len) {
> > if (g_verbose >= 3)
> > @@ -1200,16 +1198,15 @@ static int do_receive(struct btrfs_receive *rctx,
> const char *tomnt,
> > rctx,
> >
> rctx->honor_end_cmd,
> > max_errors);
> > - if (ret < 0)
> > - goto out;
> > - /* Empty stream is invalid */
> > - if (ret && count == 0) {
> > + if (ret < 0 && ret == -ENODATA) {
> > + /* Empty stream is invalid */
> > error("empty stream is not considered valid");
> > ret = -EINVAL;
> > goto out;
> > + } else if (ret < 0) {
> > + goto out;
> > }
> > - count++;
> > - if (ret)
> > + if (ret > 0)
> > end = 1;
> >
> > close_inode_for_write(rctx);
> > diff --git a/send-stream.c b/send-stream.c
> > index 5a028cd9..78f2571a 100644
> > --- a/send-stream.c
> > +++ b/send-stream.c
> > @@ -492,7 +492,7 @@ int btrfs_read_and_process_send_stream(int fd,
> > if (ret < 0)
> > goto out;
> > if (ret) {
> > - ret = 1;
> > + ret = -ENODATA;
> > goto out;
> > }
> >
> > --
> > 2.11.0
> >
> > --
> > 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
next parent reply other threads:[~2017-04-28 9:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAKuJGC9hJSKnHrXPr2EvEktjHf-=OxJkhzzZbeFfB6OUYSdyJQ@mail.gmail.com>
2017-04-28 9:55 ` Christian Brauner [this message]
2017-04-28 10:03 ` [PATCH 1/2 v2] btrfs-progs: fix btrfs send & receive with -e flag Lakshmipathi.G
2017-04-28 10:47 ` Nazar Mokrynskyi
2017-04-03 20:21 [PATCH 0/2 " Christian Brauner
2017-04-03 20:21 ` [PATCH 1/2 " Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170428095530.yw74untb34oawlm2@mailbox.org \
--to=christian.brauner@canonical.com \
--cc=christian.brauner@ubuntu.com \
--cc=dsterba@suse.cz \
--cc=lakshmipathi.g@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).