Date: Sun, 20 Nov 2016 09:11:21 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r308876 - stable/11/sys/kern Message-ID: <201611200911.uAK9BLwe067138@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sun Nov 20 09:11:21 2016 New Revision: 308876 URL: https://svnweb.freebsd.org/changeset/base/308876 Log: MFC r308617: Move common cleanup code into helper. Modified: stable/11/sys/kern/vfs_mount.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_mount.c ============================================================================== --- stable/11/sys/kern/vfs_mount.c Sun Nov 20 09:04:16 2016 (r308875) +++ stable/11/sys/kern/vfs_mount.c Sun Nov 20 09:11:21 2016 (r308876) @@ -1229,6 +1229,24 @@ vfs_check_usecounts(struct mount *mp) return (0); } +static void +dounmount_cleanup(struct mount *mp, struct vnode *coveredvp, int mntkflags) +{ + + mtx_assert(MNT_MTX(mp), MA_OWNED); + mp->mnt_kern_flag &= ~mntkflags; + if ((mp->mnt_kern_flag & MNTK_MWAIT) != 0) { + mp->mnt_kern_flag &= ~MNTK_MWAIT; + wakeup(mp); + } + MNT_IUNLOCK(mp); + if (coveredvp != NULL) { + VOP_UNLOCK(coveredvp, 0); + vdrop(coveredvp); + } + vn_finished_write(mp); +} + /* * Do the actual filesystem unmount. */ @@ -1276,12 +1294,7 @@ dounmount(struct mount *mp, int flags, s MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0 || !TAILQ_EMPTY(&mp->mnt_uppers)) { - MNT_IUNLOCK(mp); - if (coveredvp != NULL) { - VOP_UNLOCK(coveredvp, 0); - vdrop(coveredvp); - } - vn_finished_write(mp); + dounmount_cleanup(mp, coveredvp, 0); return (EBUSY); } mp->mnt_kern_flag |= MNTK_UNMOUNT | MNTK_NOINSMNTQ; @@ -1290,17 +1303,8 @@ dounmount(struct mount *mp, int flags, s error = vfs_check_usecounts(mp); MNT_ILOCK(mp); if (error != 0) { - mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_NOINSMNTQ); - if (mp->mnt_kern_flag & MNTK_MWAIT) { - mp->mnt_kern_flag &= ~MNTK_MWAIT; - wakeup(mp); - } - MNT_IUNLOCK(mp); - if (coveredvp != NULL) { - VOP_UNLOCK(coveredvp, 0); - vdrop(coveredvp); - } - vn_finished_write(mp); + dounmount_cleanup(mp, coveredvp, MNTK_UNMOUNT | + MNTK_NOINSMNTQ); return (error); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611200911.uAK9BLwe067138>