fix race at exit by checking if write completed

The same issue as:
    commit 352358cd9f69f6e8296cc201b14bae938287796e
    Author: Jan Stancek <jstancek@redhat.com>
    Date: Mon, 28 Jan 2013 11:36:48 +0100
    aio_fsync/2-1.c: fix race at exit, check if write completed
This patch waits for aio_fsync to complete and after that
checks that previously queued write is also completed.

Signed-off-by: Yan Lei <yanl.fnst@cn.fujitsu.com>
Acked-by: Jan Stancek <jstancek@redhat.com>