svn commit: r350088 - head/sys/kern
Alan Somers
asomers at FreeBSD.org
Wed Jul 17 17:01:08 UTC 2019
Author: asomers
Date: Wed Jul 17 17:01:07 2019
New Revision: 350088
URL: https://svnweb.freebsd.org/changeset/base/350088
Log:
F_READAHEAD: Fix r349248's overflow protection, broken by r349391
I accidentally broke the main point of r349248 when making stylistic changes
in r349391. Restore the original behavior, and also fix an additional
overflow that was possible when uio->uio_resid was nearly SSIZE_MAX.
Reported by: cem
Reviewed by: bde
MFC after: 2 weeks
MFC-With: 349248
Sponsored by: The FreeBSD Foundation
Modified:
head/sys/kern/vfs_vnops.c
Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c Wed Jul 17 16:52:25 2019 (r350087)
+++ head/sys/kern/vfs_vnops.c Wed Jul 17 17:01:07 2019 (r350088)
@@ -499,8 +499,13 @@ sequential_heuristic(struct uio *uio, struct file *fp)
* closely related to the best I/O size for real disks than
* to any block size used by software.
*/
- fp->f_seqcount += lmin(IO_SEQMAX,
- howmany(uio->uio_resid, 16384));
+ if (uio->uio_resid >= IO_SEQMAX * 16384)
+ fp->f_seqcount = IO_SEQMAX;
+ else {
+ fp->f_seqcount += howmany(uio->uio_resid, 16384);
+ if (fp->f_seqcount > IO_SEQMAX)
+ fp->f_seqcount = IO_SEQMAX;
+ }
return (fp->f_seqcount << IO_SEQSHIFT);
}
More information about the svn-src-all
mailing list