From: Matthew Wilcox <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Subject: Returning more precise errors from read()
Date: Fri, 19 Apr 2024 16:30:10 +0100 [thread overview]
Message-ID: <ZiKOAj5TV44pKTeJ@casper.infradead.org> (raw)
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" },
reply other threads:[~2024-04-19 15:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZiKOAj5TV44pKTeJ@casper.infradead.org \
--to=willy@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).