aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/nodemgmt.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-06-18 13:35:10 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-06-18 13:39:38 -0400
commitfc6612f627c697b348a4ef64f16fb373d86dbd76 (patch)
tree5367b23890ea9ec990e4855f22115ee8e7f7f125 /fs/jffs2/nodemgmt.c
parent2ba72cb754bb091bb24a44e9682f7105110f7f38 (diff)
[JFFS2] When retiring nextblock, allocate a node_ref for the wasted space
Failing to do so makes the calculated length of the last node incorrect, when we're not using eraseblock summaries. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/nodemgmt.c')
-rw-r--r--fs/jffs2/nodemgmt.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 71d1630609a5..8bedfd2ff689 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -317,6 +317,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
317 } 317 }
318 } else { 318 } else {
319 if (jeb && minsize > jeb->free_size) { 319 if (jeb && minsize > jeb->free_size) {
320 uint32_t waste;
321
320 /* Skip the end of this block and file it as having some dirty space */ 322 /* Skip the end of this block and file it as having some dirty space */
321 /* If there's a pending write to it, flush now */ 323 /* If there's a pending write to it, flush now */
322 324
@@ -329,10 +331,26 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
329 goto restart; 331 goto restart;
330 } 332 }
331 333
332 c->wasted_size += jeb->free_size; 334 spin_unlock(&c->erase_completion_lock);
333 c->free_size -= jeb->free_size; 335
334 jeb->wasted_size += jeb->free_size; 336 ret = jffs2_prealloc_raw_node_refs(c, jeb, 1);
335 jeb->free_size = 0; 337 if (ret)
338 return ret;
339 /* Just lock it again and continue. Nothing much can change because
340 we hold c->alloc_sem anyway. In fact, it's not entirely clear why
341 we hold c->erase_completion_lock in the majority of this function...
342 but that's a question for another (more caffeine-rich) day. */
343 spin_lock(&c->erase_completion_lock);
344
345 waste = jeb->free_size;
346 jffs2_link_node_ref(c, jeb,
347 (jeb->offset + c->sector_size - waste) | REF_OBSOLETE,
348 waste, NULL);
349 /* FIXME: that made it count as dirty. Convert to wasted */
350 jeb->dirty_size -= waste;
351 c->dirty_size -= waste;
352 jeb->wasted_size += waste;
353 c->wasted_size += waste;
336 354
337 jffs2_close_nextblock(c, jeb); 355 jffs2_close_nextblock(c, jeb);
338 jeb = NULL; 356 jeb = NULL;