Module Name: src Committed By: dholland Date: Mon Mar 24 04:03:25 UTC 2014
Modified Files: src/sys/fs/cd9660: cd9660_vfsops.c Log Message: Tidy up locking in cd9660_mount; thrash the lock less, and make it clear that the lock is only dropped when calling iso_mountfs(). While here, don't use the vnode pointer's value after vrele(). To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/fs/cd9660/cd9660_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/cd9660/cd9660_vfsops.c diff -u src/sys/fs/cd9660/cd9660_vfsops.c:1.82 src/sys/fs/cd9660/cd9660_vfsops.c:1.83 --- src/sys/fs/cd9660/cd9660_vfsops.c:1.82 Sun Mar 23 15:21:15 2014 +++ src/sys/fs/cd9660/cd9660_vfsops.c Mon Mar 24 04:03:25 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vfsops.c,v 1.82 2014/03/23 15:21:15 hannken Exp $ */ +/* $NetBSD: cd9660_vfsops.c,v 1.83 2014/03/24 04:03:25 dholland Exp $ */ /*- * Copyright (c) 1994 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.82 2014/03/23 15:21:15 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.83 2014/03/24 04:03:25 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -258,34 +258,36 @@ cd9660_mount(struct mount *mp, const cha vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_MOUNT, KAUTH_REQ_SYSTEM_MOUNT_DEVICE, mp, devvp, KAUTH_ARG(VREAD)); - VOP_UNLOCK(devvp); if (error) { - vrele(devvp); - return (error); + goto fail; } if ((mp->mnt_flag & MNT_UPDATE) == 0) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); error = VOP_OPEN(devvp, FREAD, FSCRED); - VOP_UNLOCK(devvp); if (error) goto fail; + VOP_UNLOCK(devvp); error = iso_mountfs(devvp, mp, l, args); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); if (error) { - vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); (void)VOP_CLOSE(devvp, FREAD, NOCRED); - VOP_UNLOCK(devvp); goto fail; } + VOP_UNLOCK(devvp); + /* reference to devvp is donated through iso_mountfs */ } else { - vrele(devvp); if (devvp != imp->im_devvp && - devvp->v_rdev != imp->im_devvp->v_rdev) - return (EINVAL); /* needs translation */ + devvp->v_rdev != imp->im_devvp->v_rdev) { + error = EINVAL; /* needs translation */ + goto fail; + } + VOP_UNLOCK(devvp); + vrele(devvp); } return set_statvfs_info(path, UIO_USERSPACE, args->fspec, UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l); fail: + VOP_UNLOCK(devvp); vrele(devvp); return (error); }