All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dāvis Mosāns" <davispuh@gmail.com>
To: Btrfs <linux-btrfs@vger.kernel.org>
Subject: btrfs send picks wrong subvolume UUID
Date: Sun, 2 Jan 2022 06:17:15 +0200	[thread overview]
Message-ID: <CAOE4rSz2f3xHj7Mi_JFgSMHHN8XSGxMr4NWZdcu4qd1-zOYOsg@mail.gmail.com> (raw)

Hi,

I have a bunch of snapshots I want to send from one fs to another,
but it seems btrfs send is using received UUID instead of subvolumes own UUID
causing wrong subvolume to be picked by btrfs receive and thus failing.

$ btrfs subvolume show /mnt/fs/2019-11-02/etc | head -n 5
2019-11-02/etc
        Name:                   etc
        UUID:                   389ebc5e-341a-fb4a-b838-a2b7976b8220
        Parent UUID:            36d5d44b-9eaf-8542-8243-ad0dc45b8abd
        Received UUID:          15bd7d35-9f98-0b48-854c-422c445f7403

$ btrfs send /mnt/fs/2019-11-02/etc | btrfs receive --dump | head -n 2
At subvol /mnt/fs/2019-11-02/etc
subvol          ./etc
uuid=15bd7d35-9f98-0b48-854c-422c445f7403 transid=1727996
chown           ./etc/                          gid=0 uid=0
$ btrfs send /mnt/fs/2019-11-02/etc | btrfs receive /mnt/newFS/2019-11-02/
At subvol /mnt/fs/2019-11-02/etc
At subvol etc

$ btrfs subvolume show /mnt/fs/2020-09-21/etc | head -n 5
2020-09-21/etc
        Name:                   etc
        UUID:                   1c6a0138-b23b-244f-82d8-e2fcaa20870f
        Parent UUID:            36d5d44b-9eaf-8542-8243-ad0dc45b8abd
        Received UUID:          15bd7d35-9f98-0b48-854c-422c445f7403

$ btrfs send -c /mnt/fs/2019-11-02/etc -p /mnt/fs/2019-11-02/etc
/mnt/fs/2020-09-21/etc | btrfs receive --dump | head -n 2
At subvol /mnt/fs/2020-09-21/etc
snapshot        ./etc
uuid=15bd7d35-9f98-0b48-854c-422c445f7403 transid=2148016
parent_uuid=15bd7d35-9f98-0b48-854c-422c445f7403
parent_transid=1727996
utimes          ./etc/
atime=2019-08-11T14:56:46+0300 mtime=2020-09-21T20:30:38+0300
ctime=2020-09-21T20:30:38+0300
$ btrfs send -c /mnt/fs/2019-11-02/etc -p /mnt/fs/2019-11-02/etc
/mnt/fs/2020-09-21/etc | btrfs receive /mnt/newFS/2020-09-21/
At subvol /mnt/fs/2020-09-21/etc
At snapshot etc

$ btrfs subvolume list -opuqR /mnt/newFS/
ID 373 gen 1965 parent 276 top level 276 parent_uuid -
                   received_uuid 15bd7d35-9f98-0b48-854c-422c445f7403
uuid 4a21e16f-ab4e-1f45-900a-541ead4e9fa4 path 2019-11-02/etc
ID 374 gen 1968 parent 276 top level 276 parent_uuid
4a21e16f-ab4e-1f45-900a-541ead4e9fa4 received_uuid
15bd7d35-9f98-0b48-854c-422c445f7403 uuid
7e19706d-4cf4-8245-ae02-1bdd99f92e48 path 2020-09-21/etc

As you can see received_uuid is same for both and it's not the UUID of
source subvolume


$ btrfs subvolume show /mnt/fs/2020-12-09/etc | head -n 5
2020-12-09/etc
        Name:                   etc
        UUID:                   2902708e-2ebf-654a-8b03-f854e031f8c7
        Parent UUID:            36d5d44b-9eaf-8542-8243-ad0dc45b8abd
        Received UUID:          15bd7d35-9f98-0b48-854c-422c445f7403

$ btrfs send -c /mnt/fs/2020-09-21/etc -p /mnt/fs/2020-09-21/etc
/mnt/fs/2020-12-09/etc | btrfs receive --dump | head -n 2
At subvol /mnt/fs/2020-12-09/etc
snapshot        ./etc
uuid=15bd7d35-9f98-0b48-854c-422c445f7403 transid=2212940
parent_uuid=15bd7d35-9f98-0b48-854c-422c445f7403
parent_transid=2148016
utimes          ./etc/
atime=2019-08-11T14:56:46+0300 mtime=2020-12-08T17:50:18+0200
ctime=2020-12-08T17:50:18+0200
$ btrfs send -c /mnt/fs/2020-09-21/etc -p /mnt/fs/2020-09-21/etc
/mnt/fs/2020-12-09/etc | btrfs receive /mnt/newFS/2020-12-09/
At subvol /mnt/fs/2020-12-09/etc
At snapshot etc
ERROR: unlink o86334-1390558-0/d42ee4920c54898f1957cd2f38799f735dfa05
failed: No such file or directory

Here it fails because it actually used target's 2019-11-02/etc
subvolume as parent instead of 2020-09-21/etc like we specified.
We can see that in strace:
$ btrfs send -c /mnt/fs/2020-09-21/etc -p /mnt/fs/2020-09-21/etc
/mnt/fs/2020-12-09/etc | strace btrfs receive /mnt/newFS/2020-12-09/
2>&1 | grep -E '2019-11-02|SNAP_CREATE'
At subvol /mnt/fs/2020-12-09/etc
ioctl(4, BTRFS_IOC_INO_LOOKUP, {treeid=276, objectid=261} =>
{name="2019-11-02/"}) = 0
openat(4, "2019-11-02/etc", O_RDONLY|O_NOATIME) = 5
ioctl(3, BTRFS_IOC_SNAP_CREATE_V2, {fd=5, flags=0, name="etc"} =>
{transid=0}) = 0

Best regards,
Dāvis

             reply	other threads:[~2022-01-02  4:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-02  4:17 Dāvis Mosāns [this message]
2022-01-02 20:37 ` btrfs send picks wrong subvolume UUID Andrei Borzenkov
2022-01-03 18:09   ` Dāvis Mosāns
2022-01-11 15:33     ` Nikolay Borisov
2022-01-11 16:46       ` Dāvis Mosāns
2022-01-12 11:29         ` David Sterba
2022-01-12 11:37     ` David Sterba

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=CAOE4rSz2f3xHj7Mi_JFgSMHHN8XSGxMr4NWZdcu4qd1-zOYOsg@mail.gmail.com \
    --to=davispuh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.