Author: mjg
Date: Wed Aug 26 12:54:18 2020
New Revision: 364816
URL: https://svnweb.freebsd.org/changeset/base/364816

Log:
  cache: relock on failure in cache_zap_locked_vnode
  
  This gets rid of bogus scheme of yielding in hopes the blocking thread will
  make progress.

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c   Wed Aug 26 12:53:16 2020        (r364815)
+++ head/sys/kern/vfs_cache.c   Wed Aug 26 12:54:18 2020        (r364816)
@@ -1134,8 +1134,15 @@ cache_zap_locked_vnode(struct namecache *ncp, struct v
                to_unlock = vlp2;
        } else {
                if (!mtx_trylock(vlp1)) {
-                       error = EAGAIN;
-                       goto out;
+                       /*
+                        * TODO: Very wasteful but rare.
+                        */
+                       mtx_unlock(pvlp);
+                       mtx_lock(vlp1);
+                       mtx_lock(vlp2);
+                       mtx_unlock(vlp2);
+                       mtx_unlock(vlp1);
+                       return (EAGAIN);
                }
                to_unlock = vlp1;
        }
@@ -1377,7 +1384,6 @@ negative_success:
                        error = cache_zap_locked_vnode(ncp, dvp);
                        if (__predict_false(error != 0)) {
                                zap_and_exit_bucket_fail2++;
-                               cache_maybe_yield();
                                goto retry;
                        }
                        cache_free(ncp);
@@ -1465,7 +1471,6 @@ retry:
        error = cache_zap_locked_bucket(ncp, cnp, hash, blp);
        if (__predict_false(error != 0)) {
                zap_and_exit_bucket_fail++;
-               cache_maybe_yield();
                goto retry;
        }
        counter_u64_add(numposzaps, 1);
@@ -1584,7 +1589,6 @@ negative_success:
                        error = cache_zap_locked_vnode(ncp, dvp);
                        if (__predict_false(error != 0)) {
                                zap_and_exit_bucket_fail2++;
-                               cache_maybe_yield();
                                goto retry;
                        }
                        cache_free(ncp);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to