Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Always push the metadata update to the worker thread upon completion
Browse files Browse the repository at this point in the history
of the data write. This fixes a deadlock caused by an IO completion
thread blocking on a write.
Thanks to Feng Yu for finding, reporting the bug and Jens Axboe for
the fix.
  • Loading branch information
Mohan Srinivasan committed Jan 18, 2011
1 parent 6ed5159 commit 1bd0456
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/flashcache_main.c
Expand Up @@ -834,15 +834,17 @@ flashcache_md_write(struct kcached_job *job)
md_sector_head->nr_in_prog = 1;
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
/*
* If !in_interrupt, we can kick off the write(s) immediately.
* Else punt for the worker thread.
* Always push to a worker thread. If the driver has
* a completion thread, we could end up deadlocking even
* if the context would be safe enough to write from.
* This could be executed from the context of an IO
* completion thread. Kicking off the write from that
* context could result in the IO completion thread
* blocking (eg on memory allocation). That can easily
* deadlock.
*/
if (!in_interrupt()) {
flashcache_md_write_kickoff(job);
} else {
push_md_io(job);
schedule_work(&_kcached_wq);
}
push_md_io(job);
schedule_work(&_kcached_wq);
}
}

Expand Down

0 comments on commit 1bd0456

Please sign in to comment.