提交 1ddd0d9a 编写于 作者: G Grant Erickson 提交者: David Woodhouse

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: NGrant Erickson <marathon96@gmail.com>
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 3e45cf5e
...@@ -94,7 +94,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) ...@@ -94,7 +94,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
uint32_t buf_size = 0; uint32_t buf_size = 0;
struct jffs2_summary *s = NULL; /* summary info collected by the scan process */ struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
#ifndef __ECOS #ifndef __ECOS
size_t pointlen; size_t pointlen, try_size;
if (c->mtd->point) { if (c->mtd->point) {
ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen, 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,18 +113,21 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
/* For NAND it's quicker to read a whole eraseblock at a time, /* For NAND it's quicker to read a whole eraseblock at a time,
apparently */ apparently */
if (jffs2_cleanmarker_oob(c)) if (jffs2_cleanmarker_oob(c))
buf_size = c->sector_size; try_size = c->sector_size;
else else
buf_size = PAGE_SIZE; try_size = PAGE_SIZE;
/* Respect kmalloc limitations */ D1(printk(KERN_DEBUG "Trying to allocate readbuf of %zu "
if (buf_size > 128*1024) "bytes\n", try_size));
buf_size = 128*1024;
D1(printk(KERN_DEBUG "Allocating readbuf of %d bytes\n", buf_size)); flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size);
flashbuf = kmalloc(buf_size, GFP_KERNEL);
if (!flashbuf) if (!flashbuf)
return -ENOMEM; return -ENOMEM;
D1(printk(KERN_DEBUG "Allocated readbuf of %zu bytes\n",
try_size));
buf_size = (uint32_t)try_size;
} }
if (jffs2_sum_active()) { if (jffs2_sum_active()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册