svn commit: r356820 - head/sys/ufs/ffs

Warner Losh imp at FreeBSD.org
Fri Jan 17 01:16:24 UTC 2020


Author: imp
Date: Fri Jan 17 01:16:23 2020
New Revision: 356820
URL: https://svnweb.freebsd.org/changeset/base/356820

Log:
  We only want to send the speedup to the lower layers when there's a shortage.
  
  Only send a speedup when there's a shortage. While this is a little racy, lost
  races aren't a big deal for this function. If there's a shorage just popping up
  after we check these values, then we'll catch it next time. If there's a
  shortage that's just clearing up, we may do some work at the lower layers a
  little sooner than we otherwise would have. Sicne shortages are relatively rare
  events, both races are acceptable.
  
  Reviewed by: chs
  Differential Revision: https://reviews.freebsd.org/D23182

Modified:
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c	Fri Jan 17 01:16:19 2020	(r356819)
+++ head/sys/ufs/ffs/ffs_softdep.c	Fri Jan 17 01:16:23 2020	(r356820)
@@ -13771,23 +13771,28 @@ check_clear_deps(mp)
 	struct mount *mp;
 {
 	struct ufsmount *ump;
+	bool suj_susp;
 
 	/*
-	 * Tell the lower layers that any TRIM or WRITE transactions
-	 * that have been delayed for performance reasons should
-	 * proceed to help alleviate the shortage faster.
+	 * Tell the lower layers that any TRIM or WRITE transactions that have
+	 * been delayed for performance reasons should proceed to help alleviate
+	 * the shortage faster. The race between checking req_* and the softdep
+	 * mutex (lk) is fine since this is an advisory operation that at most
+	 * causes deferred work to be done sooner.
 	 */
 	ump = VFSTOUFS(mp);
-	FREE_LOCK(ump);
-	softdep_send_speedup(ump, 0, BIO_SPEEDUP_TRIM | BIO_SPEEDUP_WRITE);
-	ACQUIRE_LOCK(ump);
+	suj_susp = MOUNTEDSUJ(mp) && ump->softdep_jblocks->jb_suspended;
+	if (req_clear_remove || req_clear_inodedeps || suj_susp) {
+		FREE_LOCK(ump);
+		softdep_send_speedup(ump, 0, BIO_SPEEDUP_TRIM | BIO_SPEEDUP_WRITE);
+		ACQUIRE_LOCK(ump);
+	}
 
-
 	/*
 	 * If we are suspended, it may be because of our using
 	 * too many inodedeps, so help clear them out.
 	 */
-	if (MOUNTEDSUJ(mp) && VFSTOUFS(mp)->softdep_jblocks->jb_suspended)
+	if (suj_susp)
 		clear_inodedeps(mp);
 
 	/*


More information about the svn-src-all mailing list