From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: linux-fsdevel@vger.kernel.org, Jeff Moyer <jmoyer@redhat.com>
Subject: Race between flush and write during an AIO+DIO+O_SYNC write?
Date: Mon, 5 Nov 2012 18:21:55 -0800 [thread overview]
Message-ID: <20121106022155.GA4255@blackbox.djwong.org> (raw)
Hi all,
One of our (app) developers noticed that io_submit() takes a very long time to
return if the program initiates a write to a block device that's been opened in
O_SYNC and O_DIRECTIO mode. We traced the slowness to blkdev_aio_write, which
seems to initiate a disk cache flush if __generic_file_aio_write returns a
positive value or -EIOCBQUEUED. Usually we see -EIOCBQUEUED returned, which
triggers the flush, hence io_submit() stalls for a long time. That doesn't
really feel like the intended usage pattern for aio.
This -EIOCBQUEUED case seems a little strange -- if an async io has been queued
(but not necessarily completed), why would we immediately issue a cache flush?
This seems like a setup for the flush racing against the write, which means
that the write could happen after the flush, which would be bad.
Jeff Moyer proposed a patchset last spring[1] that removed the -EIOCBQUEUED
case and deferred the flush issue to each filesystem's end_io handler. Google
doesn't find any NAKs, but the patches don't seem to have gone anywhere. Is
there a technical reason why this patches haven't gone anywhere?
Could one establish an end_io handler in blkdev_direct_IO so that async writes
to an O_SYNC+DIO block device will result in a blkdev_issue_flush before
aio_complete? That would seem to fix the problem of the write and flush race.
--D
[1] http://oss.sgi.com/archives/xfs/2012-03/msg00082.html
"fs: fix up AIO+DIO+O_SYNC to actually do the sync part"
next reply other threads:[~2012-11-06 2:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-06 2:21 Darrick J. Wong [this message]
2012-11-06 16:54 ` Race between flush and write during an AIO+DIO+O_SYNC write? Jeff Moyer
2012-11-06 19:42 ` Darrick J. Wong
2012-11-06 20:26 ` [RFC PATCH] blkdev: Fix up AIO+DIO+O_SYNC to do the sync part correctly Darrick J. Wong
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=20121106022155.GA4255@blackbox.djwong.org \
--to=darrick.wong@oracle.com \
--cc=jmoyer@redhat.com \
--cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).