linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@gmail.com>
To: Darrell Enns <darrell@darrellenns.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Backup failing with "failed to clone extents" error
Date: Wed, 1 Sep 2021 15:50:25 +0100	[thread overview]
Message-ID: <CAL3q7H5y6z7rRu-ZsZe_WXeHteWx1edZi+L3-UL0aa0oYg+qQA@mail.gmail.com> (raw)
In-Reply-To: <CAOaVUnXDzd-+jvq95DGpYcV7mApomrViDhiyjm-BdPz5MvFqZg@mail.gmail.com>

On Tue, Aug 31, 2021 at 5:48 PM Darrell Enns <darrell@darrellenns.com> wrote:
>
> It's btrfs-progs v5.13.1. Debug logs are attached.

Ok, now I see what's going on.

Somehow you have at least two snapshots (with IDs 881 and 977 on the
send filesystem), that have the same 'received_uuid' -
e346e5a1-536c-8d42-ba33-c5452dec7888.
So these snapshots were received from some other filesystem in the past.

What's unusual is that they have different content - this suggests that maybe:

1) 881 was successfully sent to the destination filesystem (perhaps as
a full send, or as an incremental, doesn't matter);

2) 977 was turned from RO mode to RW mode, some changes made to it
(several writes to the sqlite file at least), turned back to RO mode
and then used for the incremental send operation.
Or that 977 was a RW snapshot of 881, then changed, someone called the
BTRFS_IOC_SET_RECEIVED_SUBVOL ioctl to set the received_uuid of the
snapshot to e346e5a1-536c-8d42-ba33-c5452dec7888, then turned it RO
and then used it for the incremental send.

Looking at the beginning of 'receive -vvv' output, shows:

At subvol /.snapshots/374/snapshot/
receiving snapshot snapshot uuid=e346e5a1-536c-8d42-ba33-c5452dec7888,
ctransid=39921 parent_uuid=e346e5a1-536c-8d42-ba33-c5452dec7888,
parent_ctransid=35384

The send snapshot and the parent snapshot have the same UUID. This is
asking for trouble, and in this case it causes problems.

And the sending side:

[  391.131006] BTRFS info (device dm-0): send: clone_range() start ino
400698 offset 79134720 send root 977, clone root 881 ino 400698 offset
79134720 data_offset 491520 len 4751360 disk_byte 308100730880
clone_src_i_size 83886080 next_write_offset 79134720
(...)
[  391.131025] BTRFS info (device dm-0): send_clone: ino 400698
clone_ino 400698 send_root 977 clone_root 881 offset 79134720
clone_offset 79134720 ino_path
home/denns/.mozilla/firefox/dtfto95g.default/places.sqlite clone_path
home/denns/.mozilla/firefox/dtfto95g.default/places.sqlite
send_root_uuid ab408d81-05ac-c346-a99a-f525d907c532
send_root_received_uuid e346e5a1-536c-8d42-ba33-c5452dec7888
clone_root_uuid fb2c8e58-2ffa-ad4e-9e0e-9b494691db63
clone_root_received_uuid e346e5a1-536c-8d42-ba33-c5452dec7888

We confirm that send root and parent roots have the same
received_uuid, which is e346e5a1-536c-8d42-ba33-c5452dec7888.
This results in the kernel sending a clone operation with a source
snapshot of e346e5a1-536c-8d42-ba33-c5452dec7888.

The kernel's intention is to emit a clone operation from the parent to
the send snapshot, using valid offsets and lengths.

But because both snapshots have the same received_uuid value, the
receiver picks the first snapshot it finds with a received_uuid of
e346e5a1-536c-8d42-ba33-c5452dec7888 as the source for the clone
operation - but it picks the snapshot that is being received, and not
the parent snapshot - in this case the clone operation is invalid as
we try to clone from the same inode to itself using the range as a
source and destination.

Having two different snapshots with the same received_uuid but
different content is unexpected and breaks send/receive.

I wonder how you managed to get two different snapshots, with the same
received_uuid and different content.




-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

  reply	other threads:[~2021-09-01 14:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 23:22 Backup failing with "failed to clone extents" error Darrell Enns
2021-08-26  9:48 ` Filipe Manana
2021-08-26 18:30   ` Darrell Enns
2021-08-27 11:35     ` Filipe Manana
2021-08-27 18:01       ` Darrell Enns
2021-08-27 19:31         ` Filipe Manana
2021-08-27 21:04           ` Darrell Enns
2021-08-30 10:51             ` Filipe Manana
2021-08-30 16:38               ` Filipe Manana
2021-08-30 17:37                 ` Darrell Enns
2021-08-30 18:34                   ` Filipe Manana
2021-08-30 19:08                     ` Darrell Enns
2021-08-30 19:52                       ` Filipe Manana
2021-08-30 20:08                         ` Darrell Enns
2021-08-30 20:11                           ` Darrell Enns
2021-08-30 20:58                           ` Filipe Manana
2021-08-31  2:46                             ` Darrell Enns
2021-08-31 11:20                               ` Filipe Manana
2021-08-31 11:21                                 ` Filipe Manana
2021-08-31 16:48                                   ` Darrell Enns
2021-09-01 14:50                                     ` Filipe Manana [this message]
2021-09-01 15:34                                       ` Andrei Borzenkov
2021-09-01 15:37                                         ` Filipe Manana
2021-09-01 17:16                                       ` Darrell Enns
2021-09-01 17:40                                         ` Andrei Borzenkov
2021-09-01 17:52                                           ` Darrell Enns
2021-09-01 18:16                                             ` Andrei Borzenkov
2021-09-01 18:28                                               ` Darrell Enns
  -- strict thread matches above, loose matches on Subject: below --
2020-04-16  0:31 Matt Huszagh
2020-04-16 11:53 ` Filipe Manana

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=CAL3q7H5y6z7rRu-ZsZe_WXeHteWx1edZi+L3-UL0aa0oYg+qQA@mail.gmail.com \
    --to=fdmanana@gmail.com \
    --cc=darrell@darrellenns.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).