Re: O_DIRECT wierd behavior..

From: Joel Becker (jlbec@evilplan.org)
Date: Mon Dec 17 2001 - 14:53:12 EST


On Mon, Dec 17, 2001 at 07:26:05PM +0000, Linus Torvalds wrote:
> Andrew Morton <akpm@zip.com.au> wrote:
> >I take that to mean that if an error occurs, we return that
> >error regardless of how much was written.
>
> I disagree.
>
> Note that writing 15 characters out of 30 is also a "successful write" -
> it's just a _partial_ write.
>
> >Which makes sense. Consider this code:
> >
> > open(file)
> > write(100k)
> > close(fd)
> >
> >if the write gets an IO error halfway through, it looks like
> >the caller never gets to hear about it at present.

        IIRC, SUS states that if a fatal error occurred causing the
partial write, that error will be returned on the next write or upon
close(). Thus:

        /* Smart program handles partial writes */
        write(100k); = 50k
        write(remaining 50k); = -1/ENOSPC|EIO|etc

or:

        /* Dumb program doesn't handle partial write */
        write(100k); = 50k
        close(fd); = -1/EIO
        
Joel

-- 

Life's Little Instruction Book #444

"Never underestimate the power of a kind word or deed."

http://www.jlbec.org/ jlbec@evilplan.org - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Dec 23 2001 - 21:00:14 EST