提交 39ce81ce 编写于 作者: A Artem Bityutskiy

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: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
上级 7e2d9bfa
...@@ -705,12 +705,12 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct page *page1) ...@@ -705,12 +705,12 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct page *page1)
int err, page_idx, page_cnt, ret = 0, n = 0; int err, page_idx, page_cnt, ret = 0, n = 0;
loff_t isize; loff_t isize;
bu = kmalloc(sizeof(struct bu_info), GFP_NOFS); bu = kmalloc(sizeof(struct bu_info), GFP_NOFS | __GFP_NOWARN);
if (!bu) if (!bu)
return 0; return 0;
bu->buf_len = c->bulk_read_buf_size; bu->buf_len = c->bulk_read_buf_size;
bu->buf = kmalloc(bu->buf_len, GFP_NOFS); bu->buf = kmalloc(bu->buf_len, GFP_NOFS | __GFP_NOWARN);
if (!bu->buf) if (!bu->buf)
goto out_free; goto out_free;
......
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
#include <linux/mount.h> #include <linux/mount.h>
#include "ubifs.h" #include "ubifs.h"
/*
* Maximum amount of memory we may 'kmalloc()' without worrying that we are
* allocating too much.
*/
#define UBIFS_KMALLOC_OK (128*1024)
/* Slab cache for UBIFS inodes */ /* Slab cache for UBIFS inodes */
struct kmem_cache *ubifs_inode_slab; struct kmem_cache *ubifs_inode_slab;
...@@ -561,17 +567,18 @@ static int init_constants_early(struct ubifs_info *c) ...@@ -561,17 +567,18 @@ static int init_constants_early(struct ubifs_info *c)
* calculations when reporting free space. * calculations when reporting free space.
*/ */
c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ; c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ;
/* Buffer size for bulk-reads */ /* Buffer size for bulk-reads */
c->bulk_read_buf_size = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ; c->bulk_read_buf_size = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ;
if (c->bulk_read_buf_size > c->leb_size) if (c->bulk_read_buf_size > c->leb_size)
c->bulk_read_buf_size = c->leb_size; c->bulk_read_buf_size = c->leb_size;
if (c->bulk_read_buf_size > 128 * 1024) { if (c->bulk_read_buf_size > UBIFS_KMALLOC_OK) {
/* Check if we can kmalloc more than 128KiB */ /* Check if we can kmalloc that much */
void *try = kmalloc(c->bulk_read_buf_size, GFP_KERNEL); void *try = kmalloc(c->bulk_read_buf_size,
GFP_KERNEL | __GFP_NOWARN);
kfree(try); kfree(try);
if (!try) if (!try)
c->bulk_read_buf_size = 128 * 1024; c->bulk_read_buf_size = UBIFS_KMALLOC_OK;
} }
return 0; return 0;
} }
......
...@@ -753,7 +753,7 @@ struct ubifs_znode { ...@@ -753,7 +753,7 @@ struct ubifs_znode {
}; };
/** /**
* struct bu_info - bulk-read information * struct bu_info - bulk-read information.
* @key: first data node key * @key: first data node key
* @zbranch: zbranches of data nodes to bulk read * @zbranch: zbranches of data nodes to bulk read
* @buf: buffer to read into * @buf: buffer to read into
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册