Nick Piggin <nickpiggin@xxxxxxxxxxxx> wrote:
fsstress -v -d $DIR/tmp -n 1000 -p 1000 -l 2
on an ext2 filesystem with 1024 byte block size, on SMP i386 with 4096 byte
page size over loopback to an image file on a tmpfs filesystem, I would
very quickly hit
It seems that more than one request would be submitted for a given bh
at a time.
What would happen is the following:
2 threads doing __mpage_writepages on the same page.
Thread 1 - lock the page first, and enter __block_write_full_page.
Thread 1 - (eg.) mark_buffer_async_write on the first 2 buffers.
Thread 1 - set page writeback, unlock page.
Thread 2 - lock page, wait on page writeback
Thread 1 - submit_bh on the first 2 buffers.
=> both requests complete, none of the page buffers are async_write,
end_page_writeback is called.
Thread 2 - wakes up. enters __block_write_full_page.
Thread 2 - mark_buffer_async_write on (eg.) the last buffer
Thread 1 - finds the last buffer has async_write set, submit_bh on that.
Thread 2 - submit_bh on the last buffer.
There are two situations:
a) Thread 2 comes in and tries to write a buffer which thread1 didn't write:
Yes, thread 1 will get confused and will try to write thread 2's buffer.
b) Thread 2 comes in and tries to write a buffer which thread 1 is
writing. (Say, the buffer was redirtied by
munmap->__set_page_dirty_buffers, which doesn't lock the page or the
Thread 2 will fail the test_set_buffer_locked() and will redirty the page.
That's all a bit too complex. How's about this instead?