Module Name: src Committed By: hannken Date: Mon Mar 17 09:34:51 UTC 2014
Modified Files: src/sys/nfs: nfs_vfsops.c Log Message: Change nfs_sync() to use vfs_vnode_iterator. To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/sys/nfs/nfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/nfs/nfs_vfsops.c diff -u src/sys/nfs/nfs_vfsops.c:1.224 src/sys/nfs/nfs_vfsops.c:1.225 --- src/sys/nfs/nfs_vfsops.c:1.224 Tue Feb 25 18:30:12 2014 +++ src/sys/nfs/nfs_vfsops.c Mon Mar 17 09:34:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_vfsops.c,v 1.224 2014/02/25 18:30:12 pooka Exp $ */ +/* $NetBSD: nfs_vfsops.c,v 1.225 2014/03/17 09:34:51 hannken Exp $ */ /* * Copyright (c) 1989, 1993, 1995 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.224 2014/02/25 18:30:12 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.225 2014/03/17 09:34:51 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_nfs.h" @@ -945,51 +945,33 @@ extern int syncprt; int nfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred) { - struct vnode *vp, *mvp; + struct vnode *vp; + struct vnode_iterator *marker; int error, allerror = 0; /* * Force stale buffer cache information to be flushed. */ - mvp = vnalloc(mp); -loop: - /* - * NOTE: not using the TAILQ_FOREACH here since in this loop vgone() - * and vclean() can be called indirectly - */ - mutex_enter(&mntvnode_lock); - for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) { - vmark(mvp, vp); - if (vp->v_mount != mp || vismarker(vp)) - continue; - mutex_enter(vp->v_interlock); - /* XXX MNT_LAZY cannot be right? */ - if (waitfor == MNT_LAZY || - (LIST_EMPTY(&vp->v_dirtyblkhd) && - UVM_OBJ_IS_CLEAN(&vp->v_uobj))) { - mutex_exit(vp->v_interlock); + vfs_vnode_iterator_init(mp, &marker); + while (vfs_vnode_iterator_next(marker, &vp)) { + error = vn_lock(vp, LK_EXCLUSIVE); + if (error) { + vrele(vp); continue; } - mutex_exit(&mntvnode_lock); - error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT); - if (error != 0) { - if (error != ENOENT) { - mutex_enter(&mntvnode_lock); - continue; - } - (void)vunmark(mvp); - goto loop; + if (LIST_EMPTY(&vp->v_dirtyblkhd) && + UVM_OBJ_IS_CLEAN(&vp->v_uobj)) { + vput(vp); + continue; } error = VOP_FSYNC(vp, cred, waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0); if (error) allerror = error; vput(vp); - mutex_enter(&mntvnode_lock); } - mutex_exit(&mntvnode_lock); - vnfree(mvp); - return (allerror); + vfs_vnode_iterator_destroy(marker); + return allerror; } /*