Skip to content

Commit 7a6b75b

Browse files
fdmananakdave
authored andcommitted
btrfs: fix lost error handling when looking up extended ref on log replay
During log replay, when processing inode references, if we get an error when looking up for an extended reference at __add_inode_ref(), we ignore it and proceed, returning success (0) if no other error happens after the lookup. This is obviously wrong because in case an extended reference exists and it encodes some name not in the log, we need to unlink it, otherwise the filesystem state will not match the state it had after the last fsync. So just make __add_inode_ref() return an error it gets from the extended reference lookup. Fixes: f186373 ("btrfs: extended inode refs") CC: [email protected] # 4.9+ Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b40130b commit 7a6b75b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/btrfs/tree-log.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,9 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
11461146
extref = btrfs_lookup_inode_extref(NULL, root, path, name, namelen,
11471147
inode_objectid, parent_objectid, 0,
11481148
0);
1149-
if (!IS_ERR_OR_NULL(extref)) {
1149+
if (IS_ERR(extref)) {
1150+
return PTR_ERR(extref);
1151+
} else if (extref) {
11501152
u32 item_size;
11511153
u32 cur_offset = 0;
11521154
unsigned long base;

0 commit comments

Comments
 (0)