diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-05-06 15:59:49 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1999-05-06 15:59:49 +0000 |
commit | b98c3f75685de38f4cd5cc7b1803bcf1eaa2fc0c (patch) | |
tree | f1e5a63724596944c2aeb16c1c869db3fa6de843 /sys/kern | |
parent | 45c4053b6afc960776d9fc78366ec2e281981a53 (diff) |
factor out sync+wait code into vfa_syncwait() routine for
applications in system like power management and such.
art@ finally said `commit it'
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_subr.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 05317f457ad..4df9a385a12 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.37 1999/04/30 08:21:52 art Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.38 1999/05/06 15:59:40 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; } /* |