All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [JFFS2] load_xattr_datum need to return a positive number in case of unrecoverable error
@ 2012-04-11 20:54 Jean-Christophe DUBOIS
  2012-04-22 13:08 ` Artem Bityutskiy
  2012-04-22 13:16 ` Artem Bityutskiy
  0 siblings, 2 replies; 10+ messages in thread
From: Jean-Christophe DUBOIS @ 2012-04-11 20:54 UTC (permalink / raw)
  To: linux-mtd; +Cc: Jean-Christophe DUBOIS

As per load_xattr_datum() comment:
	rc < 0 : recoverable error, try again
	rc = 0 : success
	rc > 0 : Unrecoverable error, this node should be deleted.

For now we were only returning negative number (so recoverable error).
But a CRC failure or some inconsitent data seems fatal enough to
consider the attribute instance (version) as lost.

So this patch returns a positive number (1) when it detects an
unrecoverable error.

Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
---
 fs/jffs2/xattr.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index b55b803..382b1e0 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -11,6 +11,8 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#define JFFS2_XATTR_IS_CORRUPTED	1
+
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/fs.h>
@@ -153,7 +155,7 @@ static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_dat
 		JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
 			    offset, je32_to_cpu(rx.hdr_crc), crc);
 		xd->flags |= JFFS2_XFLAGS_INVALID;
-		return -EIO;
+		return JFFS2_XATTR_IS_CORRUPTED;
 	}
 	totlen = PAD(sizeof(rx) + rx.name_len + 1 + je16_to_cpu(rx.value_len));
 	if (je16_to_cpu(rx.magic) != JFFS2_MAGIC_BITMASK
@@ -169,7 +171,7 @@ static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_dat
 			    je32_to_cpu(rx.xid), xd->xid,
 			    je32_to_cpu(rx.version), xd->version);
 		xd->flags |= JFFS2_XFLAGS_INVALID;
-		return -EIO;
+		return JFFS2_XATTR_IS_CORRUPTED;
 	}
 	xd->xprefix = rx.xprefix;
 	xd->name_len = rx.name_len;
@@ -232,7 +234,7 @@ static int do_load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum
 			      ref_offset(xd->node), xd->data_crc, crc);
 		kfree(data);
 		xd->flags |= JFFS2_XFLAGS_INVALID;
-		return -EIO;
+		return JFFS2_XATTR_IS_CORRUPTED;
 	}
 
 	xd->flags |= JFFS2_XFLAGS_HOT;
@@ -1282,7 +1284,7 @@ int jffs2_verify_xattr(struct jffs2_sb_info *c)
 	down_write(&c->xattr_sem);
 	list_for_each_entry_safe(xd, _xd, &c->xattr_unchecked, xindex) {
 		rc = do_verify_xattr_datum(c, xd);
-		if (rc < 0)
+		if (rc)
 			continue;
 		list_del_init(&xd->xindex);
 		spin_lock(&c->erase_completion_lock);
-- 
1.7.5.4

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

end of thread, other threads:[~2012-05-01 14:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-11 20:54 [PATCH] [JFFS2] load_xattr_datum need to return a positive number in case of unrecoverable error Jean-Christophe DUBOIS
2012-04-22 13:08 ` Artem Bityutskiy
2012-04-22 13:16 ` Artem Bityutskiy
2012-04-22 17:35   ` Jean-Christophe DUBOIS
2012-04-25 13:59     ` Artem Bityutskiy
2012-04-26 21:09       ` Jean-Christophe DUBOIS
2012-04-29 15:44         ` Artem Bityutskiy
2012-04-30 20:54           ` Jean-Christophe DUBOIS
2012-05-01 12:15             ` Artem Bityutskiy
2012-05-01 14:31               ` Jean-Christophe DUBOIS

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.