Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195981
b: refs/heads/master
c: 0717bf8
h: refs/heads/master
i:
  195979: 1217ff6
v: v3
  • Loading branch information
David Woodhouse authored and David Woodhouse committed May 19, 2010
1 parent fead2f8 commit 0bbd5c3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9957abea31aed5783d6ca7175cce553045c0eb19
refs/heads/master: 0717bf8411bb673dd2369aaa096f7396446b38f5
1 change: 1 addition & 0 deletions trunk/fs/jffs2/erase.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblo
mutex_unlock(&c->erase_free_sem);
/* Ensure that kupdated calls us again to mark them clean */
jffs2_erase_pending_trigger(c);
wake_up(&c->erase_wait);
}

static void jffs2_erase_failed(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, uint32_t bad_offset)
Expand Down
15 changes: 14 additions & 1 deletion trunk/fs/jffs2/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
return ret;
}

/* If there are any blocks which need erasing, erase them now */
if (!list_empty(&c->erase_complete_list) ||
!list_empty(&c->erase_pending_list)) {
spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() erasing pending blocks\n"));
if (jffs2_erase_pending_blocks(c, 1)) {
mutex_unlock(&c->alloc_sem);
return 0;
}
D1(printk(KERN_DEBUG "No progress from erasing blocks; doing GC anyway\n"));
spin_lock(&c->erase_completion_lock);
}

/* First, work out which block we're garbage-collecting */
jeb = c->gcblock;

Expand All @@ -222,7 +235,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)

if (!jeb) {
/* Couldn't find a free block. But maybe we can just erase one and make 'progress'? */
if (!list_empty(&c->erase_pending_list)) {
if (c->nr_erasing_blocks) {
spin_unlock(&c->erase_completion_lock);
mutex_unlock(&c->alloc_sem);
return -EAGAIN;
Expand Down
18 changes: 15 additions & 3 deletions trunk/fs/jffs2/nodemgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,21 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,

ret = jffs2_garbage_collect_pass(c);

if (ret == -EAGAIN)
jffs2_erase_pending_blocks(c, 1);
else if (ret)
if (ret == -EAGAIN) {
spin_lock(&c->erase_completion_lock);
if (c->nr_erasing_blocks &&
list_empty(&c->erase_pending_list) &&
list_empty(&c->erase_complete_list)) {
DECLARE_WAITQUEUE(wait, current);
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&c->erase_wait, &wait);
D1(printk(KERN_DEBUG "%s waiting for erase to complete\n", __func__));
spin_unlock(&c->erase_completion_lock);

schedule();
} else
spin_unlock(&c->erase_completion_lock);
} else if (ret)
return ret;

cond_resched();
Expand Down

0 comments on commit 0bbd5c3

Please sign in to comment.