From: Wang Shilong Date: Wed, 13 Nov 2013 09:25:46 +0000 (+0800) Subject: Btrfs-progs: try harder to make btrfs receive successfully X-Git-Tag: upstream/4.16.1~3021 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67d3c3c0d3505377e6468849b086aefc69ae5411;p=platform%2Fupstream%2Fbtrfs-progs.git 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 --- diff --git a/cmds-receive.c b/cmds-receive.c index 2b880c0..95dc3ec 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -234,6 +234,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"); goto out;