summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_vnops.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-08-31 10:20:52 +0000
committerkib <kib@FreeBSD.org>2009-08-31 10:20:52 +0000
commiteab33b2665846d5084e82efd82cee52fbdeacc00 (patch)
tree3c43f27414cce2467f2789f07a5165917b2efb82 /sys/kern/vfs_vnops.c
parent06073946facbcbb7b66e30b4ff79bff51e5460bb (diff)
downloadFreeBSD-src-eab33b2665846d5084e82efd82cee52fbdeacc00.zip
FreeBSD-src-eab33b2665846d5084e82efd82cee52fbdeacc00.tar.gz
Make the mnt_writeopcount and mnt_secondary_writes counters,
used by the suspension code, not greater then mnt_ref reference counter value. Increment mnt_ref together with write counter in vn_start_write()/ vn_start_secondary_write(), releasing in vn_finished_write/vn_finished_secondary_write(). Since r186197, unmount code requires that no writers occured after all references are expired. We still could get write counter incremented for freed or reused struct mount, but it seems to be innocent, since corresponding vnode should be referenced and reclaimed then. Reported by: pho (last half a year), erwin Reviewed by: attilio Tested by: pho, erwin MFC after: 1 week
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r--sys/kern/vfs_vnops.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index f670646..986bc8e 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -999,7 +999,8 @@ vn_start_write(vp, mpp, flags)
goto unlock;
mp->mnt_writeopcount++;
unlock:
- MNT_REL(mp);
+ if (error != 0)
+ MNT_REL(mp);
MNT_IUNLOCK(mp);
return (error);
}
@@ -1049,7 +1050,6 @@ vn_start_secondary_write(vp, mpp, flags)
if ((mp->mnt_kern_flag & (MNTK_SUSPENDED | MNTK_SUSPEND2)) == 0) {
mp->mnt_secondary_writes++;
mp->mnt_secondary_accwrites++;
- MNT_REL(mp);
MNT_IUNLOCK(mp);
return (0);
}
@@ -1081,6 +1081,7 @@ vn_finished_write(mp)
if (mp == NULL)
return;
MNT_ILOCK(mp);
+ MNT_REL(mp);
mp->mnt_writeopcount--;
if (mp->mnt_writeopcount < 0)
panic("vn_finished_write: neg cnt");
@@ -1103,6 +1104,7 @@ vn_finished_secondary_write(mp)
if (mp == NULL)
return;
MNT_ILOCK(mp);
+ MNT_REL(mp);
mp->mnt_secondary_writes--;
if (mp->mnt_secondary_writes < 0)
panic("vn_finished_secondary_write: neg cnt");
OpenPOWER on IntegriCloud