Module Name: src Committed By: ad Date: Thu Apr 23 21:47:09 UTC 2020
Modified Files: src/sys/fs/adosfs: advnops.c src/sys/fs/cd9660: cd9660_vnops.c src/sys/fs/efs: efs_vnops.c src/sys/fs/filecorefs: filecore_vnops.c src/sys/fs/hfs: hfs_vnops.c src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vnops.c src/sys/fs/nilfs: nilfs_vnops.c src/sys/fs/puffs: puffs_vnops.c src/sys/fs/sysvbfs: sysvbfs_vnops.c src/sys/fs/tmpfs: tmpfs_subr.c tmpfs_vnops.c src/sys/fs/udf: udf_allocation.c udf_vnops.c src/sys/fs/v7fs: v7fs_vnops.c src/sys/nfs: nfs_bio.c src/sys/rump/librump/rumpvfs: rumpfs.c src/sys/ufs/chfs: chfs_subr.c chfs_vnops.c src/sys/ufs/ext2fs: ext2fs_inode.c ext2fs_readwrite.c src/sys/ufs/ffs: ffs_inode.c src/sys/ufs/lfs: lfs_inode.c ulfs_readwrite.c src/sys/ufs/ufs: ufs_readwrite.c src/sys/uvm: uvm_bio.c uvm_extern.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/fs/adosfs/advnops.c cvs rdiff -u -r1.55 -r1.56 src/sys/fs/cd9660/cd9660_vnops.c cvs rdiff -u -r1.38 -r1.39 src/sys/fs/efs/efs_vnops.c cvs rdiff -u -r1.44 -r1.45 src/sys/fs/filecorefs/filecore_vnops.c cvs rdiff -u -r1.34 -r1.35 src/sys/fs/hfs/hfs_vnops.c cvs rdiff -u -r1.58 -r1.59 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.101 -r1.102 src/sys/fs/msdosfs/msdosfs_vnops.c cvs rdiff -u -r1.39 -r1.40 src/sys/fs/nilfs/nilfs_vnops.c cvs rdiff -u -r1.214 -r1.215 src/sys/fs/puffs/puffs_vnops.c cvs rdiff -u -r1.64 -r1.65 src/sys/fs/sysvbfs/sysvbfs_vnops.c cvs rdiff -u -r1.108 -r1.109 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.135 -r1.136 src/sys/fs/tmpfs/tmpfs_vnops.c cvs rdiff -u -r1.40 -r1.41 src/sys/fs/udf/udf_allocation.c cvs rdiff -u -r1.111 -r1.112 src/sys/fs/udf/udf_vnops.c cvs rdiff -u -r1.28 -r1.29 src/sys/fs/v7fs/v7fs_vnops.c cvs rdiff -u -r1.195 -r1.196 src/sys/nfs/nfs_bio.c cvs rdiff -u -r1.156 -r1.157 src/sys/rump/librump/rumpvfs/rumpfs.c cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/chfs/chfs_subr.c cvs rdiff -u -r1.37 -r1.38 src/sys/ufs/chfs/chfs_vnops.c cvs rdiff -u -r1.88 -r1.89 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.76 -r1.77 src/sys/ufs/ext2fs/ext2fs_readwrite.c cvs rdiff -u -r1.127 -r1.128 src/sys/ufs/ffs/ffs_inode.c cvs rdiff -u -r1.159 -r1.160 src/sys/ufs/lfs/lfs_inode.c cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/lfs/ulfs_readwrite.c cvs rdiff -u -r1.125 -r1.126 src/sys/ufs/ufs/ufs_readwrite.c cvs rdiff -u -r1.109 -r1.110 src/sys/uvm/uvm_bio.c cvs rdiff -u -r1.223 -r1.224 src/sys/uvm/uvm_extern.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/adosfs/advnops.c diff -u src/sys/fs/adosfs/advnops.c:1.52 src/sys/fs/adosfs/advnops.c:1.53 --- src/sys/fs/adosfs/advnops.c:1.52 Thu Apr 23 09:58:37 2020 +++ src/sys/fs/adosfs/advnops.c Thu Apr 23 21:47:07 2020 @@ -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; } Index: src/sys/fs/cd9660/cd9660_vnops.c diff -u src/sys/fs/cd9660/cd9660_vnops.c:1.55 src/sys/fs/cd9660/cd9660_vnops.c:1.56 --- src/sys/fs/cd9660/cd9660_vnops.c:1.55 Fri Jul 12 17:18:30 2019 +++ src/sys/fs/cd9660/cd9660_vnops.c Thu Apr 23 21:47:07 2020 @@ -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; } Index: src/sys/fs/efs/efs_vnops.c diff -u src/sys/fs/efs/efs_vnops.c:1.38 src/sys/fs/efs/efs_vnops.c:1.39 --- src/sys/fs/efs/efs_vnops.c:1.38 Fri May 26 14:21:00 2017 +++ src/sys/fs/efs/efs_vnops.c Thu Apr 23 21:47:07 2020 @@ -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 <rum...@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)); Index: src/sys/fs/filecorefs/filecore_vnops.c diff -u src/sys/fs/filecorefs/filecore_vnops.c:1.44 src/sys/fs/filecorefs/filecore_vnops.c:1.45 --- src/sys/fs/filecorefs/filecore_vnops.c:1.44 Mon Apr 20 23:03:08 2015 +++ src/sys/fs/filecorefs/filecore_vnops.c Thu Apr 23 21:47:07 2020 @@ -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; } Index: src/sys/fs/hfs/hfs_vnops.c diff -u src/sys/fs/hfs/hfs_vnops.c:1.34 src/sys/fs/hfs/hfs_vnops.c:1.35 --- src/sys/fs/hfs/hfs_vnops.c:1.34 Fri May 26 14:21:00 2017 +++ src/sys/fs/hfs/hfs_vnops.c Thu Apr 23 21:47:07 2020 @@ -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; Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.58 src/sys/fs/msdosfs/msdosfs_denode.c:1.59 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.58 Mon Apr 13 19:23:17 2020 +++ src/sys/fs/msdosfs/msdosfs_denode.c Thu Apr 23 21:47:07 2020 @@ -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 lengt } 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 leng 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)); } Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.101 src/sys/fs/msdosfs/msdosfs_vnops.c:1.102 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.101 Mon Apr 13 19:23:17 2020 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Thu Apr 23 21:47:07 2020 @@ -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; Index: src/sys/fs/nilfs/nilfs_vnops.c diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.39 src/sys/fs/nilfs/nilfs_vnops.c:1.40 --- src/sys/fs/nilfs/nilfs_vnops.c:1.39 Mon Apr 13 19:23:18 2020 +++ src/sys/fs/nilfs/nilfs_vnops.c Thu Apr 23 21:47:07 2020 @@ -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; } Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.214 src/sys/fs/puffs/puffs_vnops.c:1.215 --- src/sys/fs/puffs/puffs_vnops.c:1.214 Sun Feb 23 15:46:40 2020 +++ src/sys/fs/puffs/puffs_vnops.c Thu Apr 23 21:47:07 2020 @@ -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 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; Index: src/sys/fs/sysvbfs/sysvbfs_vnops.c diff -u src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.64 src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.65 --- src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.64 Fri Jan 17 20:08:08 2020 +++ src/sys/fs/sysvbfs/sysvbfs_vnops.c Thu Apr 23 21:47:08 2020 @@ -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); Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.108 src/sys/fs/tmpfs/tmpfs_subr.c:1.109 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.108 Sat Apr 4 20:49:30 2020 +++ src/sys/fs/tmpfs/tmpfs_subr.c Thu Apr 23 21:47:08 2020 @@ -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 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; Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.135 src/sys/fs/tmpfs/tmpfs_vnops.c:1.136 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.135 Sat Mar 14 13:39:36 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Thu Apr 23 21:47:08 2020 @@ -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); Index: src/sys/fs/udf/udf_allocation.c diff -u src/sys/fs/udf/udf_allocation.c:1.40 src/sys/fs/udf/udf_allocation.c:1.41 --- src/sys/fs/udf/udf_allocation.c:1.40 Sun Oct 14 17:37:40 2018 +++ src/sys/fs/udf/udf_allocation.c Thu Apr 23 21:47:08 2020 @@ -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, #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, /* 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_nod /* 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); Index: src/sys/fs/udf/udf_vnops.c diff -u src/sys/fs/udf/udf_vnops.c:1.111 src/sys/fs/udf/udf_vnops.c:1.112 --- src/sys/fs/udf/udf_vnops.c:1.111 Tue Apr 14 11:45:42 2020 +++ src/sys/fs/udf/udf_vnops.c Thu Apr 23 21:47:08 2020 @@ -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; Index: src/sys/fs/v7fs/v7fs_vnops.c diff -u src/sys/fs/v7fs/v7fs_vnops.c:1.28 src/sys/fs/v7fs/v7fs_vnops.c:1.29 --- src/sys/fs/v7fs/v7fs_vnops.c:1.28 Mon Apr 13 19:23:18 2020 +++ src/sys/fs/v7fs/v7fs_vnops.c Thu Apr 23 21:47:08 2020 @@ -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); } Index: src/sys/nfs/nfs_bio.c diff -u src/sys/nfs/nfs_bio.c:1.195 src/sys/nfs/nfs_bio.c:1.196 --- src/sys/nfs/nfs_bio.c:1.195 Sun Mar 22 18:32:42 2020 +++ src/sys/nfs/nfs_bio.c Thu Apr 23 21:47:08 2020 @@ -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 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) { Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.156 src/sys/rump/librump/rumpvfs/rumpfs.c:1.157 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.156 Mon Apr 13 19:23:20 2020 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Thu Apr 23 21:47:08 2020 @@ -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; } Index: src/sys/ufs/chfs/chfs_subr.c diff -u src/sys/ufs/chfs/chfs_subr.c:1.11 src/sys/ufs/chfs/chfs_subr.c:1.12 --- src/sys/ufs/chfs/chfs_subr.c:1.11 Tue Dec 31 13:07:13 2019 +++ src/sys/ufs/chfs/chfs_subr.c Thu Apr 23 21:47:08 2020 @@ -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 s } 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 */ Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.37 src/sys/ufs/chfs/chfs_vnops.c:1.38 --- src/sys/ufs/chfs/chfs_vnops.c:1.37 Sat Apr 4 20:49:31 2020 +++ src/sys/ufs/chfs/chfs_vnops.c Thu Apr 23 21:47:08 2020 @@ -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); Index: src/sys/ufs/ext2fs/ext2fs_inode.c diff -u src/sys/ufs/ext2fs/ext2fs_inode.c:1.88 src/sys/ufs/ext2fs/ext2fs_inode.c:1.89 --- src/sys/ufs/ext2fs/ext2fs_inode.c:1.88 Fri May 26 14:34:20 2017 +++ src/sys/ufs/ext2fs/ext2fs_inode.c Thu Apr 23 21:47:08 2020 @@ -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 /* 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); Index: src/sys/ufs/ext2fs/ext2fs_readwrite.c diff -u src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.76 src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.77 --- src/sys/ufs/ext2fs/ext2fs_readwrite.c:1.76 Sun Feb 23 15:46:42 2020 +++ src/sys/ufs/ext2fs/ext2fs_readwrite.c Thu Apr 23 21:47:08 2020 @@ -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; Index: src/sys/ufs/ffs/ffs_inode.c diff -u src/sys/ufs/ffs/ffs_inode.c:1.127 src/sys/ufs/ffs/ffs_inode.c:1.128 --- src/sys/ufs/ffs/ffs_inode.c:1.127 Sat Apr 18 19:18:34 2020 +++ src/sys/ufs/ffs/ffs_inode.c Thu Apr 23 21:47:09 2020 @@ -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 le 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), Index: src/sys/ufs/lfs/lfs_inode.c diff -u src/sys/ufs/lfs/lfs_inode.c:1.159 src/sys/ufs/lfs/lfs_inode.c:1.160 --- src/sys/ufs/lfs/lfs_inode.c:1.159 Sun Feb 23 15:46:42 2020 +++ src/sys/ufs/lfs/lfs_inode.c Thu Apr 23 21:47:09 2020 @@ -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 le 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), Index: src/sys/ufs/lfs/ulfs_readwrite.c diff -u src/sys/ufs/lfs/ulfs_readwrite.c:1.26 src/sys/ufs/lfs/ulfs_readwrite.c:1.27 --- src/sys/ufs/lfs/ulfs_readwrite.c:1.26 Sun Feb 23 15:46:42 2020 +++ src/sys/ufs/lfs/ulfs_readwrite.c Thu Apr 23 21:47:09 2020 @@ -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 Index: src/sys/ufs/ufs/ufs_readwrite.c diff -u src/sys/ufs/ufs/ufs_readwrite.c:1.125 src/sys/ufs/ufs/ufs_readwrite.c:1.126 --- src/sys/ufs/ufs/ufs_readwrite.c:1.125 Sun Feb 23 15:46:43 2020 +++ src/sys/ufs/ufs/ufs_readwrite.c Thu Apr 23 21:47:09 2020 @@ -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 Index: src/sys/uvm/uvm_bio.c diff -u src/sys/uvm/uvm_bio.c:1.109 src/sys/uvm/uvm_bio.c:1.110 --- src/sys/uvm/uvm_bio.c:1.109 Thu Apr 23 21:12:06 2020 +++ src/sys/uvm/uvm_bio.c Thu Apr 23 21:47:09 2020 @@ -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, str ((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 Index: src/sys/uvm/uvm_extern.h diff -u src/sys/uvm/uvm_extern.h:1.223 src/sys/uvm/uvm_extern.h:1.224 --- src/sys/uvm/uvm_extern.h:1.223 Sat Apr 18 03:27:13 2020 +++ src/sys/uvm/uvm_extern.h Thu Apr 23 21:47:09 2020 @@ -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) /*