readahead02: estimate max readahead size

Max readahead size is kernel implementation detail, which can and
already has changed in past (and probably will again [1]).
Futher, current (4.8) implementation defines it as block device's
read_ahead_kb, which means its value varies based on storage/fs
setup.

This patch estimates max readahead size based on cache increase
from first readahead call and then advances offset for subsequent
calls by that amount. It also makes sure it's > 0 to guarantee,
that it eventually reaches end of file.

This also fixes test on Btrfs, where it wasn't working previously
since there is no /sys/dev/block/$major:$minor/ for the anonymous
block devices that are used internaly for subvolumes.

[1] https://lkml.org/lkml/2016/7/25/308

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Tested-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
Change-Id: I67f541be2035a65ef5ee5e7d29d467abc929e051
Bug: 37156726
Test: run vts-kernel
Signed-off-by: Steve Muckle <smuckle@google.com>
1 file changed