Commit 1edaa447 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer

dm writecache: add cond_resched to avoid CPU hangs

Initializing a dm-writecache device can take a long time when the
persistent memory device is large.  Add cond_resched() to a few loops
to avoid warnings that the CPU is stuck.

Cc: stable@vger.kernel.org # v4.18+
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 31843eda
...@@ -925,6 +925,7 @@ static int writecache_alloc_entries(struct dm_writecache *wc) ...@@ -925,6 +925,7 @@ static int writecache_alloc_entries(struct dm_writecache *wc)
struct wc_entry *e = &wc->entries[b]; struct wc_entry *e = &wc->entries[b];
e->index = b; e->index = b;
e->write_in_progress = false; e->write_in_progress = false;
cond_resched();
} }
return 0; return 0;
...@@ -979,6 +980,7 @@ static void writecache_resume(struct dm_target *ti) ...@@ -979,6 +980,7 @@ static void writecache_resume(struct dm_target *ti)
e->original_sector = le64_to_cpu(wme.original_sector); e->original_sector = le64_to_cpu(wme.original_sector);
e->seq_count = le64_to_cpu(wme.seq_count); e->seq_count = le64_to_cpu(wme.seq_count);
} }
cond_resched();
} }
#endif #endif
for (b = 0; b < wc->n_blocks; b++) { for (b = 0; b < wc->n_blocks; b++) {
...@@ -1886,8 +1888,10 @@ static int init_memory(struct dm_writecache *wc) ...@@ -1886,8 +1888,10 @@ static int init_memory(struct dm_writecache *wc)
pmem_assign(sb(wc)->n_blocks, cpu_to_le64(wc->n_blocks)); pmem_assign(sb(wc)->n_blocks, cpu_to_le64(wc->n_blocks));
pmem_assign(sb(wc)->seq_count, cpu_to_le64(0)); pmem_assign(sb(wc)->seq_count, cpu_to_le64(0));
for (b = 0; b < wc->n_blocks; b++) for (b = 0; b < wc->n_blocks; b++) {
write_original_sector_seq_count(wc, &wc->entries[b], -1, -1); write_original_sector_seq_count(wc, &wc->entries[b], -1, -1);
cond_resched();
}
writecache_flush_all_metadata(wc); writecache_flush_all_metadata(wc);
writecache_commit_flushed(wc, false); writecache_commit_flushed(wc, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment