* [PATCH v2 0/2] Move fscrypt keyring destruction to after ->put_super
@ 2023-12-27 17:14 Eric Biggers
2023-12-27 17:14 ` [PATCH v2 1/2] f2fs: move release of block devices to after kill_block_super() Eric Biggers
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Eric Biggers @ 2023-12-27 17:14 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-fsdevel, linux-f2fs-devel, Josef Bacik, Christoph Hellwig
This series moves the fscrypt keyring destruction to after ->put_super,
as this will be needed by the btrfs fscrypt support. To make this
possible, it also changes f2fs to release its block devices after
generic_shutdown_super() rather than before.
This supersedes "[PATCH] fscrypt: move the call to
fscrypt_destroy_keyring() into ->put_super()"
(https://lore.kernel.org/linux-fscrypt/20231206001325.13676-1-ebiggers@kernel.org/T/#u)
Changed in v2:
- Added a comment to f2fs patch.
- Dropped btrfs patch from series; it will go in separately.
- Added some Reviewed-bys.
Eric Biggers (1):
f2fs: move release of block devices to after kill_block_super()
Josef Bacik (1):
fs: move fscrypt keyring destruction to after ->put_super
fs/f2fs/super.c | 13 ++++++++-----
fs/super.c | 12 ++++++------
2 files changed, 14 insertions(+), 11 deletions(-)
base-commit: fbafc3e621c3f4ded43720fdb1d6ce1728ec664e
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] f2fs: move release of block devices to after kill_block_super()
2023-12-27 17:14 [PATCH v2 0/2] Move fscrypt keyring destruction to after ->put_super Eric Biggers
@ 2023-12-27 17:14 ` Eric Biggers
2023-12-28 1:09 ` [f2fs-dev] " Chao Yu
2023-12-27 17:14 ` [PATCH v2 2/2] fs: move fscrypt keyring destruction to after ->put_super Eric Biggers
2024-01-16 19:02 ` [f2fs-dev] [PATCH v2 0/2] Move " patchwork-bot+f2fs
2 siblings, 1 reply; 5+ messages in thread
From: Eric Biggers @ 2023-12-27 17:14 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-fsdevel, linux-f2fs-devel, Josef Bacik, Christoph Hellwig
From: Eric Biggers <ebiggers@google.com>
Call destroy_device_list() and free the f2fs_sb_info from
kill_f2fs_super(), after the call to kill_block_super(). This is
necessary to order it after the call to fscrypt_destroy_keyring() once
generic_shutdown_super() starts calling fscrypt_destroy_keyring() just
after calling ->put_super. This is because fscrypt_destroy_keyring()
may call into f2fs_get_devices() via the fscrypt_operations.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/f2fs/super.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 033af907c3b1d..d66e0692ac02e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1710,42 +1710,39 @@ static void f2fs_put_super(struct super_block *sb)
f2fs_destroy_node_manager(sbi);
f2fs_destroy_segment_manager(sbi);
/* flush s_error_work before sbi destroy */
flush_work(&sbi->s_error_work);
f2fs_destroy_post_read_wq(sbi);
kvfree(sbi->ckpt);
- sb->s_fs_info = NULL;
if (sbi->s_chksum_driver)
crypto_free_shash(sbi->s_chksum_driver);
kfree(sbi->raw_super);
- destroy_device_list(sbi);
f2fs_destroy_page_array_cache(sbi);
f2fs_destroy_xattr_caches(sbi);
mempool_destroy(sbi->write_io_dummy);
#ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++)
kfree(F2FS_OPTION(sbi).s_qf_names[i]);
#endif
fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy);
destroy_percpu_info(sbi);
f2fs_destroy_iostat(sbi);
for (i = 0; i < NR_PAGE_TYPE; i++)
kvfree(sbi->write_io[i]);
#if IS_ENABLED(CONFIG_UNICODE)
utf8_unload(sb->s_encoding);
#endif
- kfree(sbi);
}
int f2fs_sync_fs(struct super_block *sb, int sync)
{
struct f2fs_sb_info *sbi = F2FS_SB(sb);
int err = 0;
if (unlikely(f2fs_cp_error(sbi)))
return 0;
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
@@ -4895,23 +4892,23 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
}
static struct dentry *f2fs_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *data)
{
return mount_bdev(fs_type, flags, dev_name, data, f2fs_fill_super);
}
static void kill_f2fs_super(struct super_block *sb)
{
- if (sb->s_root) {
- struct f2fs_sb_info *sbi = F2FS_SB(sb);
+ struct f2fs_sb_info *sbi = F2FS_SB(sb);
+ if (sb->s_root) {
set_sbi_flag(sbi, SBI_IS_CLOSE);
f2fs_stop_gc_thread(sbi);
f2fs_stop_discard_thread(sbi);
#ifdef CONFIG_F2FS_FS_COMPRESSION
/*
* latter evict_inode() can bypass checking and invalidating
* compress inode cache.
*/
if (test_opt(sbi, COMPRESS_CACHE))
@@ -4924,20 +4921,26 @@ static void kill_f2fs_super(struct super_block *sb)
.reason = CP_UMOUNT,
};
stat_inc_cp_call_count(sbi, TOTAL_CALL);
f2fs_write_checkpoint(sbi, &cpc);
}
if (is_sbi_flag_set(sbi, SBI_IS_RECOVERED) && f2fs_readonly(sb))
sb->s_flags &= ~SB_RDONLY;
}
kill_block_super(sb);
+ /* Release block devices last, after fscrypt_destroy_keyring(). */
+ if (sbi) {
+ destroy_device_list(sbi);
+ kfree(sbi);
+ sb->s_fs_info = NULL;
+ }
}
static struct file_system_type f2fs_fs_type = {
.owner = THIS_MODULE,
.name = "f2fs",
.mount = f2fs_mount,
.kill_sb = kill_f2fs_super,
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP,
};
MODULE_ALIAS_FS("f2fs");
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] fs: move fscrypt keyring destruction to after ->put_super
2023-12-27 17:14 [PATCH v2 0/2] Move fscrypt keyring destruction to after ->put_super Eric Biggers
2023-12-27 17:14 ` [PATCH v2 1/2] f2fs: move release of block devices to after kill_block_super() Eric Biggers
@ 2023-12-27 17:14 ` Eric Biggers
2024-01-16 19:02 ` [f2fs-dev] [PATCH v2 0/2] Move " patchwork-bot+f2fs
2 siblings, 0 replies; 5+ messages in thread
From: Eric Biggers @ 2023-12-27 17:14 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-fsdevel, linux-f2fs-devel, Josef Bacik, Christoph Hellwig,
Neal Gompa
From: Josef Bacik <josef@toxicpanda.com>
btrfs has a variety of asynchronous things we do with inodes that can
potentially last until ->put_super, when we shut everything down and
clean up all of our async work. Due to this we need to move
fscrypt_destroy_keyring() to after ->put_super, otherwise we get
warnings about still having active references on the master key.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Neal Gompa <neal@gompa.dev>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/super.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index 076392396e724..faf7d248145d2 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -674,34 +674,34 @@ void generic_shutdown_super(struct super_block *sb)
/* Evict all inodes with zero refcount. */
evict_inodes(sb);
/*
* Clean up and evict any inodes that still have references due
* to fsnotify or the security policy.
*/
fsnotify_sb_delete(sb);
security_sb_delete(sb);
- /*
- * Now that all potentially-encrypted inodes have been evicted,
- * the fscrypt keyring can be destroyed.
- */
- fscrypt_destroy_keyring(sb);
-
if (sb->s_dio_done_wq) {
destroy_workqueue(sb->s_dio_done_wq);
sb->s_dio_done_wq = NULL;
}
if (sop->put_super)
sop->put_super(sb);
+ /*
+ * Now that all potentially-encrypted inodes have been evicted,
+ * the fscrypt keyring can be destroyed.
+ */
+ fscrypt_destroy_keyring(sb);
+
if (CHECK_DATA_CORRUPTION(!list_empty(&sb->s_inodes),
"VFS: Busy inodes after unmount of %s (%s)",
sb->s_id, sb->s_type->name)) {
/*
* Adding a proper bailout path here would be hard, but
* we can at least make it more likely that a later
* iput_final() or such crashes cleanly.
*/
struct inode *inode;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH v2 1/2] f2fs: move release of block devices to after kill_block_super()
2023-12-27 17:14 ` [PATCH v2 1/2] f2fs: move release of block devices to after kill_block_super() Eric Biggers
@ 2023-12-28 1:09 ` Chao Yu
0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2023-12-28 1:09 UTC (permalink / raw)
To: Eric Biggers, linux-fscrypt
Cc: linux-fsdevel, Christoph Hellwig, Josef Bacik, linux-f2fs-devel
On 2023/12/28 1:14, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Call destroy_device_list() and free the f2fs_sb_info from
> kill_f2fs_super(), after the call to kill_block_super(). This is
> necessary to order it after the call to fscrypt_destroy_keyring() once
> generic_shutdown_super() starts calling fscrypt_destroy_keyring() just
> after calling ->put_super. This is because fscrypt_destroy_keyring()
> may call into f2fs_get_devices() via the fscrypt_operations.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH v2 0/2] Move fscrypt keyring destruction to after ->put_super
2023-12-27 17:14 [PATCH v2 0/2] Move fscrypt keyring destruction to after ->put_super Eric Biggers
2023-12-27 17:14 ` [PATCH v2 1/2] f2fs: move release of block devices to after kill_block_super() Eric Biggers
2023-12-27 17:14 ` [PATCH v2 2/2] fs: move fscrypt keyring destruction to after ->put_super Eric Biggers
@ 2024-01-16 19:02 ` patchwork-bot+f2fs
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+f2fs @ 2024-01-16 19:02 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-fscrypt, linux-fsdevel, hch, josef, linux-f2fs-devel
Hello:
This series was applied to jaegeuk/f2fs.git (dev)
by Eric Biggers <ebiggers@google.com>:
On Wed, 27 Dec 2023 11:14:27 -0600 you wrote:
> This series moves the fscrypt keyring destruction to after ->put_super,
> as this will be needed by the btrfs fscrypt support. To make this
> possible, it also changes f2fs to release its block devices after
> generic_shutdown_super() rather than before.
>
> This supersedes "[PATCH] fscrypt: move the call to
> fscrypt_destroy_keyring() into ->put_super()"
> (https://lore.kernel.org/linux-fscrypt/20231206001325.13676-1-ebiggers@kernel.org/T/#u)
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2,1/2] f2fs: move release of block devices to after kill_block_super()
https://git.kernel.org/jaegeuk/f2fs/c/275dca4630c1
- [f2fs-dev,v2,2/2] fs: move fscrypt keyring destruction to after ->put_super
https://git.kernel.org/jaegeuk/f2fs/c/2a0e85719892
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-16 19:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-27 17:14 [PATCH v2 0/2] Move fscrypt keyring destruction to after ->put_super Eric Biggers
2023-12-27 17:14 ` [PATCH v2 1/2] f2fs: move release of block devices to after kill_block_super() Eric Biggers
2023-12-28 1:09 ` [f2fs-dev] " Chao Yu
2023-12-27 17:14 ` [PATCH v2 2/2] fs: move fscrypt keyring destruction to after ->put_super Eric Biggers
2024-01-16 19:02 ` [f2fs-dev] [PATCH v2 0/2] Move " patchwork-bot+f2fs
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).