From 67d3c3c0d3505377e6468849b086aefc69ae5411 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Wed, 13 Nov 2013 17:25:46 +0800 Subject: Btrfs-progs: try harder to make btrfs receive successfully Steps to reproduce: # mkfs.btrfs -f # mount # mkdir /backup # btrfs sub create /subv # btrfs sub snapshot -r /subv /snap1 # btrfs sub snapshot -r /subv /snap2 # btrfs send /snap2 -p /snap1 -f sent_file # btrfs receive -f sent_file /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 Reviewed-by: Stefan Behrens Signed-off-by: David Sterba Signed-off-by: Chris Mason --- cmds-receive.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmds-receive.c') diff --git a/cmds-receive.c b/cmds-receive.c index 2b880c01..95dc3ec4 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -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"); -- cgit v1.2.3