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