generic: unaligned direct AIO write test
authorZorro Lang <zlang@redhat.com>
Sat, 30 Mar 2019 15:14:47 +0000 (23:14 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sat, 6 Apr 2019 11:14:59 +0000 (19:14 +0800)
commited8463509b01540787fbd6ada95532a5577e6d15
tree23b57b5110d4e8873d47e3c3942726e4772b40ba
parentb591875529d13006c2b4e62dbc4b5726d8e2d77a
generic: unaligned direct AIO write test

A simply reproducer from Frank Sorenson:

  ftruncate(fd, 65012224)
  io_prep_pwrite(iocbs[0], fd, buf[0], 1048576, 63963648);
  io_prep_pwrite(iocbs[1], fd, buf[1], 1048576, 65012224);

  io_submit(io_ctx, 1, &iocbs[0]);
  io_submit(io_ctx, 1, &iocbs[1]);

  io_getevents(io_ctx, 2, 2, events, NULL)

help to find an ext4 corruption:
           **************** **************** ****************
           *    page 1    * *    page 2    * *    page 3    *
           **************** **************** ****************
  existing 0000000000000000 0000000000000000 0000000000000000
  write 1    AAAAAAAAAAAAAA AA
  write 2                     BBBBBBBBBBBBBB BB

  result   00AAAAAAAAAAAAAA 00BBBBBBBBBBBBBB BB00000000000000
  desired  00AAAAAAAAAAAAAA AABBBBBBBBBBBBBB BB00000000000000

This issue remind us we might miss unaligned AIO test for long time.
We thought fsx cover this part, but looks like it's not. So this case
trys to cover unaligned direct AIO write test on file with different
initial truncate i_size.

The following patches fix the issue on xfs and ext4.

xfs: serialize unaligned dio writes against all other dio writes
ext4: Fix data corruption caused by unaligned direct AIO

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
.gitignore
src/aio-dio-regress/aio-dio-write-verify.c [new file with mode: 0644]
tests/generic/538 [new file with mode: 0755]
tests/generic/538.out [new file with mode: 0644]
tests/generic/group