diff options
author | kib <kib@FreeBSD.org> | 2015-01-30 11:41:46 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2015-01-30 11:41:46 +0000 |
commit | 83723416a6bb8695d60c6573722a81086899f521 (patch) | |
tree | cddca20e453743409d446d8ffab186b55f924c15 /sys/ufs | |
parent | 798c260360aa2655668a54cde1ccf742a182f923 (diff) | |
download | FreeBSD-src-83723416a6bb8695d60c6573722a81086899f521.zip FreeBSD-src-83723416a6bb8695d60c6573722a81086899f521.tar.gz |
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
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 23 | ||||
-rw-r--r-- | sys/ufs/ffs/softdep.h | 2 |
2 files changed, 18 insertions, 7 deletions
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index a95e1ca..79783c8 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -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 diff --git a/sys/ufs/ffs/softdep.h b/sys/ufs/ffs/softdep.h index 514f054..d95ae60 100644 --- a/sys/ufs/ffs/softdep.h +++ b/sys/ufs/ffs/softdep.h @@ -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. */ |