From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org, jack@suse.cz
Cc: Christian Brauner <brauner@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
James Bottomley <James.Bottomley@hansenpartnership.com>,
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: [PATCH 3/6] xfs: replace kthread freezing with auto fs freezing
Date: Tue, 1 Apr 2025 02:32:48 +0200 [thread overview]
Message-ID: <20250401-work-freeze-v1-3-d000611d4ab0@kernel.org> (raw)
In-Reply-To: <20250401-work-freeze-v1-0-d000611d4ab0@kernel.org>
From: Luis Chamberlain <mcgrof@kernel.org>
The kernel power management now supports allowing the VFS
to handle filesystem freezing freezes and thawing. Take advantage
of that and remove the kthread freezing. 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.
The filesystem therefore is in charge of properly dealing with
quiescing of the filesystem through its callbacks if it thinks
it knows better than how the VFS handles it.
The following Coccinelle rule was used as to remove the now superfluous
freezer calls:
make coccicheck MODE=patch SPFLAGS="--in-place --no-show-diff" COCCI=./fs-freeze-cleanup.cocci M=fs/xfs
virtual patch
@ remove_set_freezable @
expression time;
statement S, S2;
expression task, current;
@@
(
- set_freezable();
|
- if (try_to_freeze())
- continue;
|
- try_to_freeze();
|
- freezable_schedule();
+ schedule();
|
- freezable_schedule_timeout(time);
+ schedule_timeout(time);
|
- if (freezing(task)) { S }
|
- if (freezing(task)) { S }
- else
{ S2 }
|
- freezing(current)
)
@ remove_wq_freezable @
expression WQ_E, WQ_ARG1, WQ_ARG2, WQ_ARG3, WQ_ARG4;
identifier fs_wq_fn;
@@
(
WQ_E = alloc_workqueue(WQ_ARG1,
- WQ_ARG2 | WQ_FREEZABLE,
+ WQ_ARG2,
...);
|
WQ_E = alloc_workqueue(WQ_ARG1,
- WQ_ARG2 | WQ_FREEZABLE | WQ_ARG3,
+ WQ_ARG2 | WQ_ARG3,
...);
|
WQ_E = alloc_workqueue(WQ_ARG1,
- WQ_ARG2 | WQ_ARG3 | WQ_FREEZABLE,
+ WQ_ARG2 | WQ_ARG3,
...);
|
WQ_E = alloc_workqueue(WQ_ARG1,
- WQ_ARG2 | WQ_ARG3 | WQ_FREEZABLE | WQ_ARG4,
+ WQ_ARG2 | WQ_ARG3 | WQ_ARG4,
...);
|
WQ_E =
- WQ_ARG1 | WQ_FREEZABLE
+ WQ_ARG1
|
WQ_E =
- WQ_ARG1 | WQ_FREEZABLE | WQ_ARG3
+ WQ_ARG1 | WQ_ARG3
|
fs_wq_fn(
- WQ_FREEZABLE | WQ_ARG2 | WQ_ARG3
+ WQ_ARG2 | WQ_ARG3
)
|
fs_wq_fn(
- WQ_FREEZABLE | WQ_ARG2
+ WQ_ARG2
)
|
fs_wq_fn(
- WQ_FREEZABLE
+ 0
)
)
@ add_auto_flag @
expression E1;
identifier fs_type;
@@
struct file_system_type fs_type = {
.fs_flags = E1
+ | FS_AUTOFREEZE
,
};
Generated-by: Coccinelle SmPL
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20250326112220.1988619-7-mcgrof@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/xfs/xfs_discard.c | 2 +-
fs/xfs/xfs_log.c | 3 +--
fs/xfs/xfs_log_cil.c | 2 +-
fs/xfs/xfs_mru_cache.c | 2 +-
fs/xfs/xfs_pwork.c | 2 +-
fs/xfs/xfs_super.c | 14 +++++++-------
fs/xfs/xfs_trans_ail.c | 3 ---
fs/xfs/xfs_zone_gc.c | 2 --
8 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index c1a306268ae4..1596cf0ecb9b 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -333,7 +333,7 @@ xfs_trim_gather_extents(
static bool
xfs_trim_should_stop(void)
{
- return fatal_signal_pending(current) || freezing(current);
+ return fatal_signal_pending(current);
}
/*
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 6493bdb57351..317f6db292fb 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1489,8 +1489,7 @@ xlog_alloc_log(
log->l_iclog->ic_prev = prev_iclog; /* re-write 1st prev ptr */
log->l_ioend_workqueue = alloc_workqueue("xfs-log/%s",
- XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM |
- WQ_HIGHPRI),
+ XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_HIGHPRI),
0, mp->m_super->s_id);
if (!log->l_ioend_workqueue)
goto out_free_iclog;
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 1ca406ec1b40..8ff5d68394e6 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -1932,7 +1932,7 @@ xlog_cil_init(
* concurrency the log spinlocks will be exposed to.
*/
cil->xc_push_wq = alloc_workqueue("xfs-cil/%s",
- XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM | WQ_UNBOUND),
+ XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_UNBOUND),
4, log->l_mp->m_super->s_id);
if (!cil->xc_push_wq)
goto out_destroy_cil;
diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
index d0f5b403bdbe..c9a49c6f6129 100644
--- a/fs/xfs/xfs_mru_cache.c
+++ b/fs/xfs/xfs_mru_cache.c
@@ -293,7 +293,7 @@ int
xfs_mru_cache_init(void)
{
xfs_mru_reap_wq = alloc_workqueue("xfs_mru_cache",
- XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_FREEZABLE), 1);
+ XFS_WQFLAGS(WQ_MEM_RECLAIM), 1);
if (!xfs_mru_reap_wq)
return -ENOMEM;
return 0;
diff --git a/fs/xfs/xfs_pwork.c b/fs/xfs/xfs_pwork.c
index c283b801cc5d..3f5bf53f8778 100644
--- a/fs/xfs/xfs_pwork.c
+++ b/fs/xfs/xfs_pwork.c
@@ -72,7 +72,7 @@ xfs_pwork_init(
trace_xfs_pwork_init(mp, nr_threads, current->pid);
pctl->wq = alloc_workqueue("%s-%d",
- WQ_UNBOUND | WQ_SYSFS | WQ_FREEZABLE, nr_threads, tag,
+ WQ_UNBOUND | WQ_SYSFS, nr_threads, tag,
current->pid);
if (!pctl->wq)
return -ENOMEM;
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 53944cc7af24..06eb51a3d13b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -565,37 +565,37 @@ xfs_init_mount_workqueues(
struct xfs_mount *mp)
{
mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s",
- XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
+ XFS_WQFLAGS(WQ_MEM_RECLAIM),
1, mp->m_super->s_id);
if (!mp->m_buf_workqueue)
goto out;
mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s",
- XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
+ XFS_WQFLAGS(WQ_MEM_RECLAIM),
0, mp->m_super->s_id);
if (!mp->m_unwritten_workqueue)
goto out_destroy_buf;
mp->m_reclaim_workqueue = alloc_workqueue("xfs-reclaim/%s",
- XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
+ XFS_WQFLAGS(WQ_MEM_RECLAIM),
0, mp->m_super->s_id);
if (!mp->m_reclaim_workqueue)
goto out_destroy_unwritten;
mp->m_blockgc_wq = alloc_workqueue("xfs-blockgc/%s",
- XFS_WQFLAGS(WQ_UNBOUND | WQ_FREEZABLE | WQ_MEM_RECLAIM),
+ XFS_WQFLAGS(WQ_UNBOUND | WQ_MEM_RECLAIM),
0, mp->m_super->s_id);
if (!mp->m_blockgc_wq)
goto out_destroy_reclaim;
mp->m_inodegc_wq = alloc_workqueue("xfs-inodegc/%s",
- XFS_WQFLAGS(WQ_FREEZABLE | WQ_MEM_RECLAIM),
+ XFS_WQFLAGS(WQ_MEM_RECLAIM),
1, mp->m_super->s_id);
if (!mp->m_inodegc_wq)
goto out_destroy_blockgc;
mp->m_sync_workqueue = alloc_workqueue("xfs-sync/%s",
- XFS_WQFLAGS(WQ_FREEZABLE), 0, mp->m_super->s_id);
+ XFS_WQFLAGS(0), 0, mp->m_super->s_id);
if (!mp->m_sync_workqueue)
goto out_destroy_inodegc;
@@ -2488,7 +2488,7 @@ xfs_init_workqueues(void)
* max_active value for this workqueue.
*/
xfs_alloc_wq = alloc_workqueue("xfsalloc",
- XFS_WQFLAGS(WQ_MEM_RECLAIM | WQ_FREEZABLE), 0);
+ XFS_WQFLAGS(WQ_MEM_RECLAIM), 0);
if (!xfs_alloc_wq)
return -ENOMEM;
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
index 0fcb1828e598..ad8183db0780 100644
--- a/fs/xfs/xfs_trans_ail.c
+++ b/fs/xfs/xfs_trans_ail.c
@@ -636,7 +636,6 @@ xfsaild(
unsigned int noreclaim_flag;
noreclaim_flag = memalloc_noreclaim_save();
- set_freezable();
while (1) {
/*
@@ -695,8 +694,6 @@ xfsaild(
__set_current_state(TASK_RUNNING);
- try_to_freeze();
-
tout = xfsaild_push(ailp);
}
diff --git a/fs/xfs/xfs_zone_gc.c b/fs/xfs/xfs_zone_gc.c
index c5136ea9bb1d..1875b6551ab0 100644
--- a/fs/xfs/xfs_zone_gc.c
+++ b/fs/xfs/xfs_zone_gc.c
@@ -993,7 +993,6 @@ xfs_zone_gc_handle_work(
}
__set_current_state(TASK_RUNNING);
- try_to_freeze();
if (reset_list)
xfs_zone_gc_reset_zones(data, reset_list);
@@ -1041,7 +1040,6 @@ xfs_zoned_gcd(
unsigned int nofs_flag;
nofs_flag = memalloc_nofs_save();
- set_freezable();
for (;;) {
set_current_state(TASK_INTERRUPTIBLE | TASK_FREEZABLE);
--
2.47.2
next prev parent reply other threads:[~2025-04-01 0:33 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 14:06 [RFC PATCH 0/4] vfs freeze/thaw on suspend/resume James Bottomley
2025-03-27 14:06 ` [RFC PATCH 1/4] locking/percpu-rwsem: add freezable alternative to down_read James Bottomley
2025-03-31 19:51 ` James Bottomley
2025-03-31 23:32 ` Christian Brauner
2025-04-01 1:13 ` James Bottomley
2025-04-01 11:20 ` Jan Kara
2025-04-01 12:50 ` Christian Brauner
2025-04-01 12:52 ` James Bottomley
2025-04-02 11:47 ` Jan Kara
2025-03-27 14:06 ` [RFC PATCH 2/4] vfs: make sb_start_write freezable James Bottomley
2025-03-27 17:36 ` Jan Kara
2025-03-27 14:06 ` [RFC PATCH 3/4] fs/super.c: introduce reverse superblock iterator and use it in emergency remount James Bottomley
2025-03-28 11:56 ` Christian Brauner
2025-03-28 12:38 ` James Bottomley
2025-03-28 16:15 ` [PATCH 0/6] Extend freeze support to suspend and hibernate Christian Brauner
2025-03-28 16:15 ` [PATCH 1/6] super: remove pointless s_root checks Christian Brauner
2025-03-28 16:15 ` [PATCH 2/6] super: simplify user_get_super() Christian Brauner
2025-03-28 16:15 ` [PATCH 3/6] super: skip dying superblocks early Christian Brauner
2025-03-28 16:15 ` [PATCH 4/6] super: use a common iterator (Part 1) Christian Brauner
2025-03-28 16:15 ` [PATCH 5/6] super: use common iterator (Part 2) Christian Brauner
2025-03-28 18:58 ` James Bottomley
2025-03-29 7:34 ` Christian Brauner
2025-03-28 16:15 ` [PATCH 6/6] super: add filesystem freezing helpers for suspend and hibernate Christian Brauner
2025-03-29 8:42 ` [PATCH v2 0/6] Extend freeze support to " Christian Brauner
2025-03-29 8:42 ` [PATCH v2 1/6] super: remove pointless s_root checks Christian Brauner
2025-03-31 9:57 ` Jan Kara
2025-06-11 16:26 ` Darrick J. Wong
2025-06-12 12:20 ` Christian Brauner
2025-03-29 8:42 ` [PATCH v2 2/6] super: simplify user_get_super() Christian Brauner
2025-03-31 9:58 ` Jan Kara
2025-03-29 8:42 ` [PATCH v2 3/6] super: skip dying superblocks early Christian Brauner
2025-03-31 10:00 ` Jan Kara
2025-03-29 8:42 ` [PATCH v2 4/6] super: use a common iterator (Part 1) Christian Brauner
2025-03-31 10:01 ` Jan Kara
2025-03-29 8:42 ` [PATCH v2 5/6] super: use common iterator (Part 2) Christian Brauner
2025-03-31 10:07 ` Jan Kara
2025-03-31 10:15 ` Christian Brauner
2025-03-29 8:42 ` [PATCH v2 6/6] super: add filesystem freezing helpers for suspend and hibernate Christian Brauner
2025-03-29 8:46 ` Christian Brauner
2025-03-31 10:23 ` Jan Kara
2025-03-31 10:25 ` Christian Brauner
2025-03-29 14:04 ` [PATCH v2 0/6] Extend freeze support to " James Bottomley
2025-03-29 17:02 ` James Bottomley
2025-03-30 8:33 ` Christian Brauner
2025-03-30 11:53 ` Christian Brauner
2025-03-30 14:00 ` James Bottomley
2025-03-31 9:13 ` Christian Brauner
2025-03-31 10:36 ` Jan Kara
2025-03-31 14:49 ` James Bottomley
2025-03-31 23:33 ` Christian Brauner
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
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 ` Christian Brauner [this message]
2025-04-01 1:11 ` [PATCH 3/6] xfs: " 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
2025-03-27 14:06 ` [RFC PATCH 4/4] vfs: add filesystem freeze/thaw callbacks for power management James Bottomley
2025-03-27 18:20 ` Jan Kara
2025-03-28 14:21 ` James Bottomley
2025-03-28 14:36 ` James Bottomley
2025-03-28 10:08 ` Christian Brauner
2025-03-28 14:14 ` James Bottomley
2025-03-28 15:52 ` Christian Brauner
2025-03-28 16:15 ` James Bottomley
2025-03-29 8:23 ` Christian Brauner
2025-03-28 12:01 ` Christian Brauner
2025-03-28 14:40 ` James Bottomley
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=20250401-work-freeze-v1-3-d000611d4ab0@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).