Index: vfs_cache.c =================================================================== RCS file: /cvsroot/src/sys/kern/vfs_cache.c,v retrieving revision 1.119 diff -p -u -r1.119 vfs_cache.c --- vfs_cache.c 18 Mar 2017 22:04:52 -0000 1.119 +++ vfs_cache.c 18 Mar 2017 22:15:58 -0000 @@ -1056,10 +1056,8 @@ cache_purge1(struct vnode *vp, const cha mutex_enter(namecache_lock); if (flags & PURGE_PARENTS) { SDT_PROBE(vfs, namecache, purge, parents, vp, 0, 0, 0, 0); - - for (ncp = LIST_FIRST(&VNODE_TO_VIMPL(vp)->vi_nclist); - ncp != NULL; ncp = ncnext) { - ncnext = LIST_NEXT(ncp, nc_vlist); + LIST_FOREACH_SAFE(ncp, &VNODE_TO_VIMPL(vp)->vi_nclist, + nc_vlist, ncnext) { mutex_enter(&ncp->nc_lock); cache_invalidate(ncp); mutex_exit(&ncp->nc_lock); @@ -1068,9 +1066,8 @@ cache_purge1(struct vnode *vp, const cha } if (flags & PURGE_CHILDREN) { SDT_PROBE(vfs, namecache, purge, children, vp, 0, 0, 0, 0); - for (ncp = LIST_FIRST(&VNODE_TO_VIMPL(vp)->vi_dnclist); - ncp != NULL; ncp = ncnext) { - ncnext = LIST_NEXT(ncp, nc_dvlist); + LIST_FOREACH_SAFE(ncp, &VNODE_TO_VIMPL(vp)->vi_dnclist, + nc_dvlist, ncnext) { mutex_enter(&ncp->nc_lock); cache_invalidate(ncp); mutex_exit(&ncp->nc_lock); @@ -1100,8 +1097,7 @@ cache_purgevfs(struct mount *mp) SDT_PROBE(vfs, namecache, purge, vfs, mp, 0, 0, 0, 0); mutex_enter(namecache_lock); - for (ncp = TAILQ_FIRST(&nclruhead); ncp != NULL; ncp = nxtcp) { - nxtcp = TAILQ_NEXT(ncp, nc_lru); + TAILQ_FOREACH_SAFE(ncp, &nclruhead, nc_lru, nxtcp) { mutex_enter(&ncp->nc_lock); if (ncp->nc_dvp != NULL && ncp->nc_dvp->v_mount == mp) { /* Free the resources we had. */ @@ -1133,11 +1129,10 @@ cache_prune(int incache, int target) tryharder = 0; recent = hardclock_ticks - hz * cache_hottime; sentinel = NULL; - for (ncp = TAILQ_FIRST(&nclruhead); ncp != NULL; ncp = nxtcp) { + TAILQ_FOREACH_SAFE(ncp, &nclruhead, nc_lru, nxtcp) { if (incache <= target) break; items++; - nxtcp = TAILQ_NEXT(ncp, nc_lru); if (ncp == sentinel) { /* * If we looped back on ourself, then ignore