Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/cd9660 Tidy up locking in cd9660_mount; thrash the lo...



details:   https://anonhg.NetBSD.org/src/rev/e1726ac3fd2e
branches:  trunk
changeset: 328027:e1726ac3fd2e
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Mar 24 04:03:25 2014 +0000

description:
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().

diffstat:

 sys/fs/cd9660/cd9660_vfsops.c |  26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diffs (65 lines):

diff -r 90b38a9208e3 -r e1726ac3fd2e sys/fs/cd9660/cd9660_vfsops.c
--- a/sys/fs/cd9660/cd9660_vfsops.c     Mon Mar 24 01:04:37 2014 +0000
+++ b/sys/fs/cd9660/cd9660_vfsops.c     Mon Mar 24 04:03:25 2014 +0000
@@ -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 @@
        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);
 }



Home | Main Index | Thread Index | Old Index