]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/linux-2.6/kmem.c
[XFS] kill the v_flag member in struct bhv_vnode
[linux-2.6-omap-h63xx.git] / fs / xfs / linux-2.6 / kmem.c
index f77fe5c8fcc137082715aff6844c87c92293d24a..ed2b16dff91434f2bd0b90d35dec3921c447cb27 100644 (file)
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
-#include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
 #include <linux/highmem.h>
 #include <linux/swap.h>
 #include <linux/blkdev.h>
+#include <linux/backing-dev.h>
 #include "time.h"
 #include "kmem.h"
 
@@ -53,7 +53,7 @@ kmem_alloc(size_t size, unsigned int __nocast flags)
                        printk(KERN_ERR "XFS: possible memory allocation "
                                        "deadlock in %s (mode:0x%x)\n",
                                        __FUNCTION__, lflags);
-               blk_congestion_wait(WRITE, HZ/50);
+               congestion_wait(WRITE, HZ/50);
        } while (1);
 }
 
@@ -68,6 +68,27 @@ 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;
+       size_t          kmsize = maxsize;
+       unsigned int    kmflags = (flags & ~KM_SLEEP) | KM_NOSLEEP;
+
+       while (!(ptr = kmem_zalloc(kmsize, kmflags))) {
+               if ((kmsize <= minsize) && (flags & KM_NOSLEEP))
+                       break;
+               if ((kmsize >>= 1) <= minsize) {
+                       kmsize = minsize;
+                       kmflags = flags;
+               }
+       }
+       if (ptr)
+               *size = kmsize;
+       return ptr;
+}
+
 void
 kmem_free(void *ptr, size_t size)
 {
@@ -110,7 +131,7 @@ kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags)
                        printk(KERN_ERR "XFS: possible memory allocation "
                                        "deadlock in %s (mode:0x%x)\n",
                                        __FUNCTION__, lflags);
-               blk_congestion_wait(WRITE, HZ/50);
+               congestion_wait(WRITE, HZ/50);
        } while (1);
 }