hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/md/dm-crypt.c
....@@ -67,7 +67,9 @@
6767 struct crypt_config *cc;
6868 struct bio *base_bio;
6969 u8 *integrity_metadata;
70
- bool integrity_metadata_from_pool;
70
+ bool integrity_metadata_from_pool:1;
71
+ bool in_tasklet:1;
72
+
7173 struct work_struct work;
7274 struct tasklet_struct tasklet;
7375
....@@ -1722,6 +1724,7 @@
17221724 io->ctx.r.req = NULL;
17231725 io->integrity_metadata = NULL;
17241726 io->integrity_metadata_from_pool = false;
1727
+ io->in_tasklet = false;
17251728 atomic_set(&io->io_pending, 0);
17261729 }
17271730
....@@ -1767,14 +1770,13 @@
17671770 * our tasklet. In this case we need to delay bio_endio()
17681771 * execution to after the tasklet is done and dequeued.
17691772 */
1770
- if (tasklet_trylock(&io->tasklet)) {
1771
- tasklet_unlock(&io->tasklet);
1772
- bio_endio(base_bio);
1773
+ if (io->in_tasklet) {
1774
+ INIT_WORK(&io->work, kcryptd_io_bio_endio);
1775
+ queue_work(cc->io_queue, &io->work);
17731776 return;
17741777 }
17751778
1776
- INIT_WORK(&io->work, kcryptd_io_bio_endio);
1777
- queue_work(cc->io_queue, &io->work);
1779
+ bio_endio(base_bio);
17781780 }
17791781
17801782 /*
....@@ -1934,6 +1936,7 @@
19341936 io = crypt_io_from_node(rb_first(&write_tree));
19351937 rb_erase(&io->rb_node, &write_tree);
19361938 kcryptd_io_write(io);
1939
+ cond_resched();
19371940 } while (!RB_EMPTY_ROOT(&write_tree));
19381941 blk_finish_plug(&plug);
19391942 }
....@@ -2227,6 +2230,7 @@
22272230 * it is being executed with irqs disabled.
22282231 */
22292232 if (in_irq() || irqs_disabled()) {
2233
+ io->in_tasklet = true;
22302234 tasklet_init(&io->tasklet, kcryptd_crypt_tasklet, (unsigned long)&io->work);
22312235 tasklet_schedule(&io->tasklet);
22322236 return;