aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/nodelist.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-05-20 14:45:26 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-20 14:45:26 -0400
commitf1f9671bd8f7d2ac6a918bad806ab5bdc0daaf4e (patch)
treef1fb5992fbd299375c911eb4c36d7fc8774f9208 /fs/jffs2/nodelist.c
parent0cfc7da3ff4b39a3aac261ab3f6b1329e2485653 (diff)
[JFFS2] Introduce jffs2_link_node_ref() function to reduce code duplication
The same sequence of code was repeated in many places, to add a new struct jffs2_raw_node_ref to an eraseblock and adjust the space accounting accordingly. Move it out-of-line. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/nodelist.c')
-rw-r--r--fs/jffs2/nodelist.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 4973cd648ba8..1fc8aedb56fb 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -1046,3 +1046,37 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
1046 cond_resched(); 1046 cond_resched();
1047 } 1047 }
1048} 1048}
1049
1050void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
1051 struct jffs2_raw_node_ref *ref, uint32_t len)
1052{
1053 if (!jeb->first_node)
1054 jeb->first_node = ref;
1055 if (jeb->last_node)
1056 jeb->last_node->next_phys = ref;
1057 jeb->last_node = ref;
1058
1059 switch(ref_flags(ref)) {
1060 case REF_UNCHECKED:
1061 c->unchecked_size += len;
1062 jeb->unchecked_size += len;
1063 break;
1064
1065 case REF_NORMAL:
1066 case REF_PRISTINE:
1067 c->used_size += len;
1068 jeb->used_size += len;
1069 break;
1070
1071 case REF_OBSOLETE:
1072 c->dirty_size += len;
1073 jeb->used_size += len;
1074 break;
1075 }
1076 c->free_size -= len;
1077 jeb->free_size -= len;
1078
1079 /* Set __totlen field... for now */
1080 ref->__totlen = len;
1081 ref->next_phys = NULL;
1082}