From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: [RFC PATCH] blkdev: Fix up AIO+DIO+O_SYNC to do the sync part correctly
Date: Tue, 6 Nov 2012 12:26:13 -0800 [thread overview]
Message-ID: <20121106202613.GE3941@blackbox.djwong.org> (raw)
In-Reply-To: <x49ehk6pt8x.fsf@segfault.boston.devel.redhat.com>
For block devices, use the DIO_SYNC_WRITES so that flushes are issued /after/
the write completes, not before. Furthermore, we need to use the bdevfs
workqueue to issue the flush, not the fs that just happened to contain the
device node.
This patch requires Jeff Moyer's "fix up AIO+DIO+O_SYNC to actually do the sync
part" patch set.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/block_dev.c | 5 +++--
fs/direct-io.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1a1e5e3..05ff33a 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -235,7 +235,8 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
struct inode *inode = file->f_mapping->host;
return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
- nr_segs, blkdev_get_blocks, NULL, NULL, 0);
+ nr_segs, blkdev_get_blocks, NULL, NULL,
+ DIO_SYNC_WRITES);
}
int __sync_blockdev(struct block_device *bdev, int wait)
@@ -1631,7 +1632,7 @@ ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
percpu_down_read(&bdev->bd_block_size_semaphore);
ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
- if (ret > 0 || ret == -EIOCBQUEUED) {
+ if (ret > 0) {
ssize_t err;
err = generic_write_sync(file, pos, ret);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 25dbd14..33c0bc2 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -258,7 +258,7 @@ void generic_dio_end_io(struct kiocb *iocb, loff_t offset, ssize_t bytes,
work->ret = ret;
work->offset = offset;
work->len = bytes;
- queue_work(inode->i_sb->s_dio_flush_wq, &work->work);
+ queue_work(iocb->ki_filp->f_mapping->host->i_sb->s_dio_flush_wq, &work->work);
} else {
aio_complete(iocb, ret, 0);
inode_dio_done(inode);
prev parent reply other threads:[~2012-11-06 20:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-06 2:21 Race between flush and write during an AIO+DIO+O_SYNC write? Darrick J. Wong
2012-11-06 16:54 ` Jeff Moyer
2012-11-06 19:42 ` Darrick J. Wong
2012-11-06 20:26 ` Darrick J. Wong [this message]
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=20121106202613.GE3941@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).