What error should FS return when I/O failure occurs?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Chris Siebenmann
You write:
| When I/O failure occurs, there should be some standards which | define the ONLY error that should be returned from VFS, right?In practice there is no standard and there never will be any standard.
In general the only thing code can do on any write error is to abort the operation, regardless of what errno is. (The exceptions are for things like nonblocking IO, where 'EAGAIN' and 'EWOULDBLOCK' are not real errors.)
Yes, we're sure to abort the operation, but we can't use exit(EXIT_FAILURE) directly. For HA environment, we should identify the cause of the error, take correspondent action, right? So we need to get the right error.
Quoted 4 lines
---
"I shall clasp my hands together and bow to the corners of the world."
Number Ten Ox, "Bridge of Birds"
[email protected] utgpu!cks
regards,
----
Qu Fuping
Quoted 4 lines
Yes, we're sure to abort the operation, but we can't use
exit(EXIT_FAILURE)directly. For HA environment, we should identify the cause of the error, take correspondent action, right? So we need to get the right error.
You mean a computer program will take the correspondent action? I think it would take a remarkably intelligent program to respond appropriately to particular failures -- especially if the program isn't tailored to a very specific environment. In practice, all I ever see a binary response -- one for success, one for failure. The errno is used at most for giving a three word explanation to a human so the human can respond. That's why people don't take this issue seriously.
"pass the errno up" is definitely a layering violation and cheap architecture. It's why the 3 word description you get is often meaningless -- it's telling you about a failure deep in computations you aren't even supposed to know about. I myself stay away from errnos where possible and produce error information in English text, with each layer adding information meaningful at that layer. But where we're sticking with classic errnos, it just doesn't make sense to work really hard on it.
Nonetheless, I think there's broad agreement, and the current discussion is consistent with it, that if write() fails due to an I/O error, the errno should be EIO. Whether it's formally specified or not, the standard is there. That ext3 returns EROFS is either a bug or an implementation convenience compromise or a case where the actual failure is more complicated than you imagine (maybe an operation fails and gets retried -- the original failure caused an automatic switch to R/O and the retry failed because of the R/O status. Errnos are definitely not sufficient to give you the whole chain of causation for a failure -- if it gives you even the immediate cause, you should feel fortunate).
--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems
Quoted 21 lines · Bryan Henderson
Quoted 4 lines
Yes, we're sure to abort the operation, but we can't use
exit(EXIT_FAILURE)directly. For HA environment, we should identify the cause of the error, take correspondent action, right? So we need to get the right error.You mean a computer program will take the correspondent action? I think it would take a remarkably intelligent program to respond appropriately to particular failures -- especially if the program isn't tailored to a very specific environment. In practice, all I ever see a binary response -- one for success, one for failure. The errno is used at most for giving a three word explanation to a human so the human can respond. That's why people don't take this issue seriously.
"pass the errno up" is definitely a layering violation and cheap architecture. It's why the 3 word description you get is often meaningless -- it's telling you about a failure deep in computations you aren't even supposed to know about. I myself stay away from errnos where possible and produce error information in English text, with each layer adding information meaningful at that layer. But where we're sticking with classic errnos, it just doesn't make sense to work really hard on it.
Quoted 4 lines
Nonetheless, I think there's broad agreement, and the current discussion is consistent with it, that if
write()fails due to an I/O error, the errno should be EIO. Whether it's formally specified or not, the standard is there. That ext3 returns EROFS is either a bug or an implementation
what standard do you mean?
Quoted 6 lines
convenience compromise or a case where the actual failure is more complicated than you imagine (maybe an operation fails and gets retried -- the original failure caused an automatic switch to R/O and the retry failed because of the R/O status. Errnos are definitely not sufficient to give you the whole chain of causation for a failure -- if it gives you even the immediate cause, you should feel fortunate).
I suggest you visit our project, see the testing result,
http://developer.osdl.jp/projects/doubt/fs-consistency-and-coherency
For each test case, different FS returns different result.
Quoted 1 line
From user's perspective, it's really annoying, so, there should be a
standard which constraints the error type. Otherwise, different fs can return whatever they want, regardless of the user's need.
Quoted 4 lines
--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems
Quoted 4 lines · fs
For each test case, different FS returns different result. From user's perspective, it's really annoying, so, there should be a standard which constraints the error type. Otherwise, different fs can return whatever they want, regardless of the user's need.
Which does the user "need":
a) an 'errno' valye that's forced to be one of a specific subset of values, even if none of them explain what's going on
or
b) an 'errno' value that actually tells you about the error?
Remember - if the *kernel* forces a -EROFS to become a -EIO, then userspace is stuck with that value. If the kernel passes -EROFS back to userspace, then after glibc stashes an EROFS into errno, either glibc or the application program can insert a 'if (errno == EROFS) {errno = EIO;}' if it feels that EROFS is unnatural.
And in any case, that's what the *application programmer* needs. What the *user* needs is for the file to either be safely stored, or a dialog box put up saying that it failed....
Quoted 6 lines
Quoted 4 lines
there's broad agreement, and the current discussion
is consistent with it, that ifwrite()fails due to an I/O error, the errno should be EIO. Whether it's formally specified or not, the standard is there.what standard do you mean?
De facto standard.
Quoted 1 line
For each test case, different FS returns different result.
But not because the designers disagreed on what the appropriate errno for a particular failure is. As I described in previous emails, there are other explanations for the diversity, including bugs.
Quoted 3 lines
From user's perspective, it's really annoying, so, there should be a standard which constrains the error type. Otherwise, different fs can return whatever they want, regardless of the user's need.
Different filesystem types and the driver implementations for them give different meaning to file operations, and therefore the effects of errors can be quite different. To get the level of standardization where unplugging a device produces exactly the same symptom at the user level for everybody, you need to say that a particular filesystem type (ext3, for example) is standard.
I don't think it's feasible to get diversity in filesystem types and drivers and still consistency in something as detailed as what effect an I/O error has. Note that one can't even write a precise universal definition of I/O error.
I think you'll make more progress, rather than talking about defining a universal error response, by taking some of the cases which are most unusual or unnatural and asking if each should/could be "fixed."
Or, if you're particularly concerned about USB unplugs of a device that contains a filesystem, you might ask if some new function could be added to Linux to deal with unplugs gracefully rather than just having them be generic I/O errors with consequent unpredictable behavior.
--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems