mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@clusterfs.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: Nigel Cunningham <ncunningham@clear.net.nz>,
	Andrew Morton <akpm@digeo.com>,
	cat@zip.com.au, mbligh@aracnet.com, gigerstyle@gmx.ch,
	geert@linux-m68k.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Fix SWSUSP & !SWAP
Date: Fri, 25 Apr 2003 10:20:14 -0600	[thread overview]
Message-ID: <20030425102014.A26054@schatzie.adilger.int> (raw)
In-Reply-To: <20030425125918.GA25733@atrey.karlin.mff.cuni.cz>; from pavel@ucw.cz on Fri, Apr 25, 2003 at 02:59:18PM +0200

On Apr 25, 2003  14:59 +0200, Pavel Machek wrote:
> > I don't believe Pavel was saying the image would be corrupted. Rather,
> > the rest of the disk contents are corrupted by replaying the journal and
> > then resuming back to a memory state that has been made inconsistent
> > with the disk state because of the journal replay.
> 
> Right.

But that is happening regardless of whether a swapfile is in use or not.
It is a problem whether the filesystem is journaling or not.  Basically,
if you are entering into a normal boot sequence and mounting filesystems
and then resuming from your saved state you risk filesystem corruption.

The only way to avoid that would be for the kernel to detect the swsusp
magic data in the swap partition _before_ any filesystems are mounted
(probably via initramfs), and then resume from that image (which will
implicitly "mount" the filesystem because it was never unmounted in
that image).  Then, swsusp becomes a special case of the 2-kernel-monte
(or add your other favourite kernel-booting-kernel method here), where
most of your kernel state is swapped out and only a limited recovery
state is loaded into RAM before doing the kernel dance).

> > > If that is the case, then the only way to avoid this would be to call
> > > sync_supers_lockfs() on each filesystem before the suspend, which will
> > > force the journal to be empty when it returns.  That API is supported
> > > by all of the journaling filesystems, and is probably a good thing to
> > > do anyways, as it will potentially free a lot of dirty data from RAM,
> > > and also ensure that the on-disk data is consistent in case the resume
> > > isn't handled gracefully.
> > 
> > Sounds like a good idea to me.
> 
> When I do sys_sync(), will it trigger that?

No, having sys_sync() do journal purging would really hurt journal fs
performance.  That's why I said you need to call sync_supers_lockfs(),
which is unfortunately not in 2.4 kernels (available in the LVM CVS
as a patch), but it does appear to be in 2.5 kernels.  For journaling
filesystems this is the equivalent of temporarily unmounting the
filesystem and then remounting it when unlockfs() is called.

Note that you must explicitly pass a block device to lock, so that you
do this before shutting down the disk device.  I've never tested, but
locking the filesystem probably does not prevent writing to an existing
swapfile on that filesystem, since the swap code bypasses the filesystem
entirely.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/


  reply	other threads:[~2003-04-25 16:10 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-23 13:51 Pavel Machek
2003-04-23 14:32 ` Geert Uytterhoeven
2003-04-23 14:47   ` Pavel Machek
2003-04-23 15:56     ` gigerstyle
2003-04-23 19:41       ` Nigel Cunningham
2003-04-23 20:36         ` Marc Giger
2003-04-23 22:25           ` Nigel Cunningham
2003-04-23 23:28             ` Martin J. Bligh
2003-04-23 23:58               ` Pavel Machek
2003-04-23 23:55                 ` Martin J. Bligh
2003-04-24  0:07                 ` Andrew Morton
2003-04-24  0:17                   ` CaT
2003-04-24  0:16                     ` Nigel Cunningham
2003-04-24  0:26                       ` Randy.Dunlap
2003-04-24  0:31                         ` CaT
2003-04-24  0:38                         ` Andrew Morton
2003-04-24  0:54                           ` CaT
2003-04-24  1:06                             ` Andrew Morton
2003-04-24  8:48                           ` John Bradford
2003-04-24  0:37                       ` Andrew Morton
2003-04-24  9:12                         ` Pavel Machek
2003-04-24  9:25                           ` Andrew Morton
2003-04-24  9:35                             ` Pavel Machek
2003-04-24  9:46                               ` Andrew Morton
2003-04-24 11:13                                 ` Nigel Cunningham
2003-04-24 11:36                                   ` Andrew Morton
2003-04-24 14:26                                     ` Pavel Machek
2003-04-24 16:37                                       ` Andreas Dilger
2003-04-24 20:48                                         ` Pavel Machek
2003-04-24 21:46                                           ` Andreas Dilger
2003-04-25  1:09                                             ` Nigel Cunningham
2003-04-25 12:59                                               ` Pavel Machek
2003-04-25 16:20                                                 ` Andreas Dilger [this message]
2003-04-25 18:28                                                   ` Nigel Cunningham
2003-04-25 19:32                                                     ` Jamie Lokier
2003-04-25 19:58                                                     ` Andreas Dilger
2003-04-27 18:59                                                   ` Pavel Machek
2003-04-24 11:36                                   ` Geert Uytterhoeven
2003-04-25  1:22                                     ` H. Peter Anvin
2003-04-25  1:19                                       ` Nigel Cunningham
2003-04-25  1:31                                       ` Hua Zhong
2003-04-25 19:41                                         ` H. Peter Anvin
2003-04-25  4:27                                       ` Andreas Dilger
2003-04-25  4:33                                         ` H. Peter Anvin
2003-04-24  0:25                   ` Pavel Machek
2003-04-24  9:01                     ` Andrew Morton
2003-04-24  9:14                       ` Pavel Machek
2003-04-24  9:05                     ` Jamie Lokier
2003-04-24  9:34                       ` Pavel Machek
2003-04-24 15:22                     ` Carl-Daniel Hailfinger
2003-04-24  8:00             ` Marc Giger
2003-04-23 23:47 Grover, Andrew
2003-04-24  0:03 ` Pavel Machek
2003-04-23 23:57   ` Martin J. Bligh
2003-04-24  0:25     ` Pavel Machek
2003-04-24  0:37       ` CaT
2003-04-24  0:49       ` Martin J. Bligh
2003-04-24  9:16         ` Pavel Machek
2003-04-24  0:02   ` Nigel Cunningham
2003-04-24  0:23     ` Pavel Machek
2003-04-24  0:45     ` Martin J. Bligh
2003-04-24  3:17       ` Nigel Cunningham
2003-04-24  4:37         ` Martin J. Bligh
2003-04-24  7:49           ` Marc Giger
2003-04-24  9:27           ` Pavel Machek
2003-04-24  3:49   ` David Ford
2003-04-24  6:54     ` Jörn Engel
2003-04-24  7:01     ` Elladan

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=20030425102014.A26054@schatzie.adilger.int \
    --to=adilger@clusterfs.com \
    --cc=akpm@digeo.com \
    --cc=cat@zip.com.au \
    --cc=geert@linux-m68k.org \
    --cc=gigerstyle@gmx.ch \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbligh@aracnet.com \
    --cc=ncunningham@clear.net.nz \
    --cc=pavel@ucw.cz \
    /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®