]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix rounding in vop_stdadvise() for POSIX_FADV_NOREUSE (really
authorbde <bde@FreeBSD.org>
Fri, 21 Dec 2018 04:57:59 +0000 (04:57 +0000)
committerbde <bde@FreeBSD.org>
Fri, 21 Dec 2018 04:57:59 +0000 (04:57 +0000)
commit97d496ecdd50f15bec72a93d092b09bbcef70d9a
tree5374e7bdfcf8ca7b35f123b70dde6f80114bc920
parentb9ea8013d1708d71e5a25568a38b5c23b2f31343
Fix rounding in vop_stdadvise() for POSIX_FADV_NOREUSE (really
POSIX_FADV_DONTNEED).  The most broken case was for applications that
advise for the whole file and then do block-aligned i/o's 1 block at
a time.  Then advice is sent to VOP_ADVISE() 1 block at a time, but
in vop_stdadvise() the 1-block advice was turned into 0-block advice
for the buffer cache part.

The bugs were caused partly by callers representing the region as
(a_start, a_end), where a_end is actually the maximum, and everything
else representing the region as (start, end) where 'end' is actually
the end (1 after the maximum).  The maximum a_end must be rounded up,
but was rounded down.  Also, rounding to page boundaries was inconsistent.

The bugs and fixes have no effect for zfs and other file systems that
don't use the buffer cache or the page cache.  Most or all file systems
currently use the default VOP_FADVISE(), but it finds a null buffer cache
and a null page cache for file systems that don't use normal methods.

Reviewed by: kib
sys/kern/vfs_default.c