2002-10-04 20:24:14

by Andrew Morton

[permalink] [raw]
Subject: Re: 2.5 O)DIRECT problem

Steve Lord wrote:
>
> Hi Andrew,
>
> I ran into a problem with 2.5's O_DIRECT read path,
>
> generic_file_direct_IO usually ends up in generic_direct_IO
> this does bounds checking on the I/O and then flushes any
> cached data.
>
> Once we return to generic_file_direct_IO we unconditionally
> call invalidate_inode_pages2 if there are any cached pages.
>
> If we make a non-aligned O_DIRECT read call, the end result is we
> call invalidate_inode_pages2, but we do not do the filemap_fdatawrite,
> filemap_fdatawait calls. End result is we throw the buffered data away.

Well you could always switch to Linus' current BK tree, in
which invalidate_inode_pages2() is a no-op (whoops).

> Either the flush needs to happen before the bounds checks, or the
> invalidate should only be done on a successful write. It looks
> pretty hard to detect the latter case with the current structure,
> we can get EINVAL from the bounds check and possibly from an
> aligned, but invalid memory address being passed in.

Yes I agree; let's just do the sync before any checks.

I think it should be moved into generic_file_direct_IO(),
because that's the place where the invalidation happens, yes?


2002-10-04 20:33:34

by Steve Lord

[permalink] [raw]
Subject: Re: 2.5 O)DIRECT problem

On Fri, 2002-10-04 at 15:29, Andrew Morton wrote:
> Steve Lord wrote:
> > Either the flush needs to happen before the bounds checks, or the
> > invalidate should only be done on a successful write. It looks
> > pretty hard to detect the latter case with the current structure,
> > we can get EINVAL from the bounds check and possibly from an
> > aligned, but invalid memory address being passed in.
>
> Yes I agree; let's just do the sync before any checks.
>
> I think it should be moved into generic_file_direct_IO(),
> because that's the place where the invalidation happens, yes?

OK, sounds good to me, I will let my tests churn away on that
version and see what happens. I think something else is doing
the same thing to me elsewhere, but it might well be an xfs
specific case.

Steve

--

Steve Lord voice: +1-651-683-3511
Principal Engineer, Filesystem Software email: [email protected]