Skip to contentSkip to conversation

generic: test writev with page fault when it processes iov

PATCH Superseded Zorro Lang 1 participant 1 message Jun 21, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH v2 1/1 generic: test writev with page fault when it processes iov

We met a kernel assertion failure recently as below:

XFS: Assertion failed: tp->t_blk_res_used <= tp->t_blk_res, file: fs/xfs/xfs_trans.c, line: 309

Eric Sandeen digged into it and find a good reproducer.

The problem comes when the several IO vectors are copied in, and it runs into page faults, which stops the copy before all vectors are copied. XFS sees this as a failed/short write, and so tries to unmap the blocks & truncate away the pages in xfs_vm_write_end.

generic_perform_write is looping, and comes back around for the other iovecs, but the page is still there, the buffer head is still mapped, and so a new delalloc block isn't allocated - and ends up being allocated at writeback time, despite the fact that we "should" have accounted for it all at delalloc write time, and trips the assert.

---

Hi,

V2 did below changes:
1) provide a parameter to specify iov count for writev.
2) check the return value of malloc() and calloc()
3) add more commit log

Thanks,
Zorro

 .gitignore                |   1 +
 src/Makefile              |   2 +-
 src/writev_on_pagefault.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/441         |  61 +++++++++++++++++++++++++++
 tests/generic/441.out     |   2 +
 tests/generic/group       |   1 +
 6 files changed, 168 insertions(+), 1 deletion(-)
 create mode 100644 src/writev_on_pagefault.c
 create mode 100755 tests/generic/441
 create mode 100644 tests/generic/441.out
.gitignore +1 -0
index 39664b0..043e87f 100644
@@ -130,6 +130,7 @@
 /src/unwritten_sync
 /src/usemem
 /src/writemod
+/src/writev_on_pagefault
 /src/xfsctl
 /src/aio-dio-regress/aio-dio-extend-stat
 /src/aio-dio-regress/aio-dio-fcntl-race
src/Makefile +1 -1
index 6b0e4b0..9d54fe7 100644
@@ -9,7 +9,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
 	nametest permname randholes runas truncfile usemem \
 	mmapcat append_reader append_writer dirperf metaperf \
 	devzero feature alloc fault fstest t_access_root \
-	godown resvtest writemod makeextents itrash rename \
+	godown resvtest writemod writev_on_pagefault makeextents itrash rename \
 	multi_open_unlink dmiperf unwritten_sync genhashnames t_holes \
 	t_mmap_writev t_truncate_cmtime dirhash_collide t_rename_overwrite \
 	holetest t_truncate_self t_mmap_dio af_unix t_mmap_stale_pmd \
src/writev_on_pagefault.c new file +102 -0

102 lines not on this page · raw message

tests/generic/441 new file +61 -0

61 lines not on this page · raw message

tests/generic/441.out new file +2 -0
new file mode 100644
index 0000000..2d5acf9
@@ -0,0 +1,2 @@
+QA output created by 441
+wrote 3 bytes
tests/generic/group +1 -0
index ab1e9d3..5046c97 100644
@@ -443,3 +443,4 @@
 438 auto
 439 auto quick punch
 440 auto quick encrypt
+441 auto quick rw
Signature · 1 line
2.7.5