Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src extent_alloc_subregion shouldn't allocate a region pasts the...
details: https://anonhg.NetBSD.org/src/rev/9f86b17182c4
branches: trunk
changeset: 514280:9f86b17182c4
user: enami <enami%NetBSD.org@localhost>
date: Mon Aug 27 13:35:44 2001 +0000
description:
extent_alloc_subregion shouldn't allocate a region pasts the end of subregion.
diffstat:
regress/sys/kern/extent/extest.exp | 8 +++++++-
regress/sys/kern/extent/tests | 11 ++++++++++-
sys/kern/subr_extent.c | 21 ++++++++++++++++++---
3 files changed, 35 insertions(+), 5 deletions(-)
diffs (97 lines):
diff -r 56eae72eff9a -r 9f86b17182c4 regress/sys/kern/extent/extest.exp
--- a/regress/sys/kern/extent/extest.exp Mon Aug 27 13:07:03 2001 +0000
+++ b/regress/sys/kern/extent/extest.exp Mon Aug 27 13:35:44 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: extest.exp,v 1.5 2000/07/02 22:36:50 pk Exp $
+# $NetBSD: extest.exp,v 1.6 2001/08/27 13:35:45 enami Exp $
# real output must start in line 4
output for test1
@@ -37,3 +37,9 @@
extent `test7' (0x0 - 0xb), flags = 0x0
0x0 - 0x6
0x8 - 0xb
+output for test8
+result: 0x0
+error: Resource temporarily unavailable
+extent `test8' (0x0 - 0x4f), flags = 0x2
+ 0x0 - 0xf
+ 0x30 - 0x3f
diff -r 56eae72eff9a -r 9f86b17182c4 regress/sys/kern/extent/tests
--- a/regress/sys/kern/extent/tests Mon Aug 27 13:07:03 2001 +0000
+++ b/regress/sys/kern/extent/tests Mon Aug 27 13:35:44 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: tests,v 1.5 2000/07/02 22:36:50 pk Exp $
+# $NetBSD: tests,v 1.6 2001/08/27 13:35:45 enami Exp $
#fill up an extent, should coalesce into one allocation
extent test1 0 0x4f
@@ -52,3 +52,12 @@
alloc_subregion 0 11 7
alloc_subregion 0 11 4
print
+
+#don't allocate a region pasts the end of subregion (i.e., the second
+#alloc_subregion should fail). subr_extent.c prior to rev. 1.43 allocates
+#region starts from 0x10.
+extent test8 0 0x4f EX_NOCOALESCE
+alloc_region 0x30 0x10
+alloc_subregion 0 0xf 0x10
+alloc_subregion 0 0xf 0x10
+print
diff -r 56eae72eff9a -r 9f86b17182c4 sys/kern/subr_extent.c
--- a/sys/kern/subr_extent.c Mon Aug 27 13:07:03 2001 +0000
+++ b/sys/kern/subr_extent.c Mon Aug 27 13:35:44 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_extent.c,v 1.42 2001/06/05 04:39:56 thorpej Exp $ */
+/* $NetBSD: subr_extent.c,v 1.43 2001/08/27 13:35:44 enami Exp $ */
/*-
* Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -537,7 +537,7 @@
u_long *result;
{
struct extent_region *rp, *myrp, *last, *bestlast;
- u_long newstart, newend, beststart, bestovh, ovh;
+ u_long newstart, newend, exend, beststart, bestovh, ovh;
u_long dontcross;
int error;
@@ -623,6 +623,12 @@
bestlast = NULL;
/*
+ * Keep track of end of free region. This is either the end of extent
+ * or the start of a region past the subend.
+ */
+ exend = ex->ex_end;
+
+ /*
* For N allocated regions, we must make (N + 1)
* checks for unallocated space. The first chunk we
* check is the area from the beginning of the subregion
@@ -665,6 +671,15 @@
for (; rp != NULL; rp = rp->er_link.le_next) {
/*
+ * If the region pasts the subend, bail out and see
+ * if we fit against the subend.
+ */
+ if (rp->er_start >= subend) {
+ exend = rp->er_start;
+ break;
+ }
+
+ /*
* Check the chunk before "rp". Note that our
* comparison is safe from overflow conditions.
*/
@@ -818,7 +833,7 @@
* fit, or we're taking the first fit, insert
* ourselves into the region list.
*/
- ovh = ex->ex_end - newstart - (size - 1);
+ ovh = exend - newstart - (size - 1);
if ((flags & EX_FAST) || (ovh == 0))
goto found;
Home |
Main Index |
Thread Index |
Old Index