aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r--fs/ubifs/super.c17
1 files changed, 12 insertions, 5 deletions
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}