]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kernfs: add warning about implementing freeze/thaw
authorChristian Brauner <brauner@kernel.org>
Wed, 2 Apr 2025 14:07:34 +0000 (16:07 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 9 May 2025 10:41:23 +0000 (12:41 +0200)
Sysfs is built on top of kernfs and sysfs provides the power management
infrastructure to support suspend/hibernate by writing to various files
in /sys/power/. As filesystems may be automatically frozen during
suspend/hibernate implementing freeze/thaw support for kernfs
generically will cause deadlocks as the suspending/hibernation
initiating task will hold a VFS lock that it will then wait upon to be
released. If freeze/thaw for kernfs is needed talk to the VFS.

Link: https://lore.kernel.org/r/20250402-work-freeze-v2-4-6719a97b52ac@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/kernfs/mount.c

index 5124e196c2bfd8862be0ee7dfae1eda06a95bbc6..46d773411ba8afcfd954993a0f0805982d7e7a83 100644 (file)
@@ -62,6 +62,21 @@ const struct super_operations kernfs_sops = {
 
        .show_options   = kernfs_sop_show_options,
        .show_path      = kernfs_sop_show_path,
+
+       /*
+        * sysfs is built on top of kernfs and sysfs provides the power
+        * management infrastructure to support suspend/hibernate by
+        * writing to various files in /sys/power/. As filesystems may
+        * be automatically frozen during suspend/hibernate implementing
+        * freeze/thaw support for kernfs generically will cause
+        * deadlocks as the suspending/hibernation initiating task will
+        * hold a VFS lock that it will then wait upon to be released.
+        * If freeze/thaw for kernfs is needed talk to the VFS.
+        */
+       .freeze_fs      = NULL,
+       .unfreeze_fs    = NULL,
+       .freeze_super   = NULL,
+       .thaw_super     = NULL,
 };
 
 static int kernfs_encode_fh(struct inode *inode, __u32 *fh, int *max_len,