From: Grant Erickson <marathon96@gmail.com>
To: linux-mtd@lists.infradead.org
Subject: [PATCH] JFFS2: Retry Medium Scan Buffer Allocations
Date: Fri, 1 Apr 2011 18:29:57 -0700 [thread overview]
Message-ID: <1301707797-9458-1-git-send-email-marathon96@gmail.com> (raw)
When handling a JFFS2 medium scan request exponentially back off on
the size of the requested scan buffer until it succeeds or until the
requested scan buffer size falls below a page. This helps ensure the
allocation and subsequent scan operation can succeed under low-memory,
highly-fragmented situations albeit somewhat more slowly.
Signed-off-by: Grant Erickson <marathon96@gmail.com>
---
fs/jffs2/scan.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index b632ddd..4d8746d 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -118,11 +118,14 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
buf_size = PAGE_SIZE;
/* Respect kmalloc limitations */
- if (buf_size > 128*1024)
- buf_size = 128*1024;
+ buf_size = min_t(uint32_t, buf_size, 128*1024);
+
+ do {
+ D1(printk(KERN_DEBUG "Trying to allocate readbuf of %d "
+ "bytes\n", buf_size));
+ flashbuf = kmalloc(buf_size, GFP_KERNEL);
+ } while (!flashbuf && ((buf_size >>= 1) >= PAGE_SIZE));
- D1(printk(KERN_DEBUG "Allocating readbuf of %d bytes\n", buf_size));
- flashbuf = kmalloc(buf_size, GFP_KERNEL);
if (!flashbuf)
return -ENOMEM;
}
--
1.7.4.2
next reply other threads:[~2011-04-02 1:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-02 1:29 Grant Erickson [this message]
2011-04-04 18:10 ` [PATCH v2] JFFS2: Retry Medium Scan Buffer Allocations Grant Erickson
2011-04-04 18:39 ` [PATCH] MTD: Retry Read/Write Transfer " Grant Erickson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1301707797-9458-1-git-send-email-marathon96@gmail.com \
--to=marathon96@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox