提交 c1373642 编写于 作者: M Marcos Paulo de Souza 提交者: Zheng Zengkai

btrfs: tree-log: check btrfs_lookup_data_extent return value

stable inclusion
from stable-5.10.67
commit b225eeaf3a02f2d47a4a5ee8cc976fc822eddac7
bugzilla: 182619 https://gitee.com/openeuler/kernel/issues/I4EWO7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b225eeaf3a02f2d47a4a5ee8cc976fc822eddac7

--------------------------------

[ Upstream commit 3736127a ]

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 checks 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.
Reviewed-by: NFilipe Manana <fdmanana@suse.com>
Signed-off-by: NMarcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 611e3220
...@@ -708,7 +708,9 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, ...@@ -708,7 +708,9 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
*/ */
ret = btrfs_lookup_data_extent(fs_info, ins.objectid, ret = btrfs_lookup_data_extent(fs_info, ins.objectid,
ins.offset); ins.offset);
if (ret == 0) { if (ret < 0) {
goto out;
} else if (ret == 0) {
btrfs_init_generic_ref(&ref, btrfs_init_generic_ref(&ref,
BTRFS_ADD_DELAYED_REF, BTRFS_ADD_DELAYED_REF,
ins.objectid, ins.offset, 0); ins.objectid, ins.offset, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册