aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-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