linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bcache and hibernation
@ 2014-11-13 13:52 Mathijs Kwik
  2014-11-13 15:52 ` Mathijs Kwik
  2014-11-13 22:11 ` Kent Overstreet
  0 siblings, 2 replies; 10+ messages in thread
From: Mathijs Kwik @ 2014-11-13 13:52 UTC (permalink / raw)
  To: linux-bcache

Hi all,

Today, I lost most my data (don't worry, got backups) after the cache
got corrupted somehow. I suspected a recent suspend-to-disk to be the
cause. I checked how my distribution (NixOS) handles suspend/resume and
I have some concerns about how bcache fits into this.

Normally, the kernel and initrd get loaded. The initrd loads required
kernel modules, waits for udev to settle, activates luks&lvm, then
finally asks the kernel to resume from the resume device.

The kernel documentation on suspend is VERY clear you should NOT touch
anything on disk between suspend and resume. So activating luks and LVM
is probably risky already, but it apppears both luks and LVM do not make
any on-disk changes when activated and any in-memory state (within the
resumed image) is still valid. The benefit of activating luks and LVM
before resume seems to be that it allows resuming from encrypted/lvm
volumes. 

Now, with bcache added, things probably get a bit hairy. NixOS supports
bcache inside the initrd and uses udev rules to activate/attach. I
suspect this is probably unsafe. Probably bcache starts to see if any
dirty pages exist, to write them to the backing store. Even without
writeback caching, the activation of lvm will read some sectors, which
might trigger the cache to update. Then after resuming the image, the
in-memory state is corrupted and further damage occurs. 

- Does this sound plausible? 
- Is there any way to tell bcache to make absolutely no changes to
  either the backing device or the cache?
  Basically like a readaround+writearound which can be triggered on
  hibernate and switched off on resume.

Thanks,
Mathijs

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

end of thread, other threads:[~2015-02-10 22:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-13 13:52 bcache and hibernation Mathijs Kwik
2014-11-13 15:52 ` Mathijs Kwik
     [not found]   ` <CAPBO7TZF5qUV64UZJVE+WQkKa2aCJSTjkQxh6eVktH7nA41Vqw@mail.gmail.com>
2014-11-13 16:52     ` Mathijs Kwik
     [not found]       ` <CAPBO7TbQA2MbFS43racKOwZ+=U2jC4OcLF413-MvvNKML5=QZQ@mail.gmail.com>
2014-11-13 17:23         ` Mathijs Kwik
2015-02-10 22:36           ` Kai Krakow
2014-11-13 22:11 ` Kent Overstreet
2014-11-30 18:25   ` Mathijs Kwik
2014-11-30 23:24     ` Kent Overstreet
2014-11-30 23:29     ` Kent Overstreet
2014-12-01  8:48       ` Mathijs Kwik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).