btrfs: tree-log: Check btrfs_lookup_data_extent return value
PATCH 1/1 btrfs: tree-log: Check btrfs_lookup_data_extent return value
Function btrfs_lookup_data_extent calls btrfs_search_slot to verify if the EXTENT_ITEM exists in the extent tree. btrfs_search_slot can return values bellow zero if an error happened.
Function replay_one_extent currently check if the search found something (0 returned) and increments the reference, and if not, it seems to evaluate as 'not found'.
Fix the condition by checking if the value was bellow zero and return early.
---
Found while inspecting some btrfs_search_slot call sites.
fs/btrfs/tree-log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/tree-log.c +3 -1
@@ -753,7 +753,9 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,*/ ret =btrfs_lookup_data_extent (fs_info, ins.objectid, ins.offset); -if (ret ==0 ) { +if (ret <0 ) { + goto out; + }else if (ret ==0 ) {btrfs_init_generic_ref (&ref,BTRFS_ADD_DELAYED_REF , ins.objectid, ins.offset,0 );
Signature · 1 line
2.26.2
Quoted 5 lines · Marcos Paulo de Souza
Function
btrfs_lookup_data_extentcallsbtrfs_search_slotto verify if theEXTENT_ITEMexists in the extent tree.btrfs_search_slotcan return values bellow zero if an error happened.
Quoted 7 lines
Function
replay_one_extentcurrently check if the search found something (0 returned) and increments the reference, and if not, it seems to evaluate as 'not found'.Fix the condition by checking if the value was bellow zero and return early.
Signed-off-by Marcos Paulo de Souza <[email protected]>
That's fine, thanks.
Quoted 25 lines
---
Found while inspecting some
btrfs_search_slotcall sites.fs/btrfs/tree-log.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/btrfs/tree-log.c +3
-2@@ -753,7 +753,9 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,*/ ret =btrfs_lookup_data_extent (fs_info, ins.objectid, ins.offset); -if (ret ==0 ) { +if (ret <0 ) { + goto out; + }else if (ret ==0 ) {btrfs_init_generic_ref (&ref,BTRFS_ADD_DELAYED_REF , ins.objectid, ins.offset,0 ); --2.26.2
Signature · 3 lines
Filipe David Manana, “Whether you think you can, or you think you can't — you're right.”
Quoted 11 lines · Marcos Paulo de Souza
Function
btrfs_lookup_data_extentcallsbtrfs_search_slotto verify if theEXTENT_ITEMexists in the extent tree.btrfs_search_slotcan return values bellow zero if an error happened.Function
replay_one_extentcurrently check if the search found something (0 returned) and increments the reference, and if not, it seems to evaluate as 'not found'.Fix the condition by checking if the value was bellow zero and return early.
Signed-off-by Marcos Paulo de Souza <[email protected]>
Added to misc-next, thanks.