FAILED: patch "[PATCH] dm-crypt: defer async write submission to write thread" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 6fed9e26810f0b466dbcebe35a73d1fd48793ff5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112521-nibble-keg-edbd@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6fed9e26810f0b466dbcebe35a73d1fd48793ff5 Mon Sep 17 00:00:00 2001
From: Josef Schlehofer <[email protected]>
Date: Thu, 5 Nov 2026 08:27:08 +0100
Subject: [PATCH] dm-crypt: defer async write submission to write thread
With no_write_workqueue, kcryptd_crypt_write_io_submit() submits the bio directly, even when called from kcryptd_async_done(). An async cipher may run this callback in softirq or with BH disabled, where submit_bio_noacct() must not be called because it can sleep.
Submit inline only when async is false. Async completions are sent to the write thread, as is already done for submit_from_crypt_cpus. Use the async flag rather than in_interrupt(), since callback context depends on the cipher driver. Sync ciphers still submit inline.
Tested with cryptd in QEMU (x86_64 and arm64) with CONFIG_DEBUG_ATOMIC_SLEEP, and on a P2020 running 6.18.55 without it.
In QEMU:
- 4k writes logging "sleeping function called from invalid context":
100/100 unpatched, 0/155 patched.
- nr_requests=4 on a loop device: 0/6 unpatched runs completed, 4/4 patched runs completed.
On the P2020, a warning in blk_mq_run_hw_queue() appeared in the 6th unpatched run and did not appear in 30 patched runs.
drivers/md/dm-crypt.c +3 -2
@@ -1982,8 +1982,9 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async)/* crypt_convert should have filled the clone bio */ BUG_ON (io->ctx.iter_out.bi_size); -if ((likely (!async) &&test_bit (DM_CRYPT_NO_OFFLOAD , &cc->flags)) || -test_bit (DM_CRYPT_NO_WRITE_WORKQUEUE , &cc->flags)) { +if (likely (!async) && + (test_bit (DM_CRYPT_NO_OFFLOAD , &cc->flags) || +test_bit (DM_CRYPT_NO_WRITE_WORKQUEUE , &cc->flags))) {dm_submit_bio_remap (io->base_bio, clone);return ; }
Sasha Levin
maintainerPATCH 1/1 dm-crypt: defer async write submission to write thread
From: Josef Schlehofer <[email protected]>
[ Upstream commit 6fed9e26810f0b466dbcebe35a73d1fd48793ff5 ]
With no_write_workqueue, kcryptd_crypt_write_io_submit() submits the bio directly, even when called from kcryptd_async_done(). An async cipher may run this callback in softirq or with BH disabled, where submit_bio_noacct() must not be called because it can sleep.
Submit inline only when async is false. Async completions are sent to the write thread, as is already done for submit_from_crypt_cpus. Use the async flag rather than in_interrupt(), since callback context depends on the cipher driver. Sync ciphers still submit inline.
Tested with cryptd in QEMU (x86_64 and arm64) with CONFIG_DEBUG_ATOMIC_SLEEP, and on a P2020 running 6.18.55 without it.
In QEMU:
- 4k writes logging "sleeping function called from invalid context":
100/100 unpatched, 0/155 patched.
- nr_requests=4 on a loop device: 0/6 unpatched runs completed, 4/4 patched runs completed.
On the P2020, a warning in blk_mq_run_hw_queue() appeared in the 6th unpatched run and did not appear in 30 patched runs.
--- drivers/md/dm-crypt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/dm-crypt.c +3 -2
@@ -1941,8 +1941,9 @@ static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async) clone->bi_iter.bi_sector = cc->start + io->sector; -if ((likely (!async) &&test_bit (DM_CRYPT_NO_OFFLOAD , &cc->flags)) || -test_bit (DM_CRYPT_NO_WRITE_WORKQUEUE , &cc->flags)) { +if (likely (!async) && + (test_bit (DM_CRYPT_NO_OFFLOAD , &cc->flags) || +test_bit (DM_CRYPT_NO_WRITE_WORKQUEUE , &cc->flags))) {submit_bio_noacct (clone);return ; }
Signature · 1 line
2.53.0