Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: handle discard errors in in btrfs_finish_extent_commit()

Coverity (ID: 1226842) reported that the return value of
btrfs_discard_extent() is assigned to ret but is immediately
overwritten by unpin_extent_range() without being checked.

Use the same error handling that is done later in the same function.

Signed-off-by: Jingkai Tan <contact@jingk.ai>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Jingkai Tan and committed by
David Sterba
2970525f ecb7c248

+7 -1
+7 -1
fs/btrfs/extent-tree.c
··· 2933 2933 while (!TRANS_ABORTED(trans) && cached_state) { 2934 2934 struct extent_state *next_state; 2935 2935 2936 - if (btrfs_test_opt(fs_info, DISCARD_SYNC)) 2936 + if (btrfs_test_opt(fs_info, DISCARD_SYNC)) { 2937 2937 ret = btrfs_discard_extent(fs_info, start, 2938 2938 end + 1 - start, NULL, true); 2939 + if (ret) { 2940 + btrfs_warn(fs_info, 2941 + "discard failed for extent [%llu, %llu]: errno=%d %s", 2942 + start, end, ret, btrfs_decode_error(ret)); 2943 + } 2944 + } 2939 2945 2940 2946 next_state = btrfs_next_extent_state(unpin, cached_state); 2941 2947 btrfs_clear_extent_dirty(unpin, start, end, &cached_state);