mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Harris Song(宋凯)" <songkai01@inspur.com>
To: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"richard@nod.at" <richard@nod.at>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>
Subject: fs/jffs2/read.c: When a data CRC error is detected, why not mark the node obsolete?
Date: Sun, 28 Sep 2025 12:10:09 +0000	[thread overview]
Message-ID: <f3ed0f6d27dc45088c4aad862dc05941@inspur.com> (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

                 reply	other threads:[~2025-09-28 12:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3ed0f6d27dc45088c4aad862dc05941@inspur.com \
    --to=songkai01@inspur.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®