Revision ad576e63e0c8b274a8558b8e05a6d0526e804dc0 authored by Nick Piggin on 05 May 2005, 23:15:46 UTC, committed by Linus Torvalds on 05 May 2005, 23:36:40 UTC
When running
	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
	BUG_ON(!buffer_async_write(bh));
in fs/buffer.c:end_buffer_async_write

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.
=> oops.

So change __block_write_full_page to explicitly keep track of the last bh
we need to issue, so we don't touch anything after issuing the last
request.

Signed-off-by: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent f3ddbdc
History
File Mode Size
Makefile -rw-r--r-- 615 bytes
bootmem.c -rw-r--r-- 10.5 KB
fadvise.c -rw-r--r-- 2.4 KB
filemap.c -rw-r--r-- 57.9 KB
fremap.c -rw-r--r-- 6.3 KB
highmem.c -rw-r--r-- 13.7 KB
hugetlb.c -rw-r--r-- 6.1 KB
internal.h -rw-r--r-- 486 bytes
madvise.c -rw-r--r-- 6.4 KB
memory.c -rw-r--r-- 59.1 KB
mempolicy.c -rw-r--r-- 28.8 KB
mempool.c -rw-r--r-- 7.7 KB
mincore.c -rw-r--r-- 4.4 KB
mlock.c -rw-r--r-- 5.3 KB
mmap.c -rw-r--r-- 52.7 KB
mprotect.c -rw-r--r-- 6.5 KB
mremap.c -rw-r--r-- 10.4 KB
msync.c -rw-r--r-- 5.5 KB
nommu.c -rw-r--r-- 27.6 KB
oom_kill.c -rw-r--r-- 7.4 KB
page-writeback.c -rw-r--r-- 22.7 KB
page_alloc.c -rw-r--r-- 54.9 KB
page_io.c -rw-r--r-- 3.6 KB
pdflush.c -rw-r--r-- 5.8 KB
prio_tree.c -rw-r--r-- 6.3 KB
readahead.c -rw-r--r-- 15.8 KB
rmap.c -rw-r--r-- 22.6 KB
shmem.c -rw-r--r-- 57.6 KB
slab.c -rw-r--r-- 81.4 KB
swap.c -rw-r--r-- 12.0 KB
swap_state.c -rw-r--r-- 9.3 KB
swapfile.c -rw-r--r-- 41.4 KB
thrash.c -rw-r--r-- 2.6 KB
tiny-shmem.c -rw-r--r-- 2.7 KB
truncate.c -rw-r--r-- 8.9 KB
vmalloc.c -rw-r--r-- 12.9 KB
vmscan.c -rw-r--r-- 35.1 KB

back to top