Skip to content

Commit cfd3126

Browse files
fdmananakdave
authored andcommitted
btrfs: check for error when looking up inode during dir entry replay
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: [email protected] # 4.14+ Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 8dcbc26 commit cfd3126

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/btrfs/tree-log.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,8 +1950,8 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
19501950
struct btrfs_key log_key;
19511951
struct inode *dir;
19521952
u8 log_type;
1953-
int exists;
1954-
int ret = 0;
1953+
bool exists;
1954+
int ret;
19551955
bool update_size = (key->type == BTRFS_DIR_INDEX_KEY);
19561956
bool name_added = false;
19571957

@@ -1971,12 +1971,12 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
19711971
name_len);
19721972

19731973
btrfs_dir_item_key_to_cpu(eb, di, &log_key);
1974-
exists = btrfs_lookup_inode(trans, root, path, &log_key, 0);
1975-
if (exists == 0)
1976-
exists = 1;
1977-
else
1978-
exists = 0;
1974+
ret = btrfs_lookup_inode(trans, root, path, &log_key, 0);
19791975
btrfs_release_path(path);
1976+
if (ret < 0)
1977+
goto out;
1978+
exists = (ret == 0);
1979+
ret = 0;
19801980

19811981
if (key->type == BTRFS_DIR_ITEM_KEY) {
19821982
dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,

0 commit comments

Comments
 (0)