Skip to contentSkip to conversation

File in JFFS2 corrupted after power loss during removal of other files

DISCUSSION Marcin Adamski 3 participants 5 messages May 4, 2015 – May 5, 2015 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi

I am working with Linux (3.4.31+) embedded system booting from JFFS2 partition. I frequently encounter a problem of a file corruption when power loss occurs while other files are being removed. It happens during upgrade procedure of the platform. These are simplified steps of the upgrade:
1. Download tar.gz containing (among other files) rootfs.squashfs image of file system that I am upgrading to, verify md5 checksum of the image.
2. Boot linux from a small JFFS2 partition that has a minimal set of tools required to perform upgrade.
3. Mount the large partition that must be upgraded.
4. Mount rootfs.squashfs which is stored in the big partition.
5. Remove all files from the large partition except from some migrated data files, the rootfs.squashfs image etc.
6. Copy all files from mounted rootfs.squashfs to the large partition
7. Boot from the large partition

The mentioned power loss occurs in 5. step. Note that the rootfs.squashfs is mounted as read only and is never altered during upgrade. Even though this file gets corrupted and after device is powered on you can see that the file's md5 checksum is different, size stays unchanged, image can be mounted but it is impossible to read some of the files from this image.

Shouldn't JFFS2 deal with this kind of scenario? Is there any way to recover from this situation?

Regards
Marcin Adamski

#1 lore raw
Quoted 11 lines · Marcin Adamski

Hi

I am working with Linux (3.4.31+) embedded system booting from JFFS2 partition. I frequently encounter a problem of a file corruption when power loss occurs while other files are being removed. It happens during upgrade procedure of the platform. These are simplified steps of the upgrade:
1. Download tar.gz containing (among other files) rootfs.squashfs image of file system that I am upgrading to, verify md5 checksum of the image.
2. Boot linux from a small JFFS2 partition that has a minimal set of tools required to perform upgrade.
3. Mount the large partition that must be upgraded.
4. Mount rootfs.squashfs which is stored in the big partition.
5. Remove all files from the large partition except from some migrated data files, the rootfs.squashfs image etc.
6. Copy all files from mounted rootfs.squashfs to the large partition
7. Boot from the large partition

Quoted 3 lines

The mentioned power loss occurs in 5. step. Note that the rootfs.squashfs is mounted as read only and is never altered during upgrade. Even though this file gets corrupted and after device is powered on you can see that the file's md5 checksum is different, size stays unchanged, image can be mounted but it is impossible to read some of the files from this image.

Shouldn't JFFS2 deal with this kind of scenario? Is there any way to recover from this situation?

I'd say "it's complicated". :)

UBIFS was created to deal with such situations.
If you want to be on the safe side, use it.

Signature · 2 lines
Thanks,
//richard
#2 lore raw
Quoted 5 lines · Richard Weinberger

I'd say "it's complicated". :)

UBIFS was created to deal with such situations.
If you want to be on the safe side, use it.

I'm afraid it is too late for me to use UBIFS, as I need to perform upgrade of my devices in the field and migration from JFFS2 to UBIFS seems impossible (at least without some additional free space in flash).

I concluded that JFFS2 should also handle this kind of scenarios after reading about CRC failures in http://www.linux-mtd.infradead.org/faq/jffs2.html#L_messages

Regards
Marcin Adamski

#3 lore raw

Am 05.05.2015 um 17:12 schrieb Marcin Adamski:

Quoted 10 lines · Richard Weinberger
Quoted 5 lines

I'd say "it's complicated". :)

UBIFS was created to deal with such situations.
If you want to be on the safe side, use it.

I'm afraid it is too late for me to use UBIFS, as I need to perform upgrade of my devices in the field and migration from JFFS2 to UBIFS seems impossible (at least without some additional free space in flash).

I concluded that JFFS2 should also handle this kind of scenarios after reading about CRC failures in http://www.linux-mtd.infradead.org/faq/jffs2.html#L_messages

AFAIK it depends on the corruption. But JFFS2 predates me. :) Usually in such situations I inspect the corrupt image by hand. Maybe it is also an hardware issue. Is this NAND flash?

Thanks,
//richard

#4 lore raw

Re: File in JFFS2 corrupted after power loss during removal of otherfiles

Dnia 5 maja 2015 17:44 Richard Weinberger <[email protected]> napisał(a):

Quoted 9 lines
Quoted 9 lines

Am 05.05.2015 um 17:12 schrieb Marcin Adamski:

Quoted 5 lines · Richard Weinberger

I'd say "it's complicated". :)

UBIFS was created to deal with such situations.
If you want to be on the safe side, use it.

Quoted 7 lines
Quoted 3 lines

I'm afraid it is too late for me to use UBIFS, as I need to perform upgrade of my devices in the field and migration from JFFS2 to UBIFS seems impossible (at least without some additional free space in flash).

I concluded that JFFS2 should also handle this kind of scenarios after reading about CRC failures in http://www.linux-mtd.infradead.org/faq/jffs2.html#L_messages

AFAIK it depends on the corruption. But JFFS2 predates me. :) Usually in such situations I inspect the corrupt image by hand. Maybe it is also an hardware issue. Is this NAND flash?

It is NAND flash. I think I will give up on inspecting image by hand, this seems too hard.

Regards
Marcin Adamski