]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix resending received snapshot with parent
authorRobin Ruede <r.ruede@gmail.com>
Wed, 30 Sep 2015 19:23:33 +0000 (21:23 +0200)
committerFilipe Manana <fdmanana@suse.com>
Tue, 13 Oct 2015 19:04:10 +0000 (20:04 +0100)
commitd28f7a084c3b66699e960a1863f1a3a78df812df
treece4d5d87e90eeed60ae5c31d00ef82c98090e096
parent3ee6f4a17a1ebdc95325fb9ccd45d094cbeb94bb
btrfs: fix resending received snapshot with parent

This fixes a regression introduced by eec70a2b between v4.1 and v4.2.

When a snapshot is received, its received_uuid is set to the original
uuid of the subvolume. When that snapshot is then resent to a third
filesystem, it's received_uuid is set to the second uuid
instead of the original one. The same was true for the parent_uuid.
This behaviour was partially changed in eec70a2b, but in that patch
only the parent_uuid was taken from the real original,
not the uuid itself, causing the search for the parent to fail in
the case below.

This happens for example when trying to send a series of linked
snapshots (e.g. created by snapper) from the backup file system back
to the original one.

The following commands reproduce the issue in v4.2.1
(no error in 4.1.6)

    # setup three test file systems
    for i in 1 2 3; do
    truncate -s 50M fs$i
    mkfs.btrfs fs$i
    mkdir $i
    mount fs$i $i
    done
    echo "content" > 1/testfile
    btrfs su snapshot -r 1/ 1/snap1
    echo "changed content" > 1/testfile
    btrfs su snapshot -r 1/ 1/snap2

    # works fine:
    btrfs send 1/snap1 | btrfs receive 2/
    btrfs send -p 1/snap1 1/snap2 | btrfs receive 2/

    # ERROR: could not find parent subvolume
    btrfs send 2/snap1 | btrfs receive 3/
    btrfs send -p 2/snap1 2/snap2 | btrfs receive 3/

Signed-off-by: Robin Ruede <rruede+git@gmail.com>
Fixes: eec70a2b8661 ("Btrfs: use received_uuid of parent during send")
Cc: stable@vger.kernel.org # v4.2+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Tested-by: Ed Tomlinson <edt@aei.ca>
fs/btrfs/send.c