On Sun, 2 Nov 2014, Ian Lepore wrote:

On Sun, 2014-11-02 at 12:27 -0800, Xin Li wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi, Mark,

I'd like to propose the attached patch for review.  It replaces
tsleep's with sx_sleep's, then checks the return value and quit the loop.

It still doesn't handle the partial read/write case Kostik mentioned,
but there are plenty of other drivers that don't get that right.

Returning an error for a partial read is good enough for random devices,
since there is no problem with discarding the input.  Upper layers are
still broken, so this (discarding the input is what happens automatically
except for ERESTART, EINTR and EWOULDBLOCK.

Given
that the ra_read/ra_write functions can't return error, it would only be
errors from uiomove() in play.  I guess it would be something like this:

        nbytes = uio->uio_resid;
        while (uio->uio_resid && !error) {
                c = MIN(uio->uio_resid, PAGE_SIZE);
                (random_adaptor->ra_read)(random_buf, c);
                error = uiomove(random_buf, c, uio);
        }
        if (uio->uio_resid != nbytes)
                error = 0; /* Return partial read, not error. */

This is unnecessary except for upper layer bugs.  Upper layers already
convert error to 0 under the condition (uio->uio_resid != original_resid),
except they only do this if 'error' was EINTR, ERESTART and EWOULDBLOCK --
other cases are broken. Thus all drivers have the burden of doing the
conversion if they want to be correct.  Some file systems generally back
out of failing writes so that returning an error is correct.

Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to