Commit 269d040f authored by Filipe David Borba Manana's avatar Filipe David Borba Manana Committed by Chris Mason

Btrfs: log recovery, don't unlink inode always on error

If we get any error while doing a dir index/item lookup in the
log tree, we were always unlinking the corresponding inode in
the subvolume. It makes sense to unlink only if the lookup failed
to find the dir index/item, which corresponds to NULL or -ENOENT,
and not when other errors happen (like a transient -ENOMEM or -EIO).
Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 488111aa
...@@ -1832,7 +1832,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans, ...@@ -1832,7 +1832,7 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
dir_key->offset, dir_key->offset,
name, name_len, 0); name, name_len, 0);
} }
if (IS_ERR_OR_NULL(log_di)) { if (!log_di || (IS_ERR(log_di) && PTR_ERR(log_di) == -ENOENT)) {
btrfs_dir_item_key_to_cpu(eb, di, &location); btrfs_dir_item_key_to_cpu(eb, di, &location);
btrfs_release_path(path); btrfs_release_path(path);
btrfs_release_path(log_path); btrfs_release_path(log_path);
...@@ -1869,6 +1869,9 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans, ...@@ -1869,6 +1869,9 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
goto again; goto again;
ret = 0; ret = 0;
goto out; goto out;
} else if (IS_ERR(log_di)) {
kfree(name);
return PTR_ERR(log_di);
} }
btrfs_release_path(log_path); btrfs_release_path(log_path);
kfree(name); kfree(name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment