aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-28 08:57:15 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-28 08:57:15 +0000
commitc87f1ad43ce664de499084f7662dd59b1c180eff (patch)
tree5216e09d1d3ceb4e2984d034b547bc157ff7fbb3 /sys
parent4d02a00a57d8ce2bd81efc6c9b65ab7ce241bc5e (diff)
downloadsrc-c87f1ad43ce664de499084f7662dd59b1c180eff.tar.gz
src-c87f1ad43ce664de499084f7662dd59b1c180eff.zip
There is a bug in vfs_allocate_syncvnode() failure handling in mount code.
Actually it is hard to properly handle such a failure, especially in MNT_UPDATE case. The only reason for the vfs_allocate_syncvnode() function to fail is getnewvnode() failure. Fortunately it is impossible for current implementation of getnewvnode() to fail, so we can assert this and make vfs_allocate_syncvnode() void. This in turn free us from handling its failures in the mount code. Reviewed by: kib MFC after: 1 month
Notes
Notes: svn path=/head/; revision=211930
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_mount.c8
-rw-r--r--sys/kern/vfs_subr.c12
-rw-r--r--sys/sys/mount.h2
3 files changed, 9 insertions, 13 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 088d93973bd7..fe9f16c33555 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -1036,7 +1036,7 @@ vfs_domount(
MNT_IUNLOCK(mp);
if ((mp->mnt_flag & MNT_RDONLY) == 0) {
if (mp->mnt_syncer == NULL)
- error = vfs_allocate_syncvnode(mp);
+ vfs_allocate_syncvnode(mp);
} else {
if (mp->mnt_syncer != NULL)
vrele(mp->mnt_syncer);
@@ -1078,10 +1078,8 @@ vfs_domount(
mountcheckdirs(vp, newdp);
vrele(newdp);
if ((mp->mnt_flag & MNT_RDONLY) == 0)
- error = vfs_allocate_syncvnode(mp);
+ vfs_allocate_syncvnode(mp);
vfs_unbusy(mp);
- if (error)
- vrele(vp);
} else {
vfs_unbusy(mp);
vfs_mount_destroy(mp);
@@ -1311,7 +1309,7 @@ dounmount(mp, flags, td)
mp->mnt_kern_flag &= ~MNTK_NOINSMNTQ;
if ((mp->mnt_flag & MNT_RDONLY) == 0 && mp->mnt_syncer == NULL) {
MNT_IUNLOCK(mp);
- (void) vfs_allocate_syncvnode(mp);
+ vfs_allocate_syncvnode(mp);
MNT_ILOCK(mp);
}
mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_UNMOUNTF);
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 985d73bc54fb..9bb365fcaae6 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -3365,7 +3365,7 @@ static struct vop_vector sync_vnodeops = {
/*
* Create a new filesystem syncer vnode for the specified mount point.
*/
-int
+void
vfs_allocate_syncvnode(struct mount *mp)
{
struct vnode *vp;
@@ -3374,16 +3374,15 @@ vfs_allocate_syncvnode(struct mount *mp)
int error;
/* Allocate a new vnode */
- if ((error = getnewvnode("syncer", mp, &sync_vnodeops, &vp)) != 0) {
- mp->mnt_syncer = NULL;
- return (error);
- }
+ error = getnewvnode("syncer", mp, &sync_vnodeops, &vp);
+ if (error != 0)
+ panic("vfs_allocate_syncvnode: getnewvnode() failed");
vp->v_type = VNON;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
vp->v_vflag |= VV_FORCEINSMQ;
error = insmntque(vp, mp);
if (error != 0)
- panic("vfs_allocate_syncvnode: insmntque failed");
+ panic("vfs_allocate_syncvnode: insmntque() failed");
vp->v_vflag &= ~VV_FORCEINSMQ;
VOP_UNLOCK(vp, 0);
/*
@@ -3411,7 +3410,6 @@ vfs_allocate_syncvnode(struct mount *mp)
mtx_unlock(&sync_mtx);
BO_UNLOCK(bo);
mp->mnt_syncer = vp;
- return (0);
}
/*
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index 20dcf641c7bd..85f16ff28020 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -730,7 +730,7 @@ void vfs_msync(struct mount *, int);
int vfs_busy(struct mount *, int);
int vfs_export /* process mount export info */
(struct mount *, struct export_args *);
-int vfs_allocate_syncvnode(struct mount *);
+void vfs_allocate_syncvnode(struct mount *);
int vfs_donmount(struct thread *td, int fsflags, struct uio *fsoptions);
void vfs_getnewfsid(struct mount *);
struct cdev *vfs_getrootfsid(struct mount *);