Author: mjg
Date: Sun Jan 26 00:40:27 2020
New Revision: 357130
URL: https://svnweb.freebsd.org/changeset/base/357130

Log:
  vfs: fix freevnodes count update race against preemption
  
  vdbatch_process leaves the critical section too early, openign a time
  window where another thread can get scheduled and modify vd->freevnodes.
  Once it the preempted thread gets back it overrides the value with 0.
  
  Just move critical_exit to the end of the function.

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c    Sun Jan 26 00:38:06 2020        (r357129)
+++ head/sys/kern/vfs_subr.c    Sun Jan 26 00:40:27 2020        (r357130)
@@ -3324,10 +3324,10 @@ vdbatch_process(struct vdbatch *vd)
                vp->v_dbatchcpu = NOCPU;
        }
        mtx_unlock(&vnode_list_mtx);
-       critical_exit();
        vd->freevnodes = 0;
        bzero(vd->tab, sizeof(vd->tab));
        vd->index = 0;
+       critical_exit();
 }
 
 static void
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to