jffs2_mark_node_obsolete race w.r.t erase_free_sem?

David Woodhouse dwmw2 at infradead.org
Thu Jun 28 14:30:02 EDT 2007


On Fri, 2007-06-22 at 13:27 +0200, Joakim Tjernlund wrote:
> I belive this jffs2_mark_node_obsolete can race against
> jffs2_erase_pending_blocks(run in pdflush context).
> 
> During jffs2_build_filesystem, the flag JFFS2_SB_FLAG_BUILDING is set and
> the erase_free_sem is NOT taken. There is nothing I can see that
> holds pdflush back from erasing blocks during this time.
> Confirmation would be great.
> 
> Dunno what the fix should be. Gut feeling is to prevent pdflush
> from running until after build phase as erasing blocks is
> a background task that shouldn't interfere with other tasks if
> it can be helpt.
> 
> I think this is the root cause to the OOPS:es I seen lately

Perhaps. Try this...

diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 1d3b7a9..0fa82d0 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -390,6 +390,12 @@ void jffs2_write_super (struct super_block *sb)
 	if (sb->s_flags & MS_RDONLY)
 		return;
 
+	if (c->flags & JFFS2_SB_FLAG_BUILDING) {
+		printk(KERN_NOTICE "jffs2_write_super() called while fs still building\n");
+		WARN_ON(1);
+		return;
+	}
+
 	D1(printk(KERN_DEBUG "jffs2_write_super()\n"));
 	jffs2_garbage_collect_trigger(c);
 	jffs2_erase_pending_blocks(c, 0);

-- 
dwmw2




More information about the linux-mtd mailing list