From owner-svn-src-stable@freebsd.org Wed Aug 8 18:51:40 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30CDB10670F6; Wed, 8 Aug 2018 18:51:40 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DC4388D4A4; Wed, 8 Aug 2018 18:51:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEFD1694F; Wed, 8 Aug 2018 18:51:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w78IpdQr043541; Wed, 8 Aug 2018 18:51:39 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w78IpdXh043540; Wed, 8 Aug 2018 18:51:39 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201808081851.w78IpdXh043540@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 8 Aug 2018 18:51:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r337483 - stable/11/sys/ufs/ffs X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/ufs/ffs X-SVN-Commit-Revision: 337483 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Aug 2018 18:51:40 -0000 Author: kib Date: Wed Aug 8 18:51:39 2018 New Revision: 337483 URL: https://svnweb.freebsd.org/changeset/base/337483 Log: MFC r337055: Avoid assertion in /dev/ufssuspend when the suspend ioctl is (incorrectly) called while another suspension is already active. PR: 230220 Modified: stable/11/sys/ufs/ffs/ffs_suspend.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/ufs/ffs/ffs_suspend.c ============================================================================== --- stable/11/sys/ufs/ffs/ffs_suspend.c Wed Aug 8 18:50:42 2018 (r337482) +++ stable/11/sys/ufs/ffs/ffs_suspend.c Wed Aug 8 18:51:39 2018 (r337483) @@ -214,6 +214,31 @@ ffs_susp_suspend(struct mount *mp) } static void +ffs_susp_unsuspend(struct mount *mp) +{ + struct ufsmount *ump; + + sx_assert(&ffs_susp_lock, SA_XLOCKED); + + /* + * XXX: The status is kept per-process; the vfs_write_resume() routine + * asserts that the resuming thread is the same one that called + * vfs_write_suspend(). The cdevpriv data, however, is attached + * to the file descriptor, e.g. is inherited during fork. Thus, + * it's possible that the resuming process will be different from + * the one that started the suspension. + * + * Work around by fooling the check in vfs_write_resume(). + */ + mp->mnt_susp_owner = curthread; + + vfs_write_resume(mp, 0); + ump = VFSTOUFS(mp); + ump->um_writesuspended = 0; + vfs_unbusy(mp); +} + +static void ffs_susp_dtor(void *data) { struct fs *fs; @@ -239,22 +264,7 @@ ffs_susp_dtor(void *data) if (error != 0) panic("failed to unsuspend writes on %s", fs->fs_fsmnt); - /* - * XXX: The status is kept per-process; the vfs_write_resume() routine - * asserts that the resuming thread is the same one that called - * vfs_write_suspend(). The cdevpriv data, however, is attached - * to the file descriptor, e.g. is inherited during fork. Thus, - * it's possible that the resuming process will be different from - * the one that started the suspension. - * - * Work around by fooling the check in vfs_write_resume(). - */ - mp->mnt_susp_owner = curthread; - - vfs_write_resume(mp, 0); - vfs_unbusy(mp); - ump->um_writesuspended = 0; - + ffs_susp_unsuspend(mp); sx_xunlock(&ffs_susp_lock); } @@ -294,7 +304,8 @@ ffs_susp_ioctl(struct cdev *dev, u_long cmd, caddr_t a break; } error = devfs_set_cdevpriv(mp, ffs_susp_dtor); - KASSERT(error == 0, ("devfs_set_cdevpriv failed")); + if (error != 0) + ffs_susp_unsuspend(mp); break; case UFSRESUME: error = devfs_get_cdevpriv((void **)&mp);