diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-04-23 10:40:52 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2008-04-23 11:01:37 -0400 |
commit | 422b120238130307da64fa44c9fb722bfaf5f1af (patch) | |
tree | 72f47ac8dcd66ae074d1b4b916ffc8fe32183bf1 | |
parent | e2bc322bf05936ec7160d62bc3fd45cbf4aa405a (diff) |
[JFFS2] Fix jffs2_reserve_space() when all blocks are pending erasure.
When _all_ the blocks were on the erase_pending_list, we could't find a
block to GC from but there was no _actually_ free space, and
jffs2_reserve_space() would get a little unhappy.
Handle this case by returning -EAGAIN from jffs2_garbage_collect_pass().
There are two callers of that function -- jffs2_flush_wbuf_gc(), which
will interpret it as an error and flush the writebuffer by other means,
and jffs2_reserve_space(), which we modify to respond to -EAGAIN with an
immediate call to jffs2_erase_pending_blocks() and another run round the
loop.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r-- | fs/jffs2/gc.c | 8 | ||||
-rw-r--r-- | fs/jffs2/nodemgmt.c | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 26c7992c45ca..bad005664e30 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -221,7 +221,13 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
221 | jeb = jffs2_find_gc_block(c); | 221 | jeb = jffs2_find_gc_block(c); |
222 | 222 | ||
223 | if (!jeb) { | 223 | if (!jeb) { |
224 | D1 (printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); | 224 | /* Couldn't find a free block. But maybe we can just erase one and make 'progress'? */ |
225 | if (!list_empty(&c->erase_pending_list)) { | ||
226 | spin_unlock(&c->erase_completion_lock); | ||
227 | mutex_unlock(&c->alloc_sem); | ||
228 | return -EAGAIN; | ||
229 | } | ||
230 | D1(printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); | ||
225 | spin_unlock(&c->erase_completion_lock); | 231 | spin_unlock(&c->erase_completion_lock); |
226 | mutex_unlock(&c->alloc_sem); | 232 | mutex_unlock(&c->alloc_sem); |
227 | return -EIO; | 233 | return -EIO; |
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 747a73f0aa4d..9df8f3ef20df 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -116,7 +116,10 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
116 | spin_unlock(&c->erase_completion_lock); | 116 | spin_unlock(&c->erase_completion_lock); |
117 | 117 | ||
118 | ret = jffs2_garbage_collect_pass(c); | 118 | ret = jffs2_garbage_collect_pass(c); |
119 | if (ret) | 119 | |
120 | if (ret == -EAGAIN) | ||
121 | jffs2_erase_pending_blocks(c, 1); | ||
122 | else if (ret) | ||
120 | return ret; | 123 | return ret; |
121 | 124 | ||
122 | cond_resched(); | 125 | cond_resched(); |