Commit e15ac641 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: deal with errors when replaying dir entry during log replay

At replay_one_one(), we are treating any error returned from
btrfs_lookup_dir_item() or from btrfs_lookup_dir_index_item() as meaning
that there is no existing directory entry in the fs/subvolume tree.
This is not correct since we can get errors such as, for example, -EIO
when reading extent buffers while searching the fs/subvolume's btree.

So fix that and return the error to the caller when it is not -ENOENT.

CC: stable@vger.kernel.org # 4.14+
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 77a5b9e3
...@@ -1988,7 +1988,14 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans, ...@@ -1988,7 +1988,14 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
if (IS_ERR_OR_NULL(dst_di)) {
if (dst_di == ERR_PTR(-ENOENT))
dst_di = NULL;
if (IS_ERR(dst_di)) {
ret = PTR_ERR(dst_di);
goto out;
} else if (!dst_di) {
/* we need a sequence number to insert, so we only /* we need a sequence number to insert, so we only
* do inserts for the BTRFS_DIR_INDEX_KEY types * do inserts for the BTRFS_DIR_INDEX_KEY types
*/ */
......
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