diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-23 21:04:45 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-23 21:04:45 -0400 |
commit | 2f785402f39b96a077b6e62bf26164bfb8e0c980 (patch) | |
tree | 3f3a38b484ef2dabda1599d4d8f08b121bd03a76 /fs/jffs2/nodelist.c | |
parent | 4cbb9b80e171107c6c34116283fe38e5a396c68b (diff) |
[JFFS2] Reduce visibility of raw_node_ref to upper layers of JFFS2 code.
As the first step towards eliminating the ref->next_phys member and saving
memory by using an _array_ of struct jffs2_raw_node_ref per eraseblock,
stop the write functions from allocating their own refs; have them just
_reserve_ the appropriate number instead. Then jffs2_link_node_ref() can
just fill them in.
Use a linked list of pre-allocated refs in the superblock, for now. Once
we switch to an array, it'll just be a case of extending that array.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'fs/jffs2/nodelist.c')
-rw-r--r-- | fs/jffs2/nodelist.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index d25d4919ca97..1e6eabd730f2 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c | |||
@@ -953,13 +953,19 @@ void jffs2_free_raw_node_refs(struct jffs2_sb_info *c) | |||
953 | 953 | ||
954 | for (i=0; i<c->nr_blocks; i++) { | 954 | for (i=0; i<c->nr_blocks; i++) { |
955 | this = c->blocks[i].first_node; | 955 | this = c->blocks[i].first_node; |
956 | while(this) { | 956 | while (this) { |
957 | next = this->next_phys; | 957 | next = this->next_phys; |
958 | jffs2_free_raw_node_ref(this); | 958 | __jffs2_free_raw_node_ref(this); |
959 | this = next; | 959 | this = next; |
960 | } | 960 | } |
961 | c->blocks[i].first_node = c->blocks[i].last_node = NULL; | 961 | c->blocks[i].first_node = c->blocks[i].last_node = NULL; |
962 | } | 962 | } |
963 | this = c->refs; | ||
964 | while (this) { | ||
965 | next = this->next_in_ino; | ||
966 | __jffs2_free_raw_node_ref(this); | ||
967 | this = next; | ||
968 | } | ||
963 | } | 969 | } |
964 | 970 | ||
965 | struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset) | 971 | struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset) |
@@ -1047,10 +1053,27 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c) | |||
1047 | } | 1053 | } |
1048 | } | 1054 | } |
1049 | 1055 | ||
1050 | void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 1056 | struct jffs2_raw_node_ref *jffs2_link_node_ref(struct jffs2_sb_info *c, |
1051 | struct jffs2_raw_node_ref *ref, uint32_t len, | 1057 | struct jffs2_eraseblock *jeb, |
1052 | struct jffs2_inode_cache *ic) | 1058 | uint32_t ofs, uint32_t len, |
1059 | struct jffs2_inode_cache *ic) | ||
1053 | { | 1060 | { |
1061 | struct jffs2_raw_node_ref *ref; | ||
1062 | |||
1063 | /* These will be preallocated _very_ shortly. */ | ||
1064 | ref = c->refs; | ||
1065 | if (!c->refs) { | ||
1066 | JFFS2_WARNING("Using non-preallocated refs!\n"); | ||
1067 | ref = __jffs2_alloc_raw_node_ref(); | ||
1068 | BUG_ON(!ref); | ||
1069 | WARN_ON(1); | ||
1070 | } else { | ||
1071 | c->refs = ref->next_in_ino; | ||
1072 | } | ||
1073 | |||
1074 | ref->next_phys = NULL; | ||
1075 | ref->flash_offset = ofs; | ||
1076 | |||
1054 | if (!jeb->first_node) | 1077 | if (!jeb->first_node) |
1055 | jeb->first_node = ref; | 1078 | jeb->first_node = ref; |
1056 | if (jeb->last_node) { | 1079 | if (jeb->last_node) { |
@@ -1093,15 +1116,15 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | |||
1093 | c->free_size -= len; | 1116 | c->free_size -= len; |
1094 | jeb->free_size -= len; | 1117 | jeb->free_size -= len; |
1095 | 1118 | ||
1096 | ref->next_phys = NULL; | ||
1097 | #ifdef TEST_TOTLEN | 1119 | #ifdef TEST_TOTLEN |
1098 | /* Set (and test) __totlen field... for now */ | 1120 | /* Set (and test) __totlen field... for now */ |
1099 | ref->__totlen = len; | 1121 | ref->__totlen = len; |
1100 | ref_totlen(c, jeb, ref); | 1122 | ref_totlen(c, jeb, ref); |
1101 | #endif | 1123 | #endif |
1124 | return ref; | ||
1102 | } | 1125 | } |
1103 | 1126 | ||
1104 | /* No locking. Do not use on a live file system */ | 1127 | /* No locking, no reservation of 'ref'. Do not use on a live file system */ |
1105 | int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 1128 | int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
1106 | uint32_t size) | 1129 | uint32_t size) |
1107 | { | 1130 | { |
@@ -1121,18 +1144,10 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb | |||
1121 | jeb->dirty_size += size; | 1144 | jeb->dirty_size += size; |
1122 | jeb->free_size -= size; | 1145 | jeb->free_size -= size; |
1123 | } else { | 1146 | } else { |
1124 | struct jffs2_raw_node_ref *ref; | 1147 | uint32_t ofs = jeb->offset + c->sector_size - jeb->free_size; |
1125 | ref = jffs2_alloc_raw_node_ref(); | 1148 | ofs |= REF_OBSOLETE; |
1126 | if (!ref) | ||
1127 | return -ENOMEM; | ||
1128 | |||
1129 | ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size; | ||
1130 | ref->flash_offset |= REF_OBSOLETE; | ||
1131 | #ifdef TEST_TOTLEN | ||
1132 | ref->__totlen = size; | ||
1133 | #endif | ||
1134 | 1149 | ||
1135 | jffs2_link_node_ref(c, jeb, ref, size, NULL); | 1150 | jffs2_link_node_ref(c, jeb, ofs, size, NULL); |
1136 | } | 1151 | } |
1137 | 1152 | ||
1138 | return 0; | 1153 | return 0; |