diff options
author | 1999-03-11 18:28:55 +0000 | |
---|---|---|
committer | 1999-03-11 18:28:55 +0000 | |
commit | 9d84d71fb24a5dcd23c301a9a94c777c0f948ce5 (patch) | |
tree | 4ecba8394ae548d40e9fb340be5bd9472fe27df7 | |
parent | Winbond W89C840F ethernet driver (diff) | |
download | wireguard-openbsd-9d84d71fb24a5dcd23c301a9a94c777c0f948ce5.tar.xz wireguard-openbsd-9d84d71fb24a5dcd23c301a9a94c777c0f948ce5.zip |
factor sync+wait operation out into a separate function.
-rw-r--r-- | sys/kern/vfs_subr.c | 43 | ||||
-rw-r--r-- | sys/sys/mount.h | 5 |
2 files changed, 31 insertions, 17 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 4b5c24997d1..44daf913b23 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.32 1999/02/26 05:17:43 art Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.33 1999/03/11 18:28:55 mickey Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1727,9 +1727,6 @@ vfs_unmountall() void vfs_shutdown() { - register struct buf *bp; - int iter, nbusy; - /* XXX Should suspend scheduling. */ (void) spl0(); @@ -1751,24 +1748,40 @@ vfs_shutdown() vfs_unmountall(); } - /* Sync again after unmount, just in case. */ - sys_sync(&proc0, (void *)0, (register_t *)0); + if (vfs_syncwait(1)) + printf("giving up\n"); + else + printf("done\n"); +} + +/* + * perform sync() operation and wait for buffers to flush. + * assumtions: called w/ scheduler disabled and physical io enabled + * for now called at spl0() XXX + */ +int +vfs_syncwait(verbose) + int verbose; +{ + register struct buf *bp; + int iter, nbusy; + sys_sync(&proc0, (void *)0, (register_t *)0); + /* Wait for sync to finish. */ for (iter = 0; iter < 20; iter++) { nbusy = 0; for (bp = &buf[nbuf]; --bp >= buf; ) if ((bp->b_flags & (B_BUSY|B_INVAL)) == B_BUSY) nbusy++; - if (nbusy == 0) - break; - printf("%d ", nbusy); - DELAY(40000 * iter); - } - if (nbusy) - printf("giving up\n"); - else - printf("done\n"); + if (nbusy == 0) + break; + if (verbose) + printf("%d ", nbusy); + DELAY(40000 * iter); + } + + return nbusy; } /* diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 3350fcdcf73..319053cfabe 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mount.h,v 1.25 1999/02/19 17:15:44 art Exp $ */ +/* $OpenBSD: mount.h,v 1.26 1999/03/11 18:29:03 mickey Exp $ */ /* $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $ */ /* @@ -506,7 +506,8 @@ struct netcred *vfs_export_lookup /* lookup host in fs export list */ __P((struct mount *, struct netexport *, struct mbuf *)); int vfs_allocate_syncvnode __P((struct mount *)); -void vfs_shutdown __P((void)); /* unmount and sync file systems */ +int vfs_syncwait __P((int)); /* sync and wait for complete */ +void vfs_shutdown __P((void)); /* unmount and sync file systems */ long makefstype __P((char *)); int dounmount __P((struct mount *, int, struct proc *)); void vfsinit __P((void)); |