aio: fix memory corruption in aio-last-ref-held-by-io
authorLiu Bo <liub.liubo@gmail.com>
Mon, 10 Nov 2014 07:01:07 +0000 (18:01 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 10 Nov 2014 07:01:07 +0000 (18:01 +1100)
commit181ba037284c35f6583af0f40c57e9396da970d7
tree558f5f76ccf5e8776e8ab954498ca6327d83b8ea
parentfa7f9fb987a26afda63511434fc1df468c861bc4
aio: fix memory corruption in aio-last-ref-held-by-io

This's been detected by testing generic/323 on btrfs, it keeps
producing chaos of checksum errors.

It is because aio-last-ref-held-by-io uses a static buffer that is
been used repeatedly for every io_submit() call, but we'll issue
NUM_IOS(=16) io_sumbit() in a 'for' loop at a time, and when those
data read by aio has not finish its endio(), its memory is likely to
be used in the next io_submit, which ends up data corruption and
numerous checksum errors.

This allocates memory for each io_submit() and generic/323 runs fine
after this.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
src/aio-dio-regress/aio-last-ref-held-by-io.c