Skip to contentSkip to conversation

Massive ext4 filesystem corruption after a failed s2disk/ram cycle

DISCUSSION Maxim Levitsky 10 participants 24 messages Oct 6, 2009 – Nov 9, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

Just prior to 2.6.32 cycle I tried -next tree and noticed that after a failed s2ram (here it works only once, and I test once in a whileto see if fixed accidentally) I got a minor filesystem corruption. I am sorry I didn't report that back then.

Now I have installed 2.6.32-rc2 (well -rc1...) and things were sort of ok, I have even thought that hibernation is once again stable (somewhere in the not that distinct past the hibernation which used to work, began to fail randomly on resume)

Few days ago, I got a read-only filesystem again, an fsck, few more corrupted files..., It should have had rung the bell for me (I have still used hibernation, trying to understand why it fails sometimes)

Yesterday, however, I have decided to fix that once and for all, and for that I have set up a loop + rtc wakealarm to make it cycle through hibernation.

Needless to say I didn't run that loop more that maybe 3 cycles (and no failures), but noticed that rtc clock is dead on resume.

I sort of fixed that (this is hpet emulation that strikes again), I will post when I test the fix (trivial), because when I had rebooted the system into the modified kernel, I got that readonly filesystem again, and this time the damage had spread over lots of files.
(I have even lost most of dpkg database..., many programs, libraries,..., settings)

Yet, thanks to Linux flexibility, after a day, and some study of nautilus source, I had the system recovered fully. (Now am doing backups.....)

But I don't want that to happen again...

Another clue that I have seen was that ext4 driver reported that it aborts journal replay.

I know that for now there is not much you can do, but just to let you know that something is there...

What is especially interesting is that there were no s2ram'disk faulure preceding the corruption, but my theory is that corruption wasn't detected for a while from last failure, probably giving such bad consequences.

You do sync file-systems before entering the hibernation, don't you?

Best regards,
Maxim Levitsky

#1 lore raw
Quoted 5 lines · Maxim Levitsky

Just prior to 2.6.32 cycle I tried -next tree and noticed that after a failed s2ram (here it works only once, and I test once in a whileto see if fixed accidentally) I got a minor filesystem corruption. I am sorry I didn't report that back then.

When you say filesystem corruption, it's important to indicate whether you meant that (a) you noticed that some files were had corrupted contents, (b) the kernel complained that the filesystem was corrupted, and remounted the filesystem read-only, or (c) e2fsck found and fixed errors.

Also, when you found errors of either class (a) or (b), did you run e2fsck to find and fix any potential errors? In a few places it sounded like the kernel had complained about errors, but you had ignored them and hadn't run e2fsck to fix them. I hope that was just me misunderstanding what you wrote! Can you clarify?

- Ted

#2 lore raw
Quoted 13 lines · Theodore Tso
Quoted 5 lines · Maxim Levitsky

Just prior to 2.6.32 cycle I tried -next tree and noticed that after a failed s2ram (here it works only once, and I test once in a whileto see if fixed accidentally) I got a minor filesystem corruption. I am sorry I didn't report that back then.

When you say filesystem corruption, it's important to indicate whether you meant that (a) you noticed that some files were had corrupted contents, (b) the kernel complained that the filesystem was corrupted, and remounted the filesystem read-only, or (c) e2fsck found and fixed errors.

Quoted 5 lines

Also, when you found errors of either class (a) or (b), did you run e2fsck to find and fix any potential errors? In a few places it sounded like the kernel had complained about errors, but you had ignored them and hadn't run e2fsck to fix them. I hope that was just me misunderstanding what you wrote! Can you clarify?

Sure, kernel noticed errors, and remounted the filesystem R/O (I didn't write anything down. really sorry)

I had rebooted the system.
Then startup scripts had booted the system to root shell

I had run fsck on the filesystem. It had plenty of files with shared blocks, many orphaned inodes, errors in free bitmaps.

Then, after the fsck, I got many missing files (many probably went to lost+found), some had garbage, some became truncated (0 size)

Mostly were affected files that were from recent dpkg update.

I use ubuntu 9.10, and (almost) latest -git of kernel tree.

Best regards,
Maxim Levitsky

#3 lore raw
Quoted 19 lines · On Wed, 07 Oct 2009 01:02:25 +0200 Maxim Levitsky <[email protected]>…
Quoted 7 lines · Theodore Tso
Quoted 5 lines · Maxim Levitsky

Just prior to 2.6.32 cycle I tried -next tree and noticed that after a failed s2ram (here it works only once, and I test once in a whileto see if fixed accidentally) I got a minor filesystem corruption. I am sorry I didn't report that back then.

Sure, kernel noticed errors, and remounted the filesystem R/O (I didn't write anything down. really sorry)

I had rebooted the system.
Then startup scripts had booted the system to root shell

I had run fsck on the filesystem. It had plenty of files with shared blocks, many orphaned inodes, errors in free bitmaps.

Quoted 7 lines

Then, after the fsck, I got many missing files (many probably went to lost+found), some had garbage, some became truncated (0 size)

Mostly were affected files that were from recent dpkg update.

I use ubuntu 9.10, and (almost) latest -git of kernel tree.

I encountered something very similar yesterday, with 2.6.32-rc3. When doing sync after accidentally removing a mounted USB stick, sync got stuck, so I resorted to SysRq+S/U/B. Unfortunately this was also just after an apt-get upgrade. The result was the same, corrupted ext4 partitions, shared blocks, orphaned inodes, free bitmap errors.

Only recently written files seem to be affected, in my case upgraded stuff in / and configuration files in /home.

Signature · 1 line
Jindrich Makovicka
#4 lore raw
In reply to Maxim Levitsky
Quoted 42 lines · Maxim Levitsky

Hi,

Just prior to 2.6.32 cycle I tried -next tree and noticed that after a failed s2ram (here it works only once, and I test once in a whileto see if fixed accidentally) I got a minor filesystem corruption. I am sorry I didn't report that back then.

Now I have installed 2.6.32-rc2 (well -rc1...) and things were sort of ok, I have even thought that hibernation is once again stable (somewhere in the not that distinct past the hibernation which used to work, began to fail randomly on resume)

Few days ago, I got a read-only filesystem again, an fsck, few more corrupted files..., It should have had rung the bell for me (I have still used hibernation, trying to understand why it fails sometimes)

Yesterday, however, I have decided to fix that once and for all, and for that I have set up a loop + rtc wakealarm to make it cycle through hibernation.

Needless to say I didn't run that loop more that maybe 3 cycles (and no failures), but noticed that rtc clock is dead on resume.

I sort of fixed that (this is hpet emulation that strikes again), I will post when I test the fix (trivial), because when I had rebooted the system into the modified kernel, I got that readonly filesystem again, and this time the damage had spread over lots of files.
(I have even lost most of dpkg database..., many programs, libraries,..., settings)

Yet, thanks to Linux flexibility, after a day, and some study of nautilus source, I had the system recovered fully. (Now am doing backups.....)

But I don't want that to happen again...

Another clue that I have seen was that ext4 driver reported that it aborts journal replay.

I know that for now there is not much you can do, but just to let you know that something is there...

Quoted 6 lines

What is especially interesting is that there were no s2ram'disk faulure preceding the corruption, but my theory is that corruption wasn't detected for a while from last failure, probably giving such bad consequences.

You do sync file-systems before entering the hibernation, don't you?

Yes, a sync is there, but it is not effective on some filesystems.

Thanks,
Rafael

#5 lore raw
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line

You do sync file-systems before entering the hibernation, don't you?

Yes, a sync is there, but it is not effective on some filesystems.

Which ones?

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#6 lore raw
Quoted 6 lines · Henrique de Moraes Holschuh
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line

You do sync file-systems before entering the hibernation, don't you?

Yes, a sync is there, but it is not effective on some filesystems.

Which ones?

XFS for one example.

#7 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Henrique de Moraes Holschuh
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line

You do sync file-systems before entering the hibernation, don't you?

Yes, a sync is there, but it is not effective on some filesystems.

Which ones?

XFS for one example.

Interesting. So XFS is not only a Bad Idea for /, but also for anything that might enter S3/S4. Not nice. I sure hope it doesn't do a half-assed job of flushing and checkpointing itself during machine shutdown/restart like it apparently does when told to "sync" before S3/S4...

Would you be so kind to disclose to us, the uninitated, which other filesystems are unsafe when faced with a sleep/suspend request?

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#8 lore raw
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Henrique de Moraes Holschuh
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line

You do sync file-systems before entering the hibernation, don't you?

Yes, a sync is there, but it is not effective on some filesystems.

Which ones?

Quoted 7 lines
Quoted 1 line

XFS for one example.

Interesting. So XFS is not only a Bad Idea for /, but also for anything that might enter S3/S4. Not nice. I sure hope it doesn't do a half-assed job of flushing and checkpointing itself during machine shutdown/restart like it apparently does when told to "sync" before S3/S4...

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

Daniel

Signature · 6 lines
✣ Daniel Pittman            ✉ [email protected]            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#9 lore raw
In reply to Henrique de Moraes Holschuh
Quoted 9 lines · Henrique de Moraes Holschuh
Quoted 8 lines · Rafael J. Wysocki
Quoted 6 lines · Henrique de Moraes Holschuh
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line

You do sync file-systems before entering the hibernation, don't you?

Yes, a sync is there, but it is not effective on some filesystems.

Which ones?

Quoted 7 lines
Quoted 1 line

XFS for one example.

Interesting. So XFS is not only a Bad Idea for /, but also for anything that might enter S3/S4. Not nice. I sure hope it doesn't do a half-assed job of flushing and checkpointing itself during machine shutdown/restart like it apparently does when told to "sync" before S3/S4...

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

Daniel

Signature · 2 lines
✣ Daniel Pittman            ✉ [email protected]            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons
#10 lore raw
Quoted 3 lines · Daniel Pittman

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

#11 lore raw
In reply to Daniel Pittman
Quoted 3 lines · Daniel Pittman

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

#12 lore raw
Quoted 10 lines · Daniel Pittman
Quoted 3 lines

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

I'm sorry for the long delayed and offtopic responce. I discussed this issue with okuji-san (GRUB2 maintainer) at several month ago. He really wish linux implement real sync.

A bootloader has much constraint than OS (mainly caused by size constraint). it can't implemnt jornal log replay logic for _all_ filesystem. Why can't we implement storong sync syscall? I don't think this is PM nor bootloader fault.

#13 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Daniel Pittman
Quoted 3 lines

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

I'm sorry for the long delayed and offtopic responce. I discussed this issue with okuji-san (GRUB2 maintainer) at several month ago. He really wish linux implement real sync.

A bootloader has much constraint than OS (mainly caused by size constraint). it can't implemnt jornal log replay logic for _all_ filesystem. Why can't we implement storong sync syscall? I don't think this is PM nor bootloader fault.

#14 lore raw
Quoted 11 lines · KOSAKI Motohiro
Quoted 10 lines · Daniel Pittman
Quoted 3 lines

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

Quoted 3 lines

I'm sorry for the long delayed and offtopic responce. I discussed this issue with okuji-san (GRUB2 maintainer) at several month ago. He really wish linux implement real sync.

This is not about real sync. It is about the box being able to reboot after a crash or power failure.

GRUB2 is broken in that regard, at least in its peecee-BIOS version: last time I checked, it doesn't sort RAID components so that it won't boot from failed or out-of-sync older components, it can't deal with some of the filesystems being unclean...

Quoted 3 lines

A bootloader has much constraint than OS (mainly caused by size constraint). it can't implemnt jornal log replay logic for _all_ filesystem. Why can't we implement storong sync syscall? I don't think this is PM nor bootloader fault.

A bootloader that can't boot a system that went through an unclean shutdown is quite broken.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#15 lore raw
Quoted 25 lines · Henrique de Moraes Holschuh
Quoted 12 lines · KOSAKI Motohiro
Quoted 11 lines · Daniel Pittman
Quoted 4 lines

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

Quoted 3 lines

I'm sorry for the long delayed and offtopic responce. I discussed this issue with okuji-san (GRUB2 maintainer) at several month ago. He really wish linux implement real sync.

This is not about real sync. It is about the box being able to reboot
after a crash or power failure.

GRUB2 is broken in that regard, at least in its peecee-BIOS version:
last time I checked, it doesn't sort RAID components so that it won't boot from failed or out-of-sync older components, it can't deal with some of the filesystems being unclean...

Quoted 8 lines
Quoted 4 lines

A bootloader has much constraint than OS (mainly caused by size constraint). it can't implemnt jornal log replay logic for _all_ filesystem. Why can't we implement storong sync syscall? I don't think this is PM nor bootloader fault.

A bootloader that can't boot a system that went through an unclean
shutdown is quite broken.

It can barely boot a system that's gone through a clean shutdown. "bios read error" and all that.

Signature · 2 lines
Thomas Fjellstrom
[email protected]
#16 lore raw
In reply to KOSAKI Motohiro
Quoted 11 lines · KOSAKI Motohiro
Quoted 10 lines · Daniel Pittman
Quoted 3 lines

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

Quoted 3 lines

I'm sorry for the long delayed and offtopic responce. I discussed this issue with okuji-san (GRUB2 maintainer) at several month ago. He really wish linux implement real sync.

This is not about real sync. It is about the box being able to reboot after a crash or power failure.

GRUB2 is broken in that regard, at least in its peecee-BIOS version: last time I checked, it doesn't sort RAID components so that it won't boot from failed or out-of-sync older components, it can't deal with some of the filesystems being unclean...

Quoted 3 lines

A bootloader has much constraint than OS (mainly caused by size constraint). it can't implemnt jornal log replay logic for _all_ filesystem. Why can't we implement storong sync syscall? I don't think this is PM nor bootloader fault.

A bootloader that can't boot a system that went through an unclean shutdown is quite broken.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#17 lore raw
In reply to KOSAKI Motohiro
Quoted 13 lines · KOSAKI Motohiro
Quoted 6 lines · Daniel Pittman
Quoted 4 lines

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

Quoted 6 lines

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

Quoted 8 lines

I'm sorry for the long delayed and offtopic responce. I discussed this issue with okuji-san (GRUB2 maintainer) at several month ago. He really wish linux implement real sync.

A bootloader has much constraint than OS (mainly caused by size constraint). it can't implemnt jornal log replay logic for _all_ filesystem. Why can't we implement storong sync syscall? I don't think this is PM nor bootloader fault.

We already have an ioctl that does what you want: FIFREEZE.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#18 lore raw
In reply to KOSAKI Motohiro
Quoted 13 lines · KOSAKI Motohiro
Quoted 6 lines · Daniel Pittman
Quoted 4 lines

For what it is worth, I would also be quite interested to know /why/ XFS is bad in this regard. Is it just the previously stated "XFS writes to disk despite freezing kernel threads" issue, or something deeper?

Quoted 6 lines

sync pushes out all data to disk, but in a journaling filesystem that might just but the log not the "normal" place on disk. For a boot loader to deal with it properly it actually needs to do an replay of the log. Grub does so for reiserfs but not for XFS for some reason. I don't know why problems don't trigger more often with ext3, though.

Quoted 8 lines

I'm sorry for the long delayed and offtopic responce. I discussed this issue with okuji-san (GRUB2 maintainer) at several month ago. He really wish linux implement real sync.

A bootloader has much constraint than OS (mainly caused by size constraint). it can't implemnt jornal log replay logic for _all_ filesystem. Why can't we implement storong sync syscall? I don't think this is PM nor bootloader fault.

We already have an ioctl that does what you want: FIFREEZE.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#19 lore raw
Quoted 1 line · Dave Chinner

We already have an ioctl that does what you want: FIFREEZE.

Doesn't really help as there is not guarentee important metadata is modified again before the bootloader accesses it, but that's a fate share with any other kind of super sync. The only way to really fix the problem is to implement proper (in-memory) log recovery in the bootloader, especially as it doesn't only have to deal with the relatively easy case of clean shutdowns but also needs to deal with the case of an unclean shutdown with major amounts of updates to the lookup and allocation data structures in the log.

IMHO the best option is to have a separate partition for /boot with a very simple filesystem that we can expect boot loader developers to implement fully and correctly.

#20 lore raw
In reply to Dave Chinner
Quoted 1 line · Dave Chinner

We already have an ioctl that does what you want: FIFREEZE.

Doesn't really help as there is not guarentee important metadata is modified again before the bootloader accesses it, but that's a fate share with any other kind of super sync. The only way to really fix the problem is to implement proper (in-memory) log recovery in the bootloader, especially as it doesn't only have to deal with the relatively easy case of clean shutdowns but also needs to deal with the case of an unclean shutdown with major amounts of updates to the lookup and allocation data structures in the log.

IMHO the best option is to have a separate partition for /boot with a very simple filesystem that we can expect boot loader developers to implement fully and correctly.

#21 lore raw
Quoted 3 lines · Christoph Hellwig

IMHO the best option is to have a separate partition for /boot with a very simple filesystem that we can expect boot loader developers to implement fully and correctly.

Agreed. And one that is not all but abandoned kernel-side, or you will risk bugs there.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#22 lore raw
In reply to Christoph Hellwig
Quoted 3 lines · Christoph Hellwig

IMHO the best option is to have a separate partition for /boot with a very simple filesystem that we can expect boot loader developers to implement fully and correctly.

Agreed. And one that is not all but abandoned kernel-side, or you will risk bugs there.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#23 lore raw

ext4 filesystem corruption

In reply to Maxim Levitsky

I have more information on that issue.

First of all this isn't related to s2ram/disk.
Second, this happened here again 3 times.

Now kernel complains loudly about access to freed inode.

After a reboot fsck tells the following:

- Some directory entries point to freed inodes,
Which means these files are gone, but I never deleted some of them

- Some inodes have shared blocks

- Some orpahaned inodes found

- Free block counts/bitmaps corrupted.

That all happens without any s2ram/disk cycle.

However, yet an unusual situation did happen today.
I had installed an update to mountall ubuntu package, and it hosed all boot process.
I had to reboot many times, and once did hold the power button for 4 seconds.

I also used often the SYSRQ+U/SYSRQ+B tool.

On the contrary, I did several s2disk cycles, and one did fail, but there was no corruption.

I must say that until now, I had never seen any ext3/ext4 corruption, even though there were many many crashes, power failures, forced reboots, etc...

Best regards,
Maxim Levitsky