* [PATCH] [JFFS2] allow JFFS2 to discriminate between recoverable and non-recoverable errors
@ 2012-05-10 15:13 Jean-Christophe DUBOIS
2012-05-11 17:05 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Jean-Christophe DUBOIS @ 2012-05-10 15:13 UTC (permalink / raw)
To: linux-mtd; +Cc: Jean-Christophe DUBOIS
This patch is basicaly a reverse of commit f326966b3df47f4fa7e90425f60efdd30c31fe19.
It allows JFFS2 to make the distinction between a potential transient error
(reading or writing the media) and a non recoverable error like a bad CRC on
the extended attribute data or some insconsitent paramaters.
In order to make clear that the error is indeed intended to report a corrupted
attribute, a new local error code (JFFS2_XATTR_IS_CORRUPTED) is introduced.
This error code is never reported to user space and only checked locally in this
file.
Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
---
fs/jffs2/xattr.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index b55b803..c18c0ab 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;
@@ -227,12 +229,12 @@ static int do_load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum
data[xd->name_len] = '\0';
crc = crc32(0, data, length);
if (crc != xd->data_crc) {
- JFFS2_WARNING("node CRC failed (JFFS2_NODETYPE_XREF)"
+ JFFS2_WARNING("node CRC failed (JFFS2_NODETYPE_XATTR)"
" at %#08x, read: 0x%08x calculated: 0x%08x\n",
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;
@@ -270,7 +272,7 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
if (xd->xname)
return 0;
if (xd->flags & JFFS2_XFLAGS_INVALID)
- return -EIO;
+ return JFFS2_XATTR_IS_CORRUPTED;
if (unlikely(is_xattr_datum_unchecked(c, xd)))
rc = do_verify_xattr_datum(c, xd);
if (!rc)
@@ -462,7 +464,7 @@ static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref
if (crc != je32_to_cpu(rr.node_crc)) {
JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
offset, je32_to_cpu(rr.node_crc), crc);
- return -EIO;
+ return JFFS2_XATTR_IS_CORRUPTED;
}
if (je16_to_cpu(rr.magic) != JFFS2_MAGIC_BITMASK
|| je16_to_cpu(rr.nodetype) != JFFS2_NODETYPE_XREF
@@ -472,7 +474,7 @@ static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref
offset, je16_to_cpu(rr.magic), JFFS2_MAGIC_BITMASK,
je16_to_cpu(rr.nodetype), JFFS2_NODETYPE_XREF,
je32_to_cpu(rr.totlen), PAD(sizeof(rr)));
- return -EIO;
+ return JFFS2_XATTR_IS_CORRUPTED;
}
ref->ino = je32_to_cpu(rr.ino);
ref->xid = je32_to_cpu(rr.xid);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [JFFS2] allow JFFS2 to discriminate between recoverable and non-recoverable errors
2012-05-10 15:13 [PATCH] [JFFS2] allow JFFS2 to discriminate between recoverable and non-recoverable errors Jean-Christophe DUBOIS
@ 2012-05-11 17:05 ` Artem Bityutskiy
2012-05-16 8:19 ` Artem Bityutskiy
0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2012-05-11 17:05 UTC (permalink / raw)
To: Jean-Christophe DUBOIS; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 823 bytes --]
On Thu, 2012-05-10 at 17:13 +0200, Jean-Christophe DUBOIS wrote:
> This patch is basicaly a reverse of commit f326966b3df47f4fa7e90425f60efdd30c31fe19.
>
> It allows JFFS2 to make the distinction between a potential transient error
> (reading or writing the media) and a non recoverable error like a bad CRC on
> the extended attribute data or some insconsitent paramaters.
>
> In order to make clear that the error is indeed intended to report a corrupted
> attribute, a new local error code (JFFS2_XATTR_IS_CORRUPTED) is introduced.
>
> This error code is never reported to user space and only checked locally in this
> file.
Pushed both to l2-mtd.git, thanks!
Can you confirm that these 2 patches solve the issues you earlier
described on this mailing list?
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [JFFS2] allow JFFS2 to discriminate between recoverable and non-recoverable errors
2012-05-11 17:05 ` Artem Bityutskiy
@ 2012-05-16 8:19 ` Artem Bityutskiy
2012-05-16 8:28 ` Jean-Christophe DUBOIS
0 siblings, 1 reply; 4+ messages in thread
From: Artem Bityutskiy @ 2012-05-16 8:19 UTC (permalink / raw)
To: Jean-Christophe DUBOIS; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 255 bytes --]
On Fri, 2012-05-11 at 20:05 +0300, Artem Bityutskiy wrote:
> Pushed both to l2-mtd.git, thanks!
>
> Can you confirm that these 2 patches solve the issues you earlier
> described on this mailing list?
Ping.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [JFFS2] allow JFFS2 to discriminate between recoverable and non-recoverable errors
2012-05-16 8:19 ` Artem Bityutskiy
@ 2012-05-16 8:28 ` Jean-Christophe DUBOIS
0 siblings, 0 replies; 4+ messages in thread
From: Jean-Christophe DUBOIS @ 2012-05-16 8:28 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd
On 16/05/2012 10:19, Artem Bityutskiy wrote:
> On Fri, 2012-05-11 at 20:05 +0300, Artem Bityutskiy wrote:
>> Pushed both to l2-mtd.git, thanks!
>>
>> Can you confirm that these 2 patches solve the issues you earlier
>> described on this mailing list?
Yes, it does allow JFFS2 to recover from all the attribute integrity
problems I demonstrated in an earlier email [1].
JC
[1]: http://patchwork.ozlabs.org/patch/151881/
> Ping.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-16 8:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-10 15:13 [PATCH] [JFFS2] allow JFFS2 to discriminate between recoverable and non-recoverable errors Jean-Christophe DUBOIS
2012-05-11 17:05 ` Artem Bityutskiy
2012-05-16 8:19 ` Artem Bityutskiy
2012-05-16 8:28 ` Jean-Christophe DUBOIS
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).