Commit de1c3893 authored by Tim Wright's avatar Tim Wright Committed by Linus Torvalds

[PATCH] Forward port of 2.4 fsync_buffers_list() fix.

there was a bug in fysnc_buffers_list() in 2.4 (fixed in 2.4.19) that
could cause the function to return without having written the current
contents of all the buffers.

Obviously, this could be bad for anybody relying on ordering using
O_SYNC or fsync().  If an I/O was already in flight for a particular bh
at the time of the call to fsync_buffers_list(), ll_rw_block() will not
initiate a new I/O even though the contents may have changed.  It is
therefore necessary to wait before the call.  Here's a patch against
2.5.42 that applies the same fix.
parent 4c34d455
...@@ -811,6 +811,13 @@ int fsync_buffers_list(spinlock_t *lock, struct list_head *list) ...@@ -811,6 +811,13 @@ int fsync_buffers_list(spinlock_t *lock, struct list_head *list)
if (buffer_dirty(bh)) { if (buffer_dirty(bh)) {
get_bh(bh); get_bh(bh);
spin_unlock(lock); spin_unlock(lock);
/*
* Ensure any pending I/O completes so that
* ll_rw_block() actually writes the current
* contents - it is a noop if I/O is still in
* flight on potentially older contents.
*/
wait_on_buffer(bh);
ll_rw_block(WRITE, 1, &bh); ll_rw_block(WRITE, 1, &bh);
brelse(bh); brelse(bh);
spin_lock(lock); spin_lock(lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment