Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Aug 2020 23:09:16 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r363875 - head/sys/ufs/ffs
Message-ID:  <202008042309.074N9Gao027102@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Tue Aug  4 23:09:15 2020
New Revision: 363875
URL: https://svnweb.freebsd.org/changeset/base/363875

Log:
  ufs: only pass LK_ADAPTIVE if LK_NODDLKTREAT is set
  
  This restores the pre-adaptive spinning state for SU which livelocks
  otherwise. Note this is a bug in SU.
  
  Reported by:	pho

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

Modified: head/sys/ufs/ffs/ffs_vnops.c
==============================================================================
--- head/sys/ufs/ffs/ffs_vnops.c	Tue Aug  4 23:07:42 2020	(r363874)
+++ head/sys/ufs/ffs/ffs_vnops.c	Tue Aug  4 23:09:15 2020	(r363875)
@@ -445,7 +445,13 @@ ffs_lock(ap)
 	struct lock *lkp;
 	int result;
 
-	ap->a_flags |= LK_ADAPTIVE;
+	/*
+	 * Adaptive spinning mixed with SU leads to trouble. use a giant hammer
+	 * and only use it when LK_NODDLKTREAT is set. Currently this means it
+	 * is only used during path lookup.
+	 */
+	if ((ap->a_flags & LK_NODDLKTREAT) != 0)
+		ap->a_flags |= LK_ADAPTIVE;
 	switch (ap->a_flags & LK_TYPE_MASK) {
 	case LK_SHARED:
 	case LK_UPGRADE:
@@ -483,7 +489,11 @@ ffs_lock(ap)
 	}
 	return (result);
 #else
-	ap->a_flags |= LK_ADAPTIVE;
+	/*
+	 * See above for an explanation.
+	 */
+	if ((ap->a_flags & LK_NODDLKTREAT) != 0)
+		ap->a_flags |= LK_ADAPTIVE;
 	return (VOP_LOCK1_APV(&ufs_vnodeops, ap));
 #endif
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008042309.074N9Gao027102>