aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/scan.c')
-rw-r--r--fs/jffs2/scan.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index b3fc9fd5b03d..cffafec01e48 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -65,6 +65,25 @@ static inline uint32_t EMPTY_SCAN_SIZE(uint32_t sector_size) {
65 return DEFAULT_EMPTY_SCAN_SIZE; 65 return DEFAULT_EMPTY_SCAN_SIZE;
66} 66}
67 67
68static int file_dirty(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
69{
70 int ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size);
71 if (ret)
72 return ret;
73 /* Turned wasted size into dirty, since we apparently
74 think it's recoverable now. */
75 jeb->dirty_size += jeb->wasted_size;
76 c->dirty_size += jeb->wasted_size;
77 c->wasted_size -= jeb->wasted_size;
78 jeb->wasted_size = 0;
79 if (VERYDIRTY(c, jeb->dirty_size)) {
80 list_add(&jeb->list, &c->very_dirty_list);
81 } else {
82 list_add(&jeb->list, &c->dirty_list);
83 }
84 return 0;
85}
86
68int jffs2_scan_medium(struct jffs2_sb_info *c) 87int jffs2_scan_medium(struct jffs2_sb_info *c)
69{ 88{
70 int i, ret; 89 int i, ret;
@@ -170,34 +189,20 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
170 (!c->nextblock || c->nextblock->free_size < jeb->free_size)) { 189 (!c->nextblock || c->nextblock->free_size < jeb->free_size)) {
171 /* Better candidate for the next writes to go to */ 190 /* Better candidate for the next writes to go to */
172 if (c->nextblock) { 191 if (c->nextblock) {
173 c->nextblock->dirty_size += c->nextblock->free_size + c->nextblock->wasted_size; 192 ret = file_dirty(c, c->nextblock);
174 c->dirty_size += c->nextblock->free_size + c->nextblock->wasted_size; 193 if (ret)
175 c->free_size -= c->nextblock->free_size; 194 return ret;
176 c->wasted_size -= c->nextblock->wasted_size;
177 c->nextblock->free_size = c->nextblock->wasted_size = 0;
178 if (VERYDIRTY(c, c->nextblock->dirty_size)) {
179 list_add(&c->nextblock->list, &c->very_dirty_list);
180 } else {
181 list_add(&c->nextblock->list, &c->dirty_list);
182 }
183 /* deleting summary information of the old nextblock */ 195 /* deleting summary information of the old nextblock */
184 jffs2_sum_reset_collected(c->summary); 196 jffs2_sum_reset_collected(c->summary);
185 } 197 }
186 /* update collected summary infromation for the current nextblock */ 198 /* update collected summary information for the current nextblock */
187 jffs2_sum_move_collected(c, s); 199 jffs2_sum_move_collected(c, s);
188 D1(printk(KERN_DEBUG "jffs2_scan_medium(): new nextblock = 0x%08x\n", jeb->offset)); 200 D1(printk(KERN_DEBUG "jffs2_scan_medium(): new nextblock = 0x%08x\n", jeb->offset));
189 c->nextblock = jeb; 201 c->nextblock = jeb;
190 } else { 202 } else {
191 jeb->dirty_size += jeb->free_size + jeb->wasted_size; 203 ret = file_dirty(c, jeb);
192 c->dirty_size += jeb->free_size + jeb->wasted_size; 204 if (ret)
193 c->free_size -= jeb->free_size; 205 return ret;
194 c->wasted_size -= jeb->wasted_size;
195 jeb->free_size = jeb->wasted_size = 0;
196 if (VERYDIRTY(c, jeb->dirty_size)) {
197 list_add(&jeb->list, &c->very_dirty_list);
198 } else {
199 list_add(&jeb->list, &c->dirty_list);
200 }
201 } 206 }
202 break; 207 break;
203 208