Skip to contentSkip to conversation

fs/jffs2/readinode.c: data crc error detected

DISCUSSION Harris Song(宋凯) 1 participant 1 message Sep 24, 2025 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

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

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/