aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-11-18 11:09:49 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-11-21 11:59:16 -0500
commit39ce81ce7168aa7226fb9f182c3a2b57060d0905 (patch)
tree8b3c8ff8559c7d3243c0299cae6986aa21601c60
parent7e2d9bfa4eabee3e1919a40f20d2ef8b569bd07e (diff)
UBIFS: do not print scary memory allocation warnings
Bulk-read allocates a lot of memory with 'kmalloc()', and when it is/gets fragmented 'kmalloc()' fails with a scarry warning. But because bulk-read is just an optimization, UBIFS keeps working fine. Supress the warning by passing __GFP_NOWARN option to 'kmalloc()'. This patch also introduces a macro for the magic 128KiB constant. This is just neater. Note, this is not really fixes the problem we had, but just hides the warnings. The further patches fix the problem. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--fs/ubifs/file.c4
-rw-r--r--fs/ubifs/super.c17
-rw-r--r--fs/ubifs/ubifs.h2
3 files changed, 15 insertions, 8 deletions
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 9124eee73aea..8be827cc7078 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -705,12 +705,12 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct page *page1)
705 int err, page_idx, page_cnt, ret = 0, n = 0; 705 int err, page_idx, page_cnt, ret = 0, n = 0;
706 loff_t isize; 706 loff_t isize;
707 707
708 bu = kmalloc(sizeof(struct bu_info), GFP_NOFS); 708 bu = kmalloc(sizeof(struct bu_info), GFP_NOFS | __GFP_NOWARN);
709 if (!bu) 709 if (!bu)
710 return 0; 710 return 0;
711 711
712 bu->buf_len = c->bulk_read_buf_size; 712 bu->buf_len = c->bulk_read_buf_size;
713 bu->buf = kmalloc(bu->buf_len, GFP_NOFS); 713 bu->buf = kmalloc(bu->buf_len, GFP_NOFS | __GFP_NOWARN);
714 if (!bu->buf) 714 if (!bu->buf)
715 goto out_free; 715 goto out_free;
716 716
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 8780efbf40ac..ea493e6f2652 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -36,6 +36,12 @@
36#include <linux/mount.h> 36#include <linux/mount.h>
37#include "ubifs.h" 37#include "ubifs.h"
38 38
39/*
40 * Maximum amount of memory we may 'kmalloc()' without worrying that we are
41 * allocating too much.
42 */
43#define UBIFS_KMALLOC_OK (128*1024)
44
39/* Slab cache for UBIFS inodes */ 45/* Slab cache for UBIFS inodes */
40struct kmem_cache *ubifs_inode_slab; 46struct kmem_cache *ubifs_inode_slab;
41 47
@@ -561,17 +567,18 @@ static int init_constants_early(struct ubifs_info *c)
561 * calculations when reporting free space. 567 * calculations when reporting free space.
562 */ 568 */
563 c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ; 569 c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ;
570
564 /* Buffer size for bulk-reads */ 571 /* Buffer size for bulk-reads */
565 c->bulk_read_buf_size = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ; 572 c->bulk_read_buf_size = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ;
566 if (c->bulk_read_buf_size > c->leb_size) 573 if (c->bulk_read_buf_size > c->leb_size)
567 c->bulk_read_buf_size = c->leb_size; 574 c->bulk_read_buf_size = c->leb_size;
568 if (c->bulk_read_buf_size > 128 * 1024) { 575 if (c->bulk_read_buf_size > UBIFS_KMALLOC_OK) {
569 /* Check if we can kmalloc more than 128KiB */ 576 /* Check if we can kmalloc that much */
570 void *try = kmalloc(c->bulk_read_buf_size, GFP_KERNEL); 577 void *try = kmalloc(c->bulk_read_buf_size,
571 578 GFP_KERNEL | __GFP_NOWARN);
572 kfree(try); 579 kfree(try);
573 if (!try) 580 if (!try)
574 c->bulk_read_buf_size = 128 * 1024; 581 c->bulk_read_buf_size = UBIFS_KMALLOC_OK;
575 } 582 }
576 return 0; 583 return 0;
577} 584}
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index a7bd32fa15b9..06ba51efd65d 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -753,7 +753,7 @@ struct ubifs_znode {
753}; 753};
754 754
755/** 755/**
756 * struct bu_info - bulk-read information 756 * struct bu_info - bulk-read information.
757 * @key: first data node key 757 * @key: first data node key
758 * @zbranch: zbranches of data nodes to bulk read 758 * @zbranch: zbranches of data nodes to bulk read
759 * @buf: buffer to read into 759 * @buf: buffer to read into