diff --git a/sys/fs/tarfs/tarfs_vnops.c b/sys/fs/tarfs/tarfs_vnops.c --- a/sys/fs/tarfs/tarfs_vnops.c +++ b/sys/fs/tarfs/tarfs_vnops.c @@ -38,11 +38,19 @@ #include #include #include +#include #include #include #include +static int bmap_readbehind = 1; +SYSCTL_INT(_vfs_tarfs, OID_AUTO, bmap_readbehind, CTLFLAG_RWTUN, + &bmap_readbehind, 0, "Enable read-behind for block mapping operations"); +static int readahead_max = -1; +SYSCTL_INT(_vfs_tarfs, OID_AUTO, readahead_max, CTLFLAG_RWTUN, + &readahead_max, 0, "Maximum read-ahead in blocks"); + static int tarfs_open(struct vop_open_args *ap) { @@ -173,9 +181,11 @@ } rmax = vp->v_mount->mnt_iosize_max / iosize - 1; + if (readahead_max >= 0 && rmax > readahead_max) + rmax = readahead_max; *ap->a_runp = imin(ra, rmax); if (ap->a_runb != NULL) - *ap->a_runb = imin(rb, rmax); + *ap->a_runb = bmap_readbehind ? imin(rb, rmax) : 0; return (0); }