Returning more precise errors from read()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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" },





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux