aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/jffs2/TODO38
-rw-r--r--fs/jffs2/build.c112
-rw-r--r--fs/jffs2/debug.c3
-rw-r--r--fs/jffs2/debug.h50
-rw-r--r--fs/jffs2/erase.c2
-rw-r--r--fs/jffs2/malloc.c34
-rw-r--r--fs/jffs2/nodelist.c107
-rw-r--r--fs/jffs2/nodemgmt.c6
-rw-r--r--fs/jffs2/os-linux.h6
-rw-r--r--fs/jffs2/readinode.c32
-rw-r--r--fs/jffs2/scan.c48
-rw-r--r--fs/jffs2/summary.c53
-rw-r--r--fs/jffs2/wbuf.c5
-rw-r--r--include/linux/jffs2_fs_sb.h5
14 files changed, 235 insertions, 266 deletions
diff --git a/fs/jffs2/TODO b/fs/jffs2/TODO
index 2bff82fd221f..d0e23b26fa50 100644
--- a/fs/jffs2/TODO
+++ b/fs/jffs2/TODO
@@ -1,5 +1,11 @@
1$Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $ 1$Id: TODO,v 1.18 2005/09/22 11:24:56 dedekind Exp $
2 2
3 - support asynchronous operation -- add a per-fs 'reserved_space' count,
4 let each outstanding write reserve the _maximum_ amount of physical
5 space it could take. Let GC flush the outstanding writes because the
6 reservations will necessarily be pessimistic. With this we could even
7 do shared writable mmap, if we can have a fs hook for do_wp_page() to
8 make the reservation.
3 - disable compression in commit_write()? 9 - disable compression in commit_write()?
4 - fine-tune the allocation / GC thresholds 10 - fine-tune the allocation / GC thresholds
5 - chattr support - turning on/off and tuning compression per-inode 11 - chattr support - turning on/off and tuning compression per-inode
@@ -11,26 +17,15 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $
11 - test, test, test 17 - test, test, test
12 18
13 - NAND flash support: 19 - NAND flash support:
14 - flush_wbuf using GC to fill it, don't just pad. 20 - almost done :)
15 - Deal with write errors. Data don't get lost - we just have to write 21 - use bad block check instead of the hardwired byte check
16 the affected node(s) out again somewhere else.
17 - make fsync flush only if actually required
18 - make sys_sync() work.
19 - reboot notifier
20 - timed flush of old wbuf
21 - fix magical second arg of jffs2_flush_wbuf(). Split into two or more functions instead.
22
23 22
24 - Optimisations: 23 - Optimisations:
25 - Stop GC from decompressing and immediately recompressing nodes which could 24 - Split writes so they go to two separate blocks rather than just c->nextblock.
26 just be copied intact. (We now keep track of REF_PRISTINE flag. Easy now.) 25 By writing _new_ nodes to one block, and garbage-collected REF_PRISTINE
27 - Furthermore, in the case where it could be copied intact we don't even need 26 nodes to a different one, we can separate clean nodes from those which
28 to call iget() for it -- if we use (raw_node_raw->flash_offset & 2) as a flag 27 are likely to become dirty, and end up with blocks which are each far
29 to show a node can be copied intact and it's _not_ in icache, we could just do 28 closer to 100% or 0% clean, hence speeding up later GC progress dramatically.
30 it, fix up the next_in_ino list and move on. We would need a way to find out
31 _whether_ it's in icache though -- if it's in icache we also need to do the
32 fragment lists, etc. P'raps a flag or pointer in the jffs2_inode_cache could
33 help. (We have half of this now.)
34 - Stop keeping name in-core with struct jffs2_full_dirent. If we keep the hash in 29 - Stop keeping name in-core with struct jffs2_full_dirent. If we keep the hash in
35 the full dirent, we only need to go to the flash in lookup() when we think we've 30 the full dirent, we only need to go to the flash in lookup() when we think we've
36 got a match, and in readdir(). 31 got a match, and in readdir().
@@ -38,3 +33,8 @@ $Id: TODO,v 1.10 2002/09/09 16:31:21 dwmw2 Exp $
38 - Remove totlen from jffs2_raw_node_ref? Need to have totlen passed into 33 - Remove totlen from jffs2_raw_node_ref? Need to have totlen passed into
39 jffs2_mark_node_obsolete(). Can all callers work it out? 34 jffs2_mark_node_obsolete(). Can all callers work it out?
40 - Remove size from jffs2_raw_node_frag. 35 - Remove size from jffs2_raw_node_frag.
36
37dedekind:
381. __jffs2_flush_wbuf() has a strange 'pad' parameter. Eliminate.
392. get_sb()->build_fs()->scan() path... Why get_sb() removes scan()'s crap in
40 case of failure? scan() does not clean everything. Fix.
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c
index f2cf562ebd2a..ac393b3d6ea3 100644
--- a/fs/jffs2/build.c
+++ b/fs/jffs2/build.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: build.c,v 1.79 2005/09/07 11:21:57 havasi Exp $ 10 * $Id: build.c,v 1.83 2005/09/21 15:52:33 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -18,7 +18,8 @@
18#include <linux/mtd/mtd.h> 18#include <linux/mtd/mtd.h>
19#include "nodelist.h" 19#include "nodelist.h"
20 20
21static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *, struct jffs2_full_dirent **); 21static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *,
22 struct jffs2_inode_cache *, struct jffs2_full_dirent **);
22 23
23static inline struct jffs2_inode_cache * 24static inline struct jffs2_inode_cache *
24first_inode_chain(int *i, struct jffs2_sb_info *c) 25first_inode_chain(int *i, struct jffs2_sb_info *c)
@@ -46,11 +47,12 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c)
46 ic = next_inode(&i, ic, (c))) 47 ic = next_inode(&i, ic, (c)))
47 48
48 49
49static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) 50static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
51 struct jffs2_inode_cache *ic)
50{ 52{
51 struct jffs2_full_dirent *fd; 53 struct jffs2_full_dirent *fd;
52 54
53 D1(printk(KERN_DEBUG "jffs2_build_inode building directory inode #%u\n", ic->ino)); 55 dbg_fsbuild("building directory inode #%u\n", ic->ino);
54 56
55 /* For each child, increase nlink */ 57 /* For each child, increase nlink */
56 for(fd = ic->scan_dents; fd; fd = fd->next) { 58 for(fd = ic->scan_dents; fd; fd = fd->next) {
@@ -58,26 +60,23 @@ static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2
58 if (!fd->ino) 60 if (!fd->ino)
59 continue; 61 continue;
60 62
61 /* XXX: Can get high latency here with huge directories */ 63 /* we can get high latency here with huge directories */
62 64
63 child_ic = jffs2_get_ino_cache(c, fd->ino); 65 child_ic = jffs2_get_ino_cache(c, fd->ino);
64 if (!child_ic) { 66 if (!child_ic) {
65 printk(KERN_NOTICE "Eep. Child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n", 67 dbg_fsbuild("child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n",
66 fd->name, fd->ino, ic->ino); 68 fd->name, fd->ino, ic->ino);
67 jffs2_mark_node_obsolete(c, fd->raw); 69 jffs2_mark_node_obsolete(c, fd->raw);
68 continue; 70 continue;
69 } 71 }
70 72
71 if (child_ic->nlink++ && fd->type == DT_DIR) { 73 if (child_ic->nlink++ && fd->type == DT_DIR) {
72 printk(KERN_NOTICE "Child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n", fd->name, fd->ino, ic->ino); 74 JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n",
73 if (fd->ino == 1 && ic->ino == 1) { 75 fd->name, fd->ino, ic->ino);
74 printk(KERN_NOTICE "This is mostly harmless, and probably caused by creating a JFFS2 image\n"); 76 /* TODO: What do we do about it? */
75 printk(KERN_NOTICE "using a buggy version of mkfs.jffs2. Use at least v1.17.\n");
76 }
77 /* What do we do about it? */
78 } 77 }
79 D1(printk(KERN_DEBUG "Increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino)); 78 dbg_fsbuild("increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino);
80 /* Can't free them. We might need them in pass 2 */ 79 /* Can't free scan_dents so far. We might need them in pass 2 */
81 } 80 }
82} 81}
83 82
@@ -94,6 +93,8 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
94 struct jffs2_full_dirent *fd; 93 struct jffs2_full_dirent *fd;
95 struct jffs2_full_dirent *dead_fds = NULL; 94 struct jffs2_full_dirent *dead_fds = NULL;
96 95
96 dbg_fsbuild("build FS data structures\n");
97
97 /* First, scan the medium and build all the inode caches with 98 /* First, scan the medium and build all the inode caches with
98 lists of physical nodes */ 99 lists of physical nodes */
99 100
@@ -103,33 +104,29 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
103 if (ret) 104 if (ret)
104 goto exit; 105 goto exit;
105 106
106 D1(printk(KERN_DEBUG "Scanned flash completely\n")); 107 dbg_fsbuild("scanned flash completely\n");
107 jffs2_dbg_dump_block_lists_nolock(c); 108 jffs2_dbg_dump_block_lists_nolock(c);
108 109
110 dbg_fsbuild("pass 1 starting\n");
109 c->flags |= JFFS2_SB_FLAG_BUILDING; 111 c->flags |= JFFS2_SB_FLAG_BUILDING;
110 /* Now scan the directory tree, increasing nlink according to every dirent found. */ 112 /* Now scan the directory tree, increasing nlink according to every dirent found. */
111 for_each_inode(i, c, ic) { 113 for_each_inode(i, c, ic) {
112 D1(printk(KERN_DEBUG "Pass 1: ino #%u\n", ic->ino));
113
114 D1(BUG_ON(ic->ino > c->highest_ino));
115
116 if (ic->scan_dents) { 114 if (ic->scan_dents) {
117 jffs2_build_inode_pass1(c, ic); 115 jffs2_build_inode_pass1(c, ic);
118 cond_resched(); 116 cond_resched();
119 } 117 }
120 } 118 }
121 119
122 D1(printk(KERN_DEBUG "Pass 1 complete\n")); 120 dbg_fsbuild("pass 1 complete\n");
123 121
124 /* Next, scan for inodes with nlink == 0 and remove them. If 122 /* Next, scan for inodes with nlink == 0 and remove them. If
125 they were directories, then decrement the nlink of their 123 they were directories, then decrement the nlink of their
126 children too, and repeat the scan. As that's going to be 124 children too, and repeat the scan. As that's going to be
127 a fairly uncommon occurrence, it's not so evil to do it this 125 a fairly uncommon occurrence, it's not so evil to do it this
128 way. Recursion bad. */ 126 way. Recursion bad. */
129 D1(printk(KERN_DEBUG "Pass 2 starting\n")); 127 dbg_fsbuild("pass 2 starting\n");
130 128
131 for_each_inode(i, c, ic) { 129 for_each_inode(i, c, ic) {
132 D1(printk(KERN_DEBUG "Pass 2: ino #%u, nlink %d, ic %p, nodes %p\n", ic->ino, ic->nlink, ic, ic->nodes));
133 if (ic->nlink) 130 if (ic->nlink)
134 continue; 131 continue;
135 132
@@ -137,26 +134,24 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
137 cond_resched(); 134 cond_resched();
138 } 135 }
139 136
140 D1(printk(KERN_DEBUG "Pass 2a starting\n")); 137 dbg_fsbuild("pass 2a starting\n");
141 138
142 while (dead_fds) { 139 while (dead_fds) {
143 fd = dead_fds; 140 fd = dead_fds;
144 dead_fds = fd->next; 141 dead_fds = fd->next;
145 142
146 ic = jffs2_get_ino_cache(c, fd->ino); 143 ic = jffs2_get_ino_cache(c, fd->ino);
147 D1(printk(KERN_DEBUG "Removing dead_fd ino #%u (\"%s\"), ic at %p\n", fd->ino, fd->name, ic));
148 144
149 if (ic) 145 if (ic)
150 jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); 146 jffs2_build_remove_unlinked_inode(c, ic, &dead_fds);
151 jffs2_free_full_dirent(fd); 147 jffs2_free_full_dirent(fd);
152 } 148 }
153 149
154 D1(printk(KERN_DEBUG "Pass 2 complete\n")); 150 dbg_fsbuild("pass 2a complete\n");
151 dbg_fsbuild("freeing temporary data structures\n");
155 152
156 /* Finally, we can scan again and free the dirent structs */ 153 /* Finally, we can scan again and free the dirent structs */
157 for_each_inode(i, c, ic) { 154 for_each_inode(i, c, ic) {
158 D1(printk(KERN_DEBUG "Pass 3: ino #%u, ic %p, nodes %p\n", ic->ino, ic, ic->nodes));
159
160 while(ic->scan_dents) { 155 while(ic->scan_dents) {
161 fd = ic->scan_dents; 156 fd = ic->scan_dents;
162 ic->scan_dents = fd->next; 157 ic->scan_dents = fd->next;
@@ -167,8 +162,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
167 } 162 }
168 c->flags &= ~JFFS2_SB_FLAG_BUILDING; 163 c->flags &= ~JFFS2_SB_FLAG_BUILDING;
169 164
170 D1(printk(KERN_DEBUG "Pass 3 complete\n")); 165 dbg_fsbuild("FS build complete\n");
171 jffs2_dbg_dump_block_lists_nolock(c);
172 166
173 /* Rotate the lists by some number to ensure wear levelling */ 167 /* Rotate the lists by some number to ensure wear levelling */
174 jffs2_rotate_lists(c); 168 jffs2_rotate_lists(c);
@@ -189,24 +183,26 @@ exit:
189 return ret; 183 return ret;
190} 184}
191 185
192static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, struct jffs2_full_dirent **dead_fds) 186static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c,
187 struct jffs2_inode_cache *ic,
188 struct jffs2_full_dirent **dead_fds)
193{ 189{
194 struct jffs2_raw_node_ref *raw; 190 struct jffs2_raw_node_ref *raw;
195 struct jffs2_full_dirent *fd; 191 struct jffs2_full_dirent *fd;
196 192
197 D1(printk(KERN_DEBUG "JFFS2: Removing ino #%u with nlink == zero.\n", ic->ino)); 193 dbg_fsbuild("removing ino #%u with nlink == zero.\n", ic->ino);
198 194
199 raw = ic->nodes; 195 raw = ic->nodes;
200 while (raw != (void *)ic) { 196 while (raw != (void *)ic) {
201 struct jffs2_raw_node_ref *next = raw->next_in_ino; 197 struct jffs2_raw_node_ref *next = raw->next_in_ino;
202 D1(printk(KERN_DEBUG "obsoleting node at 0x%08x\n", ref_offset(raw))); 198 dbg_fsbuild("obsoleting node at 0x%08x\n", ref_offset(raw));
203 jffs2_mark_node_obsolete(c, raw); 199 jffs2_mark_node_obsolete(c, raw);
204 raw = next; 200 raw = next;
205 } 201 }
206 202
207 if (ic->scan_dents) { 203 if (ic->scan_dents) {
208 int whinged = 0; 204 int whinged = 0;
209 D1(printk(KERN_DEBUG "Inode #%u was a directory which may have children...\n", ic->ino)); 205 dbg_fsbuild("inode #%u was a directory which may have children...\n", ic->ino);
210 206
211 while(ic->scan_dents) { 207 while(ic->scan_dents) {
212 struct jffs2_inode_cache *child_ic; 208 struct jffs2_inode_cache *child_ic;
@@ -216,21 +212,19 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jf
216 212
217 if (!fd->ino) { 213 if (!fd->ino) {
218 /* It's a deletion dirent. Ignore it */ 214 /* It's a deletion dirent. Ignore it */
219 D1(printk(KERN_DEBUG "Child \"%s\" is a deletion dirent, skipping...\n", fd->name)); 215 dbg_fsbuild("child \"%s\" is a deletion dirent, skipping...\n", fd->name);
220 jffs2_free_full_dirent(fd); 216 jffs2_free_full_dirent(fd);
221 continue; 217 continue;
222 } 218 }
223 if (!whinged) { 219 if (!whinged)
224 whinged = 1; 220 whinged = 1;
225 printk(KERN_NOTICE "Inode #%u was a directory with children - removing those too...\n", ic->ino);
226 }
227 221
228 D1(printk(KERN_DEBUG "Removing child \"%s\", ino #%u\n", 222 dbg_fsbuild("removing child \"%s\", ino #%u\n", fd->name, fd->ino);
229 fd->name, fd->ino));
230 223
231 child_ic = jffs2_get_ino_cache(c, fd->ino); 224 child_ic = jffs2_get_ino_cache(c, fd->ino);
232 if (!child_ic) { 225 if (!child_ic) {
233 printk(KERN_NOTICE "Cannot remove child \"%s\", ino #%u, because it doesn't exist\n", fd->name, fd->ino); 226 dbg_fsbuild("cannot remove child \"%s\", ino #%u, because it doesn't exist\n",
227 fd->name, fd->ino);
234 jffs2_free_full_dirent(fd); 228 jffs2_free_full_dirent(fd);
235 continue; 229 continue;
236 } 230 }
@@ -241,13 +235,13 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jf
241 child_ic->nlink--; 235 child_ic->nlink--;
242 236
243 if (!child_ic->nlink) { 237 if (!child_ic->nlink) {
244 D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got zero nlink. Adding to dead_fds list.\n", 238 dbg_fsbuild("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n",
245 fd->ino, fd->name)); 239 fd->ino, fd->name);
246 fd->next = *dead_fds; 240 fd->next = *dead_fds;
247 *dead_fds = fd; 241 *dead_fds = fd;
248 } else { 242 } else {
249 D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got nlink %d. Ignoring.\n", 243 dbg_fsbuild("inode #%u (\"%s\") has now got nlink %d. Ignoring.\n",
250 fd->ino, fd->name, child_ic->nlink)); 244 fd->ino, fd->name, child_ic->nlink);
251 jffs2_free_full_dirent(fd); 245 jffs2_free_full_dirent(fd);
252 } 246 }
253 } 247 }
@@ -295,20 +289,20 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c)
295 trying to GC to make more space. It'll be a fruitless task */ 289 trying to GC to make more space. It'll be a fruitless task */
296 c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); 290 c->nospc_dirty_size = c->sector_size + (c->flash_size / 100);
297 291
298 D1(printk(KERN_DEBUG "JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", 292 dbg_fsbuild("JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n",
299 c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks)); 293 c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks);
300 D1(printk(KERN_DEBUG "Blocks required to allow deletion: %d (%d KiB)\n", 294 dbg_fsbuild("Blocks required to allow deletion: %d (%d KiB)\n",
301 c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024)); 295 c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024);
302 D1(printk(KERN_DEBUG "Blocks required to allow writes: %d (%d KiB)\n", 296 dbg_fsbuild("Blocks required to allow writes: %d (%d KiB)\n",
303 c->resv_blocks_write, c->resv_blocks_write*c->sector_size/1024)); 297 c->resv_blocks_write, c->resv_blocks_write*c->sector_size/1024);
304 D1(printk(KERN_DEBUG "Blocks required to quiesce GC thread: %d (%d KiB)\n", 298 dbg_fsbuild("Blocks required to quiesce GC thread: %d (%d KiB)\n",
305 c->resv_blocks_gctrigger, c->resv_blocks_gctrigger*c->sector_size/1024)); 299 c->resv_blocks_gctrigger, c->resv_blocks_gctrigger*c->sector_size/1024);
306 D1(printk(KERN_DEBUG "Blocks required to allow GC merges: %d (%d KiB)\n", 300 dbg_fsbuild("Blocks required to allow GC merges: %d (%d KiB)\n",
307 c->resv_blocks_gcmerge, c->resv_blocks_gcmerge*c->sector_size/1024)); 301 c->resv_blocks_gcmerge, c->resv_blocks_gcmerge*c->sector_size/1024);
308 D1(printk(KERN_DEBUG "Blocks required to GC bad blocks: %d (%d KiB)\n", 302 dbg_fsbuild("Blocks required to GC bad blocks: %d (%d KiB)\n",
309 c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024)); 303 c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024);
310 D1(printk(KERN_DEBUG "Amount of dirty space required to GC: %d bytes\n", 304 dbg_fsbuild("Amount of dirty space required to GC: %d bytes\n",
311 c->nospc_dirty_size)); 305 c->nospc_dirty_size);
312} 306}
313 307
314int jffs2_do_mount_fs(struct jffs2_sb_info *c) 308int jffs2_do_mount_fs(struct jffs2_sb_info *c)
@@ -358,7 +352,7 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
358 return ret; 352 return ret;
359 353
360 if (jffs2_build_filesystem(c)) { 354 if (jffs2_build_filesystem(c)) {
361 D1(printk(KERN_DEBUG "build_fs failed\n")); 355 dbg_fsbuild("build_fs failed\n");
362 jffs2_free_ino_caches(c); 356 jffs2_free_ino_caches(c);
363 jffs2_free_raw_node_refs(c); 357 jffs2_free_raw_node_refs(c);
364#ifndef __ECOS 358#ifndef __ECOS
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 28983501bcef..0947284f45dd 100644
--- a/fs/jffs2/debug.c
+++ b/fs/jffs2/debug.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: debug.c,v 1.10 2005/09/14 16:57:32 dedekind Exp $ 10 * $Id: debug.c,v 1.11 2005/09/21 13:28:35 dedekind Exp $
11 * 11 *
12 */ 12 */
13#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -15,6 +15,7 @@
15#include <linux/pagemap.h> 15#include <linux/pagemap.h>
16#include <linux/crc32.h> 16#include <linux/crc32.h>
17#include <linux/jffs2.h> 17#include <linux/jffs2.h>
18#include <linux/mtd/mtd.h>
18#include "nodelist.h" 19#include "nodelist.h"
19#include "debug.h" 20#include "debug.h"
20 21
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h
index 7328e67bebb6..da1417d38914 100644
--- a/fs/jffs2/debug.h
+++ b/fs/jffs2/debug.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: debug.h,v 1.16 2005/09/14 16:57:32 dedekind Exp $ 10 * $Id: debug.h,v 1.18 2005/09/21 10:26:26 dedekind Exp $
11 * 11 *
12 */ 12 */
13#ifndef _JFFS2_DEBUG_H_ 13#ifndef _JFFS2_DEBUG_H_
@@ -23,16 +23,23 @@
23/* Enable "paranoia" checks and dumps */ 23/* Enable "paranoia" checks and dumps */
24#define JFFS2_DBG_PARANOIA_CHECKS 24#define JFFS2_DBG_PARANOIA_CHECKS
25#define JFFS2_DBG_DUMPS 25#define JFFS2_DBG_DUMPS
26
27/*
28 * By defining/undefining the below macros one may select debugging messages
29 * fro specific JFFS2 subsystems.
30 */
26#define JFFS2_DBG_READINODE_MESSAGES 31#define JFFS2_DBG_READINODE_MESSAGES
27#define JFFS2_DBG_FRAGTREE_MESSAGES 32#define JFFS2_DBG_FRAGTREE_MESSAGES
28#define JFFS2_DBG_DENTLIST_MESSAGES 33#define JFFS2_DBG_DENTLIST_MESSAGES
29#define JFFS2_DBG_NODEREF_MESSAGES 34#define JFFS2_DBG_NODEREF_MESSAGES
30#define JFFS2_DBG_INOCACHE_MESSAGES 35#define JFFS2_DBG_INOCACHE_MESSAGES
31#define JFFS2_DBG_SUMMARY_MESSAGES 36#define JFFS2_DBG_SUMMARY_MESSAGES
37#define JFFS2_DBG_FSBUILD_MESSAGES
32#endif 38#endif
33 39
34#if CONFIG_JFFS2_FS_DEBUG == 2 40#if CONFIG_JFFS2_FS_DEBUG == 2
35#define JFFS2_DBG_FRAGTREE2_MESSAGES 41#define JFFS2_DBG_FRAGTREE2_MESSAGES
42#define JFFS2_DBG_MEMALLOC_MESSAGES
36#endif 43#endif
37 44
38/* Sanity checks are supposed to be light-weight and enabled by default */ 45/* Sanity checks are supposed to be light-weight and enabled by default */
@@ -40,7 +47,7 @@
40 47
41/* 48/*
42 * Dx() are mainly used for debugging messages, they must go away and be 49 * Dx() are mainly used for debugging messages, they must go away and be
43 * superseded by nicer JFFS2_DBG_XXX() macros... 50 * superseded by nicer dbg_xxx() macros...
44 */ 51 */
45#if CONFIG_JFFS2_FS_DEBUG > 0 52#if CONFIG_JFFS2_FS_DEBUG > 0
46#define D1(x) x 53#define D1(x) x
@@ -105,56 +112,63 @@
105 */ 112 */
106/* Read inode debugging messages */ 113/* Read inode debugging messages */
107#ifdef JFFS2_DBG_READINODE_MESSAGES 114#ifdef JFFS2_DBG_READINODE_MESSAGES
108#define JFFS2_DBG_READINODE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 115#define dbg_readinode(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
109#else 116#else
110#define JFFS2_DBG_READINODE(fmt, ...) 117#define dbg_readinode(fmt, ...)
111#endif 118#endif
112 119
113/* Fragtree build debugging messages */ 120/* Fragtree build debugging messages */
114#ifdef JFFS2_DBG_FRAGTREE_MESSAGES 121#ifdef JFFS2_DBG_FRAGTREE_MESSAGES
115#define JFFS2_DBG_FRAGTREE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 122#define dbg_fragtree(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
116#else 123#else
117#define JFFS2_DBG_FRAGTREE(fmt, ...) 124#define dbg_fragtree(fmt, ...)
118#endif 125#endif
119#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES 126#ifdef JFFS2_DBG_FRAGTREE2_MESSAGES
120#define JFFS2_DBG_FRAGTREE2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 127#define dbg_fragtree2(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
121#else 128#else
122#define JFFS2_DBG_FRAGTREE2(fmt, ...) 129#define dbg_fragtree2(fmt, ...)
123#endif 130#endif
124 131
125/* Directory entry list manilulation debugging messages */ 132/* Directory entry list manilulation debugging messages */
126#ifdef JFFS2_DBG_DENTLIST_MESSAGES 133#ifdef JFFS2_DBG_DENTLIST_MESSAGES
127#define JFFS2_DBG_DENTLIST(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 134#define dbg_dentlist(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
128#else 135#else
129#define JFFS2_DBG_DENTLIST(fmt, ...) 136#define dbg_dentlist(fmt, ...)
130#endif 137#endif
131 138
132/* Print the messages about manipulating node_refs */ 139/* Print the messages about manipulating node_refs */
133#ifdef JFFS2_DBG_NODEREF_MESSAGES 140#ifdef JFFS2_DBG_NODEREF_MESSAGES
134#define JFFS2_DBG_NODEREF(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 141#define dbg_noderef(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
135#else 142#else
136#define JFFS2_DBG_NODEREF(fmt, ...) 143#define dbg_noderef(fmt, ...)
137#endif 144#endif
138 145
139/* Manipulations with the list of inodes (JFFS2 inocache) */ 146/* Manipulations with the list of inodes (JFFS2 inocache) */
140#ifdef JFFS2_DBG_INOCACHE_MESSAGES 147#ifdef JFFS2_DBG_INOCACHE_MESSAGES
141#define JFFS2_DBG_INOCACHE(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 148#define dbg_inocache(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
142#else 149#else
143#define JFFS2_DBG_INOCACHE(fmt, ...) 150#define dbg_inocache(fmt, ...)
144#endif 151#endif
145 152
146/* Summary debugging messages */ 153/* Summary debugging messages */
147#ifdef JFFS2_DBG_SUMMARY_MESSAGES 154#ifdef JFFS2_DBG_SUMMARY_MESSAGES
148#define JFFS2_DBG_SUMMARY(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 155#define dbg_summary(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
156#else
157#define dbg_summary(fmt, ...)
158#endif
159
160/* File system build messages */
161#ifdef JFFS2_DBG_FSBUILD_MESSAGES
162#define dbg_fsbuild(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
149#else 163#else
150#define JFFS2_DBG_SUMMARY(fmt, ...) 164#define dbg_fsbuild(fmt, ...)
151#endif 165#endif
152 166
153/* Watch the object allocations */ 167/* Watch the object allocations */
154#ifdef JFFS2_DBG_MEMALLOC_MESSAGES 168#ifdef JFFS2_DBG_MEMALLOC_MESSAGES
155#define JFFS2_DBG_MEMALLOC(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__) 169#define dbg_memalloc(fmt, ...) JFFS2_DEBUG(fmt, ##__VA_ARGS__)
156#else 170#else
157#define JFFS2_DBG_MEMALLOC(fmt, ...) 171#define dbg_memalloc(fmt, ...)
158#endif 172#endif
159 173
160 174
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
index a8a0908142d9..347de4efeeeb 100644
--- a/fs/jffs2/erase.c
+++ b/fs/jffs2/erase.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: erase.c,v 1.83 2005/07/22 10:32:08 dedekind Exp $ 10 * $Id: erase.c,v 1.85 2005/09/20 14:53:15 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c
index 734801145bf8..f27df015f3ec 100644
--- a/fs/jffs2/malloc.c
+++ b/fs/jffs2/malloc.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: malloc.c,v 1.29 2005/07/27 14:16:53 dedekind Exp $ 10 * $Id: malloc.c,v 1.30 2005/09/20 14:27:34 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -97,13 +97,13 @@ struct jffs2_full_dirent *jffs2_alloc_full_dirent(int namesize)
97{ 97{
98 struct jffs2_full_dirent *ret; 98 struct jffs2_full_dirent *ret;
99 ret = kmalloc(sizeof(struct jffs2_full_dirent) + namesize, GFP_KERNEL); 99 ret = kmalloc(sizeof(struct jffs2_full_dirent) + namesize, GFP_KERNEL);
100 JFFS2_DBG_MEMALLOC("%p\n", ret); 100 dbg_memalloc("%p\n", ret);
101 return ret; 101 return ret;
102} 102}
103 103
104void jffs2_free_full_dirent(struct jffs2_full_dirent *x) 104void jffs2_free_full_dirent(struct jffs2_full_dirent *x)
105{ 105{
106 JFFS2_DBG_MEMALLOC("%p\n", x); 106 dbg_memalloc("%p\n", x);
107 kfree(x); 107 kfree(x);
108} 108}
109 109
@@ -111,13 +111,13 @@ struct jffs2_full_dnode *jffs2_alloc_full_dnode(void)
111{ 111{
112 struct jffs2_full_dnode *ret; 112 struct jffs2_full_dnode *ret;
113 ret = kmem_cache_alloc(full_dnode_slab, GFP_KERNEL); 113 ret = kmem_cache_alloc(full_dnode_slab, GFP_KERNEL);
114 JFFS2_DBG_MEMALLOC("%p\n", ret); 114 dbg_memalloc("%p\n", ret);
115 return ret; 115 return ret;
116} 116}
117 117
118void jffs2_free_full_dnode(struct jffs2_full_dnode *x) 118void jffs2_free_full_dnode(struct jffs2_full_dnode *x)
119{ 119{
120 JFFS2_DBG_MEMALLOC("%p\n", x); 120 dbg_memalloc("%p\n", x);
121 kmem_cache_free(full_dnode_slab, x); 121 kmem_cache_free(full_dnode_slab, x);
122} 122}
123 123
@@ -125,13 +125,13 @@ struct jffs2_raw_dirent *jffs2_alloc_raw_dirent(void)
125{ 125{
126 struct jffs2_raw_dirent *ret; 126 struct jffs2_raw_dirent *ret;
127 ret = kmem_cache_alloc(raw_dirent_slab, GFP_KERNEL); 127 ret = kmem_cache_alloc(raw_dirent_slab, GFP_KERNEL);
128 JFFS2_DBG_MEMALLOC("%p\n", ret); 128 dbg_memalloc("%p\n", ret);
129 return ret; 129 return ret;
130} 130}
131 131
132void jffs2_free_raw_dirent(struct jffs2_raw_dirent *x) 132void jffs2_free_raw_dirent(struct jffs2_raw_dirent *x)
133{ 133{
134 JFFS2_DBG_MEMALLOC("%p\n", x); 134 dbg_memalloc("%p\n", x);
135 kmem_cache_free(raw_dirent_slab, x); 135 kmem_cache_free(raw_dirent_slab, x);
136} 136}
137 137
@@ -139,13 +139,13 @@ struct jffs2_raw_inode *jffs2_alloc_raw_inode(void)
139{ 139{
140 struct jffs2_raw_inode *ret; 140 struct jffs2_raw_inode *ret;
141 ret = kmem_cache_alloc(raw_inode_slab, GFP_KERNEL); 141 ret = kmem_cache_alloc(raw_inode_slab, GFP_KERNEL);
142 JFFS2_DBG_MEMALLOC("%p\n", ret); 142 dbg_memalloc("%p\n", ret);
143 return ret; 143 return ret;
144} 144}
145 145
146void jffs2_free_raw_inode(struct jffs2_raw_inode *x) 146void jffs2_free_raw_inode(struct jffs2_raw_inode *x)
147{ 147{
148 JFFS2_DBG_MEMALLOC("%p\n", x); 148 dbg_memalloc("%p\n", x);
149 kmem_cache_free(raw_inode_slab, x); 149 kmem_cache_free(raw_inode_slab, x);
150} 150}
151 151
@@ -153,14 +153,14 @@ struct jffs2_tmp_dnode_info *jffs2_alloc_tmp_dnode_info(void)
153{ 153{
154 struct jffs2_tmp_dnode_info *ret; 154 struct jffs2_tmp_dnode_info *ret;
155 ret = kmem_cache_alloc(tmp_dnode_info_slab, GFP_KERNEL); 155 ret = kmem_cache_alloc(tmp_dnode_info_slab, GFP_KERNEL);
156 JFFS2_DBG_MEMALLOC("%p\n", 156 dbg_memalloc("%p\n",
157 ret); 157 ret);
158 return ret; 158 return ret;
159} 159}
160 160
161void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x) 161void jffs2_free_tmp_dnode_info(struct jffs2_tmp_dnode_info *x)
162{ 162{
163 JFFS2_DBG_MEMALLOC("%p\n", x); 163 dbg_memalloc("%p\n", x);
164 kmem_cache_free(tmp_dnode_info_slab, x); 164 kmem_cache_free(tmp_dnode_info_slab, x);
165} 165}
166 166
@@ -168,13 +168,13 @@ struct jffs2_raw_node_ref *jffs2_alloc_raw_node_ref(void)
168{ 168{
169 struct jffs2_raw_node_ref *ret; 169 struct jffs2_raw_node_ref *ret;
170 ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL); 170 ret = kmem_cache_alloc(raw_node_ref_slab, GFP_KERNEL);
171 JFFS2_DBG_MEMALLOC("%p\n", ret); 171 dbg_memalloc("%p\n", ret);
172 return ret; 172 return ret;
173} 173}
174 174
175void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x) 175void jffs2_free_raw_node_ref(struct jffs2_raw_node_ref *x)
176{ 176{
177 JFFS2_DBG_MEMALLOC("%p\n", x); 177 dbg_memalloc("%p\n", x);
178 kmem_cache_free(raw_node_ref_slab, x); 178 kmem_cache_free(raw_node_ref_slab, x);
179} 179}
180 180
@@ -182,13 +182,13 @@ struct jffs2_node_frag *jffs2_alloc_node_frag(void)
182{ 182{
183 struct jffs2_node_frag *ret; 183 struct jffs2_node_frag *ret;
184 ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL); 184 ret = kmem_cache_alloc(node_frag_slab, GFP_KERNEL);
185 JFFS2_DBG_MEMALLOC("%p\n", ret); 185 dbg_memalloc("%p\n", ret);
186 return ret; 186 return ret;
187} 187}
188 188
189void jffs2_free_node_frag(struct jffs2_node_frag *x) 189void jffs2_free_node_frag(struct jffs2_node_frag *x)
190{ 190{
191 JFFS2_DBG_MEMALLOC("%p\n", x); 191 dbg_memalloc("%p\n", x);
192 kmem_cache_free(node_frag_slab, x); 192 kmem_cache_free(node_frag_slab, x);
193} 193}
194 194
@@ -196,12 +196,12 @@ struct jffs2_inode_cache *jffs2_alloc_inode_cache(void)
196{ 196{
197 struct jffs2_inode_cache *ret; 197 struct jffs2_inode_cache *ret;
198 ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL); 198 ret = kmem_cache_alloc(inode_cache_slab, GFP_KERNEL);
199 JFFS2_DBG_MEMALLOC("%p\n", ret); 199 dbg_memalloc("%p\n", ret);
200 return ret; 200 return ret;
201} 201}
202 202
203void jffs2_free_inode_cache(struct jffs2_inode_cache *x) 203void jffs2_free_inode_cache(struct jffs2_inode_cache *x)
204{ 204{
205 JFFS2_DBG_MEMALLOC("%p\n", x); 205 dbg_memalloc("%p\n", x);
206 kmem_cache_free(inode_cache_slab, x); 206 kmem_cache_free(inode_cache_slab, x);
207} 207}
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 9abb5f4cfd75..80fe8feffb4d 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: nodelist.c,v 1.112 2005/08/22 09:07:09 dedekind Exp $ 10 * $Id: nodelist.c,v 1.114 2005/09/21 13:28:35 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -25,18 +25,18 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new
25{ 25{
26 struct jffs2_full_dirent **prev = list; 26 struct jffs2_full_dirent **prev = list;
27 27
28 JFFS2_DBG_DENTLIST("add dirent \"%s\", ino #%u\n", new->name, new->ino); 28 dbg_dentlist("add dirent \"%s\", ino #%u\n", new->name, new->ino);
29 29
30 while ((*prev) && (*prev)->nhash <= new->nhash) { 30 while ((*prev) && (*prev)->nhash <= new->nhash) {
31 if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) { 31 if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
32 /* Duplicate. Free one */ 32 /* Duplicate. Free one */
33 if (new->version < (*prev)->version) { 33 if (new->version < (*prev)->version) {
34 JFFS2_DBG_DENTLIST("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n", 34 dbg_dentlist("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n",
35 (*prev)->name, (*prev)->ino); 35 (*prev)->name, (*prev)->ino);
36 jffs2_mark_node_obsolete(c, new->raw); 36 jffs2_mark_node_obsolete(c, new->raw);
37 jffs2_free_full_dirent(new); 37 jffs2_free_full_dirent(new);
38 } else { 38 } else {
39 JFFS2_DBG_DENTLIST("marking old dirent \"%s\", ino #%u bsolete\n", 39 dbg_dentlist("marking old dirent \"%s\", ino #%u bsolete\n",
40 (*prev)->name, (*prev)->ino); 40 (*prev)->name, (*prev)->ino);
41 new->next = (*prev)->next; 41 new->next = (*prev)->next;
42 jffs2_mark_node_obsolete(c, ((*prev)->raw)); 42 jffs2_mark_node_obsolete(c, ((*prev)->raw));
@@ -55,7 +55,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint
55{ 55{
56 struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size); 56 struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size);
57 57
58 JFFS2_DBG_FRAGTREE("truncating fragtree to 0x%08x bytes\n", size); 58 dbg_fragtree("truncating fragtree to 0x%08x bytes\n", size);
59 59
60 /* We know frag->ofs <= size. That's what lookup does for us */ 60 /* We know frag->ofs <= size. That's what lookup does for us */
61 if (frag && frag->ofs != size) { 61 if (frag && frag->ofs != size) {
@@ -81,7 +81,7 @@ void jffs2_truncate_fragtree(struct jffs2_sb_info *c, struct rb_root *list, uint
81 */ 81 */
82 frag = frag_last(list); 82 frag = frag_last(list);
83 if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) { 83 if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) {
84 JFFS2_DBG_FRAGTREE2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n", 84 dbg_fragtree2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n",
85 frag->ofs, frag->ofs + frag->size); 85 frag->ofs, frag->ofs + frag->size);
86 frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE; 86 frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE;
87 } 87 }
@@ -93,12 +93,12 @@ void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *t
93 this->node->frags--; 93 this->node->frags--;
94 if (!this->node->frags) { 94 if (!this->node->frags) {
95 /* The node has no valid frags left. It's totally obsoleted */ 95 /* The node has no valid frags left. It's totally obsoleted */
96 JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n", 96 dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n",
97 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size); 97 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size);
98 jffs2_mark_node_obsolete(c, this->node->raw); 98 jffs2_mark_node_obsolete(c, this->node->raw);
99 jffs2_free_full_dnode(this->node); 99 jffs2_free_full_dnode(this->node);
100 } else { 100 } else {
101 JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n", 101 dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n",
102 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags); 102 ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags);
103 mark_ref_normal(this->node->raw); 103 mark_ref_normal(this->node->raw);
104 } 104 }
@@ -112,7 +112,7 @@ static void jffs2_fragtree_insert(struct jffs2_node_frag *newfrag, struct jffs2_
112 struct rb_node *parent = &base->rb; 112 struct rb_node *parent = &base->rb;
113 struct rb_node **link = &parent; 113 struct rb_node **link = &parent;
114 114
115 JFFS2_DBG_FRAGTREE2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size); 115 dbg_fragtree2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size);
116 116
117 while (*link) { 117 while (*link) {
118 parent = *link; 118 parent = *link;
@@ -172,11 +172,11 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root,
172 /* By definition, the 'this' node has no right-hand child, 172 /* By definition, the 'this' node has no right-hand child,
173 because there are no frags with offset greater than it. 173 because there are no frags with offset greater than it.
174 So that's where we want to put the hole */ 174 So that's where we want to put the hole */
175 JFFS2_DBG_FRAGTREE2("add hole frag %#04x-%#04x on the right of the new frag.\n", 175 dbg_fragtree2("add hole frag %#04x-%#04x on the right of the new frag.\n",
176 holefrag->ofs, holefrag->ofs + holefrag->size); 176 holefrag->ofs, holefrag->ofs + holefrag->size);
177 rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right); 177 rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right);
178 } else { 178 } else {
179 JFFS2_DBG_FRAGTREE2("Add hole frag %#04x-%#04x to the root of the tree.\n", 179 dbg_fragtree2("Add hole frag %#04x-%#04x to the root of the tree.\n",
180 holefrag->ofs, holefrag->ofs + holefrag->size); 180 holefrag->ofs, holefrag->ofs + holefrag->size);
181 rb_link_node(&holefrag->rb, NULL, &root->rb_node); 181 rb_link_node(&holefrag->rb, NULL, &root->rb_node);
182 } 182 }
@@ -188,10 +188,10 @@ static int no_overlapping_node(struct jffs2_sb_info *c, struct rb_root *root,
188 /* By definition, the 'this' node has no right-hand child, 188 /* By definition, the 'this' node has no right-hand child,
189 because there are no frags with offset greater than it. 189 because there are no frags with offset greater than it.
190 So that's where we want to put new fragment */ 190 So that's where we want to put new fragment */
191 JFFS2_DBG_FRAGTREE2("add the new node at the right\n"); 191 dbg_fragtree2("add the new node at the right\n");
192 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 192 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
193 } else { 193 } else {
194 JFFS2_DBG_FRAGTREE2("insert the new node at the root of the tree\n"); 194 dbg_fragtree2("insert the new node at the root of the tree\n");
195 rb_link_node(&newfrag->rb, NULL, &root->rb_node); 195 rb_link_node(&newfrag->rb, NULL, &root->rb_node);
196 } 196 }
197 rb_insert_color(&newfrag->rb, root); 197 rb_insert_color(&newfrag->rb, root);
@@ -209,11 +209,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
209 this = jffs2_lookup_node_frag(root, newfrag->node->ofs); 209 this = jffs2_lookup_node_frag(root, newfrag->node->ofs);
210 210
211 if (this) { 211 if (this) {
212 JFFS2_DBG_FRAGTREE2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n", 212 dbg_fragtree2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n",
213 this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this); 213 this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this);
214 lastend = this->ofs + this->size; 214 lastend = this->ofs + this->size;
215 } else { 215 } else {
216 JFFS2_DBG_FRAGTREE2("lookup gave no frag\n"); 216 dbg_fragtree2("lookup gave no frag\n");
217 lastend = 0; 217 lastend = 0;
218 } 218 }
219 219
@@ -235,11 +235,11 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
235 } 235 }
236 236
237 if (this->node) 237 if (this->node)
238 JFFS2_DBG_FRAGTREE2("dealing with frag %u-%u, phys %#08x(%d).\n", 238 dbg_fragtree2("dealing with frag %u-%u, phys %#08x(%d).\n",
239 this->ofs, this->ofs + this->size, 239 this->ofs, this->ofs + this->size,
240 ref_offset(this->node->raw), ref_flags(this->node->raw)); 240 ref_offset(this->node->raw), ref_flags(this->node->raw));
241 else 241 else
242 JFFS2_DBG_FRAGTREE2("dealing with hole frag %u-%u.\n", 242 dbg_fragtree2("dealing with hole frag %u-%u.\n",
243 this->ofs, this->ofs + this->size); 243 this->ofs, this->ofs + this->size);
244 244
245 /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes, 245 /* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes,
@@ -259,10 +259,10 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
259 struct jffs2_node_frag *newfrag2; 259 struct jffs2_node_frag *newfrag2;
260 260
261 if (this->node) 261 if (this->node)
262 JFFS2_DBG_FRAGTREE2("split old frag 0x%04x-0x%04x, phys 0x%08x\n", 262 dbg_fragtree2("split old frag 0x%04x-0x%04x, phys 0x%08x\n",
263 this->ofs, this->ofs+this->size, ref_offset(this->node->raw)); 263 this->ofs, this->ofs+this->size, ref_offset(this->node->raw));
264 else 264 else
265 JFFS2_DBG_FRAGTREE2("split old hole frag 0x%04x-0x%04x\n", 265 dbg_fragtree2("split old hole frag 0x%04x-0x%04x\n",
266 this->ofs, this->ofs+this->size); 266 this->ofs, this->ofs+this->size);
267 267
268 /* New second frag pointing to this's node */ 268 /* New second frag pointing to this's node */
@@ -299,13 +299,13 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
299 } else { 299 } else {
300 /* New frag starts at the same point as 'this' used to. Replace 300 /* New frag starts at the same point as 'this' used to. Replace
301 it in the tree without doing a delete and insertion */ 301 it in the tree without doing a delete and insertion */
302 JFFS2_DBG_FRAGTREE2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n", 302 dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n",
303 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size); 303 newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size);
304 304
305 rb_replace_node(&this->rb, &newfrag->rb, root); 305 rb_replace_node(&this->rb, &newfrag->rb, root);
306 306
307 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) { 307 if (newfrag->ofs + newfrag->size >= this->ofs+this->size) {
308 JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size); 308 dbg_fragtree2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size);
309 jffs2_obsolete_node_frag(c, this); 309 jffs2_obsolete_node_frag(c, this);
310 } else { 310 } else {
311 this->ofs += newfrag->size; 311 this->ofs += newfrag->size;
@@ -321,7 +321,7 @@ static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *r
321 */ 321 */
322 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) { 322 while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) {
323 /* 'this' frag is obsoleted completely. */ 323 /* 'this' frag is obsoleted completely. */
324 JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x) and removing from tree\n", 324 dbg_fragtree2("obsoleting node frag %p (%x-%x) and removing from tree\n",
325 this, this->ofs, this->ofs+this->size); 325 this, this->ofs, this->ofs+this->size);
326 rb_erase(&this->rb, root); 326 rb_erase(&this->rb, root);
327 jffs2_obsolete_node_frag(c, this); 327 jffs2_obsolete_node_frag(c, this);
@@ -361,7 +361,7 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
361 return -ENOMEM; 361 return -ENOMEM;
362 newfrag->node->frags = 1; 362 newfrag->node->frags = 1;
363 363
364 JFFS2_DBG_FRAGTREE("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n", 364 dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n",
365 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag); 365 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag);
366 366
367 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag); 367 ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag);
@@ -410,14 +410,17 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
410 410
411 BUG_ON(tn->csize == 0); 411 BUG_ON(tn->csize == 0);
412 412
413 if (!jffs2_is_writebuffered(c))
414 goto adj_acc;
415
413 /* Calculate how many bytes were already checked */ 416 /* Calculate how many bytes were already checked */
414 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); 417 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode);
415 len = ofs & (c->wbuf_pagesize - 1); 418 len = ofs % c->wbuf_pagesize;
416 if (likely(len)) 419 if (likely(len))
417 len = c->wbuf_pagesize - len; 420 len = c->wbuf_pagesize - len;
418 421
419 if (len >= tn->csize) { 422 if (len >= tn->csize) {
420 JFFS2_DBG_READINODE("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", 423 dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n",
421 ref_offset(ref), tn->csize, ofs); 424 ref_offset(ref), tn->csize, ofs);
422 goto adj_acc; 425 goto adj_acc;
423 } 426 }
@@ -425,7 +428,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
425 ofs += len; 428 ofs += len;
426 len = tn->csize - len; 429 len = tn->csize - len;
427 430
428 JFFS2_DBG_READINODE("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", 431 dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n",
429 ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); 432 ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len);
430 433
431#ifndef __ECOS 434#ifndef __ECOS
@@ -520,7 +523,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
520 if (ref_flags(tn->fn->raw) != REF_UNCHECKED) 523 if (ref_flags(tn->fn->raw) != REF_UNCHECKED)
521 return 0; 524 return 0;
522 525
523 JFFS2_DBG_FRAGTREE2("check node %#04x-%#04x, phys offs %#08x.\n", 526 dbg_fragtree2("check node %#04x-%#04x, phys offs %#08x.\n",
524 tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw)); 527 tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw));
525 528
526 ret = check_node_data(c, tn); 529 ret = check_node_data(c, tn);
@@ -528,7 +531,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
528 JFFS2_ERROR("check_node_data() returned error: %d.\n", 531 JFFS2_ERROR("check_node_data() returned error: %d.\n",
529 ret); 532 ret);
530 } else if (unlikely(ret > 0)) { 533 } else if (unlikely(ret > 0)) {
531 JFFS2_DBG_FRAGTREE2("CRC error, mark it obsolete.\n"); 534 dbg_fragtree2("CRC error, mark it obsolete.\n");
532 jffs2_mark_node_obsolete(c, tn->fn->raw); 535 jffs2_mark_node_obsolete(c, tn->fn->raw);
533 } 536 }
534 537
@@ -544,7 +547,7 @@ static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f
544static int split_hole(struct jffs2_sb_info *c, struct rb_root *root, 547static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
545 struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole) 548 struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole)
546{ 549{
547 JFFS2_DBG_FRAGTREE2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n", 550 dbg_fragtree2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n",
548 newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size); 551 newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size);
549 552
550 if (hole->ofs == newfrag->ofs) { 553 if (hole->ofs == newfrag->ofs) {
@@ -558,7 +561,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
558 * the new node. 561 * the new node.
559 */ 562 */
560 563
561 JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and cut the left part of the hole\n", 564 dbg_fragtree2("insert fragment %#04x-%#04x and cut the left part of the hole\n",
562 newfrag->ofs, newfrag->ofs + newfrag->size); 565 newfrag->ofs, newfrag->ofs + newfrag->size);
563 rb_replace_node(&hole->rb, &newfrag->rb, root); 566 rb_replace_node(&hole->rb, &newfrag->rb, root);
564 567
@@ -576,7 +579,7 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
576 * Ah, the new fragment is of the same size as the hole. 579 * Ah, the new fragment is of the same size as the hole.
577 * Relace the hole by it. 580 * Relace the hole by it.
578 */ 581 */
579 JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and overwrite hole\n", 582 dbg_fragtree2("insert fragment %#04x-%#04x and overwrite hole\n",
580 newfrag->ofs, newfrag->ofs + newfrag->size); 583 newfrag->ofs, newfrag->ofs + newfrag->size);
581 rb_replace_node(&hole->rb, &newfrag->rb, root); 584 rb_replace_node(&hole->rb, &newfrag->rb, root);
582 jffs2_free_node_frag(hole); 585 jffs2_free_node_frag(hole);
@@ -598,14 +601,14 @@ static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
598 } 601 }
599 602
600 hole->size = newfrag->ofs - hole->ofs; 603 hole->size = newfrag->ofs - hole->ofs;
601 JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n", 604 dbg_fragtree2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n",
602 hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size); 605 hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size);
603 606
604 jffs2_fragtree_insert(newfrag, hole); 607 jffs2_fragtree_insert(newfrag, hole);
605 rb_insert_color(&newfrag->rb, root); 608 rb_insert_color(&newfrag->rb, root);
606 609
607 if (newfrag2) { 610 if (newfrag2) {
608 JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the right\n", 611 dbg_fragtree2("left the hole %#04x-%#04x at the right\n",
609 newfrag2->ofs, newfrag2->ofs + newfrag2->size); 612 newfrag2->ofs, newfrag2->ofs + newfrag2->size);
610 jffs2_fragtree_insert(newfrag2, newfrag); 613 jffs2_fragtree_insert(newfrag2, newfrag);
611 rb_insert_color(&newfrag2->rb, root); 614 rb_insert_color(&newfrag2->rb, root);
@@ -640,12 +643,12 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
640 int err, checked = 0; 643 int err, checked = 0;
641 int ref_flag; 644 int ref_flag;
642 645
643 JFFS2_DBG_FRAGTREE("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version); 646 dbg_fragtree("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version);
644 647
645 /* Skip all the nodes which are completed before this one starts */ 648 /* Skip all the nodes which are completed before this one starts */
646 this = jffs2_lookup_node_frag(root, fn_ofs); 649 this = jffs2_lookup_node_frag(root, fn_ofs);
647 if (this) 650 if (this)
648 JFFS2_DBG_FRAGTREE2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole"); 651 dbg_fragtree2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole");
649 652
650 if (this) 653 if (this)
651 lastend = this->ofs + this->size; 654 lastend = this->ofs + this->size;
@@ -745,7 +748,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
745 * The new node starts at the same offset as 748 * The new node starts at the same offset as
746 * the hole and supersieds the hole. 749 * the hole and supersieds the hole.
747 */ 750 */
748 JFFS2_DBG_FRAGTREE2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n", 751 dbg_fragtree2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n",
749 fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); 752 fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
750 753
751 rb_replace_node(&this->rb, &newfrag->rb, root); 754 rb_replace_node(&this->rb, &newfrag->rb, root);
@@ -755,10 +758,10 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
755 * The hole becomes shorter as its right part 758 * The hole becomes shorter as its right part
756 * is supersieded by the new fragment. 759 * is supersieded by the new fragment.
757 */ 760 */
758 JFFS2_DBG_FRAGTREE2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n", 761 dbg_fragtree2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n",
759 this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size); 762 this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size);
760 763
761 JFFS2_DBG_FRAGTREE2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs, 764 dbg_fragtree2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs,
762 fn_ofs + this->ofs + this->size - fn_ofs, fn->frags); 765 fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
763 766
764 this->size -= newfrag->size; 767 this->size -= newfrag->size;
@@ -771,7 +774,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
771 this = rb_entry(rb_next(&newfrag->rb), 774 this = rb_entry(rb_next(&newfrag->rb),
772 struct jffs2_node_frag, rb); 775 struct jffs2_node_frag, rb);
773 776
774 JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n", 777 dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
775 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); 778 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
776 } 779 }
777 780
@@ -782,7 +785,7 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
782 if (this->ofs + this->size >= fn_ofs + fn_size) { 785 if (this->ofs + this->size >= fn_ofs + fn_size) {
783 /* The new node is obsolete, drop it */ 786 /* The new node is obsolete, drop it */
784 if (fn->frags == 0) { 787 if (fn->frags == 0) {
785 JFFS2_DBG_FRAGTREE2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size); 788 dbg_fragtree2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size);
786 ref_flag = REF_OBSOLETE; 789 ref_flag = REF_OBSOLETE;
787 } 790 }
788 goto out_ok; 791 goto out_ok;
@@ -790,13 +793,13 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
790 struct jffs2_node_frag *new_this; 793 struct jffs2_node_frag *new_this;
791 794
792 /* 'This' node obsoletes the beginning of the new node */ 795 /* 'This' node obsoletes the beginning of the new node */
793 JFFS2_DBG_FRAGTREE2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size); 796 dbg_fragtree2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size);
794 797
795 ref_flag = REF_NORMAL; 798 ref_flag = REF_NORMAL;
796 799
797 fn_size -= this->ofs + this->size - fn_ofs; 800 fn_size -= this->ofs + this->size - fn_ofs;
798 fn_ofs = this->ofs + this->size; 801 fn_ofs = this->ofs + this->size;
799 JFFS2_DBG_FRAGTREE2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size); 802 dbg_fragtree2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size);
800 803
801 new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb); 804 new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb);
802 if (!new_this) { 805 if (!new_this) {
@@ -816,14 +819,14 @@ int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode
816 if (unlikely(!newfrag)) 819 if (unlikely(!newfrag))
817 return -ENOMEM; 820 return -ENOMEM;
818 821
819 JFFS2_DBG_FRAGTREE2("there are no more fragments, insert %#04x-%#04x\n", 822 dbg_fragtree2("there are no more fragments, insert %#04x-%#04x\n",
820 newfrag->ofs, newfrag->ofs + newfrag->size); 823 newfrag->ofs, newfrag->ofs + newfrag->size);
821 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right); 824 rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
822 rb_insert_color(&newfrag->rb, root); 825 rb_insert_color(&newfrag->rb, root);
823 goto out_ok; 826 goto out_ok;
824 } else { 827 } else {
825 this = new_this; 828 this = new_this;
826 JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n", 829 dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
827 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)"); 830 this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
828 } 831 }
829 } 832 }
@@ -833,13 +836,13 @@ out_ok:
833 BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE); 836 BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE);
834 837
835 if (ref_flag == REF_OBSOLETE) { 838 if (ref_flag == REF_OBSOLETE) {
836 JFFS2_DBG_FRAGTREE2("the node is obsolete now\n"); 839 dbg_fragtree2("the node is obsolete now\n");
837 /* jffs2_mark_node_obsolete() will adjust space accounting */ 840 /* jffs2_mark_node_obsolete() will adjust space accounting */
838 jffs2_mark_node_obsolete(c, fn->raw); 841 jffs2_mark_node_obsolete(c, fn->raw);
839 return 1; 842 return 1;
840 } 843 }
841 844
842 JFFS2_DBG_FRAGTREE2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE"); 845 dbg_fragtree2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE");
843 846
844 /* Space accounting was adjusted at check_node_data() */ 847 /* Space accounting was adjusted at check_node_data() */
845 spin_lock(&c->erase_completion_lock); 848 spin_lock(&c->erase_completion_lock);
@@ -885,7 +888,7 @@ void jffs2_add_ino_cache (struct jffs2_sb_info *c, struct jffs2_inode_cache *new
885 if (!new->ino) 888 if (!new->ino)
886 new->ino = ++c->highest_ino; 889 new->ino = ++c->highest_ino;
887 890
888 JFFS2_DBG_INOCACHE("add %p (ino #%u)\n", new, new->ino); 891 dbg_inocache("add %p (ino #%u)\n", new, new->ino);
889 892
890 prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE]; 893 prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE];
891 894
@@ -902,7 +905,7 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
902{ 905{
903 struct jffs2_inode_cache **prev; 906 struct jffs2_inode_cache **prev;
904 907
905 JFFS2_DBG_INOCACHE("del %p (ino #%u)\n", old, old->ino); 908 dbg_inocache("del %p (ino #%u)\n", old, old->ino);
906 spin_lock(&c->inocache_lock); 909 spin_lock(&c->inocache_lock);
907 910
908 prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE]; 911 prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE];
@@ -965,7 +968,7 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_
965 struct jffs2_node_frag *prev = NULL; 968 struct jffs2_node_frag *prev = NULL;
966 struct jffs2_node_frag *frag = NULL; 969 struct jffs2_node_frag *frag = NULL;
967 970
968 JFFS2_DBG_FRAGTREE2("root %p, offset %d\n", fragtree, offset); 971 dbg_fragtree2("root %p, offset %d\n", fragtree, offset);
969 972
970 next = fragtree->rb_node; 973 next = fragtree->rb_node;
971 974
@@ -988,10 +991,10 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_
988 and return the closest smaller one */ 991 and return the closest smaller one */
989 992
990 if (prev) 993 if (prev)
991 JFFS2_DBG_FRAGTREE2("no match. Returning frag %#04x-%#04x, closest previous\n", 994 dbg_fragtree2("no match. Returning frag %#04x-%#04x, closest previous\n",
992 prev->ofs, prev->ofs+prev->size); 995 prev->ofs, prev->ofs+prev->size);
993 else 996 else
994 JFFS2_DBG_FRAGTREE2("returning NULL, empty fragtree\n"); 997 dbg_fragtree2("returning NULL, empty fragtree\n");
995 998
996 return prev; 999 return prev;
997} 1000}
@@ -1006,7 +1009,7 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
1006 if (!root->rb_node) 1009 if (!root->rb_node)
1007 return; 1010 return;
1008 1011
1009 JFFS2_DBG_FRAGTREE("killing\n"); 1012 dbg_fragtree("killing\n");
1010 1013
1011 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb)); 1014 frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
1012 while(frag) { 1015 while(frag) {
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 2cf576ae1120..2c938d1bffb0 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: nodemgmt.c,v 1.126 2005/09/16 12:58:17 havasi Exp $ 10 * $Id: nodemgmt.c,v 1.127 2005/09/20 15:49:12 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -273,7 +273,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
273 273
274 if (jeb) { 274 if (jeb) {
275 reserved_size = PAD(sumsize + c->summary->sum_size + JFFS2_SUMMARY_FRAME_SIZE); 275 reserved_size = PAD(sumsize + c->summary->sum_size + JFFS2_SUMMARY_FRAME_SIZE);
276 JFFS2_DBG_SUMMARY("minsize=%d , jeb->free=%d ," 276 dbg_summary("minsize=%d , jeb->free=%d ,"
277 "summary->size=%d , sumsize=%d\n", 277 "summary->size=%d , sumsize=%d\n",
278 minsize, jeb->free_size, 278 minsize, jeb->free_size,
279 c->summary->sum_size, sumsize); 279 c->summary->sum_size, sumsize);
@@ -291,7 +291,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
291 } 291 }
292 292
293 /* Writing out the collected summary information */ 293 /* Writing out the collected summary information */
294 JFFS2_DBG_SUMMARY("generating summary for 0x%08x.\n", jeb->offset); 294 dbg_summary("generating summary for 0x%08x.\n", jeb->offset);
295 ret = jffs2_sum_write_sumnode(c); 295 ret = jffs2_sum_write_sumnode(c);
296 296
297 if (ret) 297 if (ret)
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index e026888cf1cb..48ad4202fbb1 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: os-linux.h,v 1.61 2005/09/07 08:34:54 havasi Exp $ 10 * $Id: os-linux.h,v 1.63 2005/09/21 11:55:21 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -80,8 +80,8 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
80 80
81#define jffs2_flash_write(c, ofs, len, retlen, buf) jffs2_flash_direct_write(c, ofs, len, retlen, buf) 81#define jffs2_flash_write(c, ofs, len, retlen, buf) jffs2_flash_direct_write(c, ofs, len, retlen, buf)
82#define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf)) 82#define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf))
83#define jffs2_flush_wbuf_pad(c) ({ (void)(c), 0; }) 83#define jffs2_flush_wbuf_pad(c) ({ do{} while(0); (void)(c), 0; })
84#define jffs2_flush_wbuf_gc(c, i) ({ (void)(c), (void) i, 0; }) 84#define jffs2_flush_wbuf_gc(c, i) ({ do{} while(0); (void)(c), (void) i, 0; })
85#define jffs2_write_nand_badblock(c,jeb,bad_offset) (1) 85#define jffs2_write_nand_badblock(c,jeb,bad_offset) (1)
86#define jffs2_nand_flash_setup(c) (0) 86#define jffs2_nand_flash_setup(c) (0)
87#define jffs2_nand_flash_cleanup(c) do {} while(0) 87#define jffs2_nand_flash_cleanup(c) do {} while(0)
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 6f1e4a7ecd9f..08f8c5ec6118 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: readinode.c,v 1.141 2005/08/17 14:57:39 dedekind Exp $ 10 * $Id: readinode.c,v 1.142 2005/09/20 14:27:34 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -97,7 +97,7 @@ static struct jffs2_raw_node_ref *jffs2_first_valid_node(struct jffs2_raw_node_r
97 while (ref && ref->next_in_ino) { 97 while (ref && ref->next_in_ino) {
98 if (!ref_obsolete(ref)) 98 if (!ref_obsolete(ref))
99 return ref; 99 return ref;
100 JFFS2_DBG_NODEREF("node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref)); 100 dbg_noderef("node at 0x%08x is obsoleted. Ignoring.\n", ref_offset(ref));
101 ref = ref->next_in_ino; 101 ref = ref->next_in_ino;
102 } 102 }
103 return NULL; 103 return NULL;
@@ -274,7 +274,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
274 len = min_t(uint32_t, rdlen - sizeof(*rd), csize); 274 len = min_t(uint32_t, rdlen - sizeof(*rd), csize);
275 tn->partial_crc = crc32(0, buf, len); 275 tn->partial_crc = crc32(0, buf, len);
276 276
277 JFFS2_DBG_READINODE("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize); 277 dbg_readinode("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize);
278 278
279 /* If we actually calculated the whole data CRC 279 /* If we actually calculated the whole data CRC
280 * and it is wrong, drop the node. */ 280 * and it is wrong, drop the node. */
@@ -293,7 +293,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
293 */ 293 */
294 struct jffs2_eraseblock *jeb; 294 struct jffs2_eraseblock *jeb;
295 295
296 JFFS2_DBG_READINODE("the node has no data.\n"); 296 dbg_readinode("the node has no data.\n");
297 jeb = &c->blocks[ref->flash_offset / c->sector_size]; 297 jeb = &c->blocks[ref->flash_offset / c->sector_size];
298 len = ref_totlen(c, jeb, ref); 298 len = ref_totlen(c, jeb, ref);
299 299
@@ -327,7 +327,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
327 else // normal case... 327 else // normal case...
328 tn->fn->size = je32_to_cpu(rd->dsize); 328 tn->fn->size = je32_to_cpu(rd->dsize);
329 329
330 JFFS2_DBG_READINODE("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n", 330 dbg_readinode("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n",
331 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize); 331 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize);
332 332
333 jffs2_add_tn_to_tree(tn, tnp); 333 jffs2_add_tn_to_tree(tn, tnp);
@@ -424,7 +424,7 @@ static int read_more(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *ref,
424 len = right_size - *rdlen; 424 len = right_size - *rdlen;
425 } 425 }
426 426
427 JFFS2_DBG_READINODE("read more %d bytes\n", len); 427 dbg_readinode("read more %d bytes\n", len);
428 428
429 err = jffs2_flash_read(c, offs, len, &retlen, bufstart); 429 err = jffs2_flash_read(c, offs, len, &retlen, bufstart);
430 if (err) { 430 if (err) {
@@ -461,7 +461,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
461 461
462 *mctime_ver = 0; 462 *mctime_ver = 0;
463 463
464 JFFS2_DBG_READINODE("ino #%u\n", f->inocache->ino); 464 dbg_readinode("ino #%u\n", f->inocache->ino);
465 465
466 if (jffs2_is_writebuffered(c)) { 466 if (jffs2_is_writebuffered(c)) {
467 /* 467 /*
@@ -531,7 +531,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
531 len = JFFS2_MIN_NODE_HEADER; 531 len = JFFS2_MIN_NODE_HEADER;
532 } 532 }
533 533
534 JFFS2_DBG_READINODE("read %d bytes at %#08x(%d).\n", len, ref_offset(ref), ref_flags(ref)); 534 dbg_readinode("read %d bytes at %#08x(%d).\n", len, ref_offset(ref), ref_flags(ref));
535 535
536 /* FIXME: point() */ 536 /* FIXME: point() */
537 err = jffs2_flash_read(c, ref_offset(ref), len, 537 err = jffs2_flash_read(c, ref_offset(ref), len,
@@ -614,7 +614,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
614 *fdp = ret_fd; 614 *fdp = ret_fd;
615 kfree(buf); 615 kfree(buf);
616 616
617 JFFS2_DBG_READINODE("nodes of inode #%u were read, the highest version is %u, latest_mctime %u, mctime_ver %u.\n", 617 dbg_readinode("nodes of inode #%u were read, the highest version is %u, latest_mctime %u, mctime_ver %u.\n",
618 f->inocache->ino, *highest_version, *latest_mctime, *mctime_ver); 618 f->inocache->ino, *highest_version, *latest_mctime, *mctime_ver);
619 return 0; 619 return 0;
620 620
@@ -639,7 +639,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
639 size_t retlen; 639 size_t retlen;
640 int ret; 640 int ret;
641 641
642 JFFS2_DBG_READINODE("ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink); 642 dbg_readinode("ino #%u nlink is %d\n", f->inocache->ino, f->inocache->nlink);
643 643
644 /* Grab all nodes relevant to this ino */ 644 /* Grab all nodes relevant to this ino */
645 ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver); 645 ret = jffs2_get_inode_nodes(c, f, &tn_list, &fd_list, &f->highest_version, &latest_mctime, &mctime_ver);
@@ -659,7 +659,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
659 tn = rb_entry(rb, struct jffs2_tmp_dnode_info, rb); 659 tn = rb_entry(rb, struct jffs2_tmp_dnode_info, rb);
660 fn = tn->fn; 660 fn = tn->fn;
661 ret = 1; 661 ret = 1;
662 JFFS2_DBG_READINODE("consider node ver %u, phys offset " 662 dbg_readinode("consider node ver %u, phys offset "
663 "%#08x(%d), range %u-%u.\n", tn->version, 663 "%#08x(%d), range %u-%u.\n", tn->version,
664 ref_offset(fn->raw), ref_flags(fn->raw), 664 ref_offset(fn->raw), ref_flags(fn->raw),
665 fn->ofs, fn->ofs + fn->size); 665 fn->ofs, fn->ofs + fn->size);
@@ -703,7 +703,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
703 703
704 jffs2_free_tmp_dnode_info(tn); 704 jffs2_free_tmp_dnode_info(tn);
705 if (ret) { 705 if (ret) {
706 JFFS2_DBG_READINODE("delete dnode %u-%u.\n", 706 dbg_readinode("delete dnode %u-%u.\n",
707 fn->ofs, fn->ofs + fn->size); 707 fn->ofs, fn->ofs + fn->size);
708 jffs2_free_full_dnode(fn); 708 jffs2_free_full_dnode(fn);
709 } 709 }
@@ -803,7 +803,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
803 } 803 }
804 804
805 f->target[je32_to_cpu(latest_node->csize)] = '\0'; 805 f->target[je32_to_cpu(latest_node->csize)] = '\0';
806 JFFS2_DBG_READINODE("symlink's target '%s' cached\n", f->target); 806 dbg_readinode("symlink's target '%s' cached\n", f->target);
807 } 807 }
808 808
809 /* fall through... */ 809 /* fall through... */
@@ -851,7 +851,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
851int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, 851int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
852 uint32_t ino, struct jffs2_raw_inode *latest_node) 852 uint32_t ino, struct jffs2_raw_inode *latest_node)
853{ 853{
854 JFFS2_DBG_READINODE("read inode #%u\n", ino); 854 dbg_readinode("read inode #%u\n", ino);
855 855
856 retry_inocache: 856 retry_inocache:
857 spin_lock(&c->inocache_lock); 857 spin_lock(&c->inocache_lock);
@@ -870,7 +870,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
870 /* If it's in either of these states, we need 870 /* If it's in either of these states, we need
871 to wait for whoever's got it to finish and 871 to wait for whoever's got it to finish and
872 put it back. */ 872 put it back. */
873 JFFS2_DBG_READINODE("waiting for ino #%u in state %d\n", ino, f->inocache->state); 873 dbg_readinode("waiting for ino #%u in state %d\n", ino, f->inocache->state);
874 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); 874 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
875 goto retry_inocache; 875 goto retry_inocache;
876 876
@@ -897,7 +897,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
897 JFFS2_ERROR("cannot allocate inocache for root inode\n"); 897 JFFS2_ERROR("cannot allocate inocache for root inode\n");
898 return -ENOMEM; 898 return -ENOMEM;
899 } 899 }
900 JFFS2_DBG_READINODE("creating inocache for root inode\n"); 900 dbg_readinode("creating inocache for root inode\n");
901 memset(f->inocache, 0, sizeof(struct jffs2_inode_cache)); 901 memset(f->inocache, 0, sizeof(struct jffs2_inode_cache));
902 f->inocache->ino = f->inocache->nlink = 1; 902 f->inocache->ino = f->inocache->nlink = 1;
903 f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; 903 f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache;
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 4e60ba8da197..8df7456472b8 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: scan.c,v 1.122 2005/09/07 08:34:54 havasi Exp $ 10 * $Id: scan.c,v 1.124 2005/09/21 13:05:22 dedekind Exp $
11 * 11 *
12 */ 12 */
13#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -429,7 +429,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
429 429
430 noise = 10; 430 noise = 10;
431 431
432 JFFS2_DBG_SUMMARY("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset); 432 dbg_summary("no summary found in jeb 0x%08x. Apply original scan.\n",jeb->offset);
433 433
434scan_more: 434scan_more:
435 while(ofs < jeb->offset + c->sector_size) { 435 while(ofs < jeb->offset + c->sector_size) {
@@ -684,7 +684,7 @@ scan_more:
684 684
685 if (jffs2_sum_active()) { 685 if (jffs2_sum_active()) {
686 if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) { 686 if (PAD(s->sum_size + JFFS2_SUMMARY_FRAME_SIZE) > jeb->free_size) {
687 JFFS2_DBG_SUMMARY("There is not enough space for " 687 dbg_summary("There is not enough space for "
688 "summary information, disabling for this jeb!\n"); 688 "summary information, disabling for this jeb!\n");
689 jffs2_sum_disable_collecting(s); 689 jffs2_sum_disable_collecting(s);
690 } 690 }
@@ -920,76 +920,34 @@ void jffs2_rotate_lists(struct jffs2_sb_info *c)
920 x = count_list(&c->clean_list); 920 x = count_list(&c->clean_list);
921 if (x) { 921 if (x) {
922 rotateby = pseudo_random % x; 922 rotateby = pseudo_random % x;
923 D1(printk(KERN_DEBUG "Rotating clean_list by %d\n", rotateby));
924
925 rotate_list((&c->clean_list), rotateby); 923 rotate_list((&c->clean_list), rotateby);
926
927 D1(printk(KERN_DEBUG "Erase block at front of clean_list is at %08x\n",
928 list_entry(c->clean_list.next, struct jffs2_eraseblock, list)->offset));
929 } else {
930 D1(printk(KERN_DEBUG "Not rotating empty clean_list\n"));
931 } 924 }
932 925
933 x = count_list(&c->very_dirty_list); 926 x = count_list(&c->very_dirty_list);
934 if (x) { 927 if (x) {
935 rotateby = pseudo_random % x; 928 rotateby = pseudo_random % x;
936 D1(printk(KERN_DEBUG "Rotating very_dirty_list by %d\n", rotateby));
937
938 rotate_list((&c->very_dirty_list), rotateby); 929 rotate_list((&c->very_dirty_list), rotateby);
939
940 D1(printk(KERN_DEBUG "Erase block at front of very_dirty_list is at %08x\n",
941 list_entry(c->very_dirty_list.next, struct jffs2_eraseblock, list)->offset));
942 } else {
943 D1(printk(KERN_DEBUG "Not rotating empty very_dirty_list\n"));
944 } 930 }
945 931
946 x = count_list(&c->dirty_list); 932 x = count_list(&c->dirty_list);
947 if (x) { 933 if (x) {
948 rotateby = pseudo_random % x; 934 rotateby = pseudo_random % x;
949 D1(printk(KERN_DEBUG "Rotating dirty_list by %d\n", rotateby));
950
951 rotate_list((&c->dirty_list), rotateby); 935 rotate_list((&c->dirty_list), rotateby);
952
953 D1(printk(KERN_DEBUG "Erase block at front of dirty_list is at %08x\n",
954 list_entry(c->dirty_list.next, struct jffs2_eraseblock, list)->offset));
955 } else {
956 D1(printk(KERN_DEBUG "Not rotating empty dirty_list\n"));
957 } 936 }
958 937
959 x = count_list(&c->erasable_list); 938 x = count_list(&c->erasable_list);
960 if (x) { 939 if (x) {
961 rotateby = pseudo_random % x; 940 rotateby = pseudo_random % x;
962 D1(printk(KERN_DEBUG "Rotating erasable_list by %d\n", rotateby));
963
964 rotate_list((&c->erasable_list), rotateby); 941 rotate_list((&c->erasable_list), rotateby);
965
966 D1(printk(KERN_DEBUG "Erase block at front of erasable_list is at %08x\n",
967 list_entry(c->erasable_list.next, struct jffs2_eraseblock, list)->offset));
968 } else {
969 D1(printk(KERN_DEBUG "Not rotating empty erasable_list\n"));
970 } 942 }
971 943
972 if (c->nr_erasing_blocks) { 944 if (c->nr_erasing_blocks) {
973 rotateby = pseudo_random % c->nr_erasing_blocks; 945 rotateby = pseudo_random % c->nr_erasing_blocks;
974 D1(printk(KERN_DEBUG "Rotating erase_pending_list by %d\n", rotateby));
975
976 rotate_list((&c->erase_pending_list), rotateby); 946 rotate_list((&c->erase_pending_list), rotateby);
977
978 D1(printk(KERN_DEBUG "Erase block at front of erase_pending_list is at %08x\n",
979 list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list)->offset));
980 } else {
981 D1(printk(KERN_DEBUG "Not rotating empty erase_pending_list\n"));
982 } 947 }
983 948
984 if (c->nr_free_blocks) { 949 if (c->nr_free_blocks) {
985 rotateby = pseudo_random % c->nr_free_blocks; 950 rotateby = pseudo_random % c->nr_free_blocks;
986 D1(printk(KERN_DEBUG "Rotating free_list by %d\n", rotateby));
987
988 rotate_list((&c->free_list), rotateby); 951 rotate_list((&c->free_list), rotateby);
989
990 D1(printk(KERN_DEBUG "Erase block at front of free_list is at %08x\n",
991 list_entry(c->free_list.next, struct jffs2_eraseblock, list)->offset));
992 } else {
993 D1(printk(KERN_DEBUG "Not rotating empty free_list\n"));
994 } 952 }
995} 953}
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index cb5dd8f11e73..1ebc81e4477d 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * For licensing information, see the file 'LICENCE' in this directory. 9 * For licensing information, see the file 'LICENCE' in this directory.
10 * 10 *
11 * $Id: summary.c,v 1.1 2005/09/07 08:34:54 havasi Exp $ 11 * $Id: summary.c,v 1.3 2005/09/21 14:43:07 dedekind Exp $
12 * 12 *
13 */ 13 */
14 14
@@ -38,17 +38,18 @@ int jffs2_sum_init(struct jffs2_sb_info *c)
38 38
39 if (!c->summary->sum_buf) { 39 if (!c->summary->sum_buf) {
40 JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n"); 40 JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n");
41 kfree(c->summary);
41 return -ENOMEM; 42 return -ENOMEM;
42 } 43 }
43 44
44 JFFS2_DBG_SUMMARY("returned succesfully\n"); 45 dbg_summary("returned succesfully\n");
45 46
46 return 0; 47 return 0;
47} 48}
48 49
49void jffs2_sum_exit(struct jffs2_sb_info *c) 50void jffs2_sum_exit(struct jffs2_sb_info *c)
50{ 51{
51 JFFS2_DBG_SUMMARY("called\n"); 52 dbg_summary("called\n");
52 53
53 jffs2_sum_disable_collecting(c->summary); 54 jffs2_sum_disable_collecting(c->summary);
54 55
@@ -71,13 +72,13 @@ static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
71 case JFFS2_NODETYPE_INODE: 72 case JFFS2_NODETYPE_INODE:
72 s->sum_size += JFFS2_SUMMARY_INODE_SIZE; 73 s->sum_size += JFFS2_SUMMARY_INODE_SIZE;
73 s->sum_num++; 74 s->sum_num++;
74 JFFS2_DBG_SUMMARY("inode (%u) added to summary\n", 75 dbg_summary("inode (%u) added to summary\n",
75 je32_to_cpu(item->i.inode)); 76 je32_to_cpu(item->i.inode));
76 break; 77 break;
77 case JFFS2_NODETYPE_DIRENT: 78 case JFFS2_NODETYPE_DIRENT:
78 s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize); 79 s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
79 s->sum_num++; 80 s->sum_num++;
80 JFFS2_DBG_SUMMARY("dirent (%u) added to summary\n", 81 dbg_summary("dirent (%u) added to summary\n",
81 je32_to_cpu(item->d.ino)); 82 je32_to_cpu(item->d.ino));
82 break; 83 break;
83 default: 84 default:
@@ -93,7 +94,7 @@ static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
93 94
94int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size) 95int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size)
95{ 96{
96 JFFS2_DBG_SUMMARY("called with %u\n", size); 97 dbg_summary("called with %u\n", size);
97 s->sum_padded += size; 98 s->sum_padded += size;
98 return 0; 99 return 0;
99} 100}
@@ -147,7 +148,7 @@ static void jffs2_sum_clean_collected(struct jffs2_summary *s)
147 union jffs2_sum_mem *temp; 148 union jffs2_sum_mem *temp;
148 149
149 if (!s->sum_list_head) { 150 if (!s->sum_list_head) {
150 JFFS2_DBG_SUMMARY("already empty\n"); 151 dbg_summary("already empty\n");
151 } 152 }
152 while (s->sum_list_head) { 153 while (s->sum_list_head) {
153 temp = s->sum_list_head; 154 temp = s->sum_list_head;
@@ -161,14 +162,14 @@ static void jffs2_sum_clean_collected(struct jffs2_summary *s)
161 162
162void jffs2_sum_reset_collected(struct jffs2_summary *s) 163void jffs2_sum_reset_collected(struct jffs2_summary *s)
163{ 164{
164 JFFS2_DBG_SUMMARY("called\n"); 165 dbg_summary("called\n");
165 jffs2_sum_clean_collected(s); 166 jffs2_sum_clean_collected(s);
166 s->sum_size = 0; 167 s->sum_size = 0;
167} 168}
168 169
169void jffs2_sum_disable_collecting(struct jffs2_summary *s) 170void jffs2_sum_disable_collecting(struct jffs2_summary *s)
170{ 171{
171 JFFS2_DBG_SUMMARY("called\n"); 172 dbg_summary("called\n");
172 jffs2_sum_clean_collected(s); 173 jffs2_sum_clean_collected(s);
173 s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; 174 s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
174} 175}
@@ -182,7 +183,7 @@ int jffs2_sum_is_disabled(struct jffs2_summary *s)
182 183
183void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s) 184void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s)
184{ 185{
185 JFFS2_DBG_SUMMARY("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n", 186 dbg_summary("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n",
186 c->summary->sum_size, c->summary->sum_num, 187 c->summary->sum_size, c->summary->sum_num,
187 s->sum_size, s->sum_num); 188 s->sum_size, s->sum_num);
188 189
@@ -260,16 +261,16 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
260 } 261 }
261 262
262 case JFFS2_NODETYPE_PADDING: 263 case JFFS2_NODETYPE_PADDING:
263 JFFS2_DBG_SUMMARY("node PADDING\n"); 264 dbg_summary("node PADDING\n");
264 c->summary->sum_padded += je32_to_cpu(node->u.totlen); 265 c->summary->sum_padded += je32_to_cpu(node->u.totlen);
265 break; 266 break;
266 267
267 case JFFS2_NODETYPE_CLEANMARKER: 268 case JFFS2_NODETYPE_CLEANMARKER:
268 JFFS2_DBG_SUMMARY("node CLEANMARKER\n"); 269 dbg_summary("node CLEANMARKER\n");
269 break; 270 break;
270 271
271 case JFFS2_NODETYPE_SUMMARY: 272 case JFFS2_NODETYPE_SUMMARY:
272 JFFS2_DBG_SUMMARY("node SUMMARY\n"); 273 dbg_summary("node SUMMARY\n");
273 break; 274 break;
274 275
275 default: 276 default:
@@ -302,7 +303,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
302 sp = summary->sum; 303 sp = summary->sum;
303 304
304 for (i=0; i<je32_to_cpu(summary->sum_num); i++) { 305 for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
305 JFFS2_DBG_SUMMARY("processing summary index %d\n", i); 306 dbg_summary("processing summary index %d\n", i);
306 307
307 switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) { 308 switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) {
308 case JFFS2_NODETYPE_INODE: { 309 case JFFS2_NODETYPE_INODE: {
@@ -311,7 +312,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
311 312
312 ino = je32_to_cpu(spi->inode); 313 ino = je32_to_cpu(spi->inode);
313 314
314 JFFS2_DBG_SUMMARY("Inode at 0x%08x\n", 315 dbg_summary("Inode at 0x%08x\n",
315 jeb->offset + je32_to_cpu(spi->offset)); 316 jeb->offset + je32_to_cpu(spi->offset));
316 317
317 raw = jffs2_alloc_raw_node_ref(); 318 raw = jffs2_alloc_raw_node_ref();
@@ -353,7 +354,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
353 struct jffs2_sum_dirent_flash *spd; 354 struct jffs2_sum_dirent_flash *spd;
354 spd = sp; 355 spd = sp;
355 356
356 JFFS2_DBG_SUMMARY("Dirent at 0x%08x\n", 357 dbg_summary("Dirent at 0x%08x\n",
357 jeb->offset + je32_to_cpu(spd->offset)); 358 jeb->offset + je32_to_cpu(spd->offset));
358 359
359 fd = jffs2_alloc_full_dirent(spd->nsize+1); 360 fd = jffs2_alloc_full_dirent(spd->nsize+1);
@@ -434,7 +435,7 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
434 sumsize = c->sector_size - ofs; 435 sumsize = c->sector_size - ofs;
435 ofs += jeb->offset; 436 ofs += jeb->offset;
436 437
437 JFFS2_DBG_SUMMARY("summary found for 0x%08x at 0x%08x (0x%x bytes)\n", 438 dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n",
438 jeb->offset, ofs, sumsize); 439 jeb->offset, ofs, sumsize);
439 440
440 summary = kmalloc(sumsize, GFP_KERNEL); 441 summary = kmalloc(sumsize, GFP_KERNEL);
@@ -457,40 +458,40 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
457 crc = crc32(0, &crcnode, sizeof(crcnode)-4); 458 crc = crc32(0, &crcnode, sizeof(crcnode)-4);
458 459
459 if (je32_to_cpu(summary->hdr_crc) != crc) { 460 if (je32_to_cpu(summary->hdr_crc) != crc) {
460 JFFS2_DBG_SUMMARY("Summary node header is corrupt (bad CRC or " 461 dbg_summary("Summary node header is corrupt (bad CRC or "
461 "no summary at all)\n"); 462 "no summary at all)\n");
462 goto crc_err; 463 goto crc_err;
463 } 464 }
464 465
465 if (je32_to_cpu(summary->totlen) != sumsize) { 466 if (je32_to_cpu(summary->totlen) != sumsize) {
466 JFFS2_DBG_SUMMARY("Summary node is corrupt (wrong erasesize?)\n"); 467 dbg_summary("Summary node is corrupt (wrong erasesize?)\n");
467 goto crc_err; 468 goto crc_err;
468 } 469 }
469 470
470 crc = crc32(0, summary, sizeof(struct jffs2_summary_node)-8); 471 crc = crc32(0, summary, sizeof(struct jffs2_summary_node)-8);
471 472
472 if (je32_to_cpu(summary->node_crc) != crc) { 473 if (je32_to_cpu(summary->node_crc) != crc) {
473 JFFS2_DBG_SUMMARY("Summary node is corrupt (bad CRC)\n"); 474 dbg_summary("Summary node is corrupt (bad CRC)\n");
474 goto crc_err; 475 goto crc_err;
475 } 476 }
476 477
477 crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_summary_node)); 478 crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_summary_node));
478 479
479 if (je32_to_cpu(summary->sum_crc) != crc) { 480 if (je32_to_cpu(summary->sum_crc) != crc) {
480 JFFS2_DBG_SUMMARY("Summary node data is corrupt (bad CRC)\n"); 481 dbg_summary("Summary node data is corrupt (bad CRC)\n");
481 goto crc_err; 482 goto crc_err;
482 } 483 }
483 484
484 if ( je32_to_cpu(summary->cln_mkr) ) { 485 if ( je32_to_cpu(summary->cln_mkr) ) {
485 486
486 JFFS2_DBG_SUMMARY("Summary : CLEANMARKER node \n"); 487 dbg_summary("Summary : CLEANMARKER node \n");
487 488
488 if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) { 489 if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
489 JFFS2_DBG_SUMMARY("CLEANMARKER node has totlen 0x%x != normal 0x%x\n", 490 dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
490 je32_to_cpu(summary->cln_mkr), c->cleanmarker_size); 491 je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
491 UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); 492 UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
492 } else if (jeb->first_node) { 493 } else if (jeb->first_node) {
493 JFFS2_DBG_SUMMARY("CLEANMARKER node not first node in block " 494 dbg_summary("CLEANMARKER node not first node in block "
494 "(0x%08x)\n", jeb->offset); 495 "(0x%08x)\n", jeb->offset);
495 UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); 496 UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
496 } else { 497 } else {
@@ -644,7 +645,7 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
644 vecs[1].iov_base = c->summary->sum_buf; 645 vecs[1].iov_base = c->summary->sum_buf;
645 vecs[1].iov_len = datasize; 646 vecs[1].iov_len = datasize;
646 647
647 JFFS2_DBG_SUMMARY("JFFS2: writing out data to flash to pos : 0x%08x\n", 648 dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n",
648 jeb->offset + c->sector_size - jeb->free_size); 649 jeb->offset + c->sector_size - jeb->free_size);
649 650
650 spin_unlock(&c->erase_completion_lock); 651 spin_unlock(&c->erase_completion_lock);
@@ -674,7 +675,7 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
674 int datasize, infosize, padsize, ret; 675 int datasize, infosize, padsize, ret;
675 struct jffs2_eraseblock *jeb; 676 struct jffs2_eraseblock *jeb;
676 677
677 JFFS2_DBG_SUMMARY("called\n"); 678 dbg_summary("called\n");
678 679
679 jeb = c->nextblock; 680 jeb = c->nextblock;
680 681
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 86860dbc670c..11e05bc014f1 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * For licensing information, see the file 'LICENCE' in this directory. 10 * For licensing information, see the file 'LICENCE' in this directory.
11 * 11 *
12 * $Id: wbuf.c,v 1.98 2005/09/07 08:34:55 havasi Exp $ 12 * $Id: wbuf.c,v 1.99 2005/09/21 16:11:04 dedekind Exp $
13 * 13 *
14 */ 14 */
15 15
@@ -33,9 +33,6 @@ static unsigned char *brokenbuf;
33/* max. erase failures before we mark a block bad */ 33/* max. erase failures before we mark a block bad */
34#define MAX_ERASE_FAILURES 2 34#define MAX_ERASE_FAILURES 2
35 35
36/* two seconds timeout for timed wbuf-flushing */
37#define WBUF_FLUSH_TIMEOUT 2 * HZ
38
39struct jffs2_inodirty { 36struct jffs2_inodirty {
40 uint32_t ino; 37 uint32_t ino;
41 struct jffs2_inodirty *next; 38 struct jffs2_inodirty *next;
diff --git a/include/linux/jffs2_fs_sb.h b/include/linux/jffs2_fs_sb.h
index 5087612ed9ac..fdc445b49e19 100644
--- a/include/linux/jffs2_fs_sb.h
+++ b/include/linux/jffs2_fs_sb.h
@@ -1,4 +1,4 @@
1/* $Id: jffs2_fs_sb.h,v 1.53 2005/09/07 08:34:56 havasi Exp $ */ 1/* $Id: jffs2_fs_sb.h,v 1.54 2005/09/21 13:37:34 dedekind Exp $ */
2 2
3#ifndef _JFFS2_FS_SB 3#ifndef _JFFS2_FS_SB
4#define _JFFS2_FS_SB 4#define _JFFS2_FS_SB
@@ -95,12 +95,13 @@ struct jffs2_sb_info {
95 to an obsoleted node. I don't like this. Alternatives welcomed. */ 95 to an obsoleted node. I don't like this. Alternatives welcomed. */
96 struct semaphore erase_free_sem; 96 struct semaphore erase_free_sem;
97 97
98 uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */
99
98#ifdef CONFIG_JFFS2_FS_WRITEBUFFER 100#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
99 /* Write-behind buffer for NAND flash */ 101 /* Write-behind buffer for NAND flash */
100 unsigned char *wbuf; 102 unsigned char *wbuf;
101 uint32_t wbuf_ofs; 103 uint32_t wbuf_ofs;
102 uint32_t wbuf_len; 104 uint32_t wbuf_len;
103 uint32_t wbuf_pagesize;
104 struct jffs2_inodirty *wbuf_inodes; 105 struct jffs2_inodirty *wbuf_inodes;
105 106
106 struct rw_semaphore wbuf_sem; /* Protects the write buffer */ 107 struct rw_semaphore wbuf_sem; /* Protects the write buffer */