[XFS] Add a greedy allocation interface, allocating within a min/max size

range.

SGI-PV: 955302
SGI-Modid: xfs-linux-melb:xfs-kern:26803a

Signed-off-by: Nathan Scott <nathans@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
This commit is contained in:
Nathan Scott
2006-09-28 11:03:27 +10:00
committed by Tim Shimmin
parent 572d95f49f
commit 77e4635ae1
5 changed files with 34 additions and 31 deletions

View File

@@ -68,6 +68,22 @@ kmem_zalloc(size_t size, unsigned int __nocast flags)
return ptr;
}
void *
kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize,
unsigned int __nocast flags)
{
void *ptr;
while (!(ptr = kmem_zalloc(maxsize, flags))) {
if ((maxsize >>= 1) <= minsize) {
maxsize = minsize;
flags = KM_SLEEP;
}
}
*size = maxsize;
return ptr;
}
void
kmem_free(void *ptr, size_t size)
{