Kernel buffer layer to stop marking good data stale on write failure
A 19-patch series stops clearing BH_Uptodate when metadata writes fail, fixing silent data loss and spurious warnings across multiple filesystems.
When a metadata write fails in the Linux kernel, the buffer layer has long cleared the BH_Uptodate flag. That was wrong: the in-memory buffer still holds exactly what the filesystem asked to write. The disk is stale, not the buffer. Chao Shi has posted a 19-patch series that stops the practice and makes BH_Write_EIO the sole signal that a write failed.
Clearing uptodate had concrete costs. Filesystems that dirtied the same buffer to retry the write hit a WARN_ON in mark_buffer_dirty(). Worse, a buffer marked not up to date could be re-read from disk, silently replacing the intended metadata with the old on-disk copy. There was also a brief window where the buffer's state was inconsistent under the folio lock.
BH_Write_EIO already records write failure. The series converts core buffer helpers and consumers in adfs, ext2, omfs, exfat, fat, ext4, ocfs2, gfs2, and jbd2 to test that flag instead, then removes the clears. Along the way it teaches buffer_heads to point at non-page-cache memory so jbd2's slab-backed shadow buffers can use the same error path, and it clears BH_Write_EIO on bforget and invalidate so freed blocks do not inherit someone else's error.
Most steps are behaviour-preserving until the final removal. One intentional change is in gfs2: its log write completion already set BH_Write_EIO without clearing uptodate, so two AIL checks were blind to log write errors and will start catching them. Jan Kara reviewed much of the series and agreed that is the desired fix. He also flagged that ocfs2 maintainers should weigh in on keeping cluster cache state uptodate after a local write IO error.
Matthew Wilcox contributed groundwork that drops the old b_page field and helped shape the folio-less buffer path. Review also surfaced a pre-existing jbd2 checksum hazard on highmem with forced kmap debug, separate from the error-flag work.