diff options
Diffstat (limited to 'fs/jffs2/nodemgmt.c')
-rw-r--r-- | fs/jffs2/nodemgmt.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index a0313fa8748e..9df8f3ef20df 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -48,7 +48,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
48 | minsize = PAD(minsize); | 48 | minsize = PAD(minsize); |
49 | 49 | ||
50 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): Requested 0x%x bytes\n", minsize)); | 50 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): Requested 0x%x bytes\n", minsize)); |
51 | down(&c->alloc_sem); | 51 | mutex_lock(&c->alloc_sem); |
52 | 52 | ||
53 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): alloc sem got\n")); | 53 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): alloc sem got\n")); |
54 | 54 | ||
@@ -57,7 +57,6 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
57 | /* this needs a little more thought (true <tglx> :)) */ | 57 | /* this needs a little more thought (true <tglx> :)) */ |
58 | while(ret == -EAGAIN) { | 58 | while(ret == -EAGAIN) { |
59 | while(c->nr_free_blocks + c->nr_erasing_blocks < blocksneeded) { | 59 | while(c->nr_free_blocks + c->nr_erasing_blocks < blocksneeded) { |
60 | int ret; | ||
61 | uint32_t dirty, avail; | 60 | uint32_t dirty, avail; |
62 | 61 | ||
63 | /* calculate real dirty size | 62 | /* calculate real dirty size |
@@ -82,7 +81,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
82 | dirty, c->unchecked_size, c->sector_size)); | 81 | dirty, c->unchecked_size, c->sector_size)); |
83 | 82 | ||
84 | spin_unlock(&c->erase_completion_lock); | 83 | spin_unlock(&c->erase_completion_lock); |
85 | up(&c->alloc_sem); | 84 | mutex_unlock(&c->alloc_sem); |
86 | return -ENOSPC; | 85 | return -ENOSPC; |
87 | } | 86 | } |
88 | 87 | ||
@@ -105,11 +104,11 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
105 | D1(printk(KERN_DEBUG "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", | 104 | D1(printk(KERN_DEBUG "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", |
106 | avail, blocksneeded * c->sector_size)); | 105 | avail, blocksneeded * c->sector_size)); |
107 | spin_unlock(&c->erase_completion_lock); | 106 | spin_unlock(&c->erase_completion_lock); |
108 | up(&c->alloc_sem); | 107 | mutex_unlock(&c->alloc_sem); |
109 | return -ENOSPC; | 108 | return -ENOSPC; |
110 | } | 109 | } |
111 | 110 | ||
112 | up(&c->alloc_sem); | 111 | mutex_unlock(&c->alloc_sem); |
113 | 112 | ||
114 | D1(printk(KERN_DEBUG "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n", | 113 | D1(printk(KERN_DEBUG "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n", |
115 | c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, | 114 | c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, |
@@ -117,7 +116,10 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
117 | spin_unlock(&c->erase_completion_lock); | 116 | spin_unlock(&c->erase_completion_lock); |
118 | 117 | ||
119 | ret = jffs2_garbage_collect_pass(c); | 118 | ret = jffs2_garbage_collect_pass(c); |
120 | if (ret) | 119 | |
120 | if (ret == -EAGAIN) | ||
121 | jffs2_erase_pending_blocks(c, 1); | ||
122 | else if (ret) | ||
121 | return ret; | 123 | return ret; |
122 | 124 | ||
123 | cond_resched(); | 125 | cond_resched(); |
@@ -125,7 +127,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
125 | if (signal_pending(current)) | 127 | if (signal_pending(current)) |
126 | return -EINTR; | 128 | return -EINTR; |
127 | 129 | ||
128 | down(&c->alloc_sem); | 130 | mutex_lock(&c->alloc_sem); |
129 | spin_lock(&c->erase_completion_lock); | 131 | spin_lock(&c->erase_completion_lock); |
130 | } | 132 | } |
131 | 133 | ||
@@ -138,7 +140,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
138 | if (!ret) | 140 | if (!ret) |
139 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); | 141 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); |
140 | if (ret) | 142 | if (ret) |
141 | up(&c->alloc_sem); | 143 | mutex_unlock(&c->alloc_sem); |
142 | return ret; | 144 | return ret; |
143 | } | 145 | } |
144 | 146 | ||
@@ -463,7 +465,7 @@ void jffs2_complete_reservation(struct jffs2_sb_info *c) | |||
463 | { | 465 | { |
464 | D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n")); | 466 | D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n")); |
465 | jffs2_garbage_collect_trigger(c); | 467 | jffs2_garbage_collect_trigger(c); |
466 | up(&c->alloc_sem); | 468 | mutex_unlock(&c->alloc_sem); |
467 | } | 469 | } |
468 | 470 | ||
469 | static inline int on_list(struct list_head *obj, struct list_head *head) | 471 | static inline int on_list(struct list_head *obj, struct list_head *head) |
@@ -512,7 +514,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
512 | any jffs2_raw_node_refs. So we don't need to stop erases from | 514 | any jffs2_raw_node_refs. So we don't need to stop erases from |
513 | happening, or protect against people holding an obsolete | 515 | happening, or protect against people holding an obsolete |
514 | jffs2_raw_node_ref without the erase_completion_lock. */ | 516 | jffs2_raw_node_ref without the erase_completion_lock. */ |
515 | down(&c->erase_free_sem); | 517 | mutex_lock(&c->erase_free_sem); |
516 | } | 518 | } |
517 | 519 | ||
518 | spin_lock(&c->erase_completion_lock); | 520 | spin_lock(&c->erase_completion_lock); |
@@ -715,7 +717,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
715 | } | 717 | } |
716 | 718 | ||
717 | out_erase_sem: | 719 | out_erase_sem: |
718 | up(&c->erase_free_sem); | 720 | mutex_unlock(&c->erase_free_sem); |
719 | } | 721 | } |
720 | 722 | ||
721 | int jffs2_thread_should_wake(struct jffs2_sb_info *c) | 723 | int jffs2_thread_should_wake(struct jffs2_sb_info *c) |