sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file
[safe/jmp/linux-2.6] / fs / jffs2 / summary.c
index 351ba9f..6caf1e1 100644 (file)
@@ -1,20 +1,17 @@
 /*
  * JFFS2 -- Journalling Flash File System, Version 2.
  *
- * Copyright (C) 2004  Ferenc Havasi <havasi@inf.u-szeged.hu>,
- *                     Zoltan Sogor <weth@inf.u-szeged.hu>,
- *                     Patrik Kluba <pajko@halom.u-szeged.hu>,
- *                     University of Szeged, Hungary
- *               2005  KaiGai Kohei <kaigai@ak.jp.nec.com>
+ * Copyright © 2004  Ferenc Havasi <havasi@inf.u-szeged.hu>,
+ *                  Zoltan Sogor <weth@inf.u-szeged.hu>,
+ *                  Patrik Kluba <pajko@halom.u-szeged.hu>,
+ *                  University of Szeged, Hungary
+ *            2006  KaiGai Kohei <kaigai@ak.jp.nec.com>
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: summary.c,v 1.4 2005/09/26 11:37:21 havasi Exp $
- *
  */
 
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/mtd/mtd.h>
 #include <linux/pagemap.h>
 
 int jffs2_sum_init(struct jffs2_sb_info *c)
 {
-       c->summary = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
+       uint32_t sum_size = max_t(uint32_t, c->sector_size, MAX_SUMMARY_SIZE);
+
+       c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
 
        if (!c->summary) {
                JFFS2_WARNING("Can't allocate memory for summary information!\n");
                return -ENOMEM;
        }
 
-       memset(c->summary, 0, sizeof(struct jffs2_summary));
-
-       c->summary->sum_buf = vmalloc(c->sector_size);
+       c->summary->sum_buf = kmalloc(sum_size, GFP_KERNEL);
 
        if (!c->summary->sum_buf) {
                JFFS2_WARNING("Can't allocate buffer for writing out summary information!\n");
@@ -43,7 +40,7 @@ int jffs2_sum_init(struct jffs2_sb_info *c)
                return -ENOMEM;
        }
 
-       dbg_summary("returned succesfully\n");
+       dbg_summary("returned successfully\n");
 
        return 0;
 }
@@ -54,7 +51,7 @@ void jffs2_sum_exit(struct jffs2_sb_info *c)
 
        jffs2_sum_disable_collecting(c->summary);
 
-       vfree(c->summary->sum_buf);
+       kfree(c->summary->sum_buf);
        c->summary->sum_buf = NULL;
 
        kfree(c->summary);
@@ -252,6 +249,11 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
        union jffs2_node_union *node;
        struct jffs2_eraseblock *jeb;
 
+       if (c->summary->sum_size == JFFS2_SUMMARY_NOSUM_SIZE) {
+               dbg_summary("Summary is disabled for this jeb! Skipping summary info!\n");
+               return 0;
+       }
+
        node = invecs[0].iov_base;
        jeb = &c->blocks[ofs / c->sector_size];
        ofs -= jeb->offset;
@@ -310,8 +312,6 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
 #ifdef CONFIG_JFFS2_FS_XATTR
                case JFFS2_NODETYPE_XATTR: {
                        struct jffs2_sum_xattr_mem *temp;
-                       if (je32_to_cpu(node->x.version) == 0xffffffff)
-                               return 0;
                        temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
                        if (!temp)
                                goto no_mem;
@@ -327,10 +327,6 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
                }
                case JFFS2_NODETYPE_XREF: {
                        struct jffs2_sum_xref_mem *temp;
-
-                       if (je32_to_cpu(node->r.ino) == 0xffffffff
-                           && je32_to_cpu(node->r.xid) == 0xffffffff)
-                               return 0;
                        temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
                        if (!temp)
                                goto no_mem;
@@ -369,22 +365,18 @@ no_mem:
        return -ENOMEM;
 }
 
