btrfs: check for error when looking up inode during dir entry replay
commit cfd312695b71df04c3a2597859ff12c470d1e2e4 upstream. At replay_one_name(), we are treating any error from btrfs_lookup_inode() as if the inode does not exists. Fix this by checking for an error and returning it to the caller. CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
4ed68471bc
commit
352349aa49
@@ -1902,8 +1902,8 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
|
|||||||
struct btrfs_key log_key;
|
struct btrfs_key log_key;
|
||||||
struct inode *dir;
|
struct inode *dir;
|
||||||
u8 log_type;
|
u8 log_type;
|
||||||
int exists;
|
bool exists;
|
||||||
int ret = 0;
|
int ret;
|
||||||
bool update_size = (key->type == BTRFS_DIR_INDEX_KEY);
|
bool update_size = (key->type == BTRFS_DIR_INDEX_KEY);
|
||||||
bool name_added = false;
|
bool name_added = false;
|
||||||
|
|
||||||
@@ -1923,12 +1923,12 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
|
|||||||
name_len);
|
name_len);
|
||||||
|
|
||||||
btrfs_dir_item_key_to_cpu(eb, di, &log_key);
|
btrfs_dir_item_key_to_cpu(eb, di, &log_key);
|
||||||
exists = btrfs_lookup_inode(trans, root, path, &log_key, 0);
|
ret = btrfs_lookup_inode(trans, root, path, &log_key, 0);
|
||||||
if (exists == 0)
|
|
||||||
exists = 1;
|
|
||||||
else
|
|
||||||
exists = 0;
|
|
||||||
btrfs_release_path(path);
|
btrfs_release_path(path);
|
||||||
|
if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
exists = (ret == 0);
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
if (key->type == BTRFS_DIR_ITEM_KEY) {
|
if (key->type == BTRFS_DIR_ITEM_KEY) {
|
||||||
dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,
|
dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,
|
||||||
|
Reference in New Issue
Block a user