All of lore.kernel.org
 help / color / mirror / Atom feed
* File in JFFS2 corrupted after power loss during removal of other files
@ 2015-05-04 12:42 Marcin Adamski
  2015-05-05 14:35 ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Marcin Adamski @ 2015-05-04 12:42 UTC (permalink / raw)
  To: linux-mtd

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: File in JFFS2 corrupted after power loss during removal of other files
  2015-05-04 12:42 File in JFFS2 corrupted after power loss during removal of other files Marcin Adamski
@ 2015-05-05 14:35 ` Richard Weinberger
  2015-05-05 15:12   ` Marcin Adamski
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2015-05-05 14:35 UTC (permalink / raw)
  To: Marcin Adamski; +Cc: linux-mtd

On Mon, May 4, 2015 at 2:42 PM, Marcin Adamski <mass85@tlen.pl> wrote:
> 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?

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.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: File in JFFS2 corrupted after power loss during removal of other files
  2015-05-05 14:35 ` Richard Weinberger
@ 2015-05-05 15:12   ` Marcin Adamski
  2015-05-05 15:44     ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Marcin Adamski @ 2015-05-05 15:12 UTC (permalink / raw)
  To: richard.weinberger; +Cc: linux-mtd

On Mon, May 5, 2015 at 16:35,  Richard Weinberger <richard.weinberger@gmail.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: File in JFFS2 corrupted after power loss during removal of other files
  2015-05-05 15:12   ` Marcin Adamski
@ 2015-05-05 15:44     ` Richard Weinberger
  2015-05-05 16:51       ` File in JFFS2 corrupted after power loss during removal of otherfiles Marcin Adamski
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2015-05-05 15:44 UTC (permalink / raw)
  To: Marcin Adamski; +Cc: linux-mtd

Am 05.05.2015 um 17:12 schrieb Marcin Adamski:
> On Mon, May 5, 2015 at 16:35,  Richard Weinberger <richard.weinberger@gmail.com> wrote:
>> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: File in JFFS2 corrupted after power loss during removal of otherfiles
  2015-05-05 15:44     ` Richard Weinberger
@ 2015-05-05 16:51       ` Marcin Adamski
  0 siblings, 0 replies; 5+ messages in thread
From: Marcin Adamski @ 2015-05-05 16:51 UTC (permalink / raw)
  To: richard; +Cc: linux-mtd

Dnia 5 maja 2015 17:44 Richard Weinberger <richard@nod.at> napisał(a):
> 
> > Am 05.05.2015 um 17:12 schrieb Marcin Adamski:
> > On Mon, May 5, 2015 at 16:35, Richard Weinberger <richard.weinberger@gmail.com> wrote:
> >> 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?

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

Regards
Marcin Adamski

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-05 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-04 12:42 File in JFFS2 corrupted after power loss during removal of other files Marcin Adamski
2015-05-05 14:35 ` Richard Weinberger
2015-05-05 15:12   ` Marcin Adamski
2015-05-05 15:44     ` Richard Weinberger
2015-05-05 16:51       ` File in JFFS2 corrupted after power loss during removal of otherfiles Marcin Adamski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.