Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2211,8 +2211,22 @@ void block_commit_write(struct folio *folio, size_t from, size_t to)
if (!buffer_uptodate(bh))
partial = true;
} else {
/*
* Per the contract documented at set_buffer_uptodate()
* in include/linux/buffer_head.h, callers must hold
* BH_Lock to serialize against concurrent clears of
* BH_Uptodate. Holding only the folio lock is not
* sufficient: a concurrent end_buffer_write_sync() on
* the write-error path clears BH_Uptodate while
* holding BH_Lock; without BH_Lock here the clear can
* land between set_buffer_uptodate() and
* mark_buffer_dirty(), tripping the WARN_ON_ONCE in
* mark_buffer_dirty().
*/
lock_buffer(bh);
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
unlock_buffer(bh);
}
if (buffer_new(bh))
clear_buffer_new(bh);
Expand Down
Loading