Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 May 2014 13:01:11 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r266804 - projects/sendfile/sys/kern
Message-ID:  <201405281301.s4SD1BkA053088@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Wed May 28 13:01:10 2014
New Revision: 266804
URL: http://svnweb.freebsd.org/changeset/base/266804

Log:
  When working on a sparse file sendfile_getpages() could skip a page. This
  happened due to increment both in the for (;;) statement and in the loop
  itself.
  
  Fix this by removing increment in for (;;). Now all increments are done
  "manually", this fixes the bug and makes code more comprehendable.
  
  Sponsored by:	Netflix
  Sponsored by:	Nginx, Inc.

Modified:
  projects/sendfile/sys/kern/uipc_syscalls.c

Modified: projects/sendfile/sys/kern/uipc_syscalls.c
==============================================================================
--- projects/sendfile/sys/kern/uipc_syscalls.c	Wed May 28 12:58:37 2014	(r266803)
+++ projects/sendfile/sys/kern/uipc_syscalls.c	Wed May 28 13:01:10 2014	(r266804)
@@ -2750,12 +2750,13 @@ sendfile_swapin(vm_object_t obj, struct 
 		pa[i] = vm_page_grab(obj, OFF_TO_IDX(vmoff(i, off)),
 		    VM_ALLOC_WIRED | VM_ALLOC_NORMAL);
 
-	for (int i = 0; i < npages; i++) {
+	for (int i = 0; i < npages;) {
 		int j, a, count, rv;
 
 		if (vm_page_is_valid(pa[i], vmoff(i, off) & PAGE_MASK,
 		    xfsize(i, npages, off, len))) {
 			vm_page_xunbusy(pa[i]);
+			i++;
 			continue;
 		}
 
@@ -2806,7 +2807,7 @@ sendfile_swapin(vm_object_t obj, struct 
 			    ("pa[j] %p lookup %p\n", pa[j],
 			    vm_page_lookup(obj, OFF_TO_IDX(vmoff(j, off)))));
 
-		i += count - 1;
+		i += count;
 	}
 
 	VM_OBJECT_WUNLOCK(obj);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405281301.s4SD1BkA053088>