add writev_retry to avoid incomplete writes