Re: 回复: XFS direct IO problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs





[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux