brd: check for REQ_NOWAIT and set correct page allocation mask
authorJens Axboe <axboe@kernel.dk>
Thu, 16 Feb 2023 15:01:08 +0000 (08:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:15 +0000 (09:34 +0100)
commit1beb41094bbf3c38edfb16b4ee0ed8ac7ca5e253
tree7acdda3e06af224794e8211a1a1047e6ae714ee7
parentf832bd2ee4c457bbb4dc75575aba75c4b396ecd2
brd: check for REQ_NOWAIT and set correct page allocation mask

commit 6ded703c56c21bfb259725d4f1831a5feb563e9b upstream.

If REQ_NOWAIT is set, then do a non-blocking allocation if the operation
is a write and we need to insert a new page. Currently REQ_NOWAIT cannot
be set as the queue isn't marked as supporting nowait, this change is in
preparation for allowing that.

radix_tree_preload() warns on attempting to call it with an allocation
mask that doesn't allow blocking. While that warning could arguably
be removed, we need to handle radix insertion failures anyway as they
are more likely if we cannot block to get memory.

Remove legacy BUG_ON()'s and turn them into proper errors instead, one
for the allocation failure and one for finding a page that doesn't
match the correct index.

Cc: stable@vger.kernel.org # 5.10+
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/brd.c