JFFS2 deadlock with alloc_sem

David Woodhouse dwmw2 at infradead.org
Sat Jun 2 13:42:05 EDT 2007


On Mon, 2007-04-30 at 15:41 -0400, Roberts Nathan-mcg31137 wrote:
> Has anyone seen this deadlock before? It seems to be a classic deadlock 
> situation so I'm not sure if maybe I'm misinterpreting things or 
> the use case (several postmark tests running in parallel on a
> preemptible kernel) is especially vulnerable. 

I think Josh has spotted the real problem here. Does this help? If so,
as better fix will be forthcoming....

diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index 2d99e06..1066120 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -1218,7 +1218,9 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
 	 *    page OK. We'll actually write it out again in commit_write, which is a little
 	 *    suboptimal, but at least we're correct.
 	 */
+	up(&f->sem);
 	pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg);
+	down(&f->sem);
 
 	if (IS_ERR(pg_ptr)) {
 		printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr));

-- 
dwmw2





More information about the linux-mtd mailing list