svn commit: r351475 - in stable/12/sys: fs/tmpfs kern sys
Konstantin Belousov
kib at FreeBSD.org
Sun Aug 25 06:22:15 UTC 2019
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 */
More information about the svn-src-stable-12
mailing list