Re: block: sleeping in atomic warnings
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2023-02-07 16:23:36
Also in:
linux-fsdevel, lkml
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2023-02-07 16:23:36
Also in:
linux-fsdevel, lkml
On Tue, Feb 7, 2023 at 6:06 AM Dan Carpenter [off-list ref] wrote:
block/blk-crypto-profile.c:382 __blk_crypto_evict_key() warn: sleeping in atomic context block/blk-crypto-profile.c:390 __blk_crypto_evict_key() warn: sleeping in atomic context
Yeah, that looks very real, but doesn't really seem to be a block bug. __put_super() has a big comment that it's called under the sb_lock spinlock, so it's all in atomic context, but then:
-> __put_super()
-> fscrypt_destroy_keyring()
-> fscrypt_put_master_key_activeref()
-> fscrypt_destroy_prepared_key()
-> fscrypt_destroy_inline_crypt_key()
-> blk_crypto_evict_key()
and we have a comment in __blk_crypto_evict_key() that it must be
called in "process context".
However, the *normal* unmount sequence does all the cleanup *before*
it gets sb_lock, and calls fscrypt_destroy_keyring() in process
context, which is probably why it never triggers in practice, because
the "last put" is normally there, not in __put_super.
Eric? Al?
It smells like __put_super() may need to do some parts delayed, not
under sb_lock.
Linus