Commit 1af56070 authored by Filipe Manana's avatar Filipe Manana Committed by Chris Mason

Btrfs: send, don't error in the presence of subvols/snapshots

If we are doing an incremental send and the base snapshot has a
directory with name X that doesn't exist anymore in the second
snapshot and a new subvolume/snapshot exists in the second snapshot
that has the same name as the directory (name X), the incremental
send would fail with -ENOENT error. This is because it attempts
to lookup for an inode with a number matching the objectid of a
root, which doesn't exist.

Steps to reproduce:

    mkfs.btrfs -f /dev/sdd
    mount /dev/sdd /mnt

    mkdir /mnt/testdir
    btrfs subvolume snapshot -r /mnt /mnt/mysnap1

    rmdir /mnt/testdir
    btrfs subvolume create /mnt/testdir
    btrfs subvolume snapshot -r /mnt /mnt/mysnap2

    btrfs send -p /mnt/mysnap1 /mnt/mysnap2 -f /tmp/send.data

A test case for xfstests follows.
Reported-by: default avatarRobert White <rwhite@pobox.com>
Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent a79b7d4b
...@@ -1628,6 +1628,10 @@ static int lookup_dir_item_inode(struct btrfs_root *root, ...@@ -1628,6 +1628,10 @@ static int lookup_dir_item_inode(struct btrfs_root *root,
goto out; goto out;
} }
btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key); btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key);
if (key.type == BTRFS_ROOT_ITEM_KEY) {
ret = -ENOENT;
goto out;
}
*found_inode = key.objectid; *found_inode = key.objectid;
*found_type = btrfs_dir_type(path->nodes[0], di); *found_type = btrfs_dir_type(path->nodes[0], di);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment