Skip to content

Commit 68b8558

Browse files
josefbacikkdave
authored andcommitted
btrfs: call mapping_set_error() on btree inode with a write error
generic/484 fails sometimes with compression on because the write ends up small enough that it goes into the btree. This means that we never call mapping_set_error() on the inode itself, because the page gets marked as fine when we inline it into the metadata. When the metadata writeback happens we see it and abort the transaction properly and mark the fs as readonly, however we don't do the mapping_set_error() on anything. In syncfs() we will simply return 0 if the sb is marked read-only, so we can't check for this in our syncfs callback. The only way the error gets returned if we called mapping_set_error() on something. Fix this by calling mapping_set_error() on the btree inode mapping. This allows us to properly return an error on syncfs and pass generic/484 with compression on. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent c2e3930 commit 68b8558

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/btrfs/extent_io.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4319,6 +4319,14 @@ static void set_btree_ioerr(struct page *page, struct extent_buffer *eb)
43194319
*/
43204320
clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
43214321

4322+
/*
4323+
* We need to set the mapping with the io error as well because a write
4324+
* error will flip the file system readonly, and then syncfs() will
4325+
* return a 0 because we are readonly if we don't modify the err seq for
4326+
* the superblock.
4327+
*/
4328+
mapping_set_error(page->mapping, -EIO);
4329+
43224330
/*
43234331
* If we error out, we should add back the dirty_metadata_bytes
43244332
* to make it consistent.

0 commit comments

Comments
 (0)