diff options
Diffstat (limited to 'fs/jffs2/gc.c')
-rw-r--r-- | fs/jffs2/gc.c | 322 |
1 files changed, 187 insertions, 135 deletions
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 31dce611337c..ad271c70aa25 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
15 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
@@ -51,44 +53,44 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c) | |||
51 | number of free blocks is low. */ | 53 | number of free blocks is low. */ |
52 | again: | 54 | again: |
53 | if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) { | 55 | if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) { |
54 | D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n")); | 56 | jffs2_dbg(1, "Picking block from bad_used_list to GC next\n"); |
55 | nextlist = &c->bad_used_list; | 57 | nextlist = &c->bad_used_list; |
56 | } else if (n < 50 && !list_empty(&c->erasable_list)) { | 58 | } else if (n < 50 && !list_empty(&c->erasable_list)) { |
57 | /* Note that most of them will have gone directly to be erased. | 59 | /* Note that most of them will have gone directly to be erased. |
58 | So don't favour the erasable_list _too_ much. */ | 60 | So don't favour the erasable_list _too_ much. */ |
59 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n")); | 61 | jffs2_dbg(1, "Picking block from erasable_list to GC next\n"); |
60 | nextlist = &c->erasable_list; | 62 | nextlist = &c->erasable_list; |
61 | } else if (n < 110 && !list_empty(&c->very_dirty_list)) { | 63 | } else if (n < 110 && !list_empty(&c->very_dirty_list)) { |
62 | /* Most of the time, pick one off the very_dirty list */ | 64 | /* Most of the time, pick one off the very_dirty list */ |
63 | D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next\n")); | 65 | jffs2_dbg(1, "Picking block from very_dirty_list to GC next\n"); |
64 | nextlist = &c->very_dirty_list; | 66 | nextlist = &c->very_dirty_list; |
65 | } else if (n < 126 && !list_empty(&c->dirty_list)) { | 67 | } else if (n < 126 && !list_empty(&c->dirty_list)) { |
66 | D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next\n")); | 68 | jffs2_dbg(1, "Picking block from dirty_list to GC next\n"); |
67 | nextlist = &c->dirty_list; | 69 | nextlist = &c->dirty_list; |
68 | } else if (!list_empty(&c->clean_list)) { | 70 | } else if (!list_empty(&c->clean_list)) { |
69 | D1(printk(KERN_DEBUG "Picking block from clean_list to GC next\n")); | 71 | jffs2_dbg(1, "Picking block from clean_list to GC next\n"); |
70 | nextlist = &c->clean_list; | 72 | nextlist = &c->clean_list; |
71 | } else if (!list_empty(&c->dirty_list)) { | 73 | } else if (!list_empty(&c->dirty_list)) { |
72 | D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next (clean_list was empty)\n")); | 74 | jffs2_dbg(1, "Picking block from dirty_list to GC next (clean_list was empty)\n"); |
73 | 75 | ||
74 | nextlist = &c->dirty_list; | 76 | nextlist = &c->dirty_list; |
75 | } else if (!list_empty(&c->very_dirty_list)) { | 77 | } else if (!list_empty(&c->very_dirty_list)) { |
76 | D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n")); | 78 | jffs2_dbg(1, "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n"); |
77 | nextlist = &c->very_dirty_list; | 79 | nextlist = &c->very_dirty_list; |
78 | } else if (!list_empty(&c->erasable_list)) { | 80 | } else if (!list_empty(&c->erasable_list)) { |
79 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n")); | 81 | jffs2_dbg(1, "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n"); |
80 | 82 | ||
81 | nextlist = &c->erasable_list; | 83 | nextlist = &c->erasable_list; |
82 | } else if (!list_empty(&c->erasable_pending_wbuf_list)) { | 84 | } else if (!list_empty(&c->erasable_pending_wbuf_list)) { |
83 | /* There are blocks are wating for the wbuf sync */ | 85 | /* There are blocks are wating for the wbuf sync */ |
84 | D1(printk(KERN_DEBUG "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n")); | 86 | jffs2_dbg(1, "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n"); |
85 | spin_unlock(&c->erase_completion_lock); | 87 | spin_unlock(&c->erase_completion_lock); |
86 | jffs2_flush_wbuf_pad(c); | 88 | jffs2_flush_wbuf_pad(c); |
87 | spin_lock(&c->erase_completion_lock); | 89 | spin_lock(&c->erase_completion_lock); |
88 | goto again; | 90 | goto again; |
89 | } else { | 91 | } else { |
90 | /* Eep. All were empty */ | 92 | /* Eep. All were empty */ |
91 | D1(printk(KERN_NOTICE "jffs2: No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n")); | 93 | jffs2_dbg(1, "No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n"); |
92 | return NULL; | 94 | return NULL; |
93 | } | 95 | } |
94 | 96 | ||
@@ -97,13 +99,15 @@ again: | |||
97 | c->gcblock = ret; | 99 | c->gcblock = ret; |
98 | ret->gc_node = ret->first_node; | 100 | ret->gc_node = ret->first_node; |
99 | if (!ret->gc_node) { | 101 | if (!ret->gc_node) { |
100 | printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset); | 102 | pr_warn("Eep. ret->gc_node for block at 0x%08x is NULL\n", |
103 | ret->offset); | ||
101 | BUG(); | 104 | BUG(); |
102 | } | 105 | } |
103 | 106 | ||
104 | /* Have we accidentally picked a clean block with wasted space ? */ | 107 | /* Have we accidentally picked a clean block with wasted space ? */ |
105 | if (ret->wasted_size) { | 108 | if (ret->wasted_size) { |
106 | D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size)); | 109 | jffs2_dbg(1, "Converting wasted_size %08x to dirty_size\n", |
110 | ret->wasted_size); | ||
107 | ret->dirty_size += ret->wasted_size; | 111 | ret->dirty_size += ret->wasted_size; |
108 | c->wasted_size -= ret->wasted_size; | 112 | c->wasted_size -= ret->wasted_size; |
109 | c->dirty_size += ret->wasted_size; | 113 | c->dirty_size += ret->wasted_size; |
@@ -140,8 +144,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
140 | 144 | ||
141 | /* checked_ino is protected by the alloc_sem */ | 145 | /* checked_ino is protected by the alloc_sem */ |
142 | if (c->checked_ino > c->highest_ino && xattr) { | 146 | if (c->checked_ino > c->highest_ino && xattr) { |
143 | printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n", | 147 | pr_crit("Checked all inodes but still 0x%x bytes of unchecked space?\n", |
144 | c->unchecked_size); | 148 | c->unchecked_size); |
145 | jffs2_dbg_dump_block_lists_nolock(c); | 149 | jffs2_dbg_dump_block_lists_nolock(c); |
146 | spin_unlock(&c->erase_completion_lock); | 150 | spin_unlock(&c->erase_completion_lock); |
147 | mutex_unlock(&c->alloc_sem); | 151 | mutex_unlock(&c->alloc_sem); |
@@ -163,8 +167,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
163 | } | 167 | } |
164 | 168 | ||
165 | if (!ic->pino_nlink) { | 169 | if (!ic->pino_nlink) { |
166 | D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink/pino zero\n", | 170 | jffs2_dbg(1, "Skipping check of ino #%d with nlink/pino zero\n", |
167 | ic->ino)); | 171 | ic->ino); |
168 | spin_unlock(&c->inocache_lock); | 172 | spin_unlock(&c->inocache_lock); |
169 | jffs2_xattr_delete_inode(c, ic); | 173 | jffs2_xattr_delete_inode(c, ic); |
170 | continue; | 174 | continue; |
@@ -172,13 +176,15 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
172 | switch(ic->state) { | 176 | switch(ic->state) { |
173 | case INO_STATE_CHECKEDABSENT: | 177 | case INO_STATE_CHECKEDABSENT: |
174 | case INO_STATE_PRESENT: | 178 | case INO_STATE_PRESENT: |
175 | D1(printk(KERN_DEBUG "Skipping ino #%u already checked\n", ic->ino)); | 179 | jffs2_dbg(1, "Skipping ino #%u already checked\n", |
180 | ic->ino); | ||
176 | spin_unlock(&c->inocache_lock); | 181 | spin_unlock(&c->inocache_lock); |
177 | continue; | 182 | continue; |
178 | 183 | ||
179 | case INO_STATE_GC: | 184 | case INO_STATE_GC: |
180 | case INO_STATE_CHECKING: | 185 | case INO_STATE_CHECKING: |
181 | printk(KERN_WARNING "Inode #%u is in state %d during CRC check phase!\n", ic->ino, ic->state); | 186 | pr_warn("Inode #%u is in state %d during CRC check phase!\n", |
187 | ic->ino, ic->state); | ||
182 | spin_unlock(&c->inocache_lock); | 188 | spin_unlock(&c->inocache_lock); |
183 | BUG(); | 189 | BUG(); |
184 | 190 | ||
@@ -186,7 +192,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
186 | /* We need to wait for it to finish, lest we move on | 192 | /* We need to wait for it to finish, lest we move on |
187 | and trigger the BUG() above while we haven't yet | 193 | and trigger the BUG() above while we haven't yet |
188 | finished checking all its nodes */ | 194 | finished checking all its nodes */ |
189 | D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); | 195 | jffs2_dbg(1, "Waiting for ino #%u to finish reading\n", |
196 | ic->ino); | ||
190 | /* We need to come back again for the _same_ inode. We've | 197 | /* We need to come back again for the _same_ inode. We've |
191 | made no progress in this case, but that should be OK */ | 198 | made no progress in this case, but that should be OK */ |
192 | c->checked_ino--; | 199 | c->checked_ino--; |
@@ -204,11 +211,13 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
204 | ic->state = INO_STATE_CHECKING; | 211 | ic->state = INO_STATE_CHECKING; |
205 | spin_unlock(&c->inocache_lock); | 212 | spin_unlock(&c->inocache_lock); |
206 | 213 | ||
207 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() triggering inode scan of ino#%u\n", ic->ino)); | 214 | jffs2_dbg(1, "%s(): triggering inode scan of ino#%u\n", |
215 | __func__, ic->ino); | ||
208 | 216 | ||
209 | ret = jffs2_do_crccheck_inode(c, ic); | 217 | ret = jffs2_do_crccheck_inode(c, ic); |
210 | if (ret) | 218 | if (ret) |
211 | printk(KERN_WARNING "Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino); | 219 | pr_warn("Returned error for crccheck of ino #%u. Expect badness...\n", |
220 | ic->ino); | ||
212 | 221 | ||
213 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); | 222 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); |
214 | mutex_unlock(&c->alloc_sem); | 223 | mutex_unlock(&c->alloc_sem); |
@@ -220,11 +229,11 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
220 | !list_empty(&c->erase_pending_list)) { | 229 | !list_empty(&c->erase_pending_list)) { |
221 | spin_unlock(&c->erase_completion_lock); | 230 | spin_unlock(&c->erase_completion_lock); |
222 | mutex_unlock(&c->alloc_sem); | 231 | mutex_unlock(&c->alloc_sem); |
223 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() erasing pending blocks\n")); | 232 | jffs2_dbg(1, "%s(): erasing pending blocks\n", __func__); |
224 | if (jffs2_erase_pending_blocks(c, 1)) | 233 | if (jffs2_erase_pending_blocks(c, 1)) |
225 | return 0; | 234 | return 0; |
226 | 235 | ||
227 | D1(printk(KERN_DEBUG "No progress from erasing blocks; doing GC anyway\n")); | 236 | jffs2_dbg(1, "No progress from erasing block; doing GC anyway\n"); |
228 | spin_lock(&c->erase_completion_lock); | 237 | spin_lock(&c->erase_completion_lock); |
229 | mutex_lock(&c->alloc_sem); | 238 | mutex_lock(&c->alloc_sem); |
230 | } | 239 | } |
@@ -242,13 +251,14 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
242 | mutex_unlock(&c->alloc_sem); | 251 | mutex_unlock(&c->alloc_sem); |
243 | return -EAGAIN; | 252 | return -EAGAIN; |
244 | } | 253 | } |
245 | D1(printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); | 254 | jffs2_dbg(1, "Couldn't find erase block to garbage collect!\n"); |
246 | spin_unlock(&c->erase_completion_lock); | 255 | spin_unlock(&c->erase_completion_lock); |
247 | mutex_unlock(&c->alloc_sem); | 256 | mutex_unlock(&c->alloc_sem); |
248 | return -EIO; | 257 | return -EIO; |
249 | } | 258 | } |
250 | 259 | ||
251 | D1(printk(KERN_DEBUG "GC from block %08x, used_size %08x, dirty_size %08x, free_size %08x\n", jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size)); | 260 | jffs2_dbg(1, "GC from block %08x, used_size %08x, dirty_size %08x, free_size %08x\n", |
261 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size); | ||
252 | D1(if (c->nextblock) | 262 | D1(if (c->nextblock) |
253 | printk(KERN_DEBUG "Nextblock at %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size)); | 263 | printk(KERN_DEBUG "Nextblock at %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size)); |
254 | 264 | ||
@@ -261,12 +271,14 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
261 | gcblock_dirty = jeb->dirty_size; | 271 | gcblock_dirty = jeb->dirty_size; |
262 | 272 | ||
263 | while(ref_obsolete(raw)) { | 273 | while(ref_obsolete(raw)) { |
264 | D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); | 274 | jffs2_dbg(1, "Node at 0x%08x is obsolete... skipping\n", |
275 | ref_offset(raw)); | ||
265 | raw = ref_next(raw); | 276 | raw = ref_next(raw); |
266 | if (unlikely(!raw)) { | 277 | if (unlikely(!raw)) { |
267 | printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); | 278 | pr_warn("eep. End of raw list while still supposedly nodes to GC\n"); |
268 | printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", | 279 | pr_warn("erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", |
269 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); | 280 | jeb->offset, jeb->free_size, |
281 | jeb->dirty_size, jeb->used_size); | ||
270 | jeb->gc_node = raw; | 282 | jeb->gc_node = raw; |
271 | spin_unlock(&c->erase_completion_lock); | 283 | spin_unlock(&c->erase_completion_lock); |
272 | mutex_unlock(&c->alloc_sem); | 284 | mutex_unlock(&c->alloc_sem); |
@@ -275,7 +287,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
275 | } | 287 | } |
276 | jeb->gc_node = raw; | 288 | jeb->gc_node = raw; |
277 | 289 | ||
278 | D1(printk(KERN_DEBUG "Going to garbage collect node at 0x%08x\n", ref_offset(raw))); | 290 | jffs2_dbg(1, "Going to garbage collect node at 0x%08x\n", |
291 | ref_offset(raw)); | ||
279 | 292 | ||
280 | if (!raw->next_in_ino) { | 293 | if (!raw->next_in_ino) { |
281 | /* Inode-less node. Clean marker, snapshot or something like that */ | 294 | /* Inode-less node. Clean marker, snapshot or something like that */ |
@@ -316,7 +329,9 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
316 | 329 | ||
317 | spin_unlock(&c->erase_completion_lock); | 330 | spin_unlock(&c->erase_completion_lock); |
318 | 331 | ||
319 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass collecting from block @0x%08x. Node @0x%08x(%d), ino #%u\n", jeb->offset, ref_offset(raw), ref_flags(raw), ic->ino)); | 332 | jffs2_dbg(1, "%s(): collecting from block @0x%08x. Node @0x%08x(%d), ino #%u\n", |
333 | __func__, jeb->offset, ref_offset(raw), ref_flags(raw), | ||
334 | ic->ino); | ||
320 | 335 | ||
321 | /* Three possibilities: | 336 | /* Three possibilities: |
322 | 1. Inode is already in-core. We must iget it and do proper | 337 | 1. Inode is already in-core. We must iget it and do proper |
@@ -336,8 +351,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
336 | if (ref_flags(raw) == REF_PRISTINE) | 351 | if (ref_flags(raw) == REF_PRISTINE) |
337 | ic->state = INO_STATE_GC; | 352 | ic->state = INO_STATE_GC; |
338 | else { | 353 | else { |
339 | D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", | 354 | jffs2_dbg(1, "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", |
340 | ic->ino)); | 355 | ic->ino); |
341 | } | 356 | } |
342 | break; | 357 | break; |
343 | 358 | ||
@@ -353,8 +368,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
353 | we're holding the alloc_sem, no other garbage collection | 368 | we're holding the alloc_sem, no other garbage collection |
354 | can happen. | 369 | can happen. |
355 | */ | 370 | */ |
356 | printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", | 371 | pr_crit("Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", |
357 | ic->ino, ic->state); | 372 | ic->ino, ic->state); |
358 | mutex_unlock(&c->alloc_sem); | 373 | mutex_unlock(&c->alloc_sem); |
359 | spin_unlock(&c->inocache_lock); | 374 | spin_unlock(&c->inocache_lock); |
360 | BUG(); | 375 | BUG(); |
@@ -367,8 +382,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
367 | drop the alloc_sem before sleeping. */ | 382 | drop the alloc_sem before sleeping. */ |
368 | 383 | ||
369 | mutex_unlock(&c->alloc_sem); | 384 | mutex_unlock(&c->alloc_sem); |
370 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", | 385 | jffs2_dbg(1, "%s(): waiting for ino #%u in state %d\n", |
371 | ic->ino, ic->state)); | 386 | __func__, ic->ino, ic->state); |
372 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 387 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
373 | /* And because we dropped the alloc_sem we must start again from the | 388 | /* And because we dropped the alloc_sem we must start again from the |
374 | beginning. Ponder chance of livelock here -- we're returning success | 389 | beginning. Ponder chance of livelock here -- we're returning success |
@@ -433,7 +448,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
433 | test_gcnode: | 448 | test_gcnode: |
434 | if (jeb->dirty_size == gcblock_dirty && !ref_obsolete(jeb->gc_node)) { | 449 | if (jeb->dirty_size == gcblock_dirty && !ref_obsolete(jeb->gc_node)) { |
435 | /* Eep. This really should never happen. GC is broken */ | 450 | /* Eep. This really should never happen. GC is broken */ |
436 | printk(KERN_ERR "Error garbage collecting node at %08x!\n", ref_offset(jeb->gc_node)); | 451 | pr_err("Error garbage collecting node at %08x!\n", |
452 | ref_offset(jeb->gc_node)); | ||
437 | ret = -ENOSPC; | 453 | ret = -ENOSPC; |
438 | } | 454 | } |
439 | release_sem: | 455 | release_sem: |
@@ -445,7 +461,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
445 | 461 | ||
446 | eraseit: | 462 | eraseit: |
447 | if (c->gcblock && !c->gcblock->used_size) { | 463 | if (c->gcblock && !c->gcblock->used_size) { |
448 | D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset)); | 464 | jffs2_dbg(1, "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", |
465 | c->gcblock->offset); | ||
449 | /* We're GC'ing an empty block? */ | 466 | /* We're GC'ing an empty block? */ |
450 | list_add_tail(&c->gcblock->list, &c->erase_pending_list); | 467 | list_add_tail(&c->gcblock->list, &c->erase_pending_list); |
451 | c->gcblock = NULL; | 468 | c->gcblock = NULL; |
@@ -475,12 +492,12 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
475 | 492 | ||
476 | if (c->gcblock != jeb) { | 493 | if (c->gcblock != jeb) { |
477 | spin_unlock(&c->erase_completion_lock); | 494 | spin_unlock(&c->erase_completion_lock); |
478 | D1(printk(KERN_DEBUG "GC block is no longer gcblock. Restart\n")); | 495 | jffs2_dbg(1, "GC block is no longer gcblock. Restart\n"); |
479 | goto upnout; | 496 | goto upnout; |
480 | } | 497 | } |
481 | if (ref_obsolete(raw)) { | 498 | if (ref_obsolete(raw)) { |
482 | spin_unlock(&c->erase_completion_lock); | 499 | spin_unlock(&c->erase_completion_lock); |
483 | D1(printk(KERN_DEBUG "node to be GC'd was obsoleted in the meantime.\n")); | 500 | jffs2_dbg(1, "node to be GC'd was obsoleted in the meantime.\n"); |
484 | /* They'll call again */ | 501 | /* They'll call again */ |
485 | goto upnout; | 502 | goto upnout; |
486 | } | 503 | } |
@@ -536,10 +553,10 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
536 | } else if (fd) { | 553 | } else if (fd) { |
537 | ret = jffs2_garbage_collect_deletion_dirent(c, jeb, f, fd); | 554 | ret = jffs2_garbage_collect_deletion_dirent(c, jeb, f, fd); |
538 | } else { | 555 | } else { |
539 | printk(KERN_WARNING "Raw node at 0x%08x wasn't in node lists for ino #%u\n", | 556 | pr_warn("Raw node at 0x%08x wasn't in node lists for ino #%u\n", |
540 | ref_offset(raw), f->inocache->ino); | 557 | ref_offset(raw), f->inocache->ino); |
541 | if (ref_obsolete(raw)) { | 558 | if (ref_obsolete(raw)) { |
542 | printk(KERN_WARNING "But it's obsolete so we don't mind too much\n"); | 559 | pr_warn("But it's obsolete so we don't mind too much\n"); |
543 | } else { | 560 | } else { |
544 | jffs2_dbg_dump_node(c, ref_offset(raw)); | 561 | jffs2_dbg_dump_node(c, ref_offset(raw)); |
545 | BUG(); | 562 | BUG(); |
@@ -562,7 +579,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
562 | uint32_t crc, rawlen; | 579 | uint32_t crc, rawlen; |
563 | int retried = 0; | 580 | int retried = 0; |
564 | 581 | ||
565 | D1(printk(KERN_DEBUG "Going to GC REF_PRISTINE node at 0x%08x\n", ref_offset(raw))); | 582 | jffs2_dbg(1, "Going to GC REF_PRISTINE node at 0x%08x\n", |
583 | ref_offset(raw)); | ||
566 | 584 | ||
567 | alloclen = rawlen = ref_totlen(c, c->gcblock, raw); | 585 | alloclen = rawlen = ref_totlen(c, c->gcblock, raw); |
568 | 586 | ||
@@ -595,8 +613,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
595 | 613 | ||
596 | crc = crc32(0, node, sizeof(struct jffs2_unknown_node)-4); | 614 | crc = crc32(0, node, sizeof(struct jffs2_unknown_node)-4); |
597 | if (je32_to_cpu(node->u.hdr_crc) != crc) { | 615 | if (je32_to_cpu(node->u.hdr_crc) != crc) { |
598 | printk(KERN_WARNING "Header CRC failed on REF_PRISTINE node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 616 | pr_warn("Header CRC failed on REF_PRISTINE node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
599 | ref_offset(raw), je32_to_cpu(node->u.hdr_crc), crc); | 617 | ref_offset(raw), je32_to_cpu(node->u.hdr_crc), crc); |
600 | goto bail; | 618 | goto bail; |
601 | } | 619 | } |
602 | 620 | ||
@@ -604,16 +622,18 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
604 | case JFFS2_NODETYPE_INODE: | 622 | case JFFS2_NODETYPE_INODE: |
605 | crc = crc32(0, node, sizeof(node->i)-8); | 623 | crc = crc32(0, node, sizeof(node->i)-8); |
606 | if (je32_to_cpu(node->i.node_crc) != crc) { | 624 | if (je32_to_cpu(node->i.node_crc) != crc) { |
607 | printk(KERN_WARNING "Node CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 625 | pr_warn("Node CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
608 | ref_offset(raw), je32_to_cpu(node->i.node_crc), crc); | 626 | ref_offset(raw), je32_to_cpu(node->i.node_crc), |
627 | crc); | ||
609 | goto bail; | 628 | goto bail; |
610 | } | 629 | } |
611 | 630 | ||
612 | if (je32_to_cpu(node->i.dsize)) { | 631 | if (je32_to_cpu(node->i.dsize)) { |
613 | crc = crc32(0, node->i.data, je32_to_cpu(node->i.csize)); | 632 | crc = crc32(0, node->i.data, je32_to_cpu(node->i.csize)); |
614 | if (je32_to_cpu(node->i.data_crc) != crc) { | 633 | if (je32_to_cpu(node->i.data_crc) != crc) { |
615 | printk(KERN_WARNING "Data CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 634 | pr_warn("Data CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
616 | ref_offset(raw), je32_to_cpu(node->i.data_crc), crc); | 635 | ref_offset(raw), |
636 | je32_to_cpu(node->i.data_crc), crc); | ||
617 | goto bail; | 637 | goto bail; |
618 | } | 638 | } |
619 | } | 639 | } |
@@ -622,21 +642,24 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
622 | case JFFS2_NODETYPE_DIRENT: | 642 | case JFFS2_NODETYPE_DIRENT: |
623 | crc = crc32(0, node, sizeof(node->d)-8); | 643 | crc = crc32(0, node, sizeof(node->d)-8); |
624 | if (je32_to_cpu(node->d.node_crc) != crc) { | 644 | if (je32_to_cpu(node->d.node_crc) != crc) { |
625 | printk(KERN_WARNING "Node CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 645 | pr_warn("Node CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
626 | ref_offset(raw), je32_to_cpu(node->d.node_crc), crc); | 646 | ref_offset(raw), |
647 | je32_to_cpu(node->d.node_crc), crc); | ||
627 | goto bail; | 648 | goto bail; |
628 | } | 649 | } |
629 | 650 | ||
630 | if (strnlen(node->d.name, node->d.nsize) != node->d.nsize) { | 651 | if (strnlen(node->d.name, node->d.nsize) != node->d.nsize) { |
631 | printk(KERN_WARNING "Name in dirent node at 0x%08x contains zeroes\n", ref_offset(raw)); | 652 | pr_warn("Name in dirent node at 0x%08x contains zeroes\n", |
653 | ref_offset(raw)); | ||
632 | goto bail; | 654 | goto bail; |
633 | } | 655 | } |
634 | 656 | ||
635 | if (node->d.nsize) { | 657 | if (node->d.nsize) { |
636 | crc = crc32(0, node->d.name, node->d.nsize); | 658 | crc = crc32(0, node->d.name, node->d.nsize); |
637 | if (je32_to_cpu(node->d.name_crc) != crc) { | 659 | if (je32_to_cpu(node->d.name_crc) != crc) { |
638 | printk(KERN_WARNING "Name CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 660 | pr_warn("Name CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
639 | ref_offset(raw), je32_to_cpu(node->d.name_crc), crc); | 661 | ref_offset(raw), |
662 | je32_to_cpu(node->d.name_crc), crc); | ||
640 | goto bail; | 663 | goto bail; |
641 | } | 664 | } |
642 | } | 665 | } |
@@ -644,8 +667,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
644 | default: | 667 | default: |
645 | /* If it's inode-less, we don't _know_ what it is. Just copy it intact */ | 668 | /* If it's inode-less, we don't _know_ what it is. Just copy it intact */ |
646 | if (ic) { | 669 | if (ic) { |
647 | printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", | 670 | pr_warn("Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", |
648 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); | 671 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); |
649 | goto bail; | 672 | goto bail; |
650 | } | 673 | } |
651 | } | 674 | } |
@@ -657,12 +680,13 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
657 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); | 680 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); |
658 | 681 | ||
659 | if (ret || (retlen != rawlen)) { | 682 | if (ret || (retlen != rawlen)) { |
660 | printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", | 683 | pr_notice("Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", |
661 | rawlen, phys_ofs, ret, retlen); | 684 | rawlen, phys_ofs, ret, retlen); |
662 | if (retlen) { | 685 | if (retlen) { |
663 | jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); | 686 | jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); |
664 | } else { | 687 | } else { |
665 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", phys_ofs); | 688 | pr_notice("Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", |
689 | phys_ofs); | ||
666 | } | 690 | } |
667 | if (!retried) { | 691 | if (!retried) { |
668 | /* Try to reallocate space and retry */ | 692 | /* Try to reallocate space and retry */ |
@@ -671,7 +695,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
671 | 695 | ||
672 | retried = 1; | 696 | retried = 1; |
673 | 697 | ||
674 | D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n")); | 698 | jffs2_dbg(1, "Retrying failed write of REF_PRISTINE node.\n"); |
675 | 699 | ||
676 | jffs2_dbg_acct_sanity_check(c,jeb); | 700 | jffs2_dbg_acct_sanity_check(c,jeb); |
677 | jffs2_dbg_acct_paranoia_check(c, jeb); | 701 | jffs2_dbg_acct_paranoia_check(c, jeb); |
@@ -681,14 +705,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
681 | it is only an upper estimation */ | 705 | it is only an upper estimation */ |
682 | 706 | ||
683 | if (!ret) { | 707 | if (!ret) { |
684 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", phys_ofs)); | 708 | jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n", |
709 | phys_ofs); | ||
685 | 710 | ||
686 | jffs2_dbg_acct_sanity_check(c,jeb); | 711 | jffs2_dbg_acct_sanity_check(c,jeb); |
687 | jffs2_dbg_acct_paranoia_check(c, jeb); | 712 | jffs2_dbg_acct_paranoia_check(c, jeb); |
688 | 713 | ||
689 | goto retry; | 714 | goto retry; |
690 | } | 715 | } |
691 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); | 716 | jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n", |
717 | ret); | ||
692 | } | 718 | } |
693 | 719 | ||
694 | if (!ret) | 720 | if (!ret) |
@@ -698,7 +724,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
698 | jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); | 724 | jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); |
699 | 725 | ||
700 | jffs2_mark_node_obsolete(c, raw); | 726 | jffs2_mark_node_obsolete(c, raw); |
701 | D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); | 727 | jffs2_dbg(1, "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", |
728 | ref_offset(raw)); | ||
702 | 729 | ||
703 | out_node: | 730 | out_node: |
704 | kfree(node); | 731 | kfree(node); |
@@ -725,29 +752,32 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
725 | /* For these, we don't actually need to read the old node */ | 752 | /* For these, we don't actually need to read the old node */ |
726 | mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f)); | 753 | mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f)); |
727 | mdata = (char *)&dev; | 754 | mdata = (char *)&dev; |
728 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bytes of kdev_t\n", mdatalen)); | 755 | jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n", |
756 | __func__, mdatalen); | ||
729 | } else if (S_ISLNK(JFFS2_F_I_MODE(f))) { | 757 | } else if (S_ISLNK(JFFS2_F_I_MODE(f))) { |
730 | mdatalen = fn->size; | 758 | mdatalen = fn->size; |
731 | mdata = kmalloc(fn->size, GFP_KERNEL); | 759 | mdata = kmalloc(fn->size, GFP_KERNEL); |
732 | if (!mdata) { | 760 | if (!mdata) { |
733 | printk(KERN_WARNING "kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n"); | 761 | pr_warn("kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n"); |
734 | return -ENOMEM; | 762 | return -ENOMEM; |
735 | } | 763 | } |
736 | ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen); | 764 | ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen); |
737 | if (ret) { | 765 | if (ret) { |
738 | printk(KERN_WARNING "read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", ret); | 766 | pr_warn("read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", |
767 | ret); | ||
739 | kfree(mdata); | 768 | kfree(mdata); |
740 | return ret; | 769 | return ret; |
741 | } | 770 | } |
742 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen)); | 771 | jffs2_dbg(1, "%s(): Writing %d bites of symlink target\n", |
772 | __func__, mdatalen); | ||
743 | 773 | ||
744 | } | 774 | } |
745 | 775 | ||
746 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen, | 776 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen, |
747 | JFFS2_SUMMARY_INODE_SIZE); | 777 | JFFS2_SUMMARY_INODE_SIZE); |
748 | if (ret) { | 778 | if (ret) { |
749 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", | 779 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", |
750 | sizeof(ri)+ mdatalen, ret); | 780 | sizeof(ri) + mdatalen, ret); |
751 | goto out; | 781 | goto out; |
752 | } | 782 | } |
753 | 783 | ||
@@ -784,7 +814,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
784 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC); | 814 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC); |
785 | 815 | ||
786 | if (IS_ERR(new_fn)) { | 816 | if (IS_ERR(new_fn)) { |
787 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); | 817 | pr_warn("Error writing new dnode: %ld\n", PTR_ERR(new_fn)); |
788 | ret = PTR_ERR(new_fn); | 818 | ret = PTR_ERR(new_fn); |
789 | goto out; | 819 | goto out; |
790 | } | 820 | } |
@@ -827,14 +857,15 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er | |||
827 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen, | 857 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen, |
828 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); | 858 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); |
829 | if (ret) { | 859 | if (ret) { |
830 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", | 860 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", |
831 | sizeof(rd)+rd.nsize, ret); | 861 | sizeof(rd)+rd.nsize, ret); |
832 | return ret; | 862 | return ret; |
833 | } | 863 | } |
834 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC); | 864 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC); |
835 | 865 | ||
836 | if (IS_ERR(new_fd)) { | 866 | if (IS_ERR(new_fd)) { |
837 | printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd)); | 867 | pr_warn("jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", |
868 | PTR_ERR(new_fd)); | ||
838 | return PTR_ERR(new_fd); | 869 | return PTR_ERR(new_fd); |
839 | } | 870 | } |
840 | jffs2_add_fd_to_list(c, new_fd, &f->dents); | 871 | jffs2_add_fd_to_list(c, new_fd, &f->dents); |
@@ -887,19 +918,22 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
887 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) | 918 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) |
888 | continue; | 919 | continue; |
889 | 920 | ||
890 | D1(printk(KERN_DEBUG "Check potential deletion dirent at %08x\n", ref_offset(raw))); | 921 | jffs2_dbg(1, "Check potential deletion dirent at %08x\n", |
922 | ref_offset(raw)); | ||
891 | 923 | ||
892 | /* This is an obsolete node belonging to the same directory, and it's of the right | 924 | /* This is an obsolete node belonging to the same directory, and it's of the right |
893 | length. We need to take a closer look...*/ | 925 | length. We need to take a closer look...*/ |
894 | ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd); | 926 | ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd); |
895 | if (ret) { | 927 | if (ret) { |
896 | printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Read error (%d) reading obsolete node at %08x\n", ret, ref_offset(raw)); | 928 | pr_warn("%s(): Read error (%d) reading obsolete node at %08x\n", |
929 | __func__, ret, ref_offset(raw)); | ||
897 | /* If we can't read it, we don't need to continue to obsolete it. Continue */ | 930 | /* If we can't read it, we don't need to continue to obsolete it. Continue */ |
898 | continue; | 931 | continue; |
899 | } | 932 | } |
900 | if (retlen != rawlen) { | 933 | if (retlen != rawlen) { |
901 | printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Short read (%zd not %u) reading header from obsolete node at %08x\n", | 934 | pr_warn("%s(): Short read (%zd not %u) reading header from obsolete node at %08x\n", |
902 | retlen, rawlen, ref_offset(raw)); | 935 | __func__, retlen, rawlen, |
936 | ref_offset(raw)); | ||
903 | continue; | 937 | continue; |
904 | } | 938 | } |
905 | 939 | ||
@@ -923,8 +957,9 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
923 | a new deletion dirent to replace it */ | 957 | a new deletion dirent to replace it */ |
924 | mutex_unlock(&c->erase_free_sem); | 958 | mutex_unlock(&c->erase_free_sem); |
925 | 959 | ||
926 | D1(printk(KERN_DEBUG "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", | 960 | jffs2_dbg(1, "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", |
927 | ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino))); | 961 | ref_offset(fd->raw), fd->name, |
962 | ref_offset(raw), je32_to_cpu(rd->ino)); | ||
928 | kfree(rd); | 963 | kfree(rd); |
929 | 964 | ||
930 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); | 965 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); |
@@ -947,7 +982,8 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
947 | fdp = &(*fdp)->next; | 982 | fdp = &(*fdp)->next; |
948 | } | 983 | } |
949 | if (!found) { | 984 | if (!found) { |
950 | printk(KERN_WARNING "Deletion dirent \"%s\" not found in list for ino #%u\n", fd->name, f->inocache->ino); | 985 | pr_warn("Deletion dirent \"%s\" not found in list for ino #%u\n", |
986 | fd->name, f->inocache->ino); | ||
951 | } | 987 | } |
952 | jffs2_mark_node_obsolete(c, fd->raw); | 988 | jffs2_mark_node_obsolete(c, fd->raw); |
953 | jffs2_free_full_dirent(fd); | 989 | jffs2_free_full_dirent(fd); |
@@ -964,8 +1000,8 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
964 | uint32_t alloclen, ilen; | 1000 | uint32_t alloclen, ilen; |
965 | int ret; | 1001 | int ret; |
966 | 1002 | ||
967 | D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", | 1003 | jffs2_dbg(1, "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", |
968 | f->inocache->ino, start, end)); | 1004 | f->inocache->ino, start, end); |
969 | 1005 | ||
970 | memset(&ri, 0, sizeof(ri)); | 1006 | memset(&ri, 0, sizeof(ri)); |
971 | 1007 | ||
@@ -976,35 +1012,37 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
976 | write it out again with the _same_ version as before */ | 1012 | write it out again with the _same_ version as before */ |
977 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); | 1013 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); |
978 | if (readlen != sizeof(ri) || ret) { | 1014 | if (readlen != sizeof(ri) || ret) { |
979 | printk(KERN_WARNING "Node read failed in jffs2_garbage_collect_hole. Ret %d, retlen %zd. Data will be lost by writing new hole node\n", ret, readlen); | 1015 | pr_warn("Node read failed in jffs2_garbage_collect_hole. Ret %d, retlen %zd. Data will be lost by writing new hole node\n", |
1016 | ret, readlen); | ||
980 | goto fill; | 1017 | goto fill; |
981 | } | 1018 | } |
982 | if (je16_to_cpu(ri.nodetype) != JFFS2_NODETYPE_INODE) { | 1019 | if (je16_to_cpu(ri.nodetype) != JFFS2_NODETYPE_INODE) { |
983 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had node type 0x%04x instead of JFFS2_NODETYPE_INODE(0x%04x)\n", | 1020 | pr_warn("%s(): Node at 0x%08x had node type 0x%04x instead of JFFS2_NODETYPE_INODE(0x%04x)\n", |
984 | ref_offset(fn->raw), | 1021 | __func__, ref_offset(fn->raw), |
985 | je16_to_cpu(ri.nodetype), JFFS2_NODETYPE_INODE); | 1022 | je16_to_cpu(ri.nodetype), JFFS2_NODETYPE_INODE); |
986 | return -EIO; | 1023 | return -EIO; |
987 | } | 1024 | } |
988 | if (je32_to_cpu(ri.totlen) != sizeof(ri)) { | 1025 | if (je32_to_cpu(ri.totlen) != sizeof(ri)) { |
989 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had totlen 0x%x instead of expected 0x%zx\n", | 1026 | pr_warn("%s(): Node at 0x%08x had totlen 0x%x instead of expected 0x%zx\n", |
990 | ref_offset(fn->raw), | 1027 | __func__, ref_offset(fn->raw), |
991 | je32_to_cpu(ri.totlen), sizeof(ri)); | 1028 | je32_to_cpu(ri.totlen), sizeof(ri)); |
992 | return -EIO; | 1029 | return -EIO; |
993 | } | 1030 | } |
994 | crc = crc32(0, &ri, sizeof(ri)-8); | 1031 | crc = crc32(0, &ri, sizeof(ri)-8); |
995 | if (crc != je32_to_cpu(ri.node_crc)) { | 1032 | if (crc != je32_to_cpu(ri.node_crc)) { |
996 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", | 1033 | pr_warn("%s: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", |
997 | ref_offset(fn->raw), | 1034 | __func__, ref_offset(fn->raw), |
998 | je32_to_cpu(ri.node_crc), crc); | 1035 | je32_to_cpu(ri.node_crc), crc); |
999 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ | 1036 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ |
1000 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 1037 | pr_warn("Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
1001 | start, end, f->inocache->ino); | 1038 | start, end, f->inocache->ino); |
1002 | goto fill; | 1039 | goto fill; |
1003 | } | 1040 | } |
1004 | if (ri.compr != JFFS2_COMPR_ZERO) { | 1041 | if (ri.compr != JFFS2_COMPR_ZERO) { |
1005 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw)); | 1042 | pr_warn("%s(): Node 0x%08x wasn't a hole node!\n", |
1006 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 1043 | __func__, ref_offset(fn->raw)); |
1007 | start, end, f->inocache->ino); | 1044 | pr_warn("Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
1045 | start, end, f->inocache->ino); | ||
1008 | goto fill; | 1046 | goto fill; |
1009 | } | 1047 | } |
1010 | } else { | 1048 | } else { |
@@ -1043,14 +1081,14 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1043 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen, | 1081 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen, |
1044 | JFFS2_SUMMARY_INODE_SIZE); | 1082 | JFFS2_SUMMARY_INODE_SIZE); |
1045 | if (ret) { | 1083 | if (ret) { |
1046 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", | 1084 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", |
1047 | sizeof(ri), ret); | 1085 | sizeof(ri), ret); |
1048 | return ret; | 1086 | return ret; |
1049 | } | 1087 | } |
1050 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC); | 1088 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC); |
1051 | 1089 | ||
1052 | if (IS_ERR(new_fn)) { | 1090 | if (IS_ERR(new_fn)) { |
1053 | printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn)); | 1091 | pr_warn("Error writing new hole node: %ld\n", PTR_ERR(new_fn)); |
1054 | return PTR_ERR(new_fn); | 1092 | return PTR_ERR(new_fn); |
1055 | } | 1093 | } |
1056 | if (je32_to_cpu(ri.version) == f->highest_version) { | 1094 | if (je32_to_cpu(ri.version) == f->highest_version) { |
@@ -1070,9 +1108,9 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1070 | * above.) | 1108 | * above.) |
1071 | */ | 1109 | */ |
1072 | D1(if(unlikely(fn->frags <= 1)) { | 1110 | D1(if(unlikely(fn->frags <= 1)) { |
1073 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Replacing fn with %d frag(s) but new ver %d != highest_version %d of ino #%d\n", | 1111 | pr_warn("%s(): Replacing fn with %d frag(s) but new ver %d != highest_version %d of ino #%d\n", |
1074 | fn->frags, je32_to_cpu(ri.version), f->highest_version, | 1112 | __func__, fn->frags, je32_to_cpu(ri.version), |
1075 | je32_to_cpu(ri.ino)); | 1113 | f->highest_version, je32_to_cpu(ri.ino)); |
1076 | }); | 1114 | }); |
1077 | 1115 | ||
1078 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ | 1116 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ |
@@ -1089,11 +1127,11 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1089 | } | 1127 | } |
1090 | } | 1128 | } |
1091 | if (fn->frags) { | 1129 | if (fn->frags) { |
1092 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Old node still has frags!\n"); | 1130 | pr_warn("%s(): Old node still has frags!\n", __func__); |
1093 | BUG(); | 1131 | BUG(); |
1094 | } | 1132 | } |
1095 | if (!new_fn->frags) { | 1133 | if (!new_fn->frags) { |
1096 | printk(KERN_WARNING "jffs2_garbage_collect_hole: New node has no frags!\n"); | 1134 | pr_warn("%s(): New node has no frags!\n", __func__); |
1097 | BUG(); | 1135 | BUG(); |
1098 | } | 1136 | } |
1099 | 1137 | ||
@@ -1117,8 +1155,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1117 | 1155 | ||
1118 | memset(&ri, 0, sizeof(ri)); | 1156 | memset(&ri, 0, sizeof(ri)); |
1119 | 1157 | ||
1120 | D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", | 1158 | jffs2_dbg(1, "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", |
1121 | f->inocache->ino, start, end)); | 1159 | f->inocache->ino, start, end); |
1122 | 1160 | ||
1123 | orig_end = end; | 1161 | orig_end = end; |
1124 | orig_start = start; | 1162 | orig_start = start; |
@@ -1149,15 +1187,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1149 | /* If the previous frag doesn't even reach the beginning, there's | 1187 | /* If the previous frag doesn't even reach the beginning, there's |
1150 | excessive fragmentation. Just merge. */ | 1188 | excessive fragmentation. Just merge. */ |
1151 | if (frag->ofs > min) { | 1189 | if (frag->ofs > min) { |
1152 | D1(printk(KERN_DEBUG "Expanding down to cover partial frag (0x%x-0x%x)\n", | 1190 | jffs2_dbg(1, "Expanding down to cover partial frag (0x%x-0x%x)\n", |
1153 | frag->ofs, frag->ofs+frag->size)); | 1191 | frag->ofs, frag->ofs+frag->size); |
1154 | start = frag->ofs; | 1192 | start = frag->ofs; |
1155 | continue; | 1193 | continue; |
1156 | } | 1194 | } |
1157 | /* OK. This frag holds the first byte of the page. */ | 1195 | /* OK. This frag holds the first byte of the page. */ |
1158 | if (!frag->node || !frag->node->raw) { | 1196 | if (!frag->node || !frag->node->raw) { |
1159 | D1(printk(KERN_DEBUG "First frag in page is hole (0x%x-0x%x). Not expanding down.\n", | 1197 | jffs2_dbg(1, "First frag in page is hole (0x%x-0x%x). Not expanding down.\n", |
1160 | frag->ofs, frag->ofs+frag->size)); | 1198 | frag->ofs, frag->ofs+frag->size); |
1161 | break; | 1199 | break; |
1162 | } else { | 1200 | } else { |
1163 | 1201 | ||
@@ -1171,19 +1209,25 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1171 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; | 1209 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; |
1172 | 1210 | ||
1173 | if (jeb == c->gcblock) { | 1211 | if (jeb == c->gcblock) { |
1174 | D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n", | 1212 | jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n", |
1175 | frag->ofs, frag->ofs+frag->size, ref_offset(raw))); | 1213 | frag->ofs, |
1214 | frag->ofs + frag->size, | ||
1215 | ref_offset(raw)); | ||
1176 | start = frag->ofs; | 1216 | start = frag->ofs; |
1177 | break; | 1217 | break; |
1178 | } | 1218 | } |
1179 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { | 1219 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { |
1180 | D1(printk(KERN_DEBUG "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n", | 1220 | jffs2_dbg(1, "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n", |
1181 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1221 | frag->ofs, |
1222 | frag->ofs + frag->size, | ||
1223 | jeb->offset); | ||
1182 | break; | 1224 | break; |
1183 | } | 1225 | } |
1184 | 1226 | ||
1185 | D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n", | 1227 | jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n", |
1186 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1228 | frag->ofs, |
1229 | frag->ofs + frag->size, | ||
1230 | jeb->offset); | ||
1187 | start = frag->ofs; | 1231 | start = frag->ofs; |
1188 | break; | 1232 | break; |
1189 | } | 1233 | } |
@@ -1199,15 +1243,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1199 | /* If the previous frag doesn't even reach the beginning, there's lots | 1243 | /* If the previous frag doesn't even reach the beginning, there's lots |
1200 | of fragmentation. Just merge. */ | 1244 | of fragmentation. Just merge. */ |
1201 | if (frag->ofs+frag->size < max) { | 1245 | if (frag->ofs+frag->size < max) { |
1202 | D1(printk(KERN_DEBUG "Expanding up to cover partial frag (0x%x-0x%x)\n", | 1246 | jffs2_dbg(1, "Expanding up to cover partial frag (0x%x-0x%x)\n", |
1203 | frag->ofs, frag->ofs+frag->size)); | 1247 | frag->ofs, frag->ofs+frag->size); |
1204 | end = frag->ofs + frag->size; | 1248 | end = frag->ofs + frag->size; |
1205 | continue; | 1249 | continue; |
1206 | } | 1250 | } |
1207 | 1251 | ||
1208 | if (!frag->node || !frag->node->raw) { | 1252 | if (!frag->node || !frag->node->raw) { |
1209 | D1(printk(KERN_DEBUG "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n", | 1253 | jffs2_dbg(1, "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n", |
1210 | frag->ofs, frag->ofs+frag->size)); | 1254 | frag->ofs, frag->ofs+frag->size); |
1211 | break; | 1255 | break; |
1212 | } else { | 1256 | } else { |
1213 | 1257 | ||
@@ -1221,25 +1265,31 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1221 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; | 1265 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; |
1222 | 1266 | ||
1223 | if (jeb == c->gcblock) { | 1267 | if (jeb == c->gcblock) { |
1224 | D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n", | 1268 | jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n", |
1225 | frag->ofs, frag->ofs+frag->size, ref_offset(raw))); | 1269 | frag->ofs, |
1270 | frag->ofs + frag->size, | ||
1271 | ref_offset(raw)); | ||
1226 | end = frag->ofs + frag->size; | 1272 | end = frag->ofs + frag->size; |
1227 | break; | 1273 | break; |
1228 | } | 1274 | } |
1229 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { | 1275 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { |
1230 | D1(printk(KERN_DEBUG "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n", | 1276 | jffs2_dbg(1, "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n", |
1231 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1277 | frag->ofs, |
1278 | frag->ofs + frag->size, | ||
1279 | jeb->offset); | ||
1232 | break; | 1280 | break; |
1233 | } | 1281 | } |
1234 | 1282 | ||
1235 | D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n", | 1283 | jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n", |
1236 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1284 | frag->ofs, |
1285 | frag->ofs + frag->size, | ||
1286 | jeb->offset); | ||
1237 | end = frag->ofs + frag->size; | 1287 | end = frag->ofs + frag->size; |
1238 | break; | 1288 | break; |
1239 | } | 1289 | } |
1240 | } | 1290 | } |
1241 | D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", | 1291 | jffs2_dbg(1, "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", |
1242 | orig_start, orig_end, start, end)); | 1292 | orig_start, orig_end, start, end); |
1243 | 1293 | ||
1244 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); | 1294 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); |
1245 | BUG_ON(end < orig_end); | 1295 | BUG_ON(end < orig_end); |
@@ -1256,7 +1306,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1256 | pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg); | 1306 | pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg); |
1257 | 1307 | ||
1258 | if (IS_ERR(pg_ptr)) { | 1308 | if (IS_ERR(pg_ptr)) { |
1259 | printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr)); | 1309 | pr_warn("read_cache_page() returned error: %ld\n", |
1310 | PTR_ERR(pg_ptr)); | ||
1260 | return PTR_ERR(pg_ptr); | 1311 | return PTR_ERR(pg_ptr); |
1261 | } | 1312 | } |
1262 | 1313 | ||
@@ -1270,8 +1321,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1270 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); | 1321 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); |
1271 | 1322 | ||
1272 | if (ret) { | 1323 | if (ret) { |
1273 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", | 1324 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", |
1274 | sizeof(ri)+ JFFS2_MIN_DATA_LEN, ret); | 1325 | sizeof(ri) + JFFS2_MIN_DATA_LEN, ret); |
1275 | break; | 1326 | break; |
1276 | } | 1327 | } |
1277 | cdatalen = min_t(uint32_t, alloclen - sizeof(ri), end - offset); | 1328 | cdatalen = min_t(uint32_t, alloclen - sizeof(ri), end - offset); |
@@ -1308,7 +1359,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1308 | jffs2_free_comprbuf(comprbuf, writebuf); | 1359 | jffs2_free_comprbuf(comprbuf, writebuf); |
1309 | 1360 | ||
1310 | if (IS_ERR(new_fn)) { | 1361 | if (IS_ERR(new_fn)) { |
1311 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); | 1362 | pr_warn("Error writing new dnode: %ld\n", |
1363 | PTR_ERR(new_fn)); | ||
1312 | ret = PTR_ERR(new_fn); | 1364 | ret = PTR_ERR(new_fn); |
1313 | break; | 1365 | break; |
1314 | } | 1366 | } |