Skip to content

Commit 647d1e4

Browse files
Fengguang Wuaxboe
Fengguang Wu
authored andcommitted
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: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8430f97 commit 647d1e4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

fs/direct-io.c

+5
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
10621062
unsigned long user_addr;
10631063
size_t bytes;
10641064
struct buffer_head map_bh = { 0, };
1065+
struct blk_plug plug;
10651066

10661067
if (rw & WRITE)
10671068
rw = WRITE_ODIRECT;
@@ -1177,6 +1178,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
11771178
PAGE_SIZE - user_addr / PAGE_SIZE);
11781179
}
11791180

1181+
blk_start_plug(&plug);
1182+
11801183
for (seg = 0; seg < nr_segs; seg++) {
11811184
user_addr = (unsigned long)iov[seg].iov_base;
11821185
sdio.size += bytes = iov[seg].iov_len;
@@ -1235,6 +1238,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
12351238
if (sdio.bio)
12361239
dio_bio_submit(dio, &sdio);
12371240

1241+
blk_finish_plug(&plug);
1242+
12381243
/*
12391244
* It is possible that, we return short IO due to end of file.
12401245
* In that case, we need to release all the pages we got hold on.

mm/filemap.c

-4
Original file line numberDiff line numberDiff line change
@@ -1412,12 +1412,8 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
14121412
retval = filemap_write_and_wait_range(mapping, pos,
14131413
pos + iov_length(iov, nr_segs) - 1);
14141414
if (!retval) {
1415-
struct blk_plug plug;
1416-
1417-
blk_start_plug(&plug);
14181415
retval = mapping->a_ops->direct_IO(READ, iocb,
14191416
iov, pos, nr_segs);
1420-
blk_finish_plug(&plug);
14211417
}
14221418
if (retval > 0) {
14231419
*ppos = pos + retval;

0 commit comments

Comments
 (0)