Skip to content

Commit ae82071

Browse files
fdmananakdave
authored andcommitted
btrfs: fix missing error handling when searching for inode refs during log replay
During log replay, at __add_inode_ref(), when we are searching for inode ref keys we totally ignore if btrfs_search_slot() returns an error. This may make a log replay succeed when there was an actual error and leave some metadata inconsistency in a subvolume tree. Fix this by checking if an error was returned from btrfs_search_slot() and if so, return it to the caller. Fixes: e02119d ("Btrfs: Add a write ahead tree log to optimize synchronous operations") Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 1d2c8bb commit ae82071

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
@@ -1073,7 +1073,9 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
10731073
search_key.type = BTRFS_INODE_REF_KEY;
10741074
search_key.offset = parent_objectid;
10751075
ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
1076-
if (ret == 0) {
1076+
if (ret < 0) {
1077+
return ret;
1078+
} else if (ret == 0) {
10771079
struct btrfs_inode_ref *victim_ref;
10781080
unsigned long ptr;
10791081
unsigned long ptr_end;

0 commit comments

Comments
 (0)