]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
generic: test eofblocks race with file extending aio dio writes
authorZorro Lang <zlang@redhat.com>
Wed, 26 Apr 2017 16:23:36 +0000 (00:23 +0800)
committerEryu Guan <eguan@redhat.com>
Thu, 27 Apr 2017 03:31:00 +0000 (11:31 +0800)
commitaccf20216c71af9d5c55933c899f68374afb86df
tree2f7b203867148b8421047766b0dfcc8f0ef3fa05
parent5d20084fefaf09e86be26d7c71bd1c7ac2a2b35c
generic: test eofblocks race with file extending aio dio writes

It's possible for post-eof blocks to end up being used for direct
I/O writes. dio write performs an upfront unwritten extent
allocation, sends the dio and then updates the inode size (if
necessary) on write completion. If a file release occurs while a
file extending dio write is in flight, it is possible to mistake the
post-eof blocks for speculative preallocation and incorrectly
truncate them from the inode. This means that the resulting dio
write completion can discover a hole and allocate new blocks rather
than perform unwritten extent conversion.

A kernel warning can be reproduced by generic/299 on XFS:
  XFS: Assertion failed: tp->t_blk_res_used <= tp->t_blk_res, \
       file: fs/xfs//xfs_trans.c, line: 309

The root cause is that xfs_free_eofblocks() uses i_size to truncate
post-eof blocks from the inode, but async, file extending direct
writes do not update i_size until write completion, long after inode
locks are dropped. Therefore, xfs_free_eofblocks() effectively
truncates the inode to the incorrect size.

Besides reproduce above kernel warning, the verification of written
data is an important distinction between this test and generic/299.
For cover this filesystem corruption testing, write this new case to
check data integrality manually, not only depend on a kernel
warning.

To increase the test stress of aio-dio-eof-race, add two arguments
to this source code to change the file size will be written.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
src/aio-dio-regress/aio-dio-eof-race.c
tests/generic/427 [new file with mode: 0755]
tests/generic/427.out [new file with mode: 0644]
tests/generic/group