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>

+15 -8
+2 -2
fs/ubifs/file.c
··· 705 705 int err, page_idx, page_cnt, ret = 0, n = 0; 706 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 709 if (!bu) 710 710 return 0; 711 711 712 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 714 if (!bu->buf) 715 715 goto out_free; 716 716
+12 -5
fs/ubifs/super.c
··· 36 36 #include <linux/mount.h> 37 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 45 /* Slab cache for UBIFS inodes */ 40 46 struct kmem_cache *ubifs_inode_slab; 41 47 ··· 567 561 * calculations when reporting free space. 568 562 */ 569 563 c->leb_overhead = c->leb_size % UBIFS_MAX_DATA_NODE_SZ; 564 + 570 565 /* Buffer size for bulk-reads */ 571 566 c->bulk_read_buf_size = UBIFS_MAX_BULK_READ * UBIFS_MAX_DATA_NODE_SZ; 572 567 if (c->bulk_read_buf_size > c->leb_size) 573 568 c->bulk_read_buf_size = c->leb_size; 574 - if (c->bulk_read_buf_size > 128 * 1024) { 575 - /* Check if we can kmalloc more than 128KiB */ 576 - void *try = kmalloc(c->bulk_read_buf_size, GFP_KERNEL); 577 - 569 + if (c->bulk_read_buf_size > UBIFS_KMALLOC_OK) { 570 + /* Check if we can kmalloc that much */ 571 + void *try = kmalloc(c->bulk_read_buf_size, 572 + GFP_KERNEL | __GFP_NOWARN); 578 573 kfree(try); 579 574 if (!try) 580 - c->bulk_read_buf_size = 128 * 1024; 575 + c->bulk_read_buf_size = UBIFS_KMALLOC_OK; 581 576 } 582 577 return 0; 583 578 }
+1 -1
fs/ubifs/ubifs.h
··· 753 753 }; 754 754 755 755 /** 756 - * struct bu_info - bulk-read information 756 + * struct bu_info - bulk-read information. 757 757 * @key: first data node key 758 758 * @zbranch: zbranches of data nodes to bulk read 759 759 * @buf: buffer to read into