diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2014-10-09 18:26:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-09 22:25:53 -0400 |
commit | 447f05bb488bff4282088259b04f47f0f9f76760 (patch) | |
tree | c999b50a97e168730e6c9a82faa22a5cb8b72283 /fs | |
parent | 4db96b71e3caea5bb39053d57683129e0682c66f (diff) |
block_dev: implement readpages() to optimize sequential read
Sequential read from a block device is expected to be equal or faster than
from the file on a filesystem. But it is not correct due to the lack of
effective readpages() in the address space operations for block device.
This implements readpages() operation for block device by using
mpage_readpages() which can create multipage BIOs instead of BIOs for each
page and reduce system CPU time consumption.
Install 1GB of RAM disk storage:
# modprobe scsi_debug dev_size_mb=1024 delay=0
Sequential read from file on a filesystem:
# mkfs.ext4 /dev/$DEV
# mount /dev/$DEV /mnt
# fio --name=t --size=512m --rw=read --filename=/mnt/file
...
read : io=524288KB, bw=2133.4MB/s, iops=546133, runt= 240msec
Sequential read from a block device:
# fio --name=t --size=512m --rw=read --filename=/dev/$DEV
...
(Without this commit)
read : io=524288KB, bw=1700.2MB/s, iops=435455, runt= 301msec
(With this commit)
read : io=524288KB, bw=2160.4MB/s, iops=553046, runt= 237msec
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/block_dev.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 6d7274619bf9..e2f3ad0879ce 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -304,6 +304,12 @@ static int blkdev_readpage(struct file * file, struct page * page) | |||
304 | return block_read_full_page(page, blkdev_get_block); | 304 | return block_read_full_page(page, blkdev_get_block); |
305 | } | 305 | } |
306 | 306 | ||
307 | static int blkdev_readpages(struct file *file, struct address_space *mapping, | ||
308 | struct list_head *pages, unsigned nr_pages) | ||
309 | { | ||
310 | return mpage_readpages(mapping, pages, nr_pages, blkdev_get_block); | ||
311 | } | ||
312 | |||
307 | static int blkdev_write_begin(struct file *file, struct address_space *mapping, | 313 | static int blkdev_write_begin(struct file *file, struct address_space *mapping, |
308 | loff_t pos, unsigned len, unsigned flags, | 314 | loff_t pos, unsigned len, unsigned flags, |
309 | struct page **pagep, void **fsdata) | 315 | struct page **pagep, void **fsdata) |
@@ -1622,6 +1628,7 @@ static int blkdev_releasepage(struct page *page, gfp_t wait) | |||
1622 | 1628 | ||
1623 | static const struct address_space_operations def_blk_aops = { | 1629 | static const struct address_space_operations def_blk_aops = { |
1624 | .readpage = blkdev_readpage, | 1630 | .readpage = blkdev_readpage, |
1631 | .readpages = blkdev_readpages, | ||
1625 | .writepage = blkdev_writepage, | 1632 | .writepage = blkdev_writepage, |
1626 | .write_begin = blkdev_write_begin, | 1633 | .write_begin = blkdev_write_begin, |
1627 | .write_end = blkdev_write_end, | 1634 | .write_end = blkdev_write_end, |