Skip to contentSkip to conversation

btrfs: return -EIO on error in btree_write_cache_pages

PATCH In review Josef Bacik 2 participants 3 messages Jul 10, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

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
index a76b7da91aa6..6f0dd15729cc 100644
@@ -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
#1 lore raw
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 -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.

Is BTRFS_FS_STATE_ERROR only set for IO errors, or could it also be set for an actual corruption state?

Quoted 20 lines
---
 fs/btrfs/extent_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent_io.c +1 -1
index a76b7da91aa6..6f0dd15729cc 100644
@@ -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;
#2 lore raw
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 -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.

Quoted 2 lines

Is BTRFS_FS_STATE_ERROR only 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