From d02601f8cf4c50dd6d50eaaaef98ea3f1033bdce Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Sat, 22 Nov 1997 06:10:36 +0000 Subject: [PATCH] Fixed rev.1.81. mp->mnt_kern_flag was restored in the non-error case of `mount -u'. This only matters for `mount -u' competing with unmounts. If I understand the locking correctly: if mount() blocks, then unmount() may run and set mp->kern_flag for the same mp. Then unmount() blocks waiting for mount() to finish. When unmount() continues, its MNTK flags (MNTK_UNMOUNT and MNTK_MWAIT) may have been clobbered. Didn't fix old bugs: - restoring mp->mnt_kern_flag is wrong for the same reasons in the error case. - the error case of unmount() seems to be broken too: (a) MNTK_UNMOUNT gets clobbered, although another unmount() may have set it. Perhaps it shouldn't be set until after the full lock is aquired. (b) MNTK_MWAIT isn't honoured. Fixed a nearby style bug. --- sys/kern/vfs_extattr.c | 7 ++++--- sys/kern/vfs_syscalls.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index eb8cb4ee6766..8a0ab1dcbafc 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.81 1997/11/12 05:42:17 julian Exp $ + * $Id: vfs_syscalls.c,v 1.82 1997/11/13 00:28:50 julian Exp $ */ /* @@ -274,10 +274,11 @@ update: if (mp->mnt_kern_flag & MNTK_WANTRDWR) mp->mnt_flag &= ~MNT_RDONLY; mp->mnt_flag &=~ (MNT_UPDATE | MNT_RELOAD | MNT_FORCE); - mp->mnt_kern_flag &=~ (MNTK_WANTRDWR); - if (error) + mp->mnt_kern_flag &=~ MNTK_WANTRDWR; + if (error) { mp->mnt_flag = flag; mp->mnt_kern_flag = flag2; + } vfs_unbusy(mp, p); return (error); } diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index eb8cb4ee6766..8a0ab1dcbafc 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.81 1997/11/12 05:42:17 julian Exp $ + * $Id: vfs_syscalls.c,v 1.82 1997/11/13 00:28:50 julian Exp $ */ /* @@ -274,10 +274,11 @@ update: if (mp->mnt_kern_flag & MNTK_WANTRDWR) mp->mnt_flag &= ~MNT_RDONLY; mp->mnt_flag &=~ (MNT_UPDATE | MNT_RELOAD | MNT_FORCE); - mp->mnt_kern_flag &=~ (MNTK_WANTRDWR); - if (error) + mp->mnt_kern_flag &=~ MNTK_WANTRDWR; + if (error) { mp->mnt_flag = flag; mp->mnt_kern_flag = flag2; + } vfs_unbusy(mp, p); return (error); }