提交 6216ff18 编写于 作者: V Vlad Apostolov 提交者: Tim Shimmin

[XFS] pv 956240, author: nathans, rv: vapo - Minor fixes in

kmem_zalloc_greedy()

SGI-PV: 956240
SGI-Modid: xfs-linux-melb:xfs-kern:26983a
Signed-off-by: NVlad Apostolov <vapo@sgi.com>
Signed-off-by: NTim Shimmin <tes@sgi.com>
上级 f273ab84
......@@ -73,14 +73,19 @@ kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize,
unsigned int __nocast flags)
{
void *ptr;
size_t kmsize = maxsize;
unsigned int kmflags = (flags & ~KM_SLEEP) | KM_NOSLEEP;
while (!(ptr = kmem_zalloc(maxsize, flags))) {
if ((maxsize >>= 1) <= minsize) {
maxsize = minsize;
flags = KM_SLEEP;
while (!(ptr = kmem_zalloc(kmsize, kmflags))) {
if ((kmsize <= minsize) && (flags & KM_NOSLEEP))
break;
if ((kmsize >>= 1) <= minsize) {
kmsize = minsize;
kmflags = flags;
}
}
*size = maxsize;
if (ptr)
*size = kmsize;
return ptr;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册