Module Name: src
Committed By: hannken
Date: Mon Mar 17 09:37:09 UTC 2014
Modified Files:
src/sys/fs/smbfs: smbfs_vfsops.c
Log Message:
Change smbfs_sync() to use vfs_vnode_iterator.
To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/fs/smbfs/smbfs_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/fs/smbfs/smbfs_vfsops.c
diff -u src/sys/fs/smbfs/smbfs_vfsops.c:1.97 src/sys/fs/smbfs/smbfs_vfsops.c:1.98
--- src/sys/fs/smbfs/smbfs_vfsops.c:1.97 Tue Feb 25 18:30:11 2014
+++ src/sys/fs/smbfs/smbfs_vfsops.c Mon Mar 17 09:37:09 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: smbfs_vfsops.c,v 1.97 2014/02/25 18:30:11 pooka Exp $ */
+/* $NetBSD: smbfs_vfsops.c,v 1.98 2014/03/17 09:37:09 hannken Exp $ */
/*
* Copyright (c) 2000-2001, Boris Popov
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.97 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.98 2014/03/17 09:37:09 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -406,45 +406,27 @@ smbfs_statvfs(struct mount *mp, struct s
int
smbfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
{
- struct vnode *vp, *mvp;
+ struct vnode *vp;
+ struct vnode_iterator *marker;
struct smbnode *np;
int error, allerror = 0;
- /* Allocate a marker vnode. */
- mvp = vnalloc(mp);
- /*
- * Force stale buffer cache information to be flushed.
- */
- mutex_enter(&mntvnode_lock);
-loop:
- for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) {
- vmark(mvp, vp);
- /*
- * If the vnode that we are about to sync is no longer
- * associated with this mount point, start over.
- */
- if (vp->v_mount != mp || vismarker(vp))
+ 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_enter(vp->v_interlock);
+ }
np = VTOSMB(vp);
if (np == NULL) {
- mutex_exit(vp->v_interlock);
+ vput(vp);
continue;
}
if ((vp->v_type == VNON || (np->n_flag & NMODIFIED) == 0) &&
LIST_EMPTY(&vp->v_dirtyblkhd) &&
vp->v_uobj.uo_npages == 0) {
- mutex_exit(vp->v_interlock);
- continue;
- }
- mutex_exit(&mntvnode_lock);
- error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT);
- if (error) {
- mutex_enter(&mntvnode_lock);
- if (error == ENOENT) {
- (void)vunmark(mvp);
- goto loop;
- }
+ vput(vp);
continue;
}
error = VOP_FSYNC(vp, cred,
@@ -452,10 +434,8 @@ loop:
if (error)
allerror = error;
vput(vp);
- mutex_enter(&mntvnode_lock);
}
- mutex_exit(&mntvnode_lock);
- vnfree(mvp);
+ vfs_vnode_iterator_destroy(marker);
return (allerror);
}