From a7b76b76e17881d47ffd2715135b3512e07d0fbf Mon Sep 17 00:00:00 2001 From: kib Date: Tue, 9 Jul 2013 20:49:32 +0000 Subject: There are several code sequences like vfs_busy(mp); vfs_write_suspend(mp); which are problematic if other thread starts unmount between two calls. The unmount starts a write, while vfs_write_suspend() drain writers. On the other hand, unmount drains busy references, causing the deadlock. Add a flag argument to vfs_write_suspend and require the callers of it to specify VS_SKIP_UNMOUNT flag, when the call is performed not in the mount path, i.e. the covered vnode is not locked. The suspension is not attempted if VS_SKIP_UNMOUNT is specified and unmount is in progress. Reported and tested by: Andreas Longwitz Sponsored by: The FreeBSD Foundation MFC after: 3 weeks --- sys/geom/journal/g_journal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys/geom') diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index a3c996c..3ce2785 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -2960,7 +2960,7 @@ g_journal_do_switch(struct g_class *classp) GJ_TIMER_STOP(1, &bt, "BIO_FLUSH time of %s", sc->sc_name); GJ_TIMER_START(1, &bt); - error = vfs_write_suspend(mp); + error = vfs_write_suspend(mp, VS_SKIP_UNMOUNT); GJ_TIMER_STOP(1, &bt, "Suspend time of %s", mountpoint); if (error != 0) { GJ_DEBUG(0, "Cannot suspend file system %s (error=%d).", -- cgit v1.1