svn commit: r244338 - stable/9/sys/kern

Konstantin Belousov kib at FreeBSD.org
Mon Dec 17 05:15:51 UTC 2012


Author: kib
Date: Mon Dec 17 05:15:51 2012
New Revision: 244338
URL: http://svnweb.freebsd.org/changeset/base/244338

Log:
  MFC r244076:
  Do not ignore zero address, possibly returned by the vm_map_find() call.

Modified:
  stable/9/sys/kern/vfs_bio.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/vfs_bio.c
==============================================================================
--- stable/9/sys/kern/vfs_bio.c	Mon Dec 17 05:13:15 2012	(r244337)
+++ stable/9/sys/kern/vfs_bio.c	Mon Dec 17 05:15:51 2012	(r244338)
@@ -2139,15 +2139,16 @@ restart:
 
 		if (maxsize != bp->b_kvasize) {
 			vm_offset_t addr = 0;
+			int rv;
 
 			bfreekva(bp);
 
 			vm_map_lock(buffer_map);
 			if (vm_map_findspace(buffer_map,
-				vm_map_min(buffer_map), maxsize, &addr)) {
+			    vm_map_min(buffer_map), maxsize, &addr)) {
 				/*
-				 * Uh oh.  Buffer map is to fragmented.  We
-				 * must defragment the map.
+				 * Buffer map is too fragmented.
+				 * We must defragment the map.
 				 */
 				atomic_add_int(&bufdefragcnt, 1);
 				vm_map_unlock(buffer_map);
@@ -2156,22 +2157,21 @@ restart:
 				brelse(bp);
 				goto restart;
 			}
-			if (addr) {
-				vm_map_insert(buffer_map, NULL, 0,
-					addr, addr + maxsize,
-					VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT);
-
-				bp->b_kvabase = (caddr_t) addr;
-				bp->b_kvasize = maxsize;
-				atomic_add_long(&bufspace, bp->b_kvasize);
-				atomic_add_int(&bufreusecnt, 1);
-			}
+			rv = vm_map_insert(buffer_map, NULL, 0, addr,
+			    addr + maxsize, VM_PROT_ALL, VM_PROT_ALL,
+			    MAP_NOFAULT);
+			KASSERT(rv == KERN_SUCCESS,
+			    ("vm_map_insert(buffer_map) rv %d", rv));
 			vm_map_unlock(buffer_map);
+			bp->b_kvabase = (caddr_t)addr;
+			bp->b_kvasize = maxsize;
+			atomic_add_long(&bufspace, bp->b_kvasize);
+			atomic_add_int(&bufreusecnt, 1);
 		}
 		bp->b_saveaddr = bp->b_kvabase;
 		bp->b_data = bp->b_saveaddr;
 	}
-	return(bp);
+	return (bp);
 }
 
 /*


More information about the svn-src-stable mailing list