changeset 1834:121da35df27b

* Merge from public MTD. * src/build.c: Removed Oyvind Harboe's patch from 2004-04-19 since it was rejected upstream.
author asl
date Fri, 12 Nov 2004 16:50:29 +0000
parents 14804b5162ae
children dca80ff444df
files packages/fs/jffs2/current/ChangeLog packages/fs/jffs2/current/cdl/jffs2.cdl packages/fs/jffs2/current/doc/TODO packages/fs/jffs2/current/doc/TODO.eCos packages/fs/jffs2/current/include/linux/jffs2_fs_i.h packages/fs/jffs2/current/include/linux/jffs2_fs_sb.h packages/fs/jffs2/current/src/build.c packages/fs/jffs2/current/src/compr.c packages/fs/jffs2/current/src/compr.h packages/fs/jffs2/current/src/erase.c packages/fs/jffs2/current/src/fs-ecos.c packages/fs/jffs2/current/src/nodelist.h packages/fs/jffs2/current/src/nodemgmt.c packages/fs/jffs2/current/src/os-ecos.h packages/fs/jffs2/current/src/scan.c
diffstat 15 files changed, 102 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/packages/fs/jffs2/current/ChangeLog
+++ b/packages/fs/jffs2/current/ChangeLog
@@ -1,3 +1,12 @@
+2004-11-11  Andrew Lunn <andrew.lunn@ascom.ch>
+
+	* Merge from public MTD.
+	
+2004-11-11  Andrew Lunn <andrew.lunn@ascom.ch>
+
+	* src/build.c: Removed Oyvind Harboe's patch from 2004-04-19 
+	since it was rejected upstream.
+	
 2004-10-20  Per Hedblom  <perhedblom@abem.se>
 
 	* src/fs-ecos.c (jffs2_open): Call iput on dir node if
--- a/packages/fs/jffs2/current/cdl/jffs2.cdl
+++ b/packages/fs/jffs2/current/cdl/jffs2.cdl
@@ -4,7 +4,7 @@
 #
 #      JFFS2 Filesystem configuration data
 #
-#      $Id: jffs2.cdl,v 1.15 2004/04/21 18:50:52 gthomas Exp $
+#      $Id: jffs2.cdl,v 1.16 2004/11/11 20:48:54 lunn Exp $
 #
 # ====================================================================
 #####ECOSGPLCOPYRIGHTBEGIN####
--- a/packages/fs/jffs2/current/doc/TODO
+++ b/packages/fs/jffs2/current/doc/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.16 2004/03/20 15:01:34 dwmw2 Exp $
+$Id: TODO,v 1.17 2004/04/14 20:11:38 gleixner Exp $
 
  - support asynchronous operation -- add a per-fs 'reserved_space' count,
    let each outstanding write reserve the _maximum_ amount of physical
--- a/packages/fs/jffs2/current/doc/TODO.eCos
+++ b/packages/fs/jffs2/current/doc/TODO.eCos
@@ -1,4 +1,4 @@
-$Id: TODO.eCos,v 1.4 2003/11/28 11:15:56 dwmw2 Exp $
+$Id: TODO.eCos,v 1.2 2003/11/28 11:15:56 dwmw2 Exp $
 
  - Make symlinks work properly.
 
--- a/packages/fs/jffs2/current/include/linux/jffs2_fs_i.h
+++ b/packages/fs/jffs2/current/include/linux/jffs2_fs_i.h
@@ -1,10 +1,11 @@
-/* $Id: jffs2_fs_i.h,v 1.16 2003/01/09 14:03:21 dwmw2 Exp $ */
+/* $Id: jffs2_fs_i.h,v 1.17 2004/11/11 23:51:27 dwmw2 Exp $ */
 
 #ifndef _JFFS2_FS_I
 #define _JFFS2_FS_I
 
 #include <linux/version.h>
 #include <linux/rbtree.h>
+#include <asm/semaphore.h>
 
 struct jffs2_inode_info {
 	/* We need an internal semaphore similar to inode->i_sem.
--- a/packages/fs/jffs2/current/include/linux/jffs2_fs_sb.h
+++ b/packages/fs/jffs2/current/include/linux/jffs2_fs_sb.h
@@ -1,4 +1,4 @@
-/* $Id: jffs2_fs_sb.h,v 1.45 2003/10/08 11:46:27 dwmw2 Exp $ */
+/* $Id: jffs2_fs_sb.h,v 1.46 2004/11/03 12:57:39 jwboyer Exp $ */
 
 #ifndef _JFFS2_FS_SB
 #define _JFFS2_FS_SB
@@ -95,7 +95,7 @@ struct jffs2_sb_info {
 	   to an obsoleted node. I don't like this. Alternatives welcomed. */
 	struct semaphore erase_free_sem;
 
-#ifdef CONFIG_JFFS2_FS_NAND
+#if defined CONFIG_JFFS2_FS_NAND || defined CONFIG_JFFS2_FS_NOR_ECC
 	/* Write-behind buffer for NAND flash */
 	unsigned char *wbuf;
 	uint32_t wbuf_ofs;
--- a/packages/fs/jffs2/current/src/build.c
+++ b/packages/fs/jffs2/current/src/build.c
@@ -259,14 +259,6 @@ static void jffs2_calc_trigger_levels(st
 
 	c->resv_blocks_write = c->resv_blocks_deletion + (size / c->sector_size);
 
-	// If the flash disk is smaller than resv_blocks_write, then we 
-	// allow writing to the disk anyway. The flash disk is then most likely
-	// being used as write once - read many medimum, e.g. configuration of 
-	// static paramters.
-	if (c->resv_blocks_write * c->sector_size > c->flash_size) {
-	  c->resv_blocks_write = 0; 
-	}
-
 	/* When do we let the GC thread run in the background */
 
 	c->resv_blocks_gctrigger = c->resv_blocks_write + 1;
--- a/packages/fs/jffs2/current/src/compr.c
+++ b/packages/fs/jffs2/current/src/compr.c
@@ -9,7 +9,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: compr.c,v 1.41 2004/06/24 09:51:38 havasi Exp $
+ * $Id: compr.c,v 1.42 2004/08/07 21:56:08 dwmw2 Exp $
  *
  */
 
@@ -180,6 +180,11 @@ int jffs2_decompress(struct jffs2_sb_inf
         struct jffs2_compressor *this;
         int ret;
 
+	/* Older code had a bug where it would write non-zero 'usercompr'
+	   fields. Deal with it. */
+	if ((comprtype & 0xff) <= JFFS2_COMPR_ZLIB)
+		comprtype &= 0xff;
+
 	switch (comprtype & 0xff) {
 	case JFFS2_COMPR_NONE:
 		/* This should be special-cased elsewhere, but we might as well deal with it */
@@ -208,7 +213,7 @@ int jffs2_decompress(struct jffs2_sb_inf
                                 return ret;
                         }
                 }
-		printk(KERN_WARNING "JFFS2 compression type 0x%02x not avaiable.\n", comprtype);
+		printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype);
                 spin_unlock(&jffs2_compressor_list_lock);
 		return -EIO;
 	}
--- a/packages/fs/jffs2/current/src/compr.h
+++ b/packages/fs/jffs2/current/src/compr.h
@@ -23,8 +23,8 @@
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/jffs2.h>
+#include <linux/jffs2_fs_i.h>
 #include <linux/jffs2_fs_sb.h>
-#include <linux/jffs2_fs_i.h>
 #include "nodelist.h"
 
 #define JFFS2_RUBINMIPS_PRIORITY 10
--- a/packages/fs/jffs2/current/src/erase.c
+++ b/packages/fs/jffs2/current/src/erase.c
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: erase.c,v 1.60 2004/06/30 17:26:15 dbrown Exp $
+ * $Id: erase.c,v 1.64 2004/11/12 15:25:14 jwboyer Exp $
  *
  */
 
@@ -387,6 +387,7 @@ static void jffs2_mark_erased_block(stru
 		jeb->dirty_size = 0;
 		jeb->wasted_size = 0;
 	} else {
+		struct iovec vecs[1];
 		struct jffs2_unknown_node marker = {
 			.magic =	cpu_to_je16(JFFS2_MAGIC_BITMASK),
 			.nodetype =	cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
@@ -395,15 +396,17 @@ static void jffs2_mark_erased_block(stru
 
 		marker.hdr_crc = cpu_to_je32(crc32(0, &marker, sizeof(struct jffs2_unknown_node)-4));
 
-		/* We only write the header; the rest was noise or padding anyway */
-		ret = jffs2_flash_write(c, jeb->offset, sizeof(marker), &retlen, (char *)&marker);
+		vecs[0].iov_base = (unsigned char *) &marker;
+		vecs[0].iov_len = sizeof(marker);
+		ret = jffs2_flash_direct_writev(c, vecs, 1, jeb->offset, &retlen);
+		
 		if (ret) {
 			printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n",
 			       jeb->offset, ret);
 			goto bad2;
 		}
 		if (retlen != sizeof(marker)) {
-			printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %d, got %zd\n",
+			printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n",
 			       jeb->offset, sizeof(marker), retlen);
 			goto bad2;
 		}
--- a/packages/fs/jffs2/current/src/fs-ecos.c
+++ b/packages/fs/jffs2/current/src/fs-ecos.c
@@ -8,7 +8,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: fs-ecos.c,v 1.37 2004/04/21 18:45:54 gthomas Exp $
+ * $Id: fs-ecos.c,v 1.39 2004/11/11 12:46:17 dwmw2 Exp $
  *
  */
 
@@ -1671,7 +1671,8 @@ unsigned char *jffs2_gc_fetch_page(struc
 	/* FIXME: This works only with one file system mounted at a time */
 	int ret;
 
-	ret = jffs2_read_inode_range(c, f, gc_buffer, offset, PAGE_CACHE_SIZE);
+	ret = jffs2_read_inode_range(c, f, gc_buffer, 
+				     offset & ~(PAGE_CACHE_SIZE-1), PAGE_CACHE_SIZE);
 	if (ret)
 		return ERR_PTR(ret);
 
--- a/packages/fs/jffs2/current/src/nodelist.h
+++ b/packages/fs/jffs2/current/src/nodelist.h
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: nodelist.h,v 1.119 2004/05/26 12:28:12 gleixner Exp $
+ * $Id: nodelist.h,v 1.120 2004/10/07 15:11:54 havasi Exp $
  *
  */
 
@@ -281,9 +281,14 @@ static inline void paranoia_failed_dump(
 			else if (!ref_obsolete(ref2)) \
 				my_used_size += ref_totlen(c, jeb, ref2); \
 			if (unlikely((!ref2->next_phys) != (ref2 == jeb->last_node))) { \
-				printk("ref for node at %p (phys %08x) has next_phys->%p (%08x), last_node->%p (phys %08x)\n", \
-				       ref2, ref_offset(ref2), ref2->next_phys, ref_offset(ref2->next_phys), \
-				       jeb->last_node, ref_offset(jeb->last_node)); \
+                                if (!ref2->next_phys) \
+				       printk("ref for node at %p (phys %08x) has next_phys->%p (----), last_node->%p (phys %08x)\n", \
+				             ref2, ref_offset(ref2), ref2->next_phys, \
+				             jeb->last_node, ref_offset(jeb->last_node)); \
+                                else \
+                                       printk("ref for node at %p (phys %08x) has next_phys->%p (%08x), last_node->%p (phys %08x)\n", \
+				             ref2, ref_offset(ref2), ref2->next_phys, ref_offset(ref2->next_phys), \
+				             jeb->last_node, ref_offset(jeb->last_node)); \
 				paranoia_failed_dump(jeb); \
 				BUG(); \
 			} \
--- a/packages/fs/jffs2/current/src/nodemgmt.c
+++ b/packages/fs/jffs2/current/src/nodemgmt.c
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: nodemgmt.c,v 1.107 2003/11/26 15:30:58 dwmw2 Exp $
+ * $Id: nodemgmt.c,v 1.109 2004/10/07 15:08:47 havasi Exp $
  *
  */
 
@@ -549,6 +549,59 @@ void jffs2_mark_node_obsolete(struct jff
 		printk(KERN_WARNING "Short write in obliterating obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen);
 		return;
 	}
+
+	/* Nodes which have been marked obsolete no longer need to be
+	   associated with any inode. Remove them from the per-inode list */
+	if (ref->next_in_ino) {
+		struct jffs2_inode_cache *ic;
+		struct jffs2_raw_node_ref **p;
+
+		ic = jffs2_raw_ref_to_ic(ref);
+		for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino))
+			;
+
+		*p = ref->next_in_ino;
+		ref->next_in_ino = NULL;
+	}
+
+
+	/* Merge with the next node in the physical list, if there is one
+	   and if it's also obsolete. */
+	if (ref->next_phys && ref_obsolete(ref->next_phys) ) {
+		struct jffs2_raw_node_ref *n = ref->next_phys;
+		
+		ref->__totlen += n->__totlen;
+		ref->next_phys = n->next_phys;
+                if (jeb->last_node == n) jeb->last_node = ref;
+		if (jeb->gc_node == n) {
+			/* gc will be happy continuing gc on this node */
+			jeb->gc_node=ref;
+		}
+		BUG_ON(n->next_in_ino);
+		jffs2_free_raw_node_ref(n);
+	}
+	
+	/* Also merge with the previous node in the list, if there is one
+	   and that one is obsolete */
+	if (ref != jeb->first_node ) {
+		struct jffs2_raw_node_ref *p = jeb->first_node;
+		
+		while (p->next_phys != ref)
+			p = p->next_phys;
+		
+		if (ref_obsolete(p) ) {
+			p->__totlen += ref->__totlen;
+			if (jeb->last_node == ref) {
+				jeb->last_node = p;
+			}
+			if (jeb->gc_node == ref) {
+				/* gc will be happy continuing gc on this node */
+				jeb->gc_node=p;
+			}
+			p->next_phys = ref->next_phys;
+			jffs2_free_raw_node_ref(ref);
+		}
+	}
 }
 
 #if CONFIG_JFFS2_FS_DEBUG > 0
--- a/packages/fs/jffs2/current/src/os-ecos.h
+++ b/packages/fs/jffs2/current/src/os-ecos.h
@@ -198,6 +198,7 @@ static inline void jffs2_erase_pending_t
 #define jffs2_flash_writev(a,b,c,d,e,f) jffs2_flash_direct_writev(a,b,c,d,e)
 #define jffs2_wbuf_timeout NULL
 #define jffs2_wbuf_process NULL
+#define jffs2_nor_ecc(c) (0)
 #else
 #error no nand yet
 #endif
--- a/packages/fs/jffs2/current/src/scan.c
+++ b/packages/fs/jffs2/current/src/scan.c
@@ -7,7 +7,7 @@
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: scan.c,v 1.111 2004/07/27 14:13:43 gleixner Exp $
+ * $Id: scan.c,v 1.113 2004/11/03 12:57:39 jwboyer Exp $
  *
  */
 #include <linux/kernel.h>
@@ -68,7 +68,7 @@ static int jffs2_scan_dirent_node(struct
 static inline int min_free(struct jffs2_sb_info *c)
 {
 	uint32_t min = 2 * sizeof(struct jffs2_raw_inode);
-#ifdef CONFIG_JFFS2_FS_NAND
+#if defined CONFIG_JFFS2_FS_NAND || defined CONFIG_JFFS2_FS_NOR_ECC
 	if (!jffs2_can_mark_obsolete(c) && min < c->wbuf_pagesize)
 		return c->wbuf_pagesize;
 #endif
@@ -223,7 +223,7 @@ int jffs2_scan_medium(struct jffs2_sb_in
 		c->dirty_size -= c->nextblock->dirty_size;
 		c->nextblock->dirty_size = 0;
 	}
-#ifdef CONFIG_JFFS2_FS_NAND
+#if defined CONFIG_JFFS2_FS_NAND || defined CONFIG_JFFS2_FS_NOR_ECC
 	if (!jffs2_can_mark_obsolete(c) && c->nextblock && (c->nextblock->free_size & (c->wbuf_pagesize-1))) {
 		/* If we're going to start writing into a block which already 
 		   contains data, and the end of the data isn't page-aligned,
@@ -241,7 +241,7 @@ int jffs2_scan_medium(struct jffs2_sb_in
 	}
 #endif
 	if (c->nr_erasing_blocks) {
-		if ( !c->used_size && ((empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
+		if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { 
 			printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");
 			printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks);
 			ret = -EIO;