Module Name: src Committed By: riastradh Date: Fri Apr 5 13:05:41 UTC 2024
Modified Files: src/sys/miscfs/genfs: genfs_io.c src/sys/uvm: uvm_vnode.c Log Message: uvm: Expand v_size <= v_writesize assertions to help diagnostics. PR kern/58117 To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.120 -r1.121 src/sys/uvm/uvm_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.103 src/sys/miscfs/genfs/genfs_io.c:1.104 --- src/sys/miscfs/genfs/genfs_io.c:1.103 Sun Apr 9 12:26:36 2023 +++ src/sys/miscfs/genfs/genfs_io.c Fri Apr 5 13:05:40 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.103 2023/04/09 12:26:36 riastradh Exp $ */ +/* $NetBSD: genfs_io.c,v 1.104 2024/04/05 13:05:40 riastradh Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.103 2023/04/09 12:26:36 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.104 2024/04/05 13:05:40 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1449,7 +1449,12 @@ genfs_do_io(struct vnode *vp, off_t off, UVMHIST_LOG(ubchist, "vp %#jx kva %#jx len 0x%jx flags 0x%jx", (uintptr_t)vp, (uintptr_t)kva, len, flags); - KASSERT(vp->v_size <= vp->v_writesize); + KASSERT(vp->v_size != VSIZENOTSET); + KASSERT(vp->v_writesize != VSIZENOTSET); + KASSERTMSG(vp->v_size <= vp->v_writesize, "vp=%p" + " v_size=0x%llx v_writesize=0x%llx", vp, + (unsigned long long)vp->v_size, + (unsigned long long)vp->v_writesize); GOP_SIZE(vp, vp->v_writesize, &eof, 0); if (vp->v_type != VBLK) { fs_bshift = vp->v_mount->mnt_fs_bshift; Index: src/sys/uvm/uvm_vnode.c diff -u src/sys/uvm/uvm_vnode.c:1.120 src/sys/uvm/uvm_vnode.c:1.121 --- src/sys/uvm/uvm_vnode.c:1.120 Sun Apr 9 12:37:12 2023 +++ src/sys/uvm/uvm_vnode.c Fri Apr 5 13:05:41 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_vnode.c,v 1.120 2023/04/09 12:37:12 riastradh Exp $ */ +/* $NetBSD: uvm_vnode.c,v 1.121 2024/04/05 13:05:41 riastradh Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -45,7 +45,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.120 2023/04/09 12:37:12 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.121 2024/04/05 13:05:41 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_uvmhist.h" @@ -451,9 +451,17 @@ uvm_vnp_setsize(struct vnode *vp, voff_t KASSERT(newsize != VSIZENOTSET); KASSERT(newsize >= 0); - KASSERT(vp->v_size <= vp->v_writesize); - KASSERT(vp->v_size == vp->v_writesize || - newsize == vp->v_writesize || newsize <= vp->v_size); + KASSERTMSG(vp->v_size <= vp->v_writesize, "vp=%p" + " v_size=0x%llx v_writesize=0x%llx", vp, + (unsigned long long)vp->v_size, + (unsigned long long)vp->v_writesize); + KASSERTMSG((vp->v_size == vp->v_writesize || + newsize == vp->v_writesize || newsize <= vp->v_size), + "vp=%p v_size=0x%llx v_writesize=0x%llx newsize=0x%llx", + vp, + (unsigned long long)vp->v_size, + (unsigned long long)vp->v_writesize, + (unsigned long long)newsize); oldsize = vp->v_writesize; @@ -481,8 +489,16 @@ uvm_vnp_setwritesize(struct vnode *vp, v KASSERT(newsize >= 0); KASSERT(vp->v_size != VSIZENOTSET); KASSERT(vp->v_writesize != VSIZENOTSET); - KASSERT(vp->v_size <= vp->v_writesize); - KASSERT(vp->v_size <= newsize); + KASSERTMSG(vp->v_size <= vp->v_writesize, "vp=%p" + " v_size=0x%llx v_writesize=0x%llx newsize=0x%llx", vp, + (unsigned long long)vp->v_size, + (unsigned long long)vp->v_writesize, + (unsigned long long)newsize); + KASSERTMSG(vp->v_size <= newsize, "vp=%p" + " v_size=0x%llx v_writesize=0x%llx newsize=0x%llx", vp, + (unsigned long long)vp->v_size, + (unsigned long long)vp->v_writesize, + (unsigned long long)newsize); mutex_enter(vp->v_interlock); vp->v_writesize = newsize; mutex_exit(vp->v_interlock);