[<prev] [next>] [day] [month] [year] [list]
Message-ID: <f3ed0f6d27dc45088c4aad862dc05941@inspur.com>
Date: Sun, 28 Sep 2025 12:10:09 +0000
From: Harris Song(宋凯) <songkai01@...pur.com>
To: "linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"richard@....at" <richard@....at>, "dwmw2@...radead.org"
<dwmw2@...radead.org>
Subject: fs/jffs2/read.c: When a data CRC error is detected, why not mark the
node obsolete?
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
Powered by blists - more mailing lists