diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/linux-2.6/kmem.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c index 80b9340488e5..d59737589815 100644 --- a/fs/xfs/linux-2.6/kmem.c +++ b/fs/xfs/linux-2.6/kmem.c | |||
@@ -72,15 +72,20 @@ void * | |||
72 | kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize, | 72 | kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize, |
73 | unsigned int __nocast flags) | 73 | unsigned int __nocast flags) |
74 | { | 74 | { |
75 | void *ptr; | 75 | void *ptr; |
76 | size_t kmsize = maxsize; | ||
77 | unsigned int kmflags = (flags & ~KM_SLEEP) | KM_NOSLEEP; | ||
76 | 78 | ||
77 | while (!(ptr = kmem_zalloc(maxsize, flags))) { | 79 | while (!(ptr = kmem_zalloc(kmsize, kmflags))) { |
78 | if ((maxsize >>= 1) <= minsize) { | 80 | if ((kmsize <= minsize) && (flags & KM_NOSLEEP)) |
79 | maxsize = minsize; | 81 | break; |
80 | flags = KM_SLEEP; | 82 | if ((kmsize >>= 1) <= minsize) { |
83 | kmsize = minsize; | ||
84 | kmflags = flags; | ||
81 | } | 85 | } |
82 | } | 86 | } |
83 | *size = maxsize; | 87 | if (ptr) |
88 | *size = kmsize; | ||
84 | return ptr; | 89 | return ptr; |
85 | } | 90 | } |
86 | 91 | ||