fs/f2fs/gc.c | 6 ++-- fs/gfs2/super.c | 20 ++++++----- fs/gfs2/sys.c | 4 +-- fs/ioctl.c | 8 ++--- fs/kernfs/mount.c | 15 +++++++++ fs/super.c | 82 ++++++++++++++++++++++++++++++++++++--------- fs/xfs/scrub/fscounters.c | 4 +-- fs/xfs/xfs_notify_failure.c | 6 ++-- include/linux/fs.h | 16 +++++---- kernel/power/hibernate.c | 16 ++++++++- kernel/power/main.c | 31 +++++++++++++++++ kernel/power/power.h | 4 +++ kernel/power/suspend.c | 7 ++++ 13 files changed, 174 insertions(+), 45 deletions(-)
Now all the pieces are in place to actually allow the power subsystem to
freeze/thaw filesystems during suspend/resume. Filesystems are only
frozen and thawed if the power subsystem does actually own the freeze.
Othwerwise it risks thawing filesystems it didn't own. This could be
done differently be e.g., keeping the filesystems that were actually
frozen on a list and then unfreezing them from that list. This is
disgustingly unclean though and reeks of an ugly hack.
If the filesystem is already frozen by the time we've frozen all
userspace processes we don't care to freeze it again. That's userspace's
job once the process resumes. We only actually freeze filesystems if we
absolutely have to and we ignore other failures to freeze.
We could bubble up errors and fail suspend/resume if the error isn't
EBUSY (aka it's already frozen) but I don't think that this is worth it.
Filesystem freezing during suspend/resume is best-effort. If the user
has 500 ext4 filesystems mounted and 4 fail to freeze for whatever
reason then we simply skip them.
What we have now is already a big improvement and let's see how we fare
with it before making our lives even harder (and uglier) than we have
to.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
Changes in v2:
- Drop all patches that remove TASK_FREEZABLE.
- Expand commit messages a bit.
- Link to v1: https://lore.kernel.org/r/20250401-work-freeze-v1-0-d000611d4ab0@kernel.org
---
Christian Brauner (4):
fs: add owner of freeze/thaw
fs: allow all writers to be frozen
power: freeze filesystems during suspend/resume
kernfs: add warning about implementing freeze/thaw
fs/f2fs/gc.c | 6 ++--
fs/gfs2/super.c | 20 ++++++-----
fs/gfs2/sys.c | 4 +--
fs/ioctl.c | 8 ++---
fs/kernfs/mount.c | 15 +++++++++
fs/super.c | 82 ++++++++++++++++++++++++++++++++++++---------
fs/xfs/scrub/fscounters.c | 4 +--
fs/xfs/xfs_notify_failure.c | 6 ++--
include/linux/fs.h | 16 +++++----
kernel/power/hibernate.c | 16 ++++++++-
kernel/power/main.c | 31 +++++++++++++++++
kernel/power/power.h | 4 +++
kernel/power/suspend.c | 7 ++++
13 files changed, 174 insertions(+), 45 deletions(-)
---
base-commit: 62dfd8d59e2d16873398ede5b1835e302df789b3
change-id: 20250401-work-freeze-693b5b5a78e0
Hi, Christian Brauner, Jan Kara and other contributors of this patchset. I did experiments on my laptop, and these experiments show that this patchset does not solve various longstanding problems related to suspend and filesystems. (Even if I enable /sys/power/freeze_filesystems ) Now let me describe problems I had in the past (and still have!) and then experiments I did and their results. So, I had these 3 problems: - Suspend doesn't work if fstrim in progress (note that I use btrfs as root file system) - Suspend doesn't work if scrub in progress - Suspend doesn't work if we try to read from fuse-sshfs filesystem while network is down Let me describe third problem in more detail. To reproduce you need to do this: - Mount remote filesystem using sshfs (it is based on ssh and fuse) - Disable internet - Run command "ls" in that sshfs filesystem (this command will, of course, hang, because network is down) - Then suspend Suspend will not work. Does your patchset supposed to fix these problems? Okay, so just now I was able to reproduce all 3 problems on latest mainline ( f4a40a4282f467ec99745c6ba62cb84346e42139 ), which (as well as I understand) has this patchset applied. I reproduced them with /sys/power/freeze_filesystems set to both 0 and 1 (thus I did 3 * 2 = 6 experiments). I'm available for further testing. -- Askar Safin
Hi! On Sun 20-07-25 22:23:36, Askar Safin wrote: > I did experiments on my laptop, and these experiments show that this > patchset does not solve various longstanding problems related to suspend > and filesystems. (Even if I enable /sys/power/freeze_filesystems ) > > Now let me describe problems I had in the past (and still have!) and then > experiments I did and their results. > > So, I had these 3 problems: > > - Suspend doesn't work if fstrim in progress (note that I use btrfs as > root file system) Right, this is expected because the FITRIM ioctl (syscall as any other) likely takes too long and so the suspend code looses its patience. There's nothing VFS can do about this. You can talk to btrfs developers to periodically check for pending signal / freezing event like e.g. ext4 does in ext4_trim_interrupted() to avoid suspend failures when FITRIM is running. > - Suspend doesn't work if scrub in progress Similar situation as with FITRIM. This is fully in control of the filesystem and unless the filesystem adds checks and early abort paths, VFS cannot do anything. > - Suspend doesn't work if we try to read from fuse-sshfs filesystem while > network is down On the surface the problem is the same as the above two but the details here are subtly different. Here I expect (although I'm not 100% sure) the blocked process is inside the FUSE filesystem waiting for the FUSE daemon to reply (a /proc/<pid>/stack of the blocked process would be useful here). In theory, FUSE filesystem should be able to make the wait for reply in TASK_FREEZABLE state which would fix your issue. In any case this is very likely work for FUSE developers. So I'm sorry but the patch set you speak about isn't supposed to fix any of the above issues you hit. Honza -- Jan Kara <jack@suse.com> SUSE Labs, CR
On Mon, 21 Jul 2025 at 14:09, Jan Kara <jack@suse.cz> wrote: > > Hi! > > On Sun 20-07-25 22:23:36, Askar Safin wrote: > > - Suspend doesn't work if we try to read from fuse-sshfs filesystem while > > network is down > > On the surface the problem is the same as the above two but the details > here are subtly different. Here I expect (although I'm not 100% sure) the > blocked process is inside the FUSE filesystem waiting for the FUSE daemon > to reply (a /proc/<pid>/stack of the blocked process would be useful here). > In theory, FUSE filesystem should be able to make the wait for reply in > TASK_FREEZABLE state which would fix your issue. In any case this is very > likely work for FUSE developers. This is a known problem with an unknown solution. We can fix some of the cases, but changing all filesystem locks to be freezable is likely not workable. Thanks, Miklos
---- On Mon, 04 Aug 2025 09:31:00 +0400 Miklos Szeredi <miklos@szeredi.hu> wrote --- > This is a known problem with an unknown solution. > > We can fix some of the cases, but changing all filesystem locks to be > freezable is likely not workable. So what to do in case of networked FUSE, such as sshfs? We should put workaround to other place? Where? To libfuse or to each networked FUSE daemon, such as sshfs? I hit this bug in the past, and I'm very angry. A lot of other people hit this FUSE bug, too: https://github.com/systemd/systemd/issues/37590 . What about this timeout solution: https://lore.kernel.org/linux-fsdevel/20250122215528.1270478-1-joannelkoong@gmail.com/ ? Will it work? As well as I understand, currently kernel waits 20 seconds, when it tries to freeze processes when suspending. So, what if we use this Joanne Koong's timeout patch, and set timeout to 19 seconds? So, in short, if we cannot properly fix kernel, then where fix belongs? What should we do? -- Askar Safin https://types.pl/@safinaskar
On (25/08/04 10:02), Askar Safin wrote: > What about this timeout solution: https://lore.kernel.org/linux-fsdevel/20250122215528.1270478-1-joannelkoong@gmail.com/ ? > Will it work? As well as I understand, currently kernel waits 20 seconds, when it tries to freeze processes when suspending. > So, what if we use this Joanne Koong's timeout patch, and set timeout to 19 seconds? I think the problem with this approach is that not all fuse connections are remote (over the network). One can use fuse to mount vfat/ntfs or even archives. Destroying those connections for suspend is unlikely to be loved by users.
© 2016 - 2026 Red Hat, Inc.