block: warn if !__GFP_DIRECT_RECLAIM in bio_crypt_set_ctx()
authorEric Biggers <ebiggers@google.com>
Wed, 16 Sep 2020 03:53:15 +0000 (20:53 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 5 Oct 2020 16:47:43 +0000 (10:47 -0600)
commitcf785af19319f9fc0fc0c0604d259f1ef31b502f
treeb047fc45f79597a6943d9408e66a376483c4b5c3
parent93f221ae08381e994ac9f9ff6aa743e612e49718
block: warn if !__GFP_DIRECT_RECLAIM in bio_crypt_set_ctx()

bio_crypt_set_ctx() assumes its gfp_mask argument always includes
__GFP_DIRECT_RECLAIM, so that the mempool_alloc() will always succeed.

For now this assumption is still fine, since no callers violate it.
Making bio_crypt_set_ctx() able to fail would add unneeded complexity.

However, if a caller didn't use __GFP_DIRECT_RECLAIM, it would be very
hard to notice the bug.  Make it easier by adding a WARN_ON_ONCE().

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Satya Tangirala <satyat@google.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Satya Tangirala <satyat@google.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-crypto.c