mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@digeo.com>
To: Bruno Diniz de Paula <diniz@cs.rutgers.edu>
Cc: cw@f00f.org, linux-kernel@vger.kernel.org
Subject: Re: O_DIRECT foolish question
Date: Wed, 12 Feb 2003 21:12:21 -0800	[thread overview]
Message-ID: <20030212211221.3f73ba45.akpm@digeo.com> (raw)
In-Reply-To: <1045096579.21195.121.camel@urca.rutgers.edu>

Bruno Diniz de Paula <diniz@cs.rutgers.edu> wrote:
>
> On Wed, 2003-02-12 at 19:13, Chris Wedgwood wrote:
> > If I had to guess, write should work more or less the same as reads
> > (ie. I should be able to write aligned-but-smaller-than-page-sized
> > blocks to the end of files).
> > 
> > Testing this however shows this is *not* the case.
> 
> This is not the case, I have also tested here and the file written has
> n*block_size always. The problem with writing is that we can't sign to
> the kernel that the actual data has finished and from that point on it
> should zero-fill the bytes. And what is worse, the information about the
> actual size is lost, since the write syscall will store what is passed
> on the 3rd argument in the inode (field st_size of stat). This means
> that after writing using O_DIRECT we can't read data correctly anymore.
> The exception is when we write together with the data information about
> the actual size and process disregarding information from stat, for
> instance.
> 
> Well, I am sure I am completely wrong because this doesn't make any
> sense for me. Someone that has already dealt with this and can bring a
> light to the discussion?
> 

For writes, I don't think it is reasonable for the kernel to be have to
handle byte-granular appends.  O_DIRECT is different.  For this case the
application should ftruncate the file back to the desired size prior to
closing it.

For the short reads at EOF, the 2.4 kernel refuses to read anything, and
returns zero.  The 2.5 kernel will return -EINVAL, which is better behaviour
(shouldn't make it just look like the file is shorter than it really is).

The ideal behaviour is that which I mistakenly described previously: we
should fill with zeroes and return the partial result.  I'll look at
converting 2.5 to do that.  As long as the changes are small - the direct-io
code does a ton of stuff, is complex, is not tested a lot and breakage tends
to be subtle.

  reply	other threads:[~2003-02-13  5:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-12 21:19 Bruno Diniz de Paula
2003-02-12 22:03 ` Andrew Morton
2003-02-12 22:29   ` Bruno Diniz de Paula
2003-02-12 22:42     ` Chris Wedgwood
2003-02-12 23:02       ` Bruno Diniz de Paula
2003-02-12 23:22         ` Bruno Diniz de Paula
2003-02-13  1:46           ` Randy.Dunlap
2003-02-12 23:24         ` Chris Wedgwood
2003-02-12 23:33           ` Bruno Diniz de Paula
2003-02-12 23:38             ` Chris Wedgwood
2003-02-12 23:49               ` Bruno Diniz de Paula
2003-02-12 23:51                 ` Chris Wedgwood
     [not found]                   ` <1045094589.4767.106.camel@urca.rutgers.edu>
     [not found]                     ` <20030213001302.GA13833@f00f.org>
2003-02-13  0:36                       ` Bruno Diniz de Paula
2003-02-13  5:12                         ` Andrew Morton [this message]
2003-02-13 15:22                           ` Bruno Diniz de Paula
2003-02-13 17:31                             ` Andrew Morton
2003-02-13 22:45                               ` Bruno Diniz de Paula
2003-02-12 23:33           ` Chris Wedgwood
2003-02-12 22:07 ` Chris Wedgwood

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=20030212211221.3f73ba45.akpm@digeo.com \
    --to=akpm@digeo.com \
    --cc=cw@f00f.org \
    --cc=diniz@cs.rutgers.edu \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®