* fs/jffs2/read.c: When a data CRC error is detected, why not mark the node obsolete?
@ 2025-09-28 12:10 Harris Song(宋凯)
0 siblings, 0 replies; only message in thread
From: Harris Song(宋凯) @ 2025-09-28 12:10 UTC (permalink / raw)
To: linux-mtd; +Cc: linux-kernel, richard, dwmw2
Hi all,
In fs/jffs2/read.c, when jffs2_read_dnode detects a data-CRC failure it immediately returns -EIO to user space. Any read attempt that the application makes shortly afterwards will fail with the same error.
int jffs2_read_dnode()
{
......
crc = crc32(0, readbuf, je32_to_cpu(ri->csize));
if (crc != je32_to_cpu(ri->data_crc)) {
pr_warn("Data CRC %08x != calculated CRC %08x for node at %08x\n",
je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw));
ret = -EIO;
goto out_decomprbuf;
}
......
return ret;
}
The system must wait for the garbage collection mechanism to handle the issue. After processing, the node may have been rolled back to an earlier (valid) version, and only then can the application read the data successfully.
In such a scenario, since the node is already corrupted, would it be possible to directly mark the node with the CRC error as obsolete(jffs2_mark_node_obsolete or a similar helper)? This way, when the application reads again, it could immediately access the correct data without waiting for background garbage collection.
like this:
int jffs2_read_dnode()
{
......
crc = crc32(0, readbuf, je32_to_cpu(ri->csize));
if (crc != je32_to_cpu(ri->data_crc)) {
pr_warn("Data CRC %08x != calculated CRC %08x for node at %08x\n",
je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw));
jffs2_mark_node_obsolete()
ret = -EIO;
goto out_decomprbuf;
}
......
return ret;
}
Thanks
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-28 12:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-28 12:10 fs/jffs2/read.c: When a data CRC error is detected, why not mark the node obsolete? Harris Song(宋凯)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®