Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/smbfs make smbfs_sync() look more like sync routines ...



details:   https://anonhg.NetBSD.org/src/rev/f2aed9df7554
branches:  trunk
changeset: 543458:f2aed9df7554
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Feb 25 22:17:20 2003 +0000

description:
make smbfs_sync() look more like sync routines for other fs, particularily:
* lock/unlock mntvnode_slock and vnode interlock appropriately
* use LK_NOWAIT for vget()
* adjust the check for vnode being dirty to check fs-private 'modified' flag,
  and drop waitfor/VOP_ISLOCKED() check

diffstat:

 sys/fs/smbfs/smbfs_vfsops.c |  36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)

diffs (82 lines):

diff -r f48db854014c -r f2aed9df7554 sys/fs/smbfs/smbfs_vfsops.c
--- a/sys/fs/smbfs/smbfs_vfsops.c       Tue Feb 25 22:12:24 2003 +0000
+++ b/sys/fs/smbfs/smbfs_vfsops.c       Tue Feb 25 22:17:20 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smbfs_vfsops.c,v 1.18 2003/02/25 09:09:31 jdolecek Exp $       */
+/*     $NetBSD: smbfs_vfsops.c,v 1.19 2003/02/25 22:17:20 jdolecek Exp $       */
 
 /*
  * Copyright (c) 2000-2001, Boris Popov
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.18 2003/02/25 09:09:31 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.19 2003/02/25 22:17:20 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -375,7 +375,6 @@
 /*
  * Flush out the buffer cache
  */
-/* ARGSUSED */
 int
 smbfs_sync(mp, waitfor, cred, p)
        struct mount *mp;
@@ -383,33 +382,46 @@
        struct ucred *cred;
        struct proc *p;
 {
-       struct vnode *vp;
+       struct vnode *vp, *nvp;
+       struct smbnode *np;
        int error, allerror = 0;
        /*
         * Force stale buffer cache information to be flushed.
         */
+       simple_lock(&mntvnode_slock);
 loop:
-       for (vp = mp->mnt_vnodelist.lh_first;
-            vp != NULL;
-            vp = vp->v_mntvnodes.le_next) {
+       for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
                /*
                 * If the vnode that we are about to sync is no longer
                 * associated with this mount point, start over.
                 */
                if (vp->v_mount != mp)
                        goto loop;
-               if (waitfor == MNT_LAZY || VOP_ISLOCKED(vp) || 
-                   (LIST_EMPTY(&vp->v_dirtyblkhd) &&
-                    vp->v_uobj.uo_npages == 0))
+               simple_lock(&vp->v_interlock);
+               nvp = LIST_NEXT(vp, v_mntvnodes);
+               np = VTOSMB(vp);
+               if ((np->n_flag & NMODIFIED) == 0 &&
+                   LIST_EMPTY(&vp->v_dirtyblkhd) &&
+                    vp->v_uobj.uo_npages == 0) {
+                       simple_unlock(&vp->v_interlock);
                        continue;
-               if (vget(vp, LK_EXCLUSIVE))
-                       goto loop;
+               }
+               simple_unlock(&mntvnode_slock);
+               error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK);
+               if (error) {
+                       simple_lock(&mntvnode_slock);
+                       if (error == ENOENT)
+                               goto loop;
+                       continue;
+               }
                error = VOP_FSYNC(vp, cred,
                    waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0, p);
                if (error)
                        allerror = error;
                vput(vp);
+               simple_lock(&mntvnode_slock);
        }
+       simple_unlock(&mntvnode_slock);
        return (allerror);
 }
 



Home | Main Index | Thread Index | Old Index