When unmounting, make sure to free the syncer vnode so that it can be reused.

This commit is contained in:
mycroft 2000-07-09 00:59:03 +00:00
parent bd8f07c394
commit caf07dfa04
5 changed files with 48 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.159 2000/06/27 17:41:52 mrg Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.160 2000/07/09 00:59:03 mycroft Exp $ */
/*
* Copyright (c) 1989, 1993
@ -329,10 +329,8 @@ update:
if (mp->mnt_syncer == NULL)
error = vfs_allocate_syncvnode(mp);
} else {
if (mp->mnt_syncer != NULL) {
vgone(mp->mnt_syncer);
mp->mnt_syncer = NULL;
}
if (mp->mnt_syncer != NULL)
vfs_deallocate_syncvnode(mp);
}
vfs_unbusy(mp);
return (error);
@ -498,10 +496,8 @@ dounmount(mp, flags, p)
async = mp->mnt_flag & MNT_ASYNC;
mp->mnt_flag &= ~MNT_ASYNC;
cache_purgevfs(mp); /* remove cache entries for this file sys */
if (mp->mnt_syncer != NULL) {
vgone(mp->mnt_syncer);
mp->mnt_syncer = NULL;
}
if (mp->mnt_syncer != NULL)
vfs_deallocate_syncvnode(mp);
if (((mp->mnt_flag & MNT_RDONLY) ||
(error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0) ||
(flags & MNT_FORCE))

View File

@ -1,4 +1,4 @@
/* $NetBSD: sync_subr.c,v 1.3 1999/11/23 23:52:41 fvdl Exp $ */
/* $NetBSD: sync_subr.c,v 1.4 2000/07/09 00:59:06 mycroft Exp $ */
/*
* Copyright 1997 Marshall Kirk McKusick. All Rights Reserved.
@ -131,6 +131,24 @@ vn_syncer_add_to_worklist(vp, delay)
splx(s);
}
/*
* Remove an item fromthe syncer work queue.
*/
void
vn_syncer_remove_from_worklist(vp)
struct vnode *vp;
{
int s;
s = splbio();
if (vp->v_flag & VONWORKLST) {
LIST_REMOVE(vp, v_synclist);
}
splx(s);
}
/*
* System filesystem synchronizer daemon.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: sync_vnops.c,v 1.2 1999/11/15 18:49:10 fvdl Exp $ */
/* $NetBSD: sync_vnops.c,v 1.3 2000/07/09 00:59:06 mycroft Exp $ */
/*
* Copyright 1997 Marshall Kirk McKusick. All Rights Reserved.
@ -70,10 +70,9 @@ vfs_allocate_syncvnode(mp)
int error;
/* Allocate a new vnode */
if ((error = getnewvnode(VT_VFS, mp, sync_vnodeop_p, &vp)) != 0) {
mp->mnt_syncer = NULL;
if ((error = getnewvnode(VT_VFS, mp, sync_vnodeop_p, &vp)) != 0)
return (error);
}
vp->v_writecount = 1;
vp->v_type = VNON;
/*
@ -97,6 +96,23 @@ vfs_allocate_syncvnode(mp)
return (0);
}
/*
* Destroy the filesystem syncer vnode for the specified mount point.
*/
void
vfs_deallocate_syncvnode(mp)
struct mount *mp;
{
struct vnode *vp;
vp = mp->mnt_syncer;
mp->mnt_syncer = 0;
vn_syncer_remove_from_worklist(vp);
vp->v_writecount = 0;
vgone(vp);
vrele(vp);
}
/*
* Do a lazy sync of the filesystem.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: syncfs.h,v 1.3 2000/03/30 02:21:49 simonb Exp $ */
/* $NetBSD: syncfs.h,v 1.4 2000/07/09 00:59:06 mycroft Exp $ */
/*
* Copyright 1997 Marshall Kirk McKusick. All Rights Reserved.
@ -46,6 +46,7 @@ int sync_print __P((void *));
void sched_sync __P((void *));
void vn_initialize_syncerd __P((void));
int vfs_allocate_syncvnode __P((struct mount *));
void vfs_deallocate_syncvnode __P((struct mount *));
extern int (**sync_vnodeop_p) __P((void *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: vnode.h,v 1.82 2000/06/29 09:01:09 mrg Exp $ */
/* $NetBSD: vnode.h,v 1.83 2000/07/09 00:59:05 mycroft Exp $ */
/*
* Copyright (c) 1989, 1993
@ -530,6 +530,7 @@ int vn_readdir __P((struct file *fp, char *buf, int segflg, u_int count,
int vn_poll __P((struct file *fp, int events, struct proc *p));
int vn_stat __P((struct vnode *vp, struct stat *sb, struct proc *p));
void vn_syncer_add_to_worklist __P((struct vnode *vp, int delay));
void vn_syncer_remove_from_worklist __P((struct vnode *vp));
int vn_write __P((struct file *fp, off_t *offset, struct uio *uio,
struct ucred *cred, int flags));
int vn_writechk __P((struct vnode *vp));