have to recompute the next pointer after possibly sleeping in sync
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 15 Aug 1994 12:54:41 +0000 (04:54 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Mon, 15 Aug 1994 12:54:41 +0000 (04:54 -0800)
(from mycroft)

SCCS-vsn: sys/kern/vfs_syscalls.c 8.21

usr/src/sys/kern/vfs_syscalls.c

index c09915c..deb34b9 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_syscalls.c      8.20 (Berkeley) %G%
+ *     @(#)vfs_syscalls.c      8.21 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -320,6 +320,10 @@ sync(p, uap, retval)
        int asyncflag;
 
        for (mp = mountlist.tqh_first; mp != NULL; mp = nmp) {
        int asyncflag;
 
        for (mp = mountlist.tqh_first; mp != NULL; mp = nmp) {
+               /*
+                * Get the next pointer in case we hang on vfs_busy
+                * while we are being unmounted.
+                */
                nmp = mp->mnt_list.tqe_next;
                /*
                 * The lock check below is to avoid races with mount
                nmp = mp->mnt_list.tqe_next;
                /*
                 * The lock check below is to avoid races with mount
@@ -332,6 +336,11 @@ sync(p, uap, retval)
                        VFS_SYNC(mp, MNT_NOWAIT, p->p_ucred, p);
                        if (asyncflag)
                                mp->mnt_flag |= MNT_ASYNC;
                        VFS_SYNC(mp, MNT_NOWAIT, p->p_ucred, p);
                        if (asyncflag)
                                mp->mnt_flag |= MNT_ASYNC;
+                       /*
+                        * Get the next pointer again, as the next filesystem
+                        * might have been unmounted while we were sync'ing.
+                        */
+                       nmp = mp->mnt_list.tqe_next;
                        vfs_unbusy(mp);
                }
        }
                        vfs_unbusy(mp);
                }
        }