All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: hch@infradead.org, song@kernel.org, rafael@kernel.org,
	gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk,
	jack@suse.cz, bvanassche@acm.org, ebiederm@xmission.com,
	mchehab@kernel.org, keescook@chromium.org, p.raghav@samsung.com,
	linux-fsdevel@vger.kernel.org, kernel@tuxforce.de,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC v3 05/24] fs: add automatic kernel fs freeze / thaw and remove kthread freezing
Date: Sat, 6 May 2023 21:07:40 -0700	[thread overview]
Message-ID: <ZFckDPpgpbvZBFyL@bombadil.infradead.org> (raw)
In-Reply-To: <Y/gqNaP4mrSMaDJo@magnolia>

On Thu, Feb 23, 2023 at 07:08:37PM -0800, Darrick J. Wong wrote:
> On Fri, Jan 13, 2023 at 04:33:50PM -0800, Luis Chamberlain wrote:
> > Add support to automatically handle freezing and thawing filesystems
> > during the kernel's suspend/resume cycle.
> > 
> > This is needed so that we properly really stop IO in flight without
> > races after userspace has been frozen. Without this we rely on
> > kthread freezing and its semantics are loose and error prone.
> > For instance, even though a kthread may use try_to_freeze() and end
> > up being frozen we have no way of being sure that everything that
> > has been spawned asynchronously from it (such as timers) have also
> > been stopped as well.
> > 
> > A long term advantage of also adding filesystem freeze / thawing
> > supporting during suspend / hibernation is that long term we may
> > be able to eventually drop the kernel's thread freezing completely
> > as it was originally added to stop disk IO in flight as we hibernate
> > or suspend.
> 
> Hooray!
> 
> One evil question though --
> 
> Say you have dm devices A and B.  Each has a distinct fs on it.
> If you mount A and then B and initiate a suspend, that should result in
> first B and then A freezing, right?
> 
> After resuming, you then change A's dm-table definition to point it
> at a loop device backed by a file on B.
> 
> What happens now when you initiate a suspend?  B freezes, then A tries
> to flush data to the loop-mounted file on B, but it's too late for that.
> That sounds like a deadlock?
> 
> Though I don't know how much we care about this corner case,

As you suggest this is not the only corner case that one could draw
upon. There was that evil ioctl added years ago to allow flipping an
installed system bootted from a USB or ISO over to the real freshly
installed root mount point. To make this bullet-proof we'll need to
eventually add a simple graph implementation to keep tags on ordering
requirements for the super blocks. I have some C code which tries to
implement a graph Linux style but since these are all corner cases at
this time, I think it's best we fix first suspend for most and later
address a proper graph solution.

> Anyway, just wondering if you'd thought about that kind of doomsday
> scenario that a nutty sysadmin could set up.
> 
> The only way I can think of to solve that kind of thing would be to hook
> filesystems and loop devices into the device model, make fs "device"
> suspend actually freeze, hope the suspend code suspends from the leaves
> inward, and hope I actually understand how the device model works (I
> don't.)

There's probably really odd things one can do, and one thing I think
we can later do is simply annotate those cases and *not* allow auto-freeze
with time for those horrible situations.

A real long term solution I think will involve a graph.

  Luis

WARNING: multiple messages have this Message-ID (diff)
From: Luis Chamberlain <mcgrof@kernel.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: hch@infradead.org, song@kernel.org, rafael@kernel.org,
	gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk,
	jack@suse.cz, bvanassche@acm.org, ebiederm@xmission.com,
	mchehab@kernel.org, keescook@chromium.org, p.raghav@samsung.com,
	linux-fsdevel@vger.kernel.org, kernel@tuxforce.de,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC v3 05/24] fs: add automatic kernel fs freeze / thaw and remove kthread freezing
Date: Sat, 6 May 2023 21:07:40 -0700	[thread overview]
Message-ID: <ZFckDPpgpbvZBFyL@bombadil.infradead.org> (raw)
In-Reply-To: <Y/gqNaP4mrSMaDJo@magnolia>

On Thu, Feb 23, 2023 at 07:08:37PM -0800, Darrick J. Wong wrote:
> On Fri, Jan 13, 2023 at 04:33:50PM -0800, Luis Chamberlain wrote:
> > Add support to automatically handle freezing and thawing filesystems
> > during the kernel's suspend/resume cycle.
> > 
> > This is needed so that we properly really stop IO in flight without
> > races after userspace has been frozen. Without this we rely on
> > kthread freezing and its semantics are loose and error prone.
> > For instance, even though a kthread may use try_to_freeze() and end
> > up being frozen we have no way of being sure that everything that
> > has been spawned asynchronously from it (such as timers) have also
> > been stopped as well.
> > 
> > A long term advantage of also adding filesystem freeze / thawing
> > supporting during suspend / hibernation is that long term we may
> > be able to eventually drop the kernel's thread freezing completely
> > as it was originally added to stop disk IO in flight as we hibernate
> > or suspend.
> 
> Hooray!
> 
> One evil question though --
> 
> Say you have dm devices A and B.  Each has a distinct fs on it.
> If you mount A and then B and initiate a suspend, that should result in
> first B and then A freezing, right?
> 
> After resuming, you then change A's dm-table definition to point it
> at a loop device backed by a file on B.
> 
> What happens now when you initiate a suspend?  B freezes, then A tries
> to flush data to the loop-mounted file on B, but it's too late for that.
> That sounds like a deadlock?
> 
> Though I don't know how much we care about this corner case,

As you suggest this is not the only corner case that one could draw
upon. There was that evil ioctl added years ago to allow flipping an
installed system bootted from a USB or ISO over to the real freshly
installed root mount point. To make this bullet-proof we'll need to
eventually add a simple graph implementation to keep tags on ordering
requirements for the super blocks. I have some C code which tries to
implement a graph Linux style but since these are all corner cases at
this time, I think it's best we fix first suspend for most and later
address a proper graph solution.

> Anyway, just wondering if you'd thought about that kind of doomsday
> scenario that a nutty sysadmin could set up.
> 
> The only way I can think of to solve that kind of thing would be to hook
> filesystems and loop devices into the device model, make fs "device"
> suspend actually freeze, hope the suspend code suspends from the leaves
> inward, and hope I actually understand how the device model works (I
> don't.)

There's probably really odd things one can do, and one thing I think
we can later do is simply annotate those cases and *not* allow auto-freeze
with time for those horrible situations.

A real long term solution I think will involve a graph.

  Luis

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2023-05-07  4:07 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14  0:33 [RFC v3 00/24] vfs: provide automatic kernel freeze / resume Luis Chamberlain
2023-01-14  0:33 ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 01/24] fs: unify locking semantics for fs freeze / thaw Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-16 15:14   ` Jan Kara
2023-01-16 15:14     ` Jan Kara
2023-05-07  3:47     ` Luis Chamberlain
2023-05-07  3:47       ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 02/24] fs: add frozen sb state helpers Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-16 16:11   ` Jan Kara
2023-01-16 16:11     ` Jan Kara
2023-01-14  0:33 ` [RFC v3 03/24] fs: distinguish between user initiated freeze and kernel initiated freeze Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-16 16:10   ` Jan Kara
2023-01-16 16:10     ` Jan Kara
2023-01-18  2:25   ` Darrick J. Wong
2023-01-18  2:25     ` Darrick J. Wong
2023-01-18  9:28     ` Jan Kara
2023-01-18  9:28       ` Jan Kara
2023-05-07  4:08       ` Luis Chamberlain
2023-05-07  4:08         ` Luis Chamberlain
2023-05-23  0:33         ` Darrick J. Wong
2023-05-23  0:33           ` Darrick J. Wong
2023-01-14  0:33 ` [RFC v3 04/24] fs: add iterate_supers_excl() and iterate_supers_reverse_excl() Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 05/24] fs: add automatic kernel fs freeze / thaw and remove kthread freezing Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:57   ` Luis Chamberlain
2023-01-14  0:57     ` Luis Chamberlain
2023-01-16 16:09   ` Jan Kara
2023-01-16 16:09     ` Jan Kara
2023-02-24  3:08   ` Darrick J. Wong
2023-02-24  3:08     ` Darrick J. Wong
2023-05-07  4:07     ` Luis Chamberlain [this message]
2023-05-07  4:07       ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 06/24] xfs: replace kthread freezing with auto fs freezing Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 07/24] btrfs: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 08/24] ext4: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 09/24] f2fs: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 10/24] cifs: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 11/24] gfs2: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 12/24] jfs: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 13/24] nilfs2: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:33 ` [RFC v3 14/24] nfs: " Luis Chamberlain
2023-01-14  0:33   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 15/24] nfsd: " Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 16/24] ubifs: " Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 17/24] ksmbd: " Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 18/24] jffs2: " Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 19/24] jbd2: " Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 20/24] coredump: drop freezer usage Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 21/24] ecryptfs: replace kthread freezing with auto fs freezing Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 22/24] fscache: " Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 23/24] lockd: " Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain
2023-01-14  0:34 ` [RFC v3 24/24] fs: remove FS_AUTOFREEZE Luis Chamberlain
2023-01-14  0:34   ` Luis Chamberlain

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=ZFckDPpgpbvZBFyL@bombadil.infradead.org \
    --to=mcgrof@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=djwong@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=keescook@chromium.org \
    --cc=kernel@tuxforce.de \
    --cc=kexec@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=p.raghav@samsung.com \
    --cc=rafael@kernel.org \
    --cc=song@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 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.