btrfs: return -EIO on error in btree_write_cache_pages
PATCH 1/1 btrfs: return -EIO on error in btree_write_cache_pages
Eric reported seeing this message while running generic/475
BTRFS: error (device dm-3) in btrfs_sync_log:3084: errno=-117 Filesystem corrupted
This ret came from btrfs_write_marked_extents(). If we get an aborted transaction via an -EIO somewhere, we'll see it in btree_write_cache_pages() and return -EUCLEAN, which we spit out as "Filesystem corrupted". Except we shouldn't be returning -EUCLEAN here, we need to be returning -EIO. -EUCLEAN is reserved for actual corruption, not IO errors.
--- fs/btrfs/extent_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent_io.c +1 -1
@@ -4122,7 +4122,7 @@ int btree_write_cache_pages(struct address_space *mapping,if (!test_bit (BTRFS_FS_STATE_ERROR , &fs_info->fs_state)) { ret =flush_write_bio (&epd); }else { - ret = -EUCLEAN ; + ret = -EIO ;end_write_bio (&epd, ret); }return ret;
Signature · 1 line
2.24.1
Quoted 10 lines · Josef Bacik
Eric reported seeing this message while running generic/475
BTRFS: error (device dm-3) in btrfs_sync_log:3084: errno=-117 Filesystem corrupted
This ret came from
btrfs_write_marked_extents(). If we get an aborted transaction via an-EIOsomewhere, we'll see it inbtree_write_cache_pages()and return-EUCLEAN, which we spit out as "Filesystem corrupted". Except we shouldn't be returning-EUCLEANhere, we need to be returning-EIO.-EUCLEANis reserved for actual corruption, not IO errors.
Is BTRFS_FS_STATE_ERROR only set for IO errors, or could it also be set for an actual corruption state?
Quoted 20 lines
Reported-by Eric Sandeen <[email protected]>Signed-off-by Josef Bacik <[email protected]>--- fs/btrfs/extent_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/extent_io.c +1
-1@@ -4122,7 +4122,7 @@ int btree_write_cache_pages(struct address_space *mapping,if (!test_bit (BTRFS_FS_STATE_ERROR , &fs_info->fs_state)) { ret =flush_write_bio (&epd); }else { - ret = -EUCLEAN ; + ret = -EIO ;end_write_bio (&epd, ret); }return ret;
Quoted 12 lines · Eric Sandeen
Quoted 10 lines · Josef Bacik
Eric reported seeing this message while running generic/475
BTRFS: error (device dm-3) in btrfs_sync_log:3084: errno=-117 Filesystem corrupted
This ret came from
btrfs_write_marked_extents(). If we get an aborted transaction via an-EIOsomewhere, we'll see it inbtree_write_cache_pages()and return-EUCLEAN, which we spit out as "Filesystem corrupted". Except we shouldn't be returning-EUCLEANhere, we need to be returning-EIO.-EUCLEANis reserved for actual corruption, not IO errors.
Quoted 2 lines
Is
BTRFS_FS_STATE_ERRORonly set for IO errors, or could it also be set for an actual corruption state?
It's set when we abort the transaction, which can be either or I suppose. At this point we don't have the offending error, but the transaction abort _would_ have it. So if there was a corruption you would see it higher up in the logs. Thanks,
Josef