diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-20 11:20:19 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-20 11:20:19 -0400 |
commit | 1417fc44ee923418df3adadeb4846c891bba1ba5 (patch) | |
tree | 07e58ced7665ec94dad951175795ed3cbf11513c /fs/jffs2 | |
parent | 9641b784ff82cf0a48a6c70ef9867f5fd728de67 (diff) |
[JFFS2] Reduce calls to ref_totlen() in jffs2_mark_node_obsolete()
We were calling ref_totlen() 18 times. Even before that becomes a real
function rather than just a dereference, apparently some compilers still
suck anyway. It'll _certainly_ suck after ref_totlen() becomes more
complicated, so calculate it once and don't rely on CSE.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2')
-rw-r--r-- | fs/jffs2/nodemgmt.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 49127a1f0458..0e1f58aa606c 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -470,6 +470,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
470 | struct jffs2_unknown_node n; | 470 | struct jffs2_unknown_node n; |
471 | int ret, addedsize; | 471 | int ret, addedsize; |
472 | size_t retlen; | 472 | size_t retlen; |
473 | uint32_t freed_len; | ||
473 | 474 | ||
474 | if(!ref) { | 475 | if(!ref) { |
475 | printk(KERN_NOTICE "EEEEEK. jffs2_mark_node_obsolete called with NULL node\n"); | 476 | printk(KERN_NOTICE "EEEEEK. jffs2_mark_node_obsolete called with NULL node\n"); |
@@ -499,32 +500,34 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
499 | 500 | ||
500 | spin_lock(&c->erase_completion_lock); | 501 | spin_lock(&c->erase_completion_lock); |
501 | 502 | ||
503 | freed_len = ref_totlen(c, jeb, ref); | ||
504 | |||
502 | if (ref_flags(ref) == REF_UNCHECKED) { | 505 | if (ref_flags(ref) == REF_UNCHECKED) { |
503 | D1(if (unlikely(jeb->unchecked_size < ref_totlen(c, jeb, ref))) { | 506 | D1(if (unlikely(jeb->unchecked_size < freed_len)) { |
504 | printk(KERN_NOTICE "raw unchecked node of size 0x%08x freed from erase block %d at 0x%08x, but unchecked_size was already 0x%08x\n", | 507 | printk(KERN_NOTICE "raw unchecked node of size 0x%08x freed from erase block %d at 0x%08x, but unchecked_size was already 0x%08x\n", |
505 | ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size); | 508 | freed_len, blocknr, ref->flash_offset, jeb->used_size); |
506 | BUG(); | 509 | BUG(); |
507 | }) | 510 | }) |
508 | D1(printk(KERN_DEBUG "Obsoleting previously unchecked node at 0x%08x of len %x: ", ref_offset(ref), ref_totlen(c, jeb, ref))); | 511 | D1(printk(KERN_DEBUG "Obsoleting previously unchecked node at 0x%08x of len %x: ", ref_offset(ref), freed_len)); |
509 | jeb->unchecked_size -= ref_totlen(c, jeb, ref); | 512 | jeb->unchecked_size -= freed_len; |
510 | c->unchecked_size -= ref_totlen(c, jeb, ref); | 513 | c->unchecked_size -= freed_len; |
511 | } else { | 514 | } else { |
512 | D1(if (unlikely(jeb->used_size < ref_totlen(c, jeb, ref))) { | 515 | D1(if (unlikely(jeb->used_size < freed_len)) { |
513 | printk(KERN_NOTICE "raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n", | 516 | printk(KERN_NOTICE "raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n", |
514 | ref_totlen(c, jeb, ref), blocknr, ref->flash_offset, jeb->used_size); | 517 | freed_len, blocknr, ref->flash_offset, jeb->used_size); |
515 | BUG(); | 518 | BUG(); |
516 | }) | 519 | }) |
517 | D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), ref_totlen(c, jeb, ref))); | 520 | D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), freed_len)); |
518 | jeb->used_size -= ref_totlen(c, jeb, ref); | 521 | jeb->used_size -= freed_len; |
519 | c->used_size -= ref_totlen(c, jeb, ref); | 522 | c->used_size -= freed_len; |
520 | } | 523 | } |
521 | 524 | ||
522 | // Take care, that wasted size is taken into concern | 525 | // Take care, that wasted size is taken into concern |
523 | if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + ref_totlen(c, jeb, ref))) && jeb != c->nextblock) { | 526 | if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + freed_len)) && jeb != c->nextblock) { |
524 | D1(printk(KERN_DEBUG "Dirtying\n")); | 527 | D1(printk(KERN_DEBUG "Dirtying\n")); |
525 | addedsize = ref_totlen(c, jeb, ref); | 528 | addedsize = freed_len; |
526 | jeb->dirty_size += ref_totlen(c, jeb, ref); | 529 | jeb->dirty_size += freed_len; |
527 | c->dirty_size += ref_totlen(c, jeb, ref); | 530 | c->dirty_size += freed_len; |
528 | 531 | ||
529 | /* Convert wasted space to dirty, if not a bad block */ | 532 | /* Convert wasted space to dirty, if not a bad block */ |
530 | if (jeb->wasted_size) { | 533 | if (jeb->wasted_size) { |
@@ -545,8 +548,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
545 | } else { | 548 | } else { |
546 | D1(printk(KERN_DEBUG "Wasting\n")); | 549 | D1(printk(KERN_DEBUG "Wasting\n")); |
547 | addedsize = 0; | 550 | addedsize = 0; |
548 | jeb->wasted_size += ref_totlen(c, jeb, ref); | 551 | jeb->wasted_size += freed_len; |
549 | c->wasted_size += ref_totlen(c, jeb, ref); | 552 | c->wasted_size += freed_len; |
550 | } | 553 | } |
551 | ref->flash_offset = ref_offset(ref) | REF_OBSOLETE; | 554 | ref->flash_offset = ref_offset(ref) | REF_OBSOLETE; |
552 | 555 | ||
@@ -634,8 +637,8 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
634 | printk(KERN_WARNING "Short read from obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen); | 637 | printk(KERN_WARNING "Short read from obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen); |
635 | goto out_erase_sem; | 638 | goto out_erase_sem; |
636 | } | 639 | } |
637 | if (PAD(je32_to_cpu(n.totlen)) != PAD(ref_totlen(c, jeb, ref))) { | 640 | if (PAD(je32_to_cpu(n.totlen)) != PAD(freed_len)) { |
638 | printk(KERN_WARNING "Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n", je32_to_cpu(n.totlen), ref_totlen(c, jeb, ref)); | 641 | printk(KERN_WARNING "Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n", je32_to_cpu(n.totlen), freed_len); |
639 | goto out_erase_sem; | 642 | goto out_erase_sem; |
640 | } | 643 | } |
641 | if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) { | 644 | if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) { |