From: Dave Chinner <david@fromorbit.com>
To: YeYin <eyniy@qq.com>
Cc: xfs <xfs@oss.sgi.com>
Subject: Re: 回复: XFS direct IO problem
Date: Thu, 9 Apr 2015 07:14:36 +1000 [thread overview]
Message-ID: <20150408211436.GF15810@dastard> (raw)
In-Reply-To: <tencent_60C0CC90244648E22E374DF9@qq.com>
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@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-04-08 21:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 4:21 XFS direct IO problem YeYin
2015-04-08 4:49 ` Dave Chinner
2015-04-08 7:05 ` 回复: " YeYin
2015-04-08 21:14 ` Dave Chinner [this message]
2015-04-09 2:37 ` 回复: " YeYin
2015-04-09 3:48 ` YeYin
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=20150408211436.GF15810@dastard \
--to=david@fromorbit.com \
--cc=eyniy@qq.com \
--cc=xfs@oss.sgi.com \
/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