aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6')
-rw-r--r--fs/xfs/linux-2.6/kmem.c16
-rw-r--r--fs/xfs/linux-2.6/kmem.h3
2 files changed, 18 insertions, 1 deletions
diff --git a/fs/xfs/linux-2.6/kmem.c b/fs/xfs/linux-2.6/kmem.c
index f77fe5c8fcc1..80b9340488e5 100644
--- a/fs/xfs/linux-2.6/kmem.c
+++ b/fs/xfs/linux-2.6/kmem.c
@@ -68,6 +68,22 @@ kmem_zalloc(size_t size, unsigned int __nocast flags)
68 return ptr; 68 return ptr;
69} 69}
70 70
71void *
72kmem_zalloc_greedy(size_t *size, size_t minsize, size_t maxsize,
73 unsigned int __nocast flags)
74{
75 void *ptr;
76
77 while (!(ptr = kmem_zalloc(maxsize, flags))) {
78 if ((maxsize >>= 1) <= minsize) {
79 maxsize = minsize;
80 flags = KM_SLEEP;
81 }
82 }
83 *size = maxsize;
84 return ptr;
85}
86
71void 87void
72kmem_free(void *ptr, size_t size) 88kmem_free(void *ptr, size_t size)
73{ 89{
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index 6d24274fb3cb..9ebabdf7829c 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -55,8 +55,9 @@ kmem_flags_convert(unsigned int __nocast flags)
55} 55}
56 56
57extern void *kmem_alloc(size_t, unsigned int __nocast); 57extern void *kmem_alloc(size_t, unsigned int __nocast);
58extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
59extern void *kmem_zalloc(size_t, unsigned int __nocast); 58extern void *kmem_zalloc(size_t, unsigned int __nocast);
59extern void *kmem_zalloc_greedy(size_t *, size_t, size_t, unsigned int __nocast);
60extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
60extern void kmem_free(void *, size_t); 61extern void kmem_free(void *, size_t);
61 62
62/* 63/*