]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/seq_file.c
Fix signed/unsigned pointer warning
[mirror_ubuntu-artful-kernel.git] / fs / seq_file.c
index 3857b720cb1b258a3964ae4a3557094087eaa2ed..dbf3a59c86bbbb081464830585f216623ab9f112 100644 (file)
 #include <asm/uaccess.h>
 #include <asm/page.h>
 
-
-/*
- * seq_files have a buffer which can may overflow. When this happens a larger
- * buffer is reallocated and all the data will be printed again.
- * The overflow state is true when m->count == m->size.
- */
-static bool seq_overflow(struct seq_file *m)
-{
-       return m->count == m->size;
-}
-
 static void seq_set_overflow(struct seq_file *m)
 {
        m->count = m->size;
@@ -36,7 +25,11 @@ static void *seq_buf_alloc(unsigned long size)
 {
        void *buf;
 
-       buf = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
+       /*
+        * __GFP_NORETRY to avoid oom-killings with high-order allocations -
+        * it's better to fall back to vmalloc() than to kill things.
+        */
+       buf = kmalloc(size, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN);
        if (!buf && size > PAGE_SIZE)
                buf = vmalloc(size);
        return buf;
@@ -124,7 +117,7 @@ static int traverse(struct seq_file *m, loff_t offset)
                        error = 0;
                        m->count = 0;
                }
-               if (seq_overflow(m))
+               if (seq_has_overflowed(m))
                        goto Eoverflow;
                if (pos + m->count > offset) {
                        m->from = offset - pos;
@@ -267,7 +260,7 @@ Fill:
                        break;
                }
                err = m->op->show(m, p);
-               if (seq_overflow(m) || err) {
+               if (seq_has_overflowed(m) || err) {
                        m->count = offs;
                        if (likely(err <= 0))
                                break;