xfs
[Top] [All Lists]

Re: ååï XFS direct IO problem

To: YeYin <eyniy@xxxxxx>
Subject: Re: ååï XFS direct IO problem
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 9 Apr 2015 07:14:36 +1000
Cc: xfs <xfs@xxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <tencent_60C0CC90244648E22E374DF9@xxxxxx>
References: <tencent_316A3DE769544D99766FE3F1@xxxxxx> <20150408044955.GE15810@dastard> <tencent_60C0CC90244648E22E374DF9@xxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Wed, Apr 08, 2015 at 03:05:57PM +0800, YeYin wrote:
> Dave,
> Thank you for your explanation. I got the reason, and I write some code to  
> simulate the MySQL.It will reproduce the progress:â
> 
> 
> open file without direct flag
> read file   //cause kernel readahead 4 pages, and inode->i_mapping->nrpages > > 0
> close file
> 
> 
> open file with direct flag
> lseek 4*4096 // skip 4 readahead pages
> read  file //cause xfs_flushinval_pages to do nothing
> ...
> 

Yes, you can cause it that way, but any application mixing buffered
IO and direct IO like that is broken.  I'll point you at the open(2)
man page, in the section about O_DIRECT:

        "Applications should avoid mixing O_DIRECT and normal I/O to
        the same file, and especially to overlapping byte regions in
        the  same file.   Even  when  the filesystem correctly
        handles the coherency issues in this situation, overall I/O
        throughput is likely to be slower than using either mode
        alone.  Likewise, applications should avoid mixing mmap(2)
        of files with direct I/O to the same files."

IOWs, your test program is behaving as documented for a program
that mixes buffered and direct IO....

AFAIK, MySQL does not do  mixed buffer/direct IO like this and so
this is extremely unlikely to be the source of the problem.  I need
to understand how MySQL is generating cached pages on it's database
files when it is supposed to be using direct IO, and the reproducer
program needs to do what MySQL does to generate cached pages.

Can you please find the location of the cached pages (as I
sugggested via tracing in my last email) in the MySQL files that are
causing the problem?

> I'd like to ask XFS how to resovle this problem?

Applications that need to mix buffered and direct IO can invalidate
the cached pages by using POSIX_FADV_DONTNEED before doing direct
IO.

FWIW, You must be looking at quite old kernel code if
xfs_flushinval_pages() exists in your kernel. Does MySQL on a
current upstream kernel have the same problem?

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>