aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/summary.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/summary.c')
-rw-r--r--fs/jffs2/summary.c53
1 files changed, 27 insertions, 26 deletions
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