diff options
author | Grant Erickson <marathon96@gmail.com> | 2011-04-08 11:51:34 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2011-05-24 21:00:50 -0400 |
commit | 1ddd0d9a3177356f2a29c8f3826ad79e1ad18397 (patch) | |
tree | 040b7bdc00b8cba4e51440e5aa8d598555bc2678 /fs/jffs2 | |
parent | 3e45cf5e85a4f344fc4c8c901ac057a2402db125 (diff) |
JFFS2: retry large buffer allocations
Replace direct call to kmalloc for a potentially large, contiguous
buffer allocation with one to mtd_kmalloc_up_to which helps ensure the
operation can succeed under low-memory, highly- fragmented situations
albeit somewhat more slowly.
Signed-off-by: Grant Erickson <marathon96@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'fs/jffs2')
-rw-r--r-- | fs/jffs2/scan.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index b632dddcb482..8d8cd3419d02 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -94,7 +94,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
94 | uint32_t buf_size = 0; | 94 | uint32_t buf_size = 0; |
95 | struct jffs2_summary *s = NULL; /* summary info collected by the scan process */ | 95 | struct jffs2_summary *s = NULL; /* summary info collected by the scan process */ |
96 | #ifndef __ECOS | 96 | #ifndef __ECOS |
97 | size_t pointlen; | 97 | size_t pointlen, try_size; |
98 | 98 | ||
99 | if (c->mtd->point) { | 99 | if (c->mtd->point) { |
100 | ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen, | 100 | ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen, |
@@ -113,18 +113,21 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
113 | /* For NAND it's quicker to read a whole eraseblock at a time, | 113 | /* For NAND it's quicker to read a whole eraseblock at a time, |
114 | apparently */ | 114 | apparently */ |
115 | if (jffs2_cleanmarker_oob(c)) | 115 | if (jffs2_cleanmarker_oob(c)) |
116 | buf_size = c->sector_size; | 116 | try_size = c->sector_size; |
117 | else | 117 | else |
118 | buf_size = PAGE_SIZE; | 118 | try_size = PAGE_SIZE; |
119 | 119 | ||
120 | /* Respect kmalloc limitations */ | 120 | D1(printk(KERN_DEBUG "Trying to allocate readbuf of %zu " |
121 | if (buf_size > 128*1024) | 121 | "bytes\n", try_size)); |
122 | buf_size = 128*1024; | ||
123 | 122 | ||
124 | D1(printk(KERN_DEBUG "Allocating readbuf of %d bytes\n", buf_size)); | 123 | flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size); |
125 | flashbuf = kmalloc(buf_size, GFP_KERNEL); | ||
126 | if (!flashbuf) | 124 | if (!flashbuf) |
127 | return -ENOMEM; | 125 | return -ENOMEM; |
126 | |||
127 | D1(printk(KERN_DEBUG "Allocated readbuf of %zu bytes\n", | ||
128 | try_size)); | ||
129 | |||
130 | buf_size = (uint32_t)try_size; | ||
128 | } | 131 | } |
129 | 132 | ||
130 | if (jffs2_sum_active()) { | 133 | if (jffs2_sum_active()) { |