svn commit: r277922 - head/sys/ufs/ffs
Konstantin Belousov
kib at FreeBSD.org
Fri Jan 30 11:41:48 UTC 2015
Author: kib
Date: Fri Jan 30 11:41:46 2015
New Revision: 277922
URL: https://svnweb.freebsd.org/changeset/base/277922
Log:
When mounting SU-enabled mount point, wait until the softdep_flush()
thread started and incremented the stat_flush_threads [1].
Unconditionally wakeup softdep_flush threads when needed, do not try
to check wchan, which is racy and breaks abstraction.
Reported by and discussed with: glebius, neel
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Modified:
head/sys/ufs/ffs/ffs_softdep.c
head/sys/ufs/ffs/softdep.h
Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c Fri Jan 30 10:08:38 2015 (r277921)
+++ head/sys/ufs/ffs/ffs_softdep.c Fri Jan 30 11:41:46 2015 (r277922)
@@ -1377,6 +1377,10 @@ softdep_flush(addr)
mp = (struct mount *)addr;
ump = VFSTOUFS(mp);
atomic_add_int(&stat_flush_threads, 1);
+ ACQUIRE_LOCK(ump);
+ ump->softdep_flags &= ~FLUSH_STARTING;
+ wakeup(&ump->softdep_flushtd);
+ FREE_LOCK(ump);
if (print_threads) {
if (stat_flush_threads == 1)
printf("Running %s at pid %d\n", bufdaemonproc->p_comm,
@@ -1389,7 +1393,7 @@ softdep_flush(addr)
VFSTOUFS(mp)->softdep_jblocks->jb_suspended))
kthread_suspend_check();
ACQUIRE_LOCK(ump);
- if ((ump->softdep_flags & FLUSH_CLEANUP) == 0)
+ while ((ump->softdep_flags & (FLUSH_CLEANUP | FLUSH_EXIT)) == 0)
msleep(&ump->softdep_flushtd, LOCK_PTR(ump), PVM,
"sdflush", hz / 2);
ump->softdep_flags &= ~FLUSH_CLEANUP;
@@ -1421,8 +1425,7 @@ worklist_speedup(mp)
LOCK_OWNED(ump);
if ((ump->softdep_flags & (FLUSH_CLEANUP | FLUSH_EXIT)) == 0) {
ump->softdep_flags |= FLUSH_CLEANUP;
- if (ump->softdep_flushtd->td_wchan == &ump->softdep_flushtd)
- wakeup(&ump->softdep_flushtd);
+ wakeup(&ump->softdep_flushtd);
}
}
@@ -1471,10 +1474,7 @@ softdep_speedup(ump)
(FLUSH_CLEANUP | FLUSH_EXIT)) == 0) {
altump->softdep_flags |= FLUSH_CLEANUP;
altump->um_softdep->sd_cleanups++;
- if (altump->softdep_flushtd->td_wchan ==
- &altump->softdep_flushtd) {
- wakeup(&altump->softdep_flushtd);
- }
+ wakeup(&altump->softdep_flushtd);
}
FREE_LOCK(altump);
}
@@ -2491,9 +2491,18 @@ softdep_mount(devvp, mp, fs, cred)
/*
* Start our flushing thread in the bufdaemon process.
*/
+ ACQUIRE_LOCK(ump);
+ ump->softdep_flags |= FLUSH_STARTING;
+ FREE_LOCK(ump);
kproc_kthread_add(&softdep_flush, mp, &bufdaemonproc,
&ump->softdep_flushtd, 0, 0, "softdepflush", "%s worker",
mp->mnt_stat.f_mntonname);
+ ACQUIRE_LOCK(ump);
+ while ((ump->softdep_flags & FLUSH_STARTING) != 0) {
+ msleep(&ump->softdep_flushtd, LOCK_PTR(ump), PVM, "sdstart",
+ hz / 2);
+ }
+ FREE_LOCK(ump);
/*
* When doing soft updates, the counters in the
* superblock may have gotten out of sync. Recomputation
Modified: head/sys/ufs/ffs/softdep.h
==============================================================================
--- head/sys/ufs/ffs/softdep.h Fri Jan 30 10:08:38 2015 (r277921)
+++ head/sys/ufs/ffs/softdep.h Fri Jan 30 11:41:46 2015 (r277922)
@@ -1063,6 +1063,8 @@ struct mount_softdeps {
*/
#define FLUSH_EXIT 0x0001 /* time to exit */
#define FLUSH_CLEANUP 0x0002 /* need to clear out softdep structures */
+#define FLUSH_STARTING 0x0004 /* flush thread not yet started */
+
/*
* Keep the old names from when these were in the ufsmount structure.
*/
More information about the svn-src-head
mailing list