diff options
author | kmacy <kmacy@FreeBSD.org> | 2008-05-05 19:48:54 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2008-05-05 19:48:54 +0000 |
commit | afbf6fcd73e04b6510fe77e5897f4b00bc2951a0 (patch) | |
tree | 79b94998e8578f744173c66f743005fc070f6a5b /sys | |
parent | 9dc66be7968f0fdd657867a3a0accae9a35121fb (diff) | |
download | FreeBSD-src-afbf6fcd73e04b6510fe77e5897f4b00bc2951a0.zip FreeBSD-src-afbf6fcd73e04b6510fe77e5897f4b00bc2951a0.tar.gz |
add malloc flag to blist so that it can be used in ithread context
Reviewed by: alc, bsdimp
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_blist.c | 15 | ||||
-rw-r--r-- | sys/sys/blist.h | 9 | ||||
-rw-r--r-- | sys/vm/swap_pager.c | 2 |
3 files changed, 14 insertions, 12 deletions
diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c index 2c83499..3357646 100644 --- a/sys/kern/subr_blist.c +++ b/sys/kern/subr_blist.c @@ -152,14 +152,15 @@ static MALLOC_DEFINE(M_SWAP, "SWAP", "Swap space"); * blist_create() - create a blist capable of handling up to the specified * number of blocks * - * blocks must be greater then 0 + * blocks - must be greater then 0 + * flags - malloc flags * * The smallest blist consists of a single leaf node capable of * managing BLIST_BMAP_RADIX blocks. */ blist_t -blist_create(daddr_t blocks) +blist_create(daddr_t blocks, int flags) { blist_t bl; int radix; @@ -175,14 +176,14 @@ blist_create(daddr_t blocks) skip = (skip + 1) * BLIST_META_RADIX; } - bl = malloc(sizeof(struct blist), M_SWAP, M_WAITOK | M_ZERO); + bl = malloc(sizeof(struct blist), M_SWAP, flags | M_ZERO); bl->bl_blocks = blocks; bl->bl_radix = radix; bl->bl_skip = skip; bl->bl_rootblks = 1 + blst_radix_init(NULL, bl->bl_radix, bl->bl_skip, blocks); - bl->bl_root = malloc(sizeof(blmeta_t) * bl->bl_rootblks, M_SWAP, M_WAITOK); + bl->bl_root = malloc(sizeof(blmeta_t) * bl->bl_rootblks, M_SWAP, flags); #if defined(BLIST_DEBUG) printf( @@ -280,9 +281,9 @@ blist_fill(blist_t bl, daddr_t blkno, daddr_t count) */ void -blist_resize(blist_t *pbl, daddr_t count, int freenew) +blist_resize(blist_t *pbl, daddr_t count, int freenew, int flags) { - blist_t newbl = blist_create(count); + blist_t newbl = blist_create(count, flags); blist_t save = *pbl; *pbl = newbl; @@ -1014,7 +1015,7 @@ main(int ac, char **av) fprintf(stderr, "Bad option: %s\n", ptr - 2); exit(1); } - bl = blist_create(size); + bl = blist_create(size, M_WAITOK); blist_free(bl, 0, size); for (;;) { diff --git a/sys/sys/blist.h b/sys/sys/blist.h index 5f4d66e..1ddffed 100644 --- a/sys/sys/blist.h +++ b/sys/sys/blist.h @@ -29,12 +29,12 @@ * Implements bitmap resource lists. * * Usage: - * blist = blist_create(blocks) + * blist = blist_create(blocks, flags) * (void) blist_destroy(blist) * blkno = blist_alloc(blist, count) * (void) blist_free(blist, blkno, count) * nblks = blist_fill(blist, blkno, count) - * (void) blist_resize(&blist, count, freeextra) + * (void) blist_resize(&blist, count, freeextra, flags) * * * Notes: @@ -50,6 +50,7 @@ * eats around 32 KBytes of memory. * * $FreeBSD$ + */ #ifndef _SYS_BLIST_H_ @@ -91,13 +92,13 @@ typedef struct blist { #define BLIST_MAX_ALLOC BLIST_BMAP_RADIX -extern blist_t blist_create(daddr_t blocks); +extern blist_t blist_create(daddr_t blocks, int flags); extern void blist_destroy(blist_t blist); extern daddr_t blist_alloc(blist_t blist, daddr_t count); extern void blist_free(blist_t blist, daddr_t blkno, daddr_t count); extern int blist_fill(blist_t bl, daddr_t blkno, daddr_t count); extern void blist_print(blist_t blist); -extern void blist_resize(blist_t *pblist, daddr_t count, int freenew); +extern void blist_resize(blist_t *pblist, daddr_t count, int freenew, int flags); #endif /* _SYS_BLIST_H_ */ diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 21a9826..eb910f7 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2018,7 +2018,7 @@ swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strateg sp->sw_strategy = strategy; sp->sw_close = close; - sp->sw_blist = blist_create(nblks); + sp->sw_blist = blist_create(nblks, M_WAITOK); /* * Do not free the first two block in order to avoid overwriting * any bsd label at the front of the partition |