[JFFS2] Add erase block summary support (mount time improvement)
[deliverable/linux.git] / fs / jffs2 / wbuf.c
index 316133c626b7424fc68ccfce9043c5d92c6e359d..86860dbc670c6ca3c0076e14eef16d8b8c1177a9 100644 (file)
@@ -9,7 +9,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: wbuf.c,v 1.92 2005/04/05 12:51:54 dedekind Exp $
+ * $Id: wbuf.c,v 1.98 2005/09/07 08:34:55 havasi Exp $
  *
  */
 
@@ -139,7 +139,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
 {
        D1(printk("About to refile bad block at %08x\n", jeb->offset));
 
-       D2(jffs2_dump_block_lists(c));
        /* File the existing block on the bad_used_list.... */
        if (c->nextblock == jeb)
                c->nextblock = NULL;
@@ -156,7 +155,6 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
                c->nr_erasing_blocks++;
                jffs2_erase_pending_trigger(c);
        }
-       D2(jffs2_dump_block_lists(c));
 
        /* Adjust its size counts accordingly */
        c->wasted_size += jeb->free_size;
@@ -164,8 +162,9 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock
        jeb->wasted_size += jeb->free_size;
        jeb->free_size = 0;
 
-       ACCT_SANITY_CHECK(c,jeb);
-       D1(ACCT_PARANOIA_CHECK(jeb));
+       jffs2_dbg_dump_block_lists_nolock(c);
+       jffs2_dbg_acct_sanity_check_nolock(c,jeb);
+       jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 }
 
 /* Recover from failure to write wbuf. Recover the nodes up to the
@@ -266,7 +265,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
 
 
        /* ... and get an allocation of space from a shiny new block instead */
-       ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len);
+       ret = jffs2_reserve_space_gc(c, end-start, &ofs, &len, JFFS2_SUMMARY_NOSUM_SIZE);
        if (ret) {
                printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n");
                kfree(buf);
@@ -392,11 +391,11 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
        else
                jeb->last_node = container_of(first_raw, struct jffs2_raw_node_ref, next_phys);
 
-       ACCT_SANITY_CHECK(c,jeb);
-        D1(ACCT_PARANOIA_CHECK(jeb));
+       jffs2_dbg_acct_sanity_check_nolock(c, jeb);
+        jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
 
-       ACCT_SANITY_CHECK(c,new_jeb);
-        D1(ACCT_PARANOIA_CHECK(new_jeb));
+       jffs2_dbg_acct_sanity_check_nolock(c, new_jeb);
+        jffs2_dbg_acct_paranoia_check_nolock(c, new_jeb);
 
        spin_unlock(&c->erase_completion_lock);
 
@@ -837,6 +836,12 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, unsig
 alldone:
        *retlen = donelen;
 
+       if (jffs2_sum_active()) {
+               int res = jffs2_sum_add_kvec(c, invecs, count, (uint32_t) to);
+               if (res)
+                       return res;
+       }
+
        if (c->wbuf_len && ino)
                jffs2_wbuf_dirties_inode(c, ino);
 
@@ -856,7 +861,7 @@ int jffs2_flash_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *r
        struct kvec vecs[1];
 
        if (!jffs2_is_writebuffered(c))
-               return c->mtd->write(c->mtd, ofs, len, retlen, buf);
+               return jffs2_flash_direct_write(c, ofs, len, retlen, buf);
 
        vecs[0].iov_base = (unsigned char *) buf;
        vecs[0].iov_len = len;
@@ -973,7 +978,7 @@ int jffs2_check_oob_empty( struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
 
                if (buf[i] != 0xFF) {
                        D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n",
-                                 buf[page+i], page+i, jeb->offset));
+                                 buf[i], i, jeb->offset));
                        ret = 1; 
                        goto out;
                }
@@ -1236,3 +1241,23 @@ int jffs2_nor_ecc_flash_setup(struct jffs2_sb_info *c) {
 void jffs2_nor_ecc_flash_cleanup(struct jffs2_sb_info *c) {
        kfree(c->wbuf);
 }
+
+int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) {
+       /* Cleanmarker currently occupies a whole programming region */
+       c->cleanmarker_size = MTD_PROGREGION_SIZE(c->mtd);
+
+       /* Initialize write buffer */
+       init_rwsem(&c->wbuf_sem);
+       c->wbuf_pagesize = MTD_PROGREGION_SIZE(c->mtd);
+       c->wbuf_ofs = 0xFFFFFFFF;
+
+       c->wbuf = kmalloc(c->wbuf_pagesize, GFP_KERNEL);
+       if (!c->wbuf)
+               return -ENOMEM;
+
+       return 0;
+}
+
+void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c) {
+       kfree(c->wbuf);
+}
This page took 0.025283 seconds and 5 git commands to generate.