diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-04-19 15:26:53 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-04-19 15:26:53 +0000 |
commit | 43dfa343205f93e307354f2eb9bb65eee19711ed (patch) | |
tree | b9bc3b266acef6eed57c4345a94802633e9968cb | |
parent | 9781289811c33accd41427618263b031a443438a (diff) |
Add a new EX_FILLED flag to make extent_create() create an extent map that
has all space allocated such that we can make holes in it using extent_free().
ok miod@
-rw-r--r-- | share/man/man9/extent.9 | 15 | ||||
-rw-r--r-- | sys/kern/subr_extent.c | 14 | ||||
-rw-r--r-- | sys/sys/extent.h | 21 |
3 files changed, 37 insertions, 13 deletions
diff --git a/share/man/man9/extent.9 b/share/man/man9/extent.9 index 275f208d7f3..ad3b8d8c28a 100644 --- a/share/man/man9/extent.9 +++ b/share/man/man9/extent.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: extent.9,v 1.13 2009/04/10 20:57:04 kettenis Exp $ +.\" $OpenBSD: extent.9,v 1.14 2009/04/19 15:26:52 kettenis Exp $ .\" $NetBSD: extent.9,v 1.15 1999/03/16 00:40:47 garbled Exp $ .\" .\" Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: April 10 2009 $ +.Dd $Mdocdate: April 19 2009 $ .Dt EXTENT 9 .Os .Sh NAME @@ -98,6 +98,12 @@ is set, internal coalescing of regions is disabled, and only entire regions may be freed within the extent map, so that .Fn extent_free will never have to allocate a region descriptor. +If the flag +.Dv EX_FILLED +is set, the entire space managed by the extent map will be allocated +upon creation of the extent map, such that selected regions may be +made available through calls to +.Fn extent_free . .Pp Some applications may want to use an extent map but can't use @@ -125,6 +131,11 @@ flag may be passed to extent requests to indicate that a fixed extent map may be extended using a call to .Fn malloc . +Note that passing the flag +.Dv EX_FILLED +to +.Fn extent_create +will consume a region descriptor upon creation of the extent map. .Pp The caller should pass the flag .Dv EX_WAITOK diff --git a/sys/kern/subr_extent.c b/sys/kern/subr_extent.c index 8053c1c9583..c309a1a123a 100644 --- a/sys/kern/subr_extent.c +++ b/sys/kern/subr_extent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_extent.c,v 1.36 2009/04/10 20:57:04 kettenis Exp $ */ +/* $OpenBSD: subr_extent.c,v 1.37 2009/04/19 15:26:52 kettenis Exp $ */ /* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */ /*- @@ -228,6 +228,18 @@ extent_create(char *name, u_long start, u_long end, int mtype, caddr_t storage, if (flags & EX_NOCOALESCE) ex->ex_flags |= EXF_NOCOALESCE; + if (flags & EX_FILLED) { + rp = extent_alloc_region_descriptor(ex, flags); + if (rp == NULL) { + if (!fixed_extent) + free(ex, mtype); + return (NULL); + } + rp->er_start = start; + rp->er_end = end; + LIST_INSERT_HEAD(&ex->ex_regions, rp, er_link); + } + #if defined(DIAGNOSTIC) || defined(DDB) extent_register(ex); #endif diff --git a/sys/sys/extent.h b/sys/sys/extent.h index 5bacde20e01..98e2f45c78e 100644 --- a/sys/sys/extent.h +++ b/sys/sys/extent.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extent.h,v 1.11 2009/04/19 11:04:11 kettenis Exp $ */ +/* $OpenBSD: extent.h,v 1.12 2009/04/19 15:26:52 kettenis Exp $ */ /* $NetBSD: extent.h,v 1.6 1997/10/09 07:43:05 jtc Exp $ */ /*- @@ -74,15 +74,16 @@ struct extent_fixed { #define EXF_BITS "\20\4FLWANTED\3WANTED\2NOCOALESCE\1FIXED" /* misc. flags passed to extent functions */ -#define EX_NOWAIT 0x00 /* not safe to sleep */ -#define EX_WAITOK 0x01 /* safe to sleep */ -#define EX_FAST 0x02 /* take first fit in extent_alloc() */ -#define EX_CATCH 0x04 /* catch signals while sleeping */ -#define EX_NOCOALESCE 0x08 /* create a non-coalescing extent */ -#define EX_MALLOCOK 0x10 /* safe to call malloc() */ -#define EX_WAITSPACE 0x20 /* wait for space to become free */ -#define EX_BOUNDZERO 0x40 /* boundary lines start at 0 */ -#define EX_CONFLICTOK 0x80 /* allow conflicts */ +#define EX_NOWAIT 0x0000 /* not safe to sleep */ +#define EX_WAITOK 0x0001 /* safe to sleep */ +#define EX_FAST 0x0002 /* take first fit in extent_alloc() */ +#define EX_CATCH 0x0004 /* catch signals while sleeping */ +#define EX_NOCOALESCE 0x0008 /* create a non-coalescing extent */ +#define EX_MALLOCOK 0x0010 /* safe to call malloc() */ +#define EX_WAITSPACE 0x0020 /* wait for space to become free */ +#define EX_BOUNDZERO 0x0040 /* boundary lines start at 0 */ +#define EX_CONFLICTOK 0x0080 /* allow conflicts */ +#define EX_FILLED 0x0100 /* create a filled extent */ /* * Special place holders for "alignment" and "boundary" arguments, |