[PATCH] x86_64: Don't invoke OOM killer during dma_alloc_coherent()
[linux-2.6/mini2440.git] / fs / jffs2 / summary.c
blobfb9cec61fcf2ebbe050d58669551ca311b6c7e70
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 2004 Ferenc Havasi <havasi@inf.u-szeged.hu>,
5 * Zoltan Sogor <weth@inf.u-szeged.hu>,
6 * Patrik Kluba <pajko@halom.u-szeged.hu>,
7 * University of Szeged, Hungary
9 * For licensing information, see the file 'LICENCE' in this directory.
11 * $Id: summary.c,v 1.4 2005/09/26 11:37:21 havasi Exp $
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/slab.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/pagemap.h>
20 #include <linux/crc32.h>
21 #include <linux/compiler.h>
22 #include <linux/vmalloc.h>
23 #include "nodelist.h"
24 #include "debug.h"
26 int jffs2_sum_init(struct jffs2_sb_info *c)
28 c->summary = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
30 if (!c->summary) {
31 JFFS2_WARNING("Can't allocate memory for summary information!\n");
32 return -ENOMEM;
35 memset(c->summary, 0, sizeof(struct jffs2_summary));
37 c->summary->sum_buf = vmalloc(c->sector_size);
39 if (!c->summary->sum_buf) {
40 JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n");
41 kfree(c->summary);
42 return -ENOMEM;
45 dbg_summary("returned succesfully\n");
47 return 0;
50 void jffs2_sum_exit(struct jffs2_sb_info *c)
52 dbg_summary("called\n");
54 jffs2_sum_disable_collecting(c->summary);
56 vfree(c->summary->sum_buf);
57 c->summary->sum_buf = NULL;
59 kfree(c->summary);
60 c->summary = NULL;
63 static int jffs2_sum_add_mem(struct jffs2_summary *s, union jffs2_sum_mem *item)
65 if (!s->sum_list_head)
66 s->sum_list_head = (union jffs2_sum_mem *) item;
67 if (s->sum_list_tail)
68 s->sum_list_tail->u.next = (union jffs2_sum_mem *) item;
69 s->sum_list_tail = (union jffs2_sum_mem *) item;
71 switch (je16_to_cpu(item->u.nodetype)) {
72 case JFFS2_NODETYPE_INODE:
73 s->sum_size += JFFS2_SUMMARY_INODE_SIZE;
74 s->sum_num++;
75 dbg_summary("inode (%u) added to summary\n",
76 je32_to_cpu(item->i.inode));
77 break;
78 case JFFS2_NODETYPE_DIRENT:
79 s->sum_size += JFFS2_SUMMARY_DIRENT_SIZE(item->d.nsize);
80 s->sum_num++;
81 dbg_summary("dirent (%u) added to summary\n",
82 je32_to_cpu(item->d.ino));
83 break;
84 default:
85 JFFS2_WARNING("UNKNOWN node type %u\n",
86 je16_to_cpu(item->u.nodetype));
87 return 1;
89 return 0;
93 /* The following 3 functions are called from scan.c to collect summary info for not closed jeb */
95 int jffs2_sum_add_padding_mem(struct jffs2_summary *s, uint32_t size)
97 dbg_summary("called with %u\n", size);
98 s->sum_padded += size;
99 return 0;
102 int jffs2_sum_add_inode_mem(struct jffs2_summary *s, struct jffs2_raw_inode *ri,
103 uint32_t ofs)
105 struct jffs2_sum_inode_mem *temp = kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
107 if (!temp)
108 return -ENOMEM;
110 temp->nodetype = ri->nodetype;
111 temp->inode = ri->ino;
112 temp->version = ri->version;
113 temp->offset = cpu_to_je32(ofs); /* relative offset from the begining of the jeb */
114 temp->totlen = ri->totlen;
115 temp->next = NULL;
117 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
120 int jffs2_sum_add_dirent_mem(struct jffs2_summary *s, struct jffs2_raw_dirent *rd,
121 uint32_t ofs)
123 struct jffs2_sum_dirent_mem *temp =
124 kmalloc(sizeof(struct jffs2_sum_dirent_mem) + rd->nsize, GFP_KERNEL);
126 if (!temp)
127 return -ENOMEM;
129 temp->nodetype = rd->nodetype;
130 temp->totlen = rd->totlen;
131 temp->offset = cpu_to_je32(ofs); /* relative from the begining of the jeb */
132 temp->pino = rd->pino;
133 temp->version = rd->version;
134 temp->ino = rd->ino;
135 temp->nsize = rd->nsize;
136 temp->type = rd->type;
137 temp->next = NULL;
139 memcpy(temp->name, rd->name, rd->nsize);
141 return jffs2_sum_add_mem(s, (union jffs2_sum_mem *)temp);
144 /* Cleanup every collected summary information */
146 static void jffs2_sum_clean_collected(struct jffs2_summary *s)
148 union jffs2_sum_mem *temp;
150 if (!s->sum_list_head) {
151 dbg_summary("already empty\n");
153 while (s->sum_list_head) {
154 temp = s->sum_list_head;
155 s->sum_list_head = s->sum_list_head->u.next;
156 kfree(temp);
158 s->sum_list_tail = NULL;
159 s->sum_padded = 0;
160 s->sum_num = 0;
163 void jffs2_sum_reset_collected(struct jffs2_summary *s)
165 dbg_summary("called\n");
166 jffs2_sum_clean_collected(s);
167 s->sum_size = 0;
170 void jffs2_sum_disable_collecting(struct jffs2_summary *s)
172 dbg_summary("called\n");
173 jffs2_sum_clean_collected(s);
174 s->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
177 int jffs2_sum_is_disabled(struct jffs2_summary *s)
179 return (s->sum_size == JFFS2_SUMMARY_NOSUM_SIZE);
182 /* Move the collected summary information into sb (called from scan.c) */
184 void jffs2_sum_move_collected(struct jffs2_sb_info *c, struct jffs2_summary *s)
186 dbg_summary("oldsize=0x%x oldnum=%u => newsize=0x%x newnum=%u\n",
187 c->summary->sum_size, c->summary->sum_num,
188 s->sum_size, s->sum_num);
190 c->summary->sum_size = s->sum_size;
191 c->summary->sum_num = s->sum_num;
192 c->summary->sum_padded = s->sum_padded;
193 c->summary->sum_list_head = s->sum_list_head;
194 c->summary->sum_list_tail = s->sum_list_tail;
196 s->sum_list_head = s->sum_list_tail = NULL;
199 /* Called from wbuf.c to collect writed node info */
201 int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
202 unsigned long count, uint32_t ofs)
204 union jffs2_node_union *node;
205 struct jffs2_eraseblock *jeb;
207 node = invecs[0].iov_base;
208 jeb = &c->blocks[ofs / c->sector_size];
209 ofs -= jeb->offset;
211 switch (je16_to_cpu(node->u.nodetype)) {
212 case JFFS2_NODETYPE_INODE: {
213 struct jffs2_sum_inode_mem *temp =
214 kmalloc(sizeof(struct jffs2_sum_inode_mem), GFP_KERNEL);
216 if (!temp)
217 goto no_mem;
219 temp->nodetype = node->i.nodetype;
220 temp->inode = node->i.ino;
221 temp->version = node->i.version;
222 temp->offset = cpu_to_je32(ofs);
223 temp->totlen = node->i.totlen;
224 temp->next = NULL;
226 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
229 case JFFS2_NODETYPE_DIRENT: {
230 struct jffs2_sum_dirent_mem *temp =
231 kmalloc(sizeof(struct jffs2_sum_dirent_mem) + node->d.nsize, GFP_KERNEL);
233 if (!temp)
234 goto no_mem;
236 temp->nodetype = node->d.nodetype;
237 temp->totlen = node->d.totlen;
238 temp->offset = cpu_to_je32(ofs);
239 temp->pino = node->d.pino;
240 temp->version = node->d.version;
241 temp->ino = node->d.ino;
242 temp->nsize = node->d.nsize;
243 temp->type = node->d.type;
244 temp->next = NULL;
246 switch (count) {
247 case 1:
248 memcpy(temp->name,node->d.name,node->d.nsize);
249 break;
251 case 2:
252 memcpy(temp->name,invecs[1].iov_base,node->d.nsize);
253 break;
255 default:
256 BUG(); /* impossible count value */
257 break;
260 return jffs2_sum_add_mem(c->summary, (union jffs2_sum_mem *)temp);
263 case JFFS2_NODETYPE_PADDING:
264 dbg_summary("node PADDING\n");
265 c->summary->sum_padded += je32_to_cpu(node->u.totlen);
266 break;
268 case JFFS2_NODETYPE_CLEANMARKER:
269 dbg_summary("node CLEANMARKER\n");
270 break;
272 case JFFS2_NODETYPE_SUMMARY:
273 dbg_summary("node SUMMARY\n");
274 break;
276 default:
277 /* If you implement a new node type you should also implement
278 summary support for it or disable summary.
280 BUG();
281 break;
284 return 0;
286 no_mem:
287 JFFS2_WARNING("MEMORY ALLOCATION ERROR!");
288 return -ENOMEM;
292 /* Process the stored summary information - helper function for jffs2_sum_scan_sumnode() */
294 static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
295 struct jffs2_raw_summary *summary, uint32_t *pseudo_random)
297 struct jffs2_raw_node_ref *raw;
298 struct jffs2_inode_cache *ic;
299 struct jffs2_full_dirent *fd;
300 void *sp;
301 int i, ino;
303 sp = summary->sum;
305 for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
306 dbg_summary("processing summary index %d\n", i);
308 switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) {
309 case JFFS2_NODETYPE_INODE: {
310 struct jffs2_sum_inode_flash *spi;
311 spi = sp;
313 ino = je32_to_cpu(spi->inode);
315 dbg_summary("Inode at 0x%08x\n",
316 jeb->offset + je32_to_cpu(spi->offset));
318 raw = jffs2_alloc_raw_node_ref();
319 if (!raw) {
320 JFFS2_NOTICE("allocation of node reference failed\n");
321 kfree(summary);
322 return -ENOMEM;
325 ic = jffs2_scan_make_ino_cache(c, ino);
326 if (!ic) {
327 JFFS2_NOTICE("scan_make_ino_cache failed\n");
328 jffs2_free_raw_node_ref(raw);
329 kfree(summary);
330 return -ENOMEM;
333 raw->flash_offset = (jeb->offset + je32_to_cpu(spi->offset)) | REF_UNCHECKED;
334 raw->__totlen = PAD(je32_to_cpu(spi->totlen));
335 raw->next_phys = NULL;
336 raw->next_in_ino = ic->nodes;
338 ic->nodes = raw;
339 if (!jeb->first_node)
340 jeb->first_node = raw;
341 if (jeb->last_node)
342 jeb->last_node->next_phys = raw;
343 jeb->last_node = raw;
344 *pseudo_random += je32_to_cpu(spi->version);
346 UNCHECKED_SPACE(PAD(je32_to_cpu(spi->totlen)));
348 sp += JFFS2_SUMMARY_INODE_SIZE;
350 break;
353 case JFFS2_NODETYPE_DIRENT: {
354 struct jffs2_sum_dirent_flash *spd;
355 spd = sp;
357 dbg_summary("Dirent at 0x%08x\n",
358 jeb->offset + je32_to_cpu(spd->offset));
360 fd = jffs2_alloc_full_dirent(spd->nsize+1);
361 if (!fd) {
362 kfree(summary);
363 return -ENOMEM;
366 memcpy(&fd->name, spd->name, spd->nsize);
367 fd->name[spd->nsize] = 0;
369 raw = jffs2_alloc_raw_node_ref();
370 if (!raw) {
371 jffs2_free_full_dirent(fd);
372 JFFS2_NOTICE("allocation of node reference failed\n");
373 kfree(summary);
374 return -ENOMEM;
377 ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(spd->pino));
378 if (!ic) {
379 jffs2_free_full_dirent(fd);
380 jffs2_free_raw_node_ref(raw);
381 kfree(summary);
382 return -ENOMEM;
385 raw->__totlen = PAD(je32_to_cpu(spd->totlen));
386 raw->flash_offset = (jeb->offset + je32_to_cpu(spd->offset)) | REF_PRISTINE;
387 raw->next_phys = NULL;
388 raw->next_in_ino = ic->nodes;
389 ic->nodes = raw;
390 if (!jeb->first_node)
391 jeb->first_node = raw;
392 if (jeb->last_node)
393 jeb->last_node->next_phys = raw;
394 jeb->last_node = raw;
396 fd->raw = raw;
397 fd->next = NULL;
398 fd->version = je32_to_cpu(spd->version);
399 fd->ino = je32_to_cpu(spd->ino);
400 fd->nhash = full_name_hash(fd->name, spd->nsize);
401 fd->type = spd->type;
402 USED_SPACE(PAD(je32_to_cpu(spd->totlen)));
403 jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
405 *pseudo_random += je32_to_cpu(spd->version);
407 sp += JFFS2_SUMMARY_DIRENT_SIZE(spd->nsize);
409 break;
412 default : {
413 JFFS2_WARNING("Unsupported node type found in summary! Exiting...");
414 kfree(summary);
415 return -EIO;
420 kfree(summary);
421 return 0;
424 /* Process the summary node - called from jffs2_scan_eraseblock() */
426 int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
427 uint32_t ofs, uint32_t *pseudo_random)
429 struct jffs2_unknown_node crcnode;
430 struct jffs2_raw_node_ref *cache_ref;
431 struct jffs2_raw_summary *summary;
432 int ret, sumsize;
433 uint32_t crc;
435 sumsize = c->sector_size - ofs;
436 ofs += jeb->offset;
438 dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n",
439 jeb->offset, ofs, sumsize);
441 summary = kmalloc(sumsize, GFP_KERNEL);
443 if (!summary) {
444 return -ENOMEM;
447 ret = jffs2_fill_scan_buf(c, (unsigned char *)summary, ofs, sumsize);
449 if (ret) {
450 kfree(summary);
451 return ret;
454 /* OK, now check for node validity and CRC */
455 crcnode.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
456 crcnode.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
457 crcnode.totlen = summary->totlen;
458 crc = crc32(0, &crcnode, sizeof(crcnode)-4);
460 if (je32_to_cpu(summary->hdr_crc) != crc) {
461 dbg_summary("Summary node header is corrupt (bad CRC or "
462 "no summary at all)\n");
463 goto crc_err;
466 if (je32_to_cpu(summary->totlen) != sumsize) {
467 dbg_summary("Summary node is corrupt (wrong erasesize?)\n");
468 goto crc_err;
471 crc = crc32(0, summary, sizeof(struct jffs2_raw_summary)-8);
473 if (je32_to_cpu(summary->node_crc) != crc) {
474 dbg_summary("Summary node is corrupt (bad CRC)\n");
475 goto crc_err;
478 crc = crc32(0, summary->sum, sumsize - sizeof(struct jffs2_raw_summary));
480 if (je32_to_cpu(summary->sum_crc) != crc) {
481 dbg_summary("Summary node data is corrupt (bad CRC)\n");
482 goto crc_err;
485 if ( je32_to_cpu(summary->cln_mkr) ) {
487 dbg_summary("Summary : CLEANMARKER node \n");
489 if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
490 dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
491 je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
492 UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
493 } else if (jeb->first_node) {
494 dbg_summary("CLEANMARKER node not first node in block "
495 "(0x%08x)\n", jeb->offset);
496 UNCHECKED_SPACE(PAD(je32_to_cpu(summary->cln_mkr)));
497 } else {
498 struct jffs2_raw_node_ref *marker_ref = jffs2_alloc_raw_node_ref();
500 if (!marker_ref) {
501 JFFS2_NOTICE("Failed to allocate node ref for clean marker\n");
502 kfree(summary);
503 return -ENOMEM;
506 marker_ref->next_in_ino = NULL;
507 marker_ref->next_phys = NULL;
508 marker_ref->flash_offset = jeb->offset | REF_NORMAL;
509 marker_ref->__totlen = je32_to_cpu(summary->cln_mkr);
510 jeb->first_node = jeb->last_node = marker_ref;
512 USED_SPACE( PAD(je32_to_cpu(summary->cln_mkr)) );
516 if (je32_to_cpu(summary->padded)) {
517 DIRTY_SPACE(je32_to_cpu(summary->padded));
520 ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random);
521 if (ret)
522 return ret;
524 /* for PARANOIA_CHECK */
525 cache_ref = jffs2_alloc_raw_node_ref();
527 if (!cache_ref) {
528 JFFS2_NOTICE("Failed to allocate node ref for cache\n");
529 return -ENOMEM;
532 cache_ref->next_in_ino = NULL;
533 cache_ref->next_phys = NULL;
534 cache_ref->flash_offset = ofs | REF_NORMAL;
535 cache_ref->__totlen = sumsize;
537 if (!jeb->first_node)
538 jeb->first_node = cache_ref;
539 if (jeb->last_node)
540 jeb->last_node->next_phys = cache_ref;
541 jeb->last_node = cache_ref;
543 USED_SPACE(sumsize);
545 jeb->wasted_size += jeb->free_size;
546 c->wasted_size += jeb->free_size;
547 c->free_size -= jeb->free_size;
548 jeb->free_size = 0;
550 return jffs2_scan_classify_jeb(c, jeb);
552 crc_err:
553 JFFS2_WARNING("Summary node crc error, skipping summary information.\n");
555 return 0;
558 /* Write summary data to flash - helper function for jffs2_sum_write_sumnode() */
560 static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
561 uint32_t infosize, uint32_t datasize, int padsize)
563 struct jffs2_raw_summary isum;
564 union jffs2_sum_mem *temp;
565 struct jffs2_sum_marker *sm;
566 struct kvec vecs[2];
567 void *wpage;
568 int ret;
569 size_t retlen;
571 memset(c->summary->sum_buf, 0xff, datasize);
572 memset(&isum, 0, sizeof(isum));
574 isum.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
575 isum.nodetype = cpu_to_je16(JFFS2_NODETYPE_SUMMARY);
576 isum.totlen = cpu_to_je32(infosize);
577 isum.hdr_crc = cpu_to_je32(crc32(0, &isum, sizeof(struct jffs2_unknown_node) - 4));
578 isum.padded = cpu_to_je32(c->summary->sum_padded);
579 isum.cln_mkr = cpu_to_je32(c->cleanmarker_size);
580 isum.sum_num = cpu_to_je32(c->summary->sum_num);
581 wpage = c->summary->sum_buf;
583 while (c->summary->sum_num) {
585 switch (je16_to_cpu(c->summary->sum_list_head->u.nodetype)) {
586 case JFFS2_NODETYPE_INODE: {
587 struct jffs2_sum_inode_flash *sino_ptr = wpage;
589 sino_ptr->nodetype = c->summary->sum_list_head->i.nodetype;
590 sino_ptr->inode = c->summary->sum_list_head->i.inode;
591 sino_ptr->version = c->summary->sum_list_head->i.version;
592 sino_ptr->offset = c->summary->sum_list_head->i.offset;
593 sino_ptr->totlen = c->summary->sum_list_head->i.totlen;
595 wpage += JFFS2_SUMMARY_INODE_SIZE;
597 break;
600 case JFFS2_NODETYPE_DIRENT: {
601 struct jffs2_sum_dirent_flash *sdrnt_ptr = wpage;
603 sdrnt_ptr->nodetype = c->summary->sum_list_head->d.nodetype;
604 sdrnt_ptr->totlen = c->summary->sum_list_head->d.totlen;
605 sdrnt_ptr->offset = c->summary->sum_list_head->d.offset;
606 sdrnt_ptr->pino = c->summary->sum_list_head->d.pino;
607 sdrnt_ptr->version = c->summary->sum_list_head->d.version;
608 sdrnt_ptr->ino = c->summary->sum_list_head->d.ino;
609 sdrnt_ptr->nsize = c->summary->sum_list_head->d.nsize;
610 sdrnt_ptr->type = c->summary->sum_list_head->d.type;
612 memcpy(sdrnt_ptr->name, c->summary->sum_list_head->d.name,
613 c->summary->sum_list_head->d.nsize);
615 wpage += JFFS2_SUMMARY_DIRENT_SIZE(c->summary->sum_list_head->d.nsize);
617 break;
620 default : {
621 BUG(); /* unknown node in summary information */
625 temp = c->summary->sum_list_head;
626 c->summary->sum_list_head = c->summary->sum_list_head->u.next;
627 kfree(temp);
629 c->summary->sum_num--;
632 jffs2_sum_reset_collected(c->summary);
634 wpage += padsize;
636 sm = wpage;
637 sm->offset = cpu_to_je32(c->sector_size - jeb->free_size);
638 sm->magic = cpu_to_je32(JFFS2_SUM_MAGIC);
640 isum.sum_crc = cpu_to_je32(crc32(0, c->summary->sum_buf, datasize));
641 isum.node_crc = cpu_to_je32(crc32(0, &isum, sizeof(isum) - 8));
643 vecs[0].iov_base = &isum;
644 vecs[0].iov_len = sizeof(isum);
645 vecs[1].iov_base = c->summary->sum_buf;
646 vecs[1].iov_len = datasize;
648 dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n",
649 jeb->offset + c->sector_size - jeb->free_size);
651 spin_unlock(&c->erase_completion_lock);
652 ret = jffs2_flash_writev(c, vecs, 2, jeb->offset + c->sector_size -
653 jeb->free_size, &retlen, 0);
654 spin_lock(&c->erase_completion_lock);
657 if (ret || (retlen != infosize)) {
658 JFFS2_WARNING("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n",
659 infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen);
661 c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
662 WASTED_SPACE(infosize);
664 return 1;
667 return 0;
670 /* Write out summary information - called from jffs2_do_reserve_space */
672 int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
674 struct jffs2_raw_node_ref *summary_ref;
675 int datasize, infosize, padsize, ret;
676 struct jffs2_eraseblock *jeb;
678 dbg_summary("called\n");
680 jeb = c->nextblock;
682 if (!c->summary->sum_num || !c->summary->sum_list_head) {
683 JFFS2_WARNING("Empty summary info!!!\n");
684 BUG();
687 datasize = c->summary->sum_size + sizeof(struct jffs2_sum_marker);
688 infosize = sizeof(struct jffs2_raw_summary) + datasize;
689 padsize = jeb->free_size - infosize;
690 infosize += padsize;
691 datasize += padsize;
693 /* Is there enough space for summary? */
694 if (padsize < 0) {
695 /* don't try to write out summary for this jeb */
696 jffs2_sum_disable_collecting(c->summary);
698 JFFS2_WARNING("Not enough space for summary, padsize = %d\n", padsize);
699 return 0;
702 ret = jffs2_sum_write_data(c, jeb, infosize, datasize, padsize);
703 if (ret)
704 return 0; /* can't write out summary, block is marked as NOSUM_SIZE */
706 /* for ACCT_PARANOIA_CHECK */
707 spin_unlock(&c->erase_completion_lock);
708 summary_ref = jffs2_alloc_raw_node_ref();
709 spin_lock(&c->erase_completion_lock);
711 if (!summary_ref) {
712 JFFS2_NOTICE("Failed to allocate node ref for summary\n");
713 return -ENOMEM;
716 summary_ref->next_in_ino = NULL;
717 summary_ref->next_phys = NULL;
718 summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL;
719 summary_ref->__totlen = infosize;
721 if (!jeb->first_node)
722 jeb->first_node = summary_ref;
723 if (jeb->last_node)
724 jeb->last_node->next_phys = summary_ref;
725 jeb->last_node = summary_ref;
727 USED_SPACE(infosize);
729 return 0;