From owner-svn-src-stable-12@freebsd.org Sun Aug 25 06:22:15 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1F351D67E4; Sun, 25 Aug 2019 06:22:15 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46GQ5y75Bwz4bV9; Sun, 25 Aug 2019 06:22:14 +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 D64AD19663; Sun, 25 Aug 2019 06:22:14 +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 x7P6MEAT058758; Sun, 25 Aug 2019 06:22:14 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7P6ME5w058754; Sun, 25 Aug 2019 06:22:14 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908250622.x7P6ME5w058754@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 25 Aug 2019 06:22:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351475 - in stable/12/sys: fs/tmpfs kern sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: fs/tmpfs kern sys X-SVN-Commit-Revision: 351475 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-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2019 06:22:15 -0000 Author: kib Date: Sun Aug 25 06:22:13 2019 New Revision: 351475 URL: https://svnweb.freebsd.org/changeset/base/351475 Log: MFC r351195: Fix an issue with executing tmpfs binary. Modified: stable/12/sys/fs/tmpfs/tmpfs_vfsops.c stable/12/sys/kern/vfs_default.c stable/12/sys/sys/mount.h stable/12/sys/sys/vnode.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- stable/12/sys/fs/tmpfs/tmpfs_vfsops.c Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/fs/tmpfs/tmpfs_vfsops.c Sun Aug 25 06:22:13 2019 (r351475) @@ -504,7 +504,8 @@ tmpfs_mount(struct mount *mp) MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; - mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED; + mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED | + MNTK_TEXT_REFS; MNT_IUNLOCK(mp); mp->mnt_data = tmp; Modified: stable/12/sys/kern/vfs_default.c ============================================================================== --- stable/12/sys/kern/vfs_default.c Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/kern/vfs_default.c Sun Aug 25 06:22:13 2019 (r351475) @@ -1068,6 +1068,7 @@ int vop_stdset_text(struct vop_set_text_args *ap) { struct vnode *vp; + struct mount *mp; int error; vp = ap->a_vp; @@ -1075,6 +1076,17 @@ vop_stdset_text(struct vop_set_text_args *ap) if (vp->v_writecount > 0) { error = ETXTBSY; } else { + /* + * If requested by fs, keep a use reference to the + * vnode until the last text reference is released. + */ + mp = vp->v_mount; + if (mp != NULL && (mp->mnt_kern_flag & MNTK_TEXT_REFS) != 0 && + vp->v_writecount == 0) { + vp->v_iflag |= VI_TEXT_REF; + vrefl(vp); + } + vp->v_writecount--; error = 0; } @@ -1087,16 +1099,25 @@ vop_stdunset_text(struct vop_unset_text_args *ap) { struct vnode *vp; int error; + bool last; vp = ap->a_vp; + last = false; VI_LOCK(vp); if (vp->v_writecount < 0) { + if ((vp->v_iflag & VI_TEXT_REF) != 0 && + vp->v_writecount == -1) { + last = true; + vp->v_iflag &= ~VI_TEXT_REF; + } vp->v_writecount++; error = 0; } else { error = EINVAL; } VI_UNLOCK(vp); + if (last) + vunref(vp); return (error); } Modified: stable/12/sys/sys/mount.h ============================================================================== --- stable/12/sys/sys/mount.h Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/sys/mount.h Sun Aug 25 06:22:13 2019 (r351475) @@ -398,6 +398,7 @@ void __mnt_vnode_markerfree_active(struct vno #define MNTK_MARKER 0x00001000 #define MNTK_UNMAPPED_BUFS 0x00002000 #define MNTK_USES_BCACHE 0x00004000 /* FS uses the buffer cache. */ +#define MNTK_TEXT_REFS 0x00008000 /* Keep use ref for text */ #define MNTK_NOASYNC 0x00800000 /* disable async */ #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ Modified: stable/12/sys/sys/vnode.h ============================================================================== --- stable/12/sys/sys/vnode.h Sun Aug 25 06:19:51 2019 (r351474) +++ stable/12/sys/sys/vnode.h Sun Aug 25 06:22:13 2019 (r351475) @@ -233,6 +233,7 @@ struct xvnode { * VI_DOOMED is doubly protected by the interlock and vnode lock. Both * are required for writing but the status may be checked with either. */ +#define VI_TEXT_REF 0x0001 /* Text ref grabbed use ref */ #define VI_MOUNT 0x0020 /* Mount in progress */ #define VI_DOOMED 0x0080 /* This vnode is being recycled */ #define VI_FREE 0x0100 /* This vnode is on the freelist */