btrfs-progs: restore: remove loop check during directory scan

There's another loop protection during scan of directory items. This can
fire under invalid conditions, ie. when there's no real endless loop.
The layout of b-tree items could trigger that and has been observed in
practice. This prevents automated restoration as it requires user
attention.

The number of loops is 1024, unjustified and without explanation. Errors
during traversing the leaves are checked so most errors would be caught.
A real loop in the directory items would require some crafting and would
not happen on a normal filesystem.

Issue: #59
Issue: #164
Issue: #237
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-06-12 21:09:17 +02:00
parent 4258b7161f
commit 9a83a0b5c0
1 changed files with 0 additions and 10 deletions

View File

@ -920,7 +920,6 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key,
int name_len;
int ret = 0;
int fd;
int loops = 0;
u8 type;
btrfs_init_path(&path);
@ -953,13 +952,6 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key,
}
while (leaf) {
if (loops++ >= 1024) {
printf("We have looped trying to restore files in %s "
"too many times to be making progress, "
"stopping\n", in_dir);
break;
}
if (path.slots[0] >= btrfs_header_nritems(leaf)) {
do {
ret = next_leaf(root, &path);
@ -1024,7 +1016,6 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key,
ret = -1;
goto out;
}
loops = 0;
ret = copy_file(root, fd, &location, path_name);
close(fd);
if (ret) {
@ -1095,7 +1086,6 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key,
ret = -1;
goto out;
}
loops = 0;
ret = search_dir(search_root, &location,
output_rootdir, dir, mreg);
free(dir);