O_DIRECT is supposed to bypass all kernel caching and buffering and
write directly to the device synchronously. All of my write calls are
also followed by a call to fsync(). However, if the write does get
buffered my code should throw an error simply stating that it didn't
get a response and the SD card should still continue to work. What is
happening now is that I suddenly stop being able to read from it part
way through my application (so after 1 or 2 successful write/read
combinations) and Android claims that the SD card is now corrupt.
Oh, and here is a snippet from dmesg after read returned error EIO
<3>[175078.338409] mmc1: Command timeout
<3>[175078.338928] mmc1: DMA channel flushed (0x80000004)
<3>[175078.339385] Flush data: 0000c003 161f3000 00000000 00400040
00080008 00000003
<6>[175078.340179] mmc1: Worked around bug 1535304
<3>[175078.340972] mmcblk0: error -110 sending read/write command
<3>[175078.341430] mmcblk0: error -5 transferring data
<3>[175078.341857] end_request: I/O error, dev mmcblk0, sector 1376
<3>[175078.437652] mmc1: Command timeout
<3>[175078.443115] mmcblk0: error -110 sending read/write command
<3>[175078.443664] mmc1: Command timeout
<3>[175078.448944] mmc1: Command timeout
<3>[175078.454223] mmc1: Command timeout
<3>[175078.459747] mmc1: Command timeout
<3>[175078.465026] mmc1: Command timeout
<3>[175078.470306] mmc1: Command timeout
<3>[175078.476989] mmcblk0: error -110 requesting status
<3>[175078.477569] mmc1: Command timeout
<3>[175078.482971] end_request: I/O error, dev mmcblk0, sector 1376
<3>[175078.526855] mmc1: Command timeout
<3>[175078.532226] mmcblk0: error -110 sending read/write command
<3>[175078.532775] mmc1: Command timeout
<3>[175078.538085] mmc1: Command timeout
<3>[175078.543365] mmc1: Command timeout
<3>[175078.548645] mmc1: Command timeout
<3>[175078.554168] mmc1: Command timeout
<3>[175078.559448] mmc1: Command timeout
<3>[175078.565490] mmcblk0: error -110 requesting status
<3>[175078.566345] mmc1: Command timeout
<3>[175078.571807] end_request: I/O error, dev mmcblk0, sector 736
<3>[175078.572265] Buffer I/O error on device mmcblk0p1, logical block
487
<4>[175078.572723] lost page write due to I/O error on mmcblk0p1