public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH]fs/jffs2/wbuf.c: add compatibility support for OOB data block
@ 2005-07-21  7:22 赵 豆豆
  2005-07-22 11:02 ` Artem B. Bityuckiy
  2005-07-22 11:59 ` Jörn Engel
  0 siblings, 2 replies; 83+ messages in thread
From: 赵 豆豆 @ 2005-07-21  7:22 UTC (permalink / raw)
  To: tglx; +Cc: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

Hi, 

Current jffs2_check_oob_empty() assumes that only OOB of first
page has data content -- the clean marker. OOB of other pages should
be all 0xFF.
But if we decide to store other kind of meta-data in OOB of the
second,third or forth page, this will cause compatibility issue.
For example, if we store some data in OOB of second page in the
future, the "old" JFFS2 will recognize all the erase blocks in
the "new" JFFS2 image as ALL_DIRTY.
So this patch solve this compatibility problem by extending existent
node type compat_bits to OOB area. In particular, I think
JFFS2_FEATURE_RWCOMPAT_COPY has no meaning for OOB, so it's
handled the same way as JFFS2_FEATURE_RWCOMPAT_DELETE.

Your comments are welcome!

Thanks,
Forrest

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com  

[-- Attachment #2: oob_compat.patch --]
[-- Type: application/octet-stream, Size: 2509 bytes --]

--- wbuf.c.bak	2005-07-21 20:50:42.000000000 +0800
+++ wbuf.c	2005-07-21 22:03:53.589883720 +0800
@@ -933,9 +933,10 @@
 {
 	unsigned char *buf;
 	int 	ret = 0;
-	int	i,len,page;
+	int	i,len,page,current_oob;
 	size_t  retlen;
 	int	oob_size;
+	struct jffs2_unknown_node *node;
 
 	/* allocate a buffer for all oob data in this sector */
 	oob_size = c->mtd->oobsize;
@@ -947,7 +948,7 @@
 	}
 	/* 
 	 * if mode = 0, we scan for a total empty oob area, else we have
-	 * to take care of the cleanmarker in the first page of the block
+	 * to take care of the data content in the subsequent pages of the block
 	*/
 	ret = jffs2_flash_read_oob(c, jeb->offset, len , &retlen, buf);
 	if (ret) {
@@ -961,28 +962,51 @@
 		ret = -EIO;
 		goto out;
 	}
-	
-	/* Special check for first page */
-	for(i = 0; i < oob_size ; i++) {
-		/* Yeah, we know about the cleanmarker. */
-		if (mode && i >= c->fsdata_pos && 
-		    i < c->fsdata_pos + c->fsdata_len)
-			continue;
-
-		if (buf[i] != 0xFF) {
-			D2(printk(KERN_DEBUG "Found %02x at %x in OOB for %08x\n",
-				  buf[i], i, jeb->offset));
-			ret = 1; 
-			goto out;
+
+
+	if (!mode) {
+		for (page = 0; page < len; page += sizeof(long)) {
+			unsigned long dat = *(unsigned long *)(&buf[page]);
+			if (dat != -1) {
+				ret = 1;
+				goto out;
+			}
 		}
-	}
+	} else {
+		for (current_oob = 0; current_oob < len; current_oob += oob_size) {
+			node = (struct jffs2_unknown_node *)&buf[current_oob + c->fsdata_pos];
+			if (je16_to_cpu(node->magic) == JFFS2_MAGIC_BITMASK) {
+				switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) {
+				case JFFS2_FEATURE_ROCOMPAT:
+					c->flags |= JFFS2_SB_FLAG_RO;
+					if (!(jffs2_is_readonly(c)))
+						return -EROFS;
+
+				case JFFS2_FEATURE_RWCOMPAT_DELETE:
+				case JFFS2_FEATURE_RWCOMPAT_COPY:
+					for (i = current_oob; i < current_oob + oob_size; i++) {
+						if (i >= current_oob + c->fsdata_pos &&
+						    i < current_oob + c->fsdata_pos + c->fsdata_len)
+							continue;
+
+						if (buf[i] != 0xFF) {
+							ret = 1;
+							goto out;
+						}
+					}
+					break;
 
-	/* we know, we are aligned :) */	
-	for (page = oob_size; page < len; page += sizeof(long)) {
-		unsigned long dat = *(unsigned long *)(&buf[page]);
-		if(dat != -1) {
-			ret = 1; 
-			goto out;
+				case JFFS2_FEATURE_INCOMPAT:
+					return -EINVAL;
+				}
+			} else {
+				for (i = current_oob; i < current_oob + oob_size; i++) {
+					if (buf[i] != 0xFF) {
+						ret = 1;
+						goto out;
+					}
+				}
+			}
 		}
 	}
 

^ permalink raw reply	[flat|nested] 83+ messages in thread

end of thread, other threads:[~2005-09-09 22:21 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-21  7:22 [PATCH]fs/jffs2/wbuf.c: add compatibility support for OOB data block 赵 豆豆
2005-07-22 11:02 ` Artem B. Bityuckiy
2005-07-22 11:59 ` Jörn Engel
2005-07-22 12:12   ` Artem B. Bityuckiy
2005-07-22 12:27     ` Jörn Engel
2005-07-26  7:36     ` Ferenc Havasi
2005-07-26  7:44       ` Jörn Engel
2005-07-26  7:57         ` Ferenc Havasi
2005-07-26  8:29           ` Steven Scholz
2005-07-26  9:36             ` Jörn Engel
2005-07-26 10:03               ` Ferenc Havasi
2005-07-26 10:12                 ` Artem B. Bityuckiy
2005-07-26 10:51                 ` Steven Scholz
2005-07-26 11:13                   ` Jörn Engel
2005-07-26 11:14                     ` Steven Scholz
2005-07-26 12:37                   ` Ferenc Havasi
2005-07-26  9:32           ` Jörn Engel
2005-07-26 10:03             ` Jörn Engel
2005-07-27 22:08               ` David Woodhouse
2005-07-28  9:01                 ` Jörn Engel
2005-08-01  9:50               ` Havasi Ferenc
2005-08-01  9:56                 ` Jörn Engel
2005-08-01 10:07                   ` Havasi Ferenc
2005-08-01 10:43                     ` Jörn Engel
2005-08-01 14:02                       ` Ferenc Havasi
2005-08-01 14:18                         ` Jörn Engel
2005-08-11 15:03                           ` Ferenc Havasi
2005-08-11 15:47                             ` Artem B. Bityuckiy
2005-08-11 16:59                               ` Ferenc Havasi
2005-08-11 16:06                                 ` Artem B. Bityuckiy
2005-08-15 11:24                                   ` Ferenc Havasi
2005-08-15 12:23                                     ` Artem B. Bityuckiy
2005-08-15 17:10                                       ` Ferenc Havasi
2005-08-16 13:19                                         ` Artem B. Bityuckiy
2005-08-11 17:24                             ` Jörn Engel
2005-08-15  9:48                             ` Jörn Engel
2005-08-15 10:20                               ` Artem B. Bityuckiy
2005-08-15 11:42                                 ` Ferenc Havasi
2005-08-15 11:56                                   ` Jörn Engel
2005-08-15 11:07                               ` Artem B. Bityuckiy
2005-08-15 11:48                                 ` Ferenc Havasi
2005-08-15 11:59                                   ` Jörn Engel
2005-08-15 12:28                                     ` Ferenc Havasi
2005-08-15 12:38                                       ` Artem B. Bityuckiy
2005-08-15 12:52                                         ` Jörn Engel
2005-08-15 13:34                                           ` Ferenc Havasi
2005-08-15 13:42                                             ` Artem B. Bityuckiy
2005-08-15 13:48                                               ` Jörn Engel
2005-08-15 14:00                                                 ` Artem B. Bityuckiy
2005-08-15 14:05                                                   ` Jörn Engel
2005-08-15 14:19                                                     ` Artem B. Bityuckiy
2005-08-15 14:32                                                       ` Jörn Engel
2005-08-15 15:22                                                         ` Artem B. Bityuckiy
2005-08-16  7:16                                                           ` Artem B. Bityuckiy
2005-08-16  7:25                                                             ` Artem B. Bityuckiy
2005-08-16  9:47                                                               ` Jörn Engel
2005-08-16  9:56                                                                 ` Artem B. Bityuckiy
2005-08-15 13:43                                             ` Jörn Engel
2005-08-15 13:46                                               ` Artem B. Bityuckiy
2005-08-16 11:34                                             ` Artem B. Bityuckiy
2005-08-15 13:27                                         ` Ferenc Havasi
2005-08-15 13:40                                           ` Artem B. Bityuckiy
2005-08-15 13:45                                             ` Jörn Engel
2005-08-15 13:50                                               ` Artem B. Bityuckiy
2005-08-15 12:35                                   ` Artem B. Bityuckiy
2005-08-15 13:22                                     ` Ferenc Havasi
2005-08-15 13:38                                       ` Artem B. Bityuckiy
2005-08-15 13:51                                         ` Jörn Engel
2005-08-15 14:01                                           ` Artem B. Bityuckiy
2005-08-16  8:22                                         ` JFFS2 eraseblock header Artem B. Bityuckiy
2005-08-16  8:25                                           ` Artem B. Bityuckiy
2005-08-16  9:13                                           ` Ferenc Havasi
2005-08-16  9:25                                             ` Artem B. Bityuckiy
2005-09-08 13:32                                           ` David Woodhouse
2005-09-08 13:35                                             ` Artem B. Bityuckiy
2005-09-08 18:43                                               ` Jörn Engel
2005-09-09 12:57                                                 ` Josh Boyer
2005-09-09 13:08                                                   ` Artem B. Bityuckiy
2005-09-09 22:20                                                     ` Jörn Engel
2005-08-15 11:53                                 ` [PATCH]fs/jffs2/wbuf.c: add compatibility support for OOB data block Jörn Engel
2005-08-15 12:46                                   ` Artem B. Bityuckiy
2005-07-26  8:40       ` Jffs2 problem with Versatile PB926EJ-S Soma sundaram Veerappan
2005-07-26 16:17         ` Todd Poynor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox