@@ -1894,6 +1894,7 @@ static int dmcrypt_write(void *data)
{
struct crypt_config *cc = data;
struct dm_crypt_io *io;
+ unsigned long start_time = jiffies;
while (1) {
struct rb_root write_tree;
@@ -1916,6 +1917,7 @@ static int dmcrypt_write(void *data)
schedule();
+ start_time = jiffies;
set_current_state(TASK_RUNNING);
spin_lock_irq(&cc->write_thread_lock);
goto continue_locked;
@@ -1927,6 +1929,10 @@ static int dmcrypt_write(void *data)
BUG_ON(rb_parent(write_tree.rb_node));
+ if (time_is_before_jiffies(start_time + HZ)) {
+ cond_resched();
+ start_time = jiffies;
+ }
/*
* Note: we cannot walk the tree here with rb_next because
* the structures may be freed when kcryptd_io_write is called.