0

What kinds of i/o error returns when remove disk abnormally(physically)?

I use linux aio functions to i/o files.

If I remove disk abnormally after "io_submit(control blocks with i/o infos)",

suspend aio(io_getevents) will return events with EBADF or EDISK? or something else?

It's hard to test on cloud, so I ask for u guys.

rnsjtngus
  • 225
  • 1
  • 8
  • 1
    You seem to be specifically mentioning some api. Could you prepare a sample compilable program to test it? I suspect `EIO` will be the errno, but I suspect that really depends at what exactly time is the disc removed (and the data may also be cached, so it may return success). I see [`aio_suspend`](https://pubs.opengroup.org/onlinepubs/9699919799/functions/aio_suspend.html) can't return EBADF nor EDISK, it most probably will succeed; use `aio_return` – KamilCuk Sep 10 '20 at 09:49
  • What is `suspend_aio`? Do you mean `aio_suspend`? The man page tells you it can return EAGAIN, EINTR, or ENOSYS. Use `aio_error` to get the error that occurred. – stark Sep 10 '20 at 13:53
  • 1
    You'll only get `EIO`. You'll need to use some other mechanism to detect if the disk has been removed. – Mike Andrews Sep 10 '20 at 14:01
  • Actually there **are** ways to test this by creating fake devices that can suddenly return errors even in the cloud assuming you're in a VM where you have root access. See the [list of Linux disk fault injection mechanisms](https://unix.stackexchange.com/a/144200/109111). – Anon Nov 11 '20 at 17:38

0 Answers0