Skip to content

Commit

Permalink
[XFS] pv 956240, author: nathans, rv: vapo - Minor fixes in
Browse files Browse the repository at this point in the history
kmem_zalloc_greedy()

SGI-PV: 956240
SGI-Modid: xfs-linux-melb:xfs-kern:26983a

Signed-off-by: Vlad Apostolov <vapo@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>
  • Loading branch information
Vlad Apostolov authored and Tim Shimmin committed Sep 28, 2006
1 parent f273ab8 commit 6216ff1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions fs/xfs/linux-2.6/kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,20 @@ void *
kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize,
unsigned int __nocast flags)
{
void *ptr;
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;
}

Expand Down

0 comments on commit 6216ff1

Please sign in to comment.