block_dev: implement readpages() to optimize sequential read
authorAkinobu Mita <akinobu.mita@gmail.com>
Thu, 9 Oct 2014 22:26:58 +0000 (15:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 10 Oct 2014 02:25:53 +0000 (22:25 -0400)
commit447f05bb488bff4282088259b04f47f0f9f76760
treec999b50a97e168730e6c9a82faa22a5cb8b72283
parent4db96b71e3caea5bb39053d57683129e0682c66f
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>
fs/block_dev.c