-static struct jffs2_raw_node_ref *alloc_ref_at(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
-                                              uint32_t offset)
+static struct jffs2_raw_node_ref *sum_link_node_ref(struct jffs2_sb_info *c,
+                                                   struct jffs2_eraseblock *jeb,
+                                                   uint32_t ofs, uint32_t len,
+                                                   struct jffs2_inode_cache *ic)
 {
-       struct jffs2_raw_node_ref *ref;
        /* If there was a gap, mark it dirty */
-       if (offset > c->sector_size - jeb->free_size) {
-               int ret = jffs2_scan_dirty_space(c, jeb, offset - (c->sector_size - jeb->free_size));
-               if (ret)
-                       return NULL;
+       if ((ofs & ~3) > c->sector_size - jeb->free_size) {
+               /* Ew. Summary doesn't actually tell us explicitly about dirty space */
+               jffs2_scan_dirty_space(c, jeb, (ofs & ~3) - (c->sector_size - jeb->free_size));
        }
-       ref = jffs2_alloc_raw_node_ref();
-       if (!ref)
-               return NULL;
 
-       ref->flash_offset = jeb->offset + offset;
-       return ref;
+       return jffs2_link_node_ref(c, jeb, jeb->offset + ofs, len, ic);
 }
 
 /* Process the stored summary information - helper function for jffs2_sum_scan_sumnode() */
@@ -392,7 +384,6 @@ static struct jffs2_raw_node_ref *alloc_ref_at(struct jffs2_sb_info *c, struct j
 static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
                                struct jffs2_raw_summary *summary, uint32_t *pseudo_random)
 {
-       struct jffs2_raw_node_ref *raw;
        struct jffs2_inode_cache *ic;
        struct jffs2_full_dirent *fd;
        void *sp;
@@ -404,6 +395,13 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
        for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
                dbg_summary("processing summary index %d\n", i);
 
+               cond_resched();
+
+               /* Make sure there's a spare ref for dirty space */
+               err = jffs2_prealloc_raw_node_refs(c, jeb, 2);
+               if (err)
+                       return err;
+
                switch (je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)) {
                        case JFFS2_NODETYPE_INODE: {
                                struct jffs2_sum_inode_flash *spi;
@@ -413,24 +411,16 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
 
                                dbg_summary("Inode at 0x%08x-0x%08x\n",
                                            jeb->offset + je32_to_cpu(spi->offset),
-                                           jeb->offset + je32_to_cpu(spi->offset) + je32_to_cpu(spu->totlen));
-
-                               raw = alloc_ref_at(c, jeb, je32_to_cpu(spi->offset));
-                               if (!raw) {
-                                       JFFS2_NOTICE("allocation of node reference failed\n");
-                                       return -ENOMEM;
-                               }
+                                           jeb->offset + je32_to_cpu(spi->offset) + je32_to_cpu(spi->totlen));
 
                                ic = jffs2_scan_make_ino_cache(c, ino);
                                if (!ic) {
                                        JFFS2_NOTICE("scan_make_ino_cache failed\n");
-                                       jffs2_free_raw_node_ref(raw);
                                        return -ENOMEM;
                                }
 
-                               raw->flash_offset |= REF_UNCHECKED;
-
-                               jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)), ic);
+                               sum_link_node_ref(c, jeb, je32_to_cpu(spi->offset) | REF_UNCHECKED,
+                                                 PAD(je32_to_cpu(spi->totlen)), ic);
 
                                *pseudo_random += je32_to_cpu(spi->version);
 
@@ -441,42 +431,47 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
 
                        case JFFS2_NODETYPE_DIRENT: {
                                struct jffs2_sum_dirent_flash *spd;
+                               int checkedlen;
                                spd = sp;
 
-                               dbg_summary("Dirent at 0x%08x\n",
+                               dbg_summary("Dirent at 0x%08x-0x%08x\n",
                                            jeb->offset + je32_to_cpu(spd->offset),
                                            jeb->offset + je32_to_cpu(spd->offset) + je32_to_cpu(spd->totlen));
 
 
-                               fd = jffs2_alloc_full_dirent(spd->nsize+1);
-                               if (!fd)
-                                       return -ENOMEM;
+                               /* This should never happen, but https://dev.laptop.org/ticket/4184 */
+                               checkedlen = strnlen(spd->name, spd->nsize);
+                               if (!checkedlen) {
+                                       printk(KERN_ERR "Dirent at %08x has zero at start of name. Aborting mount.\n",
+                                              jeb->offset + je32_to_cpu(spd->offset));
+                                       return -EIO;
+                               }
+                               if (checkedlen < spd->nsize) {
+                                       printk(KERN_ERR "Dirent at %08x has zeroes in name. Truncating to %d chars\n",
+                                              jeb->offset + je32_to_cpu(spd->offset), checkedlen);
+                               }
 
-                               memcpy(&fd->name, spd->name, spd->nsize);
-                               fd->name[spd->nsize] = 0;
 
-                               raw = alloc_ref_at(c, jeb, je32_to_cpu(spd->offset));
-                               if (!raw) {
-                                       jffs2_free_full_dirent(fd);
-                                       JFFS2_NOTICE("allocation of node reference failed\n");
+                               fd = jffs2_alloc_full_dirent(checkedlen+1);
+                               if (!fd)
                                        return -ENOMEM;
-                               }
+
+                               memcpy(&fd->name, spd->name, checkedlen);
+                               fd->name[checkedlen] = 0;
 
                                ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(spd->pino));
                                if (!ic) {
                                        jffs2_free_full_dirent(fd);
-                                       jffs2_free_raw_node_ref(raw);
                                        return -ENOMEM;
                                }
 
-                               raw->flash_offset |= REF_PRISTINE;
-                               jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)), ic);
+                               fd->raw = sum_link_node_ref(c, jeb,  je32_to_cpu(spd->offset) | REF_UNCHECKED,
+                                                           PAD(je32_to_cpu(spd->totlen)), ic);
 
-                               fd->raw = raw;
                                fd->next = NULL;
                                fd->version = je32_to_cpu(spd->version);
                                fd->ino = je32_to_cpu(spd->ino);
-                               fd->nhash = full_name_hash(fd->name, spd->nsize);
+                               fd->nhash = full_name_hash(fd->name, checkedlen);
                                fd->type = spd->type;
 
                                jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
@@ -497,32 +492,23 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
                                            jeb->offset + je32_to_cpu(spx->offset),
                                            jeb->offset + je32_to_cpu(spx->offset) + je32_to_cpu(spx->totlen),
                                            je32_to_cpu(spx->xid), je32_to_cpu(spx->version));
-                               raw = alloc_ref_at(c, jeb, je32_to_cpu(spx->offset));
-                               if (!raw) {
-                                       JFFS2_NOTICE("allocation of node reference failed\n");
-                                       return -ENOMEM;
-                               }
+
                                xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid),
                                                                je32_to_cpu(spx->version));
-                               if (IS_ERR(xd)) {
-                                       jffs2_free_raw_node_ref(raw);
-                                       if (PTR_ERR(xd) == -EEXIST) {
-                                               /* a newer version of xd exists */
-                                               if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(spx->totlen))))
-                                                       return err;
-                                               sp += JFFS2_SUMMARY_XATTR_SIZE;
-                                               break;
-                                       }
-                                       JFFS2_NOTICE("allocation of xattr_datum failed\n");
+                               if (IS_ERR(xd))
                                        return PTR_ERR(xd);
+                               if (xd->version > je32_to_cpu(spx->version)) {
+                                       /* node is not the newest one */
+                                       struct jffs2_raw_node_ref *raw
+                                               = sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
+                                                                   PAD(je32_to_cpu(spx->totlen)), NULL);
+                                       raw->next_in_ino = xd->node->next_in_ino;
+                                       xd->node->next_in_ino = raw;
+                               } else {
+                                       xd->version = je32_to_cpu(spx->version);
+                                       sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
+                                                         PAD(je32_to_cpu(spx->totlen)), (void *)xd);
                                }
-                               xd->node = raw;
-
-                               raw->flash_offset |= REF_UNCHECKED;
-
-                               jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen)), NULL);
-                               /* FIXME */ raw->next_in_ino = (void *)xd;
-
                                *pseudo_random += je32_to_cpu(spx->xid);
                                sp += JFFS2_SUMMARY_XATTR_SIZE;
 
@@ -535,31 +521,21 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
                                spr = (struct jffs2_sum_xref_flash *)sp;
                                dbg_summary("xref at %#08x-%#08x\n",
                                            jeb->offset + je32_to_cpu(spr->offset),
-                                           jeb->offset + je32_to_cpu(spr->offset) + PAD(sizeof(struct jffs2_raw_xref)));
+                                           jeb->offset + je32_to_cpu(spr->offset) + 
+                                           (uint32_t)PAD(sizeof(struct jffs2_raw_xref)));
 
-                               raw = alloc_ref_at(c, jeb, je32_to_cpu(spr->offset));
-                               if (!raw) {
-                                       JFFS2_NOTICE("allocation of node reference failed\n");
-                                       return -ENOMEM;
-                               }
                                ref = jffs2_alloc_xattr_ref();
                                if (!ref) {
                                        JFFS2_NOTICE("allocation of xattr_datum failed\n");
-                                       jffs2_free_raw_node_ref(raw);
                                        return -ENOMEM;
                                }
-                               ref->ino = 0xfffffffe;
-                               ref->xid = 0xfffffffd;
-                               ref->node = raw;
                                ref->next = c->xref_temp;
                                c->xref_temp = ref;
 
-                               raw->flash_offset |= REF_UNCHECKED;
+                               sum_link_node_ref(c, jeb, je32_to_cpu(spr->offset) | REF_UNCHECKED,
+                                                 PAD(sizeof(struct jffs2_raw_xref)), (void *)ref);
 
-                               jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref)), NULL);
-                               /* FIXME */ raw->next_in_ino = (void *)ref;
-
-                               *pseudo_random += raw->flash_offset;
+                               *pseudo_random += ref->node->flash_offset;
                                sp += JFFS2_SUMMARY_XREF_SIZE;
 
                                break;
@@ -579,12 +555,11 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
                                jeb->wasted_size = jeb->used_size = jeb->dirty_size = 0;
                                jeb->free_size = c->sector_size;
 
-                               jffs2_free_all_node_refs(c, jeb);
+                               jffs2_free_jeb_node_refs(c, jeb);
                                return -ENOTRECOVERABLE;
                        }
                }
        }
-
        return 0;
 }
 
@@ -594,10 +569,8 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
                           uint32_t *pseudo_random)
 {
        struct jffs2_unknown_node crcnode;
-       struct jffs2_raw_node_ref *cache_ref;
        int ret, ofs;
        uint32_t crc;
-       int err;
 
        ofs = c->sector_size - sumsize;
 
@@ -639,27 +612,23 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
 
                dbg_summary("Summary : CLEANMARKER node \n");
 
+               ret = jffs2_prealloc_raw_node_refs(c, jeb, 1);
+               if (ret)
+                       return ret;
+
                if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
                        dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
                                je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
-                       if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
-                               return err;
+                       if ((ret = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
+                               return ret;
                } else if (jeb->first_node) {
                        dbg_summary("CLEANMARKER node not first node in block "
                                        "(0x%08x)\n", jeb->offset);
-                       if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
-                               return err;
+                       if ((ret = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
+                               return ret;
                } else {
-                       struct jffs2_raw_node_ref *marker_ref = jffs2_alloc_raw_node_ref();
-
-                       if (!marker_ref) {
-                               JFFS2_NOTICE("Failed to allocate node ref for clean marker\n");
-                               return -ENOMEM;
-                       }
-
-                       marker_ref->flash_offset = jeb->offset | REF_NORMAL;
-
-                       jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr), NULL);
+                       jffs2_link_node_ref(c, jeb, jeb->offset | REF_NORMAL,
+                                           je32_to_cpu(summary->cln_mkr), NULL);
                }
        }
 
@@ -672,16 +641,11 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
                return ret;             /* real error */
 
        /* for PARANOIA_CHECK */
-       cache_ref = alloc_ref_at(c, jeb, ofs);
-
-       if (!cache_ref) {
-               JFFS2_NOTICE("Failed to allocate node ref for cache\n");
-               return -ENOMEM;
-       }
-
-       cache_ref->flash_offset |= REF_NORMAL;
+       ret = jffs2_prealloc_raw_node_refs(c, jeb, 2);
+       if (ret)
+               return ret;
 
-       jffs2_link_node_ref(c, jeb, cache_ref, sumsize, NULL);
+       sum_link_node_ref(c, jeb, ofs | REF_NORMAL, sumsize, NULL);
 
        if (unlikely(jeb->free_size)) {
                JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n",
@@ -703,16 +667,37 @@ crc_err:
 /* Write summary data to flash - helper function for jffs2_sum_write_sumnode() */
 
 static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
-                                       uint32_t infosize, uint32_t datasize, int padsize)
+                               uint32_t infosize, uint32_t datasize, int padsize)
 {
        struct jffs2_raw_summary isum;
        union jffs2_sum_mem *temp;
        struct jffs2_sum_marker *sm;
        struct kvec vecs[2];
+       uint32_t sum_ofs;
        void *wpage;
        int ret;
        size_t retlen;
 
+       if (padsize + datasize > MAX_SUMMARY_SIZE) {
+               /* It won't fit in the buffer. Abort summary for this jeb */
+               jffs2_sum_disable_collecting(c->summary);
+
+               JFFS2_WARNING("Summary too big (%d data, %d pad) in eraseblock at %08x\n",
+                             datasize, padsize, jeb->offset);
+               /* Non-fatal */
+               return 0;
+       }
+       /* Is there enough space for summary? */
+       if (padsize < 0) {
+               /* don't try to write out summary for this jeb */
+               jffs2_sum_disable_collecting(c->summary);
+
+               JFFS2_WARNING("Not enough space for summary, padsize = %d\n",
+                             padsize);
+               /* Non-fatal */
+               return 0;
+       }
+
        memset(c->summary->sum_buf, 0xff, datasize);
        memset(&isum, 0, sizeof(isum));
 
@@ -821,36 +806,33 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
        vecs[1].iov_base = c->summary->sum_buf;
        vecs[1].iov_len = datasize;
 
+       sum_ofs = jeb->offset + c->sector_size - jeb->free_size;
+
        dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n",
-                       jeb->offset + c->sector_size - jeb->free_size);
+                   sum_ofs);
 
-       spin_unlock(&c->erase_completion_lock);
-       ret = jffs2_flash_writev(c, vecs, 2, jeb->offset + c->sector_size -
-                               jeb->free_size, &retlen, 0);
+       ret = jffs2_flash_writev(c, vecs, 2, sum_ofs, &retlen, 0);
 
        if (ret || (retlen != infosize)) {
-               struct jffs2_raw_node_ref *ref;
 
                JFFS2_WARNING("Write of %u bytes at 0x%08x failed. returned %d, retlen %zd\n",
-                       infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen);
+                             infosize, sum_ofs, ret, retlen);
 
-               /* Waste remaining space */
-               ref = jffs2_alloc_raw_node_ref();
-               if (ref) {
+               if (retlen) {
+                       /* Waste remaining space */
                        spin_lock(&c->erase_completion_lock);
-
-                       ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
-                       ref->flash_offset |= REF_OBSOLETE;
-
-                       jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size, NULL);
+                       jffs2_link_node_ref(c, jeb, sum_ofs | REF_OBSOLETE, infosize, NULL);
+                       spin_unlock(&c->erase_completion_lock);
                }
 
                c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
 
-               return 1;
+               return 0;
        }
 
        spin_lock(&c->erase_completion_lock);
+       jffs2_link_node_ref(c, jeb, sum_ofs | REF_NORMAL, infosize, NULL);
+       spin_unlock(&c->erase_completion_lock);
 
        return 0;
 }
@@ -859,13 +841,16 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
 
 int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
 {
-       struct jffs2_raw_node_ref *summary_ref;
-       int datasize, infosize, padsize, ret;
+       int datasize, infosize, padsize;
        struct jffs2_eraseblock *jeb;
+       int ret = 0;
 
        dbg_summary("called\n");
 
+       spin_unlock(&c->erase_completion_lock);
+
        jeb = c->nextblock;
+       jffs2_prealloc_raw_node_refs(c, jeb, 1);
 
        if (!c->summary->sum_num || !c->summary->sum_list_head) {
                JFFS2_WARNING("Empty summary info!!!\n");
@@ -878,32 +863,7 @@ int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
        infosize += padsize;
        datasize += padsize;
 
-       /* Is there enough space for summary? */
-       if (padsize < 0) {
-               /* don't try to write out summary for this jeb */
-               jffs2_sum_disable_collecting(c->summary);
-
-               JFFS2_WARNING("Not enough space for summary, padsize = %d\n", padsize);
-               return 0;
-       }
-
        ret = jffs2_sum_write_data(c, jeb, infosize, datasize, padsize);
-       if (ret)
-               return 0; /* can't write out summary, block is marked as NOSUM_SIZE */
-
-       /* for ACCT_PARANOIA_CHECK */
-       spin_unlock(&c->erase_completion_lock);
-       summary_ref = jffs2_alloc_raw_node_ref();
-
-       if (!summary_ref) {
-               JFFS2_NOTICE("Failed to allocate node ref for summary\n");
-               return -ENOMEM;
-       }
-
-       summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL;
-
        spin_lock(&c->erase_completion_lock);
-       jffs2_link_node_ref(c, jeb, summary_ref, infosize, NULL);
-
-       return 0;
+       return ret;
 }