Re: [PATCH] fscrypt: move the call to fscrypt_destroy_keyring() into ->put_super()

Eric Biggers
2023-12-06T06:44:32Z

On Tue, Dec 05, 2023 at 10:38:12PM -0800, Christoph Hellwig wrote:
> On Tue, Dec 05, 2023 at 04:13:24PM -0800, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> >
> > btrfs, which is planning to add support for fscrypt, has a variety of
> > asynchronous things it does with inodes that can potentially last until
> > ->put_super, when it shuts everything down and cleans up all async work.
> > Consequently, btrfs needs the call to fscrypt_destroy_keyring() to
> > happen either after or within ->put_super.
> >
> > Meanwhile, f2fs needs the call to fscrypt_destroy_keyring() to happen
> > either *before* or within ->put_super, due to the dependency of
> > f2fs_get_devices() on ->s_fs_info still existing.
>
> And that means f2fs should free ->s_fs_info in ->kill_sb after
> the call to shutdown_generic_super.
>
> So the right thing here is:
>
> - change f2fs to free ->s_fs_info later
> - move down fscrypt_destroy_keyring in the keneric code to happen
> after ->put_super
>

There are lots of filesystems that free their ->s_fs_info in ->put_super(). Are
they all wrong?

- Eric