From: Hisashi Hifumi In the current jbd code, if a buffer on BJ_SyncData list is dirty and not locked, the buffer is refiled to BJ_Locked list, submitted to the IO and waited for IO completion. But the fsstress test showed the case that when a buffer was already submitted to the IO just before the buffer_dirty(bh) check, the buffer was not waited for IO completion. Following patch solves this problem. If it is assumed that a buffer is submitted to the IO before the buffer_dirty(bh) check and still being written to disk, this buffer is refiled to BJ_Locked list. Signed-off-by: Hisashi Hifumi Cc: Jan Kara Cc: "Stephen C. Tweedie" Cc: Signed-off-by: Andrew Morton --- fs/jbd/commit.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff -puN fs/jbd/commit.c~jbd-wait-for-already-submitted-t_sync_datalist-buffer fs/jbd/commit.c --- a/fs/jbd/commit.c~jbd-wait-for-already-submitted-t_sync_datalist-buffer +++ a/fs/jbd/commit.c @@ -248,8 +248,12 @@ write_out_data: bufs = 0; goto write_out_data; } - } - else { + } else if (!locked && buffer_locked(bh)) { + __journal_file_buffer(jh, commit_transaction, + BJ_Locked); + jbd_unlock_bh_state(bh); + put_bh(bh); + } else { BUFFER_TRACE(bh, "writeout complete: unfile"); __journal_unfile_buffer(jh); jbd_unlock_bh_state(bh); _