Btrfs-progs: try harder to make btrfs receive successfully

Steps to reproduce:
	# mkfs.btrfs -f <dev>
	# mount <dev> <mnt>
	# mkdir <mnt>/backup
	# btrfs sub create <mnt>/subv
	# btrfs sub snapshot -r <mnt>/subv <mnt>/snap1
	# btrfs sub snapshot -r <mnt>/subv <mnt>/snap2
	# btrfs send <mnt>/snap2 -p <mnt>/snap1 -f sent_file
	# btrfs receive -f sent_file <mnt>/backup

Above steps will make btrfs receive fails with "ERROR: can not find
parent subvolume", this is because we try to find parent subvolume by
RECEIVED_SUBVOL_KEY,and it will return ENOENT if parent snapshot has not
been sent or it has been deleted. Actually, we can try harder to find
whether parent subvolume exists by searching uuid key.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
Wang Shilong 2013-11-13 17:25:46 +08:00 committed by Chris Mason
parent 72f1835ae4
commit 67d3c3c0d3

View file

@ -233,6 +233,10 @@ static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid,
parent_subvol = subvol_uuid_search(&r->sus, 0, parent_uuid,
parent_ctransid, NULL, subvol_search_by_received_uuid);
if (!parent_subvol) {
parent_subvol = subvol_uuid_search(&r->sus, 0, parent_uuid,
parent_ctransid, NULL, subvol_search_by_uuid);
}
if (!parent_subvol) {
ret = -ENOENT;
fprintf(stderr, "ERROR: could not find parent subvolume\n");