From: Christian Brauner <brauner@kernel.org>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz,
Ard Biesheuvel <ardb@kernel.org>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
mcgrof@kernel.org, hch@infradead.org, david@fromorbit.com,
rafael@kernel.org, djwong@kernel.org, pavel@kernel.org,
peterz@infradead.org, mingo@redhat.com, will@kernel.org,
boqun.feng@gmail.com
Subject: Re: [PATCH 2/2] efivarfs: support freeze/thaw
Date: Mon, 31 Mar 2025 17:03:45 +0200 [thread overview]
Message-ID: <20250331-mitunter-samen-07781404fd12@brauner> (raw)
In-Reply-To: <792a6f2f5ad3285d71595860c20f354e2d2306b6.camel@HansenPartnership.com>
On Mon, Mar 31, 2025 at 10:46:43AM -0400, James Bottomley wrote:
> On Mon, 2025-03-31 at 14:42 +0200, Christian Brauner wrote:
> > Allow efivarfs to partake to resync variable state during system
> > hibernation and suspend. Add freeze/thaw support.
> >
> > This is a pretty straightforward implementation. We simply add
> > regular freeze/thaw support for both userspace and the kernel. This
> > works without any big issues and congrats afaict efivars is the first
> > pseudofilesystem that adds support for filesystem freezing and
> > thawing.
> >
> > The simplicity comes from the fact that we simply always resync
> > variable state after efivarfs has been frozen. It doesn't matter
> > whether that's because of suspend, userspace initiated freeze or
> > hibernation. Efivars is simple enough that it doesn't matter that we
> > walk all dentries. There are no directories and there aren't insane
> > amounts of entries and both freeze/thaw are already heavy-handed
> > operations. We really really don't need to care.
>
> Just as a point of order: this can't actually work until freeze/thaw is
> actually plumbed into suspend/resume.
>
> >
> > Signed-off-by: Christian Brauner <brauner@kernel.org>
> > ---
> > fs/efivarfs/internal.h | 1 -
> > fs/efivarfs/super.c | 196 +++++++++++++--------------------------
> > ----------
> > 2 files changed, 51 insertions(+), 146 deletions(-)
> >
> > diff --git a/fs/efivarfs/internal.h b/fs/efivarfs/internal.h
> > index ac6a1dd0a6a5..f913b6824289 100644
> > --- a/fs/efivarfs/internal.h
> > +++ b/fs/efivarfs/internal.h
> > @@ -17,7 +17,6 @@ struct efivarfs_fs_info {
> > struct efivarfs_mount_opts mount_opts;
> > struct super_block *sb;
> > struct notifier_block nb;
> > - struct notifier_block pm_nb;
> > };
> >
> > struct efi_variable {
> > diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
> > index 0486e9b68bc6..567e849a03fe 100644
> > --- a/fs/efivarfs/super.c
> > +++ b/fs/efivarfs/super.c
> > @@ -20,6 +20,7 @@
> > #include <linux/printk.h>
> >
> > #include "internal.h"
> > +#include "../internal.h"
> >
> > static int efivarfs_ops_notifier(struct notifier_block *nb, unsigned
> > long event,
> > void *data)
> > @@ -119,12 +120,18 @@ static int efivarfs_statfs(struct dentry
> > *dentry, struct kstatfs *buf)
> >
> > return 0;
> > }
> > +
> > +static int efivarfs_freeze_fs(struct super_block *sb);
> > +static int efivarfs_unfreeze_fs(struct super_block *sb);
> > +
> > static const struct super_operations efivarfs_ops = {
> > .statfs = efivarfs_statfs,
> > .drop_inode = generic_delete_inode,
> > .alloc_inode = efivarfs_alloc_inode,
> > .free_inode = efivarfs_free_inode,
> > .show_options = efivarfs_show_options,
> > + .freeze_fs = efivarfs_freeze_fs,
>
> Why is it necessary to have a freeze_fs operation? The current code in
> super.c:freeze_super() reads:
Fwiw, I've explained this already in prior mails. The same behavior as
for the ioctl where we check whether the filesystem provides either a
->freeze_fs or ->freeze_super method. If neither is provided the
filesystem is assumed to not have freeze support.
>
> if (sb->s_op->freeze_fs) {
> ret = sb->s_op->freeze_fs(sb);
>
> So it would seem that setting this to NULL has exactly the same effect
> as providing a null method.
No, it would cause freeze to not be called.
IOW, any filesystem that doesn't provides neither a freeze_super or
freeze_fs method doesn't support freeze (that's how the ioctls work as
well) which allows us to only call into filesystems that are able to
properly freeze so we don't need pointless FS_* flags. By only providing
thaw it would end up thawing something that was never frozen. Both are
provided and the freeze methods function as the indicator whether
freezing/thawing is supported.
That could be changed but not in this series. We could also provide
noop_freeze just like we have noop_sync but again, not for this series.
>
> > + .unfreeze_fs = efivarfs_unfreeze_fs,
> > };
> >
> > /*
> >
> [...]
> > @@ -608,9 +516,7 @@ static void efivarfs_kill_sb(struct super_block
> > *sb)
> > {
> > struct efivarfs_fs_info *sfi = sb->s_fs_info;
> >
> > - blocking_notifier_chain_unregister(&efivar_ops_nh, &sfi-
> > >nb);
>
> This is an extraneous deletion of an unrelated notifier which efivarfs
> still needs to listen for ops updates from the efi subsystem.
At first I was bewildered because I thought you were talking about pm_nb
for some reason and was ready to explode. Man, I need a post LSFMM
vacation. :)
Thanks for spotting this. This is now fixed by adding back:
blocking_notifier_chain_unregister(&efivar_ops_nh, &sfi->nb);
next prev parent reply other threads:[~2025-03-31 15:03 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250329-work-freeze-v2-0-a47af37ecc3d@kernel.org>
2025-03-31 12:42 ` [PATCH 0/2] efivarfs: support freeze/thaw Christian Brauner
2025-03-31 12:42 ` [PATCH 1/2] libfs: export find_next_child() Christian Brauner
2025-03-31 12:42 ` [PATCH 2/2] efivarfs: support freeze/thaw Christian Brauner
2025-03-31 14:46 ` James Bottomley
2025-03-31 15:03 ` Christian Brauner [this message]
2025-04-01 19:31 ` James Bottomley
2025-04-02 7:44 ` Christian Brauner
2025-03-31 14:05 ` [PATCH 0/2] " Ard Biesheuvel
2025-04-01 0:32 ` [PATCH 0/6] power: wire-up filesystem freeze/thaw with suspend/resume Christian Brauner
2025-04-01 0:32 ` [PATCH 1/6] ext4: replace kthread freezing with auto fs freezing Christian Brauner
2025-04-01 9:16 ` Jan Kara
2025-04-01 9:35 ` Christian Brauner
2025-04-01 10:08 ` Jan Kara
2025-04-01 0:32 ` [PATCH 2/6] btrfs: " Christian Brauner
2025-04-01 0:32 ` [PATCH 3/6] xfs: " Christian Brauner
2025-04-01 1:11 ` Dave Chinner
2025-04-01 7:17 ` Christian Brauner
2025-04-01 11:35 ` Dave Chinner
2025-04-01 12:45 ` Christian Brauner
2025-04-01 0:32 ` [PATCH 4/6] fs: add owner of freeze/thaw Christian Brauner
2025-04-01 0:32 ` [PATCH 5/6] fs: allow pagefault based writers to be frozen Christian Brauner
2025-04-01 0:32 ` [PATCH 6/6] power: freeze filesystems during suspend/resume Christian Brauner
2025-04-01 8:16 ` [PATCH 0/6] power: wire-up filesystem freeze/thaw with suspend/resume Christian Brauner
2025-04-01 9:32 ` Jan Kara
2025-04-01 13:03 ` Christian Brauner
2025-04-01 16:57 ` Jan Kara
2025-04-02 14:07 ` [PATCH v2 0/4] " Christian Brauner
2025-04-02 14:07 ` [PATCH v2 1/4] fs: add owner of freeze/thaw Christian Brauner
2025-04-03 14:56 ` Jan Kara
2025-04-03 19:33 ` Christian Brauner
2025-04-04 10:24 ` [PATCH] fs: allow nesting with FREEZE_EXCL Christian Brauner
2025-04-07 9:08 ` Christoph Hellwig
2025-05-07 11:18 ` Jan Kara
2025-05-09 10:38 ` Christian Brauner
2025-04-02 14:07 ` [PATCH v2 2/4] fs: allow all writers to be frozen Christian Brauner
2025-04-02 15:32 ` Christian Brauner
2025-04-02 16:03 ` James Bottomley
2025-04-02 16:13 ` Christian Brauner
2025-04-03 14:59 ` Jan Kara
2025-04-02 14:07 ` [PATCH v2 3/4] power: freeze filesystems during suspend/resume Christian Brauner
2025-04-03 16:29 ` Jan Kara
2025-04-02 14:07 ` [PATCH v2 4/4] kernfs: add warning about implementing freeze/thaw Christian Brauner
2025-04-03 15:00 ` Jan Kara
2025-07-20 19:23 ` [PATCH v2 0/4] power: wire-up filesystem freeze/thaw with suspend/resume Askar Safin
2025-07-21 12:09 ` Jan Kara
2025-08-04 5:31 ` Miklos Szeredi
2025-08-04 6:02 ` Askar Safin
2025-08-04 6:51 ` Sergey Senozhatsky
2025-04-01 14:14 ` [PATCH 0/6] " Peter Zijlstra
2025-04-01 14:40 ` Christian Brauner
2025-04-01 14:59 ` Peter Zijlstra
2025-04-01 17:02 ` James Bottomley
2025-04-02 7:46 ` Christian Brauner
2025-04-08 15:43 ` James Bottomley
2025-04-08 17:09 ` Luis Chamberlain
2025-04-08 17:20 ` Luis Chamberlain
2025-04-08 17:26 ` James Bottomley
2025-04-08 17:24 ` James Bottomley
2025-04-09 7:17 ` Christian Brauner
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=20250331-mitunter-samen-07781404fd12@brauner \
--to=brauner@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=ardb@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=david@fromorbit.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-efi@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mingo@redhat.com \
--cc=pavel@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=will@kernel.org \
/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