From: Luis Chamberlain <mcgrof@kernel.org> To: hch@infradead.org, djwong@kernel.org, song@kernel.org, rafael@kernel.org, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, jack@suse.cz, bvanassche@acm.org, ebiederm@xmission.com Cc: 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, Luis Chamberlain <mcgrof@kernel.org> Subject: [RFC v3 14/24] nfs: replace kthread freezing with auto fs freezing Date: Fri, 13 Jan 2023 16:33:59 -0800 [thread overview] Message-ID: <20230114003409.1168311-15-mcgrof@kernel.org> (raw) In-Reply-To: <20230114003409.1168311-1-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 superflous freezer calls: spatch --sp-file fs-freeze-cleanup.cocci --in-place --timeout 120 --dir fs/nfs --jobs 12 --use-gitgrep @ 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> --- fs/nfs/callback.c | 4 ---- fs/nfs/fs_context.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 456af7d230cf..f5ba4d6bf2a7 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -77,8 +77,6 @@ nfs4_callback_svc(void *vrqstp) int err; struct svc_rqst *rqstp = vrqstp; - set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { if (signal_pending(current)) @@ -109,8 +107,6 @@ nfs41_callback_svc(void *vrqstp) int error; DEFINE_WAIT(wq); - set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { if (signal_pending(current)) diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 9bcd53d5c7d4..04753962db9a 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1583,7 +1583,7 @@ struct file_system_type nfs_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA | FS_AUTOFREEZE, }; MODULE_ALIAS_FS("nfs"); EXPORT_SYMBOL_GPL(nfs_fs_type); @@ -1595,7 +1595,7 @@ struct file_system_type nfs4_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA | FS_AUTOFREEZE, }; MODULE_ALIAS_FS("nfs4"); MODULE_ALIAS("nfs4"); -- 2.35.1
WARNING: multiple messages have this Message-ID (diff)
From: Luis Chamberlain <mcgrof@kernel.org> To: hch@infradead.org, djwong@kernel.org, song@kernel.org, rafael@kernel.org, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, jack@suse.cz, bvanassche@acm.org, ebiederm@xmission.com Cc: 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, Luis Chamberlain <mcgrof@kernel.org> Subject: [RFC v3 14/24] nfs: replace kthread freezing with auto fs freezing Date: Fri, 13 Jan 2023 16:33:59 -0800 [thread overview] Message-ID: <20230114003409.1168311-15-mcgrof@kernel.org> (raw) In-Reply-To: <20230114003409.1168311-1-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 superflous freezer calls: spatch --sp-file fs-freeze-cleanup.cocci --in-place --timeout 120 --dir fs/nfs --jobs 12 --use-gitgrep @ 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> --- fs/nfs/callback.c | 4 ---- fs/nfs/fs_context.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 456af7d230cf..f5ba4d6bf2a7 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -77,8 +77,6 @@ nfs4_callback_svc(void *vrqstp) int err; struct svc_rqst *rqstp = vrqstp; - set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { if (signal_pending(current)) @@ -109,8 +107,6 @@ nfs41_callback_svc(void *vrqstp) int error; DEFINE_WAIT(wq); - set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { if (signal_pending(current)) diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 9bcd53d5c7d4..04753962db9a 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1583,7 +1583,7 @@ struct file_system_type nfs_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA | FS_AUTOFREEZE, }; MODULE_ALIAS_FS("nfs"); EXPORT_SYMBOL_GPL(nfs_fs_type); @@ -1595,7 +1595,7 @@ struct file_system_type nfs4_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA | FS_AUTOFREEZE, }; MODULE_ALIAS_FS("nfs4"); MODULE_ALIAS("nfs4"); -- 2.35.1 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2023-01-14 0:35 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 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 ` Luis Chamberlain [this message] 2023-01-14 0:33 ` [RFC v3 14/24] nfs: " 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=20230114003409.1168311-15-mcgrof@kernel.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: linkBe 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.