Commit 647d1e4c authored by Fengguang Wu's avatar Fengguang Wu Committed by Jens Axboe

block: move down direct IO plugging

Move unplugging for direct I/O from around ->direct_IO() down to
do_blockdev_direct_IO(). This implicitly adds plugging for direct
writes.

CC: Li Shaohua <shli@fusionio.com>
Acked-by: default avatarJeff Moyer <jmoyer@redhat.com>
Signed-off-by: default avatarWu Fengguang <fengguang.wu@intel.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 8430f977
...@@ -1062,6 +1062,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, ...@@ -1062,6 +1062,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
unsigned long user_addr; unsigned long user_addr;
size_t bytes; size_t bytes;
struct buffer_head map_bh = { 0, }; struct buffer_head map_bh = { 0, };
struct blk_plug plug;
if (rw & WRITE) if (rw & WRITE)
rw = WRITE_ODIRECT; rw = WRITE_ODIRECT;
...@@ -1177,6 +1178,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, ...@@ -1177,6 +1178,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
PAGE_SIZE - user_addr / PAGE_SIZE); PAGE_SIZE - user_addr / PAGE_SIZE);
} }
blk_start_plug(&plug);
for (seg = 0; seg < nr_segs; seg++) { for (seg = 0; seg < nr_segs; seg++) {
user_addr = (unsigned long)iov[seg].iov_base; user_addr = (unsigned long)iov[seg].iov_base;
sdio.size += bytes = iov[seg].iov_len; sdio.size += bytes = iov[seg].iov_len;
...@@ -1235,6 +1238,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, ...@@ -1235,6 +1238,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
if (sdio.bio) if (sdio.bio)
dio_bio_submit(dio, &sdio); dio_bio_submit(dio, &sdio);
blk_finish_plug(&plug);
/* /*
* It is possible that, we return short IO due to end of file. * It is possible that, we return short IO due to end of file.
* In that case, we need to release all the pages we got hold on. * In that case, we need to release all the pages we got hold on.
......
...@@ -1412,12 +1412,8 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1412,12 +1412,8 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
retval = filemap_write_and_wait_range(mapping, pos, retval = filemap_write_and_wait_range(mapping, pos,
pos + iov_length(iov, nr_segs) - 1); pos + iov_length(iov, nr_segs) - 1);
if (!retval) { if (!retval) {
struct blk_plug plug;
blk_start_plug(&plug);
retval = mapping->a_ops->direct_IO(READ, iocb, retval = mapping->a_ops->direct_IO(READ, iocb,
iov, pos, nr_segs); iov, pos, nr_segs);
blk_finish_plug(&plug);
} }
if (retval > 0) { if (retval > 0) {
*ppos = pos + retval; *ppos = pos + retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment