PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)

- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
  somewhere.  Use it to decide whether to do direct-mapped copy, rather than
  poking around directly in the vnode in ubc_uiomove(), which is ugly and
  doesn't work for tmpfs.  It would be nicer to contain all this in UVM but
  the filesystem provides the needed locking here (VV_MAPPED) and to
  reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS().  Pass in UBC_ISMAPPED where
  appropriate.
This commit is contained in:
ad 2020-04-23 21:47:07 +00:00
parent 10354d3c1e
commit f5ad84fdb3
27 changed files with 110 additions and 116 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: advnops.c,v 1.52 2020/04/23 09:58:37 jdolecek Exp $ */
/* $NetBSD: advnops.c,v 1.53 2020/04/23 21:47:07 ad Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.52 2020/04/23 09:58:37 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.53 2020/04/23 21:47:07 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -270,7 +270,7 @@ adosfs_read(void *v)
break;
}
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error) {
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd9660_vnops.c,v 1.55 2019/07/12 17:18:30 maxv Exp $ */
/* $NetBSD: cd9660_vnops.c,v 1.56 2020/04/23 21:47:07 ad Exp $ */
/*-
* Copyright (c) 1994
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.55 2019/07/12 17:18:30 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: cd9660_vnops.c,v 1.56 2020/04/23 21:47:07 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -241,7 +241,7 @@ cd9660_read(void *v)
if (bytelen == 0)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: efs_vnops.c,v 1.38 2017/05/26 14:21:00 riastradh Exp $ */
/* $NetBSD: efs_vnops.c,v 1.39 2020/04/23 21:47:07 ad Exp $ */
/*
* Copyright (c) 2006 Stephen M. Rumble <rumble@ephemeral.org>
@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.38 2017/05/26 14:21:00 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.39 2020/04/23 21:47:07 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -278,7 +278,7 @@ efs_read(void *v)
len = MIN(len, eip->ei_size - uio->uio_offset);
err = ubc_uiomove(&ap->a_vp->v_uobj, uio, len, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(ap->a_vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(ap->a_vp));
if (err) {
EFS_DPRINTF(("efs_read: uiomove error %d\n",
err));

View File

@ -1,4 +1,4 @@
/* $NetBSD: filecore_vnops.c,v 1.44 2015/04/20 23:03:08 riastradh Exp $ */
/* $NetBSD: filecore_vnops.c,v 1.45 2020/04/23 21:47:07 ad Exp $ */
/*-
* Copyright (c) 1994 The Regents of the University of California.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: filecore_vnops.c,v 1.44 2015/04/20 23:03:08 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: filecore_vnops.c,v 1.45 2020/04/23 21:47:07 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -230,7 +230,7 @@ filecore_read(void *v)
break;
}
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error) {
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: hfs_vnops.c,v 1.34 2017/05/26 14:21:00 riastradh Exp $ */
/* $NetBSD: hfs_vnops.c,v 1.35 2020/04/23 21:47:07 ad Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.34 2017/05/26 14:21:00 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.35 2020/04/23 21:47:07 ad Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@ -852,7 +852,7 @@ hfs_vop_read(void *v)
break;
error = ubc_uiomove(&vp->v_uobj, uio, len, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
}
return error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_denode.c,v 1.58 2020/04/13 19:23:17 ad Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.59 2020/04/23 21:47:07 ad Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.58 2020/04/13 19:23:17 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.59 2020/04/23 21:47:07 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -425,7 +425,7 @@ detrunc(struct denode *dep, u_long length, int flags, kauth_cred_t cred)
} else {
ubc_zerorange(&DETOV(dep)->v_uobj, length,
pmp->pm_bpcluster - boff,
UBC_UNMAP_FLAG(DETOV(dep)));
UBC_VNODE_FLAGS(DETOV(dep)));
}
}
@ -523,7 +523,7 @@ deextend(struct denode *dep, u_long length, kauth_cred_t cred)
dep->de_flag |= DE_UPDATE|DE_MODIFIED;
ubc_zerorange(&DETOV(dep)->v_uobj, (off_t)osize,
(size_t)(round_page(dep->de_FileSize) - osize),
UBC_UNMAP_FLAG(DETOV(dep)));
UBC_VNODE_FLAGS(DETOV(dep)));
uvm_vnp_setsize(DETOV(dep), (voff_t)dep->de_FileSize);
return (deupdat(dep, 1));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_vnops.c,v 1.101 2020/04/13 19:23:17 ad Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.102 2020/04/23 21:47:07 ad Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.101 2020/04/13 19:23:17 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.102 2020/04/23 21:47:07 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -480,7 +480,7 @@ msdosfs_read(void *v)
if (bytelen == 0)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -624,7 +624,7 @@ msdosfs_write(void *v)
rem = round_page(dep->de_FileSize) - dep->de_FileSize;
if (rem > 0)
ubc_zerorange(&vp->v_uobj, (off_t)dep->de_FileSize,
rem, UBC_UNMAP_FLAG(vp));
rem, UBC_VNODE_FLAGS(vp));
extended = 1;
}
@ -633,7 +633,7 @@ msdosfs_write(void *v)
bytelen = uio->uio_resid;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen,
IO_ADV_DECODE(ioflag), UBC_WRITE | UBC_UNMAP_FLAG(vp));
IO_ADV_DECODE(ioflag), UBC_WRITE | UBC_VNODE_FLAGS(vp));
if (error)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nilfs_vnops.c,v 1.39 2020/04/13 19:23:18 ad Exp $ */
/* $NetBSD: nilfs_vnops.c,v 1.40 2020/04/23 21:47:07 ad Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.39 2020/04/13 19:23:18 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.40 2020/04/23 21:47:07 ad Exp $");
#endif /* not lint */
@ -179,7 +179,7 @@ nilfs_read(void *v)
/* ubc, here we come, prepare to trap */
error = ubc_uiomove(uobj, uio, len, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -269,7 +269,7 @@ nilfs_write(void *v)
/* ubc, here we come, prepare to trap */
error = ubc_uiomove(uobj, uio, len, advice,
UBC_WRITE | UBC_UNMAP_FLAG(vp));
UBC_WRITE | UBC_VNODE_FLAGS(vp));
if (error)
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_vnops.c,v 1.214 2020/02/23 15:46:40 ad Exp $ */
/* $NetBSD: puffs_vnops.c,v 1.215 2020/04/23 21:47:07 ad Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.214 2020/02/23 15:46:40 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.215 2020/04/23 21:47:07 ad Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -1158,7 +1158,7 @@ zerofill_lastpage(struct vnode *vp, voff_t off)
return;
vsize_t len = round_page(off) - off;
ubc_zerorange(&vp->v_uobj, off, len, UBC_WRITE|UBC_UNMAP_FLAG(vp));
ubc_zerorange(&vp->v_uobj, off, len, UBC_WRITE|UBC_VNODE_FLAGS(vp));
}
static int
@ -2297,7 +2297,7 @@ puffs_vnop_read(void *v)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -2407,7 +2407,7 @@ puffs_vnop_write(void *v)
if (vp->v_type == VREG &&
PUFFS_USE_PAGECACHE(pmp) &&
!(pn->pn_stat & PNODE_WDIRECT)) {
ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp);
ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp);
while (uio->uio_resid > 0) {
oldoff = uio->uio_offset;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysvbfs_vnops.c,v 1.64 2020/01/17 20:08:08 ad Exp $ */
/* $NetBSD: sysvbfs_vnops.c,v 1.65 2020/04/23 21:47:08 ad Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.64 2020/01/17 20:08:08 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.65 2020/04/23 21:47:08 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -448,7 +448,7 @@ sysvbfs_read(void *arg)
break;
err = ubc_uiomove(&v->v_uobj, uio, sz, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(v));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(v));
if (err)
break;
DPRINTF("%s: read %ldbyte\n", __func__, sz);
@ -495,7 +495,7 @@ sysvbfs_write(void *arg)
while (uio->uio_resid > 0) {
sz = uio->uio_resid;
err = ubc_uiomove(&v->v_uobj, uio, sz, advice,
UBC_WRITE | UBC_UNMAP_FLAG(v));
UBC_WRITE | UBC_VNODE_FLAGS(v));
if (err)
break;
DPRINTF("%s: write %ldbyte\n", __func__, sz);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tmpfs_subr.c,v 1.108 2020/04/04 20:49:30 ad Exp $ */
/* $NetBSD: tmpfs_subr.c,v 1.109 2020/04/23 21:47:08 ad Exp $ */
/*
* Copyright (c) 2005-2013 The NetBSD Foundation, Inc.
@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.108 2020/04/04 20:49:30 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.109 2020/04/23 21:47:08 ad Exp $");
#include <sys/param.h>
#include <sys/cprng.h>
@ -929,7 +929,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize)
size_t zerolen;
zerolen = MIN(round_page(newsize), node->tn_size) - newsize;
ubc_zerorange(uobj, newsize, zerolen, UBC_UNMAP_FLAG(vp));
ubc_zerorange(uobj, newsize, zerolen, UBC_VNODE_FLAGS(vp));
}
node->tn_spec.tn_reg.tn_aobj_pages = newpages;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $ */
/* $NetBSD: tmpfs_vnops.c,v 1.136 2020/04/23 21:47:08 ad Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.136 2020/04/23 21:47:08 ad Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@ -546,7 +546,7 @@ tmpfs_read(void *v)
break;
}
error = ubc_uiomove(uobj, uio, len, IO_ADV_DECODE(ioflag),
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
}
tmpfs_update(vp, TMPFS_UPDATE_ATIME);
@ -608,7 +608,7 @@ tmpfs_write(void *v)
break;
}
error = ubc_uiomove(uobj, uio, len, IO_ADV_DECODE(ioflag),
UBC_WRITE | UBC_UNMAP_FLAG(vp));
UBC_WRITE | UBC_VNODE_FLAGS(vp));
}
if (error) {
(void)tmpfs_reg_resize(vp, oldsize);

View File

@ -1,4 +1,4 @@
/* $NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $ */
/* $NetBSD: udf_allocation.c,v 1.41 2020/04/23 21:47:08 ad Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.40 2018/10/14 17:37:40 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: udf_allocation.c,v 1.41 2020/04/23 21:47:08 ad Exp $");
#endif /* not lint */
@ -2678,7 +2678,7 @@ udf_grow_node(struct udf_node *udf_node, uint64_t new_size)
#if 0
/* zero append space in buffer */
ubc_zerorange(&vp->v_uobj, old_size,
new_size - old_size, UBC_UNMAP_FLAG(vp));
new_size - old_size, UBC_VNODE_FLAGS(vp));
#endif
udf_node_sanity_check(udf_node, &new_inflen, &new_lbrec);
@ -2784,7 +2784,7 @@ udf_grow_node(struct udf_node *udf_node, uint64_t new_size)
/* TODO zero appened space in buffer! */
/* using ubc_zerorange(&vp->v_uobj, old_size, */
/* new_size - old_size, UBC_UNMAP_FLAG(vp)); ? */
/* new_size - old_size, UBC_VNODE_FLAGS(vp)); ? */
}
memset(&s_ad, 0, sizeof(struct long_ad));
@ -2955,7 +2955,7 @@ udf_shrink_node(struct udf_node *udf_node, uint64_t new_size)
/* TODO zero appened space in buffer! */
/* using ubc_zerorange(&vp->v_uobj, old_size, */
/* old_size - new_size, UBC_UNMAP_FLAG(vp)); ? */
/* old_size - new_size, UBC_VNODE_FLAGS(vp)); ? */
/* set new size for uvm */
uvm_vnp_setsize(vp, new_size);

View File

@ -1,4 +1,4 @@
/* $NetBSD: udf_vnops.c,v 1.111 2020/04/14 11:45:42 reinoud Exp $ */
/* $NetBSD: udf_vnops.c,v 1.112 2020/04/23 21:47:08 ad Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.111 2020/04/14 11:45:42 reinoud Exp $");
__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.112 2020/04/23 21:47:08 ad Exp $");
#endif /* not lint */
@ -248,7 +248,7 @@ udf_read(void *v)
/* ubc, here we come, prepare to trap */
error = ubc_uiomove(uobj, uio, len, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -366,7 +366,7 @@ udf_write(void *v)
/* ubc, here we come, prepare to trap */
error = ubc_uiomove(uobj, uio, len, advice,
UBC_WRITE | UBC_UNMAP_FLAG(vp));
UBC_WRITE | UBC_VNODE_FLAGS(vp));
if (error)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: v7fs_vnops.c,v 1.28 2020/04/13 19:23:18 ad Exp $ */
/* $NetBSD: v7fs_vnops.c,v 1.29 2020/04/23 21:47:08 ad Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.28 2020/04/13 19:23:18 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.29 2020/04/23 21:47:08 ad Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@ -592,7 +592,7 @@ v7fs_read(void *v)
break;
error = ubc_uiomove(&vp->v_uobj, uio, sz, advice, UBC_READ |
UBC_PARTIALOK | UBC_UNMAP_FLAG(v));
UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error) {
break;
}
@ -644,7 +644,7 @@ v7fs_write(void *v)
while (uio->uio_resid > 0) {
sz = uio->uio_resid;
if ((error = ubc_uiomove(&vp->v_uobj, uio, sz, advice,
UBC_WRITE | UBC_UNMAP_FLAG(v))))
UBC_WRITE | UBC_VNODE_FLAGS(vp))))
break;
DPRINTF("write %zubyte\n", sz);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_bio.c,v 1.195 2020/03/22 18:32:42 ad Exp $ */
/* $NetBSD: nfs_bio.c,v 1.196 2020/04/23 21:47:08 ad Exp $ */
/*
* Copyright (c) 1989, 1993
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.195 2020/03/22 18:32:42 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.196 2020/04/23 21:47:08 ad Exp $");
#ifdef _KERNEL_OPT
#include "opt_nfs.h"
@ -158,7 +158,7 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag,
bytelen =
MIN(np->n_size - uio->uio_offset, uio->uio_resid);
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error) {
/*
* XXXkludge
@ -531,7 +531,7 @@ nfs_write(void *v)
error = ubc_uiomove(&vp->v_uobj, uio, bytelen,
UVM_ADV_RANDOM, UBC_WRITE | UBC_PARTIALOK |
(overwrite ? UBC_FAULTBUSY : 0) |
UBC_UNMAP_FLAG(vp));
UBC_VNODE_FLAGS(vp));
if (error) {
uvm_vnp_setwritesize(vp, vp->v_size);
if (overwrite && np->n_size != oldsize) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpfs.c,v 1.156 2020/04/13 19:23:20 ad Exp $ */
/* $NetBSD: rumpfs.c,v 1.157 2020/04/23 21:47:08 ad Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.156 2020/04/13 19:23:20 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.157 2020/04/23 21:47:08 ad Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@ -1403,7 +1403,7 @@ rump_vop_read(void *v)
if (chunk == 0)
break;
error = ubc_uiomove(&vp->v_uobj, uio, chunk, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -1505,7 +1505,7 @@ rump_vop_write(void *v)
if (chunk == 0)
break;
error = ubc_uiomove(&vp->v_uobj, uio, chunk, advice,
UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_WRITE | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: chfs_subr.c,v 1.11 2019/12/31 13:07:13 ad Exp $ */
/* $NetBSD: chfs_subr.c,v 1.12 2020/04/23 21:47:08 ad Exp $ */
/*-
* Copyright (c) 2010 Department of Software Engineering,
@ -232,7 +232,7 @@ chfs_chsize(struct vnode *vp, u_quad_t size, kauth_cred_t cred)
}
if (size != 0) {
ubc_zerorange(&vp->v_uobj, size, ip->size - size, UBC_UNMAP_FLAG(vp));
ubc_zerorange(&vp->v_uobj, size, ip->size - size, UBC_VNODE_FLAGS(vp));
}
/* drop unused fragments */

View File

@ -1,4 +1,4 @@
/* $NetBSD: chfs_vnops.c,v 1.37 2020/04/04 20:49:31 ad Exp $ */
/* $NetBSD: chfs_vnops.c,v 1.38 2020/04/23 21:47:08 ad Exp $ */
/*-
* Copyright (c) 2010 Department of Software Engineering,
@ -675,8 +675,7 @@ chfs_read(void *v)
if (bytelen == 0)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK |
(UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
@ -933,7 +932,7 @@ chfs_write(void *v)
* copy the data.
*/
ubc_flags |= UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0;
ubc_flags |= UBC_VNODE_FLAGS(vp);
error = ubc_uiomove(&vp->v_uobj, uio, bytelen,
IO_ADV_DECODE(ioflag), ubc_flags);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_inode.c,v 1.88 2017/05/26 14:34:20 riastradh Exp $ */
/* $NetBSD: ext2fs_inode.c,v 1.89 2020/04/23 21:47:08 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.88 2017/05/26 14:34:20 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.89 2020/04/23 21:47:08 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -360,7 +360,7 @@ ext2fs_truncate(struct vnode *ovp, off_t length, int ioflag,
/* XXXUBC we should handle more than just VREG */
ubc_zerorange(&ovp->v_uobj, length, size - offset,
UBC_UNMAP_FLAG(ovp));
UBC_VNODE_FLAGS(ovp));
}
(void)ext2fs_setsize(oip, length);
uvm_vnp_setsize(ovp, length);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_readwrite.c,v 1.76 2020/02/23 15:46:42 ad Exp $ */
/* $NetBSD: ext2fs_readwrite.c,v 1.77 2020/04/23 21:47:08 ad Exp $ */
/*-
* Copyright (c) 1993
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.76 2020/02/23 15:46:42 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_readwrite.c,v 1.77 2020/04/23 21:47:08 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -135,7 +135,7 @@ ext2fs_read(void *v)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -316,7 +316,7 @@ ext2fs_write(void *v)
if (error)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_WRITE | UBC_UNMAP_FLAG(vp));
UBC_WRITE | UBC_VNODE_FLAGS(vp));
if (error)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffs_inode.c,v 1.127 2020/04/18 19:18:34 christos Exp $ */
/* $NetBSD: ffs_inode.c,v 1.128 2020/04/23 21:47:09 ad Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.127 2020/04/18 19:18:34 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.128 2020/04/23 21:47:09 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -364,7 +364,7 @@ ffs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
eoz = MIN(MAX(ffs_lblktosize(fs, lbn) + size, round_page(pgoffset)),
osize);
ubc_zerorange(&ovp->v_uobj, length, eoz - length,
UBC_UNMAP_FLAG(ovp));
UBC_VNODE_FLAGS(ovp));
if (round_page(eoz) > round_page(length)) {
rw_enter(ovp->v_uobj.vmobjlock, RW_WRITER);
error = VOP_PUTPAGES(ovp, round_page(length),

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_inode.c,v 1.159 2020/02/23 15:46:42 ad Exp $ */
/* $NetBSD: lfs_inode.c,v 1.160 2020/04/23 21:47:09 ad Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.159 2020/02/23 15:46:42 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.160 2020/04/23 21:47:09 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@ -409,7 +409,7 @@ lfs_truncate(struct vnode *ovp, off_t length, int ioflag, kauth_cred_t cred)
size = lfs_blksize(fs, oip, xlbn);
eoz = MIN(lfs_lblktosize(fs, xlbn) + size, osize);
ubc_zerorange(&ovp->v_uobj, length, eoz - length,
UBC_UNMAP_FLAG(ovp));
UBC_VNODE_FLAGS(ovp));
if (round_page(eoz) > round_page(length)) {
rw_enter(ovp->v_uobj.vmobjlock, RW_WRITER);
error = VOP_PUTPAGES(ovp, round_page(length),

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_readwrite.c,v 1.26 2020/02/23 15:46:42 ad Exp $ */
/* $NetBSD: ulfs_readwrite.c,v 1.27 2020/04/23 21:47:09 ad Exp $ */
/* from NetBSD: ufs_readwrite.c,v 1.120 2015/04/12 22:48:38 riastradh Exp */
/*-
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.26 2020/02/23 15:46:42 ad Exp $");
__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.27 2020/04/23 21:47:09 ad Exp $");
#define FS struct lfs
#define I_FS i_lfs
@ -105,7 +105,7 @@ READ(void *v)
if (bytelen == 0)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -373,7 +373,7 @@ WRITE(void *v)
*/
error = ubc_uiomove(&vp->v_uobj, uio, bytelen,
IO_ADV_DECODE(ioflag), ubc_flags | UBC_UNMAP_FLAG(vp));
IO_ADV_DECODE(ioflag), ubc_flags | UBC_VNODE_FLAGS(vp));
/*
* update UVM's notion of the size now that we've

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_readwrite.c,v 1.125 2020/02/23 15:46:43 ad Exp $ */
/* $NetBSD: ufs_readwrite.c,v 1.126 2020/04/23 21:47:09 ad Exp $ */
/*-
* Copyright (c) 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.125 2020/02/23 15:46:43 ad Exp $");
__KERNEL_RCSID(1, "$NetBSD: ufs_readwrite.c,v 1.126 2020/04/23 21:47:09 ad Exp $");
#define FS struct fs
#define I_FS i_fs
@ -106,7 +106,7 @@ READ(void *v)
if (bytelen == 0)
break;
error = ubc_uiomove(&vp->v_uobj, uio, bytelen, advice,
UBC_READ | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp));
UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp));
if (error)
break;
}
@ -408,7 +408,7 @@ WRITE(void *v)
*/
error = ubc_uiomove(&vp->v_uobj, uio, bytelen,
IO_ADV_DECODE(ioflag), ubc_flags | UBC_UNMAP_FLAG(vp));
IO_ADV_DECODE(ioflag), ubc_flags | UBC_VNODE_FLAGS(vp));
/*
* update UVM's notion of the size now that we've

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_bio.c,v 1.109 2020/04/23 21:12:06 ad Exp $ */
/* $NetBSD: uvm_bio.c,v 1.110 2020/04/23 21:47:09 ad Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.109 2020/04/23 21:12:06 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.110 2020/04/23 21:47:09 ad Exp $");
#include "opt_uvmhist.h"
#include "opt_ubc.h"
@ -734,25 +734,17 @@ ubc_uiomove(struct uvm_object *uobj, struct uio *uio, vsize_t todo, int advice,
((flags & UBC_READ) != 0 && uio->uio_rw == UIO_READ));
#ifdef UBC_USE_PMAP_DIRECT
if (ubc_direct && UVM_OBJ_IS_VNODE(uobj)) {
/*
* during direct access pages need to be held busy to
* prevent them disappearing. if the LWP reads or writes
* a vnode into a mapped view of same it could deadlock.
* prevent this by disallowing direct access if the vnode
* is visible somewhere via mmap().
*
* the vnode flags are tested here, but at all points UBC is
* called for vnodes, the vnode is locked (thus preventing a
* new mapping via mmap() while busy here).
*/
/*
* during direct access pages need to be held busy to prevent them
* changing identity, and therefore if we read or write an object
* into a mapped view of same we could deadlock while faulting.
*
* avoid the problem by disallowing direct access if the object
* might be visible somewhere via mmap().
*/
struct vnode *vp = (struct vnode *)uobj;
KASSERT(VOP_ISLOCKED(vp) != LK_NONE);
if ((vp->v_vflag & VV_MAPPED) == 0) {
return ubc_uiomove_direct(uobj, uio, todo, advice,
flags);
}
if (ubc_direct && (flags & UBC_ISMAPPED) == 0) {
return ubc_uiomove_direct(uobj, uio, todo, advice, flags);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_extern.h,v 1.223 2020/04/18 03:27:13 thorpej Exp $ */
/* $NetBSD: uvm_extern.h,v 1.224 2020/04/23 21:47:09 ad Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -226,6 +226,7 @@ b\32UNMAP\0\
#define UBC_FAULTBUSY 0x004 /* nobody else is using these pages, so busy
* them at alloc and unbusy at release (e.g.,
* for writes extending a file) */
#define UBC_ISMAPPED 0x008 /* object may be mapped by a process */
/*
* flags for ubc_release()
@ -549,11 +550,13 @@ extern bool vm_page_zero_enable;
* helpers for calling ubc_release()
*/
#ifdef PMAP_CACHE_VIVT
#define UBC_WANT_UNMAP(vp) (((vp)->v_iflag & VI_TEXT) != 0)
#define UBC_VNODE_FLAGS(vp) \
((((vp)->v_iflag & VI_TEXT) != 0 ? UBC_UNMAP : 0) |
(((vp)->v_vflag & VV_MAPPED) != 0 ? UBC_ISMAPPED : 0))
#else
#define UBC_WANT_UNMAP(vp) false
#define UBC_VNODE_FLAGS(vp) \
(((vp)->v_vflag & VV_MAPPED) != 0 ? UBC_ISMAPPED : 0)
#endif
#define UBC_UNMAP_FLAG(vp) (UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0)
#if defined(_KERNEL) || defined(_KMEMUSER)
/*