btrfs-progs: receive: output the parent subvolume uuid if it cannot be found

It's a known problem that a received subvolume would lose its UUID after
switching to RW.  Thus it can lead to later receive problems for
snapshotting and cloning.

In that case, we just output a simple error message like:

  ERROR: cannot find parent subvolume

Or

  ERROR: clone: did not find source subvol

Normally we need to use "btrfs receive --dump" to know what the missing
subvolume UUID is, which would take extra work.

This patch would:

- Add extra subvolume UUID to the output
- Unify the error messages to the same format

Now the error messages would look like:

  ERROR: snapshot: cannot find parent subvolume 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb
  ERROR: clone: cannot find source subvolume 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2023-04-23 09:03:42 +08:00 committed by David Sterba
parent 1ea7292354
commit 0c94a7d005

View File

@ -297,7 +297,8 @@ static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid,
ret = -ENOENT;
else
ret = PTR_ERR(parent_subvol);
error("cannot find parent subvolume");
uuid_unparse(parent_uuid, uuid_str);
error("snapshot: cannot find parent subvolume %s", uuid_str);
goto out;
}
@ -749,11 +750,14 @@ static int process_clone(const char *path, u64 offset, u64 len,
NULL,
subvol_search_by_received_uuid);
if (IS_ERR_OR_NULL(si)) {
char uuid_str[BTRFS_UUID_UNPARSED_SIZE];
if (!si)
ret = -ENOENT;
else
ret = PTR_ERR(si);
error("clone: did not find source subvol");
uuid_unparse(clone_uuid, uuid_str);
error("clone: cannot find source subvol %s", uuid_str);
goto out;
}
/* strip the subvolume that we are receiving to from the start of subvol_path */