* Returning more precise errors from read()
@ 2024-04-19 15:30 Matthew Wilcox
0 siblings, 0 replies; only message in thread
From: Matthew Wilcox @ 2024-04-19 15:30 UTC (permalink / raw)
To: linux-fsdevel
Today we throw away the actual error returned by the block device /
network protocol and transform it into an EIO return from read() [1].
There's no way today to send the error from the I/O completion routine
up to the VFS [2]. Is it worth doing?
For block devices, there's a fairly limited set of additional errors
that would apply to reads [3].
The important question in my mind is whether returning any of these
errors to userspace would confuse applications. I suspect they would,
and returning anything other than EIO to userspace is just a bad idea.
But I'd like opinions before I pass up the opportunity to make this
improvement.
I'm not going to make this change without a reason because it would
impose some small costs on a few filesystems (notably any using iomap).
[1] For the curious, this happens in filemap_read_folio():
error = filler(file, folio);
if (error)
return error;
error = folio_wait_locked_killable(folio);
if (error)
return error;
if (folio_test_uptodate(folio))
return 0;
return -EIO;
This looks like it can return a lot of different errors, but all real
filesystems will only return synchronous errors like -ENOMEM ("couldn't
allocate memory to submit request"). Any error from the block
device simply leaves the folio being left as !uptodate and we
return -EIO.
[2] I prototyped one once, but never got round to submitting it. I'm in
the middle of converting a lot of filesystems, and it occurred to me
that a fairly small change to folio_end_read() would make this easier
to do in the future.
[3]
[BLK_STS_TIMEOUT] = { -ETIMEDOUT, "timeout" },
[BLK_STS_TRANSPORT] = { -ENOLINK, "recoverable transport" },
[BLK_STS_TARGET] = { -EREMOTEIO, "critical target" },
[BLK_STS_MEDIUM] = { -ENODATA, "critical medium" },
[BLK_STS_PROTECTION] = { -EILSEQ, "protection" },
[BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" },
[BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" },
[BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" },
[BLK_STS_OFFLINE] = { -ENODEV, "device offline" },
[BLK_STS_DURATION_LIMIT] = { -ETIME, "duration limit exceeded" },
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-19 15:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-19 15:30 Returning more precise errors from read() Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).