From 129d5b5396d7607c3886066cdb47039db5bf0d41 Mon Sep 17 00:00:00 2001 From: beck Date: Sat, 13 Jul 2024 14:37:55 +0000 Subject: [PATCH] Revert the vdoom change, while it prevents the crashes on joel's go builder and avoids the ufs_inactive problems, bluhm hits panics on shutdown and filesystem unmount on the regress testers. We'll have to try the other approach of detecting the corrupted vnode perhaps. --- sys/kern/vfs_subr.c | 30 +++--------------------------- sys/sys/vnode.h | 4 +--- sys/ufs/ext2fs/ext2fs_inode.c | 16 ++++------------ sys/ufs/ufs/ufs_inode.c | 14 +++----------- 4 files changed, 11 insertions(+), 53 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 0400fca4166..201fcac8c7d 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.321 2024/07/12 08:15:19 beck Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.322 2024/07/13 14:37:55 beck Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -626,26 +626,6 @@ loop: return (vp); } -/* - * Indicate that this vnode will be recycled by the caller and prevent any other - * access to the vnode via vget() until it is cleaned. Callers must ensure - * vclean() is called on this vnode. vclean() will permit the vnode to be passed - * in with the VXLOCK flag set if VDOOMED is set. - */ -void -vdoom(struct vnode *vp) -{ - mtx_enter(&vnode_mtx); - KASSERT(vp->v_usecount == 0); - if (vp->v_lflag & VXLOCK) - panic("vdoom: vnode already locked!"); - vp->v_lflag |= VXLOCK; - if (vp->v_lflag & VDOOMED) - panic("vdoom: vnode already doomed!"); - vp->v_lflag |= VDOOMED; - mtx_leave(&vnode_mtx); -} - /* * Grab a particular vnode from the free list, increment its * reference count and lock it. If the vnode lock bit is set, @@ -1049,10 +1029,8 @@ vclean(struct vnode *vp, int flags, struct proc *p) */ mtx_enter(&vnode_mtx); if (vp->v_lflag & VXLOCK) - if (!(vp->v_lflag & VDOOMED)) - panic("vclean: deadlock"); + panic("vclean: deadlock"); vp->v_lflag |= VXLOCK; - vp->v_lflag &= ~VDOOMED; if (vp->v_lockcount > 0) { /* @@ -1179,7 +1157,7 @@ vgonel(struct vnode *vp, struct proc *p) * wait until it is done and return. */ mtx_enter(&vnode_mtx); - if (!(vp->v_lflag & VDOOMED) && vp->v_flag & VXLOCK) { + if (vp->v_lflag & VXLOCK) { vp->v_lflag |= VXWANT; msleep_nsec(vp, &vnode_mtx, PINOD, "vgone", INFSLP); mtx_leave(&vnode_mtx); @@ -1350,8 +1328,6 @@ vprint(char *label, struct vnode *vp) strlcat(buf, "|VBIOONSYNCLIST", sizeof buf); if (vp->v_flag & VALIASED) strlcat(buf, "|VALIASED", sizeof buf); - if (vp->v_flag & VDOOMED) - strlcat(buf, "|VDOOMED", sizeof buf); if (buf[0] != '\0') printf(" flags (%s)", &buf[1]); if (vp->v_data == NULL) { diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 4ea623af9cf..b8ca4563f3c 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.172 2024/07/12 08:15:19 beck Exp $ */ +/* $OpenBSD: vnode.h,v 1.173 2024/07/13 14:37:55 beck Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -146,7 +146,6 @@ struct vnode { #define VCLONED 0x0400 /* vnode was cloned */ #define VALIASED 0x0800 /* vnode has an alias */ #define VLARVAL 0x1000 /* vnode data not yet set up by higher level */ -#define VDOOMED 0x2000 /* hold vnode with VXLOCK to be cleaned */ #define VLOCKSWORK 0x4000 /* FS supports locking discipline */ #define VCLONE 0x8000 /* vnode is a clone */ @@ -587,7 +586,6 @@ int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, struct ucred *); int vnoperm(struct vnode *); void vattr_null(struct vattr *); void vdevgone(int, int, int, enum vtype); -void vdoom(struct vnode *); int vcount(struct vnode *); int vfinddev(dev_t, enum vtype, struct vnode **); void vflushbuf(struct vnode *, int); diff --git a/sys/ufs/ext2fs/ext2fs_inode.c b/sys/ufs/ext2fs/ext2fs_inode.c index 3bbe98b6688..432dd5f12f0 100644 --- a/sys/ufs/ext2fs/ext2fs_inode.c +++ b/sys/ufs/ext2fs/ext2fs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_inode.c,v 1.67 2024/07/12 08:15:19 beck Exp $ */ +/* $OpenBSD: ext2fs_inode.c,v 1.68 2024/07/13 14:37:56 beck Exp $ */ /* $NetBSD: ext2fs_inode.c,v 1.24 2001/06/19 12:59:18 wiz Exp $ */ /* @@ -105,28 +105,20 @@ ext2fs_inactive(void *v) struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); struct timespec ts; - int recycle_vnode = 0; int error = 0; #ifdef DIAGNOSTIC extern int prtactive; - if (prtactive && vp->v_usecount != 0) + if (prtactive && vp->v_usecount != 0) vprint("ext2fs_inactive: pushing active", vp); #endif /* Get rid of inodes related to stale file handles. */ - if (ip->i_e2din == NULL || ip->i_e2fs_mode == 0 || ip->i_e2fs_dtime) { - recycle_vnode = 1; - vdoom(vp); + if (ip->i_e2din == NULL || ip->i_e2fs_mode == 0 || ip->i_e2fs_dtime) goto out; - } error = 0; if (ip->i_e2fs_nlink == 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { - /* lock this vnode and promise to vclean it */ - recycle_vnode = 1; - vdoom(vp); - if (ext2fs_size(ip) != 0) { error = ext2fs_truncate(ip, (off_t)0, 0, NOCRED); } @@ -144,7 +136,7 @@ out: * If we are done with the inode, reclaim it * so that it can be reused immediately. */ - if (recycle_vnode) + if (ip->i_e2din == NULL || ip->i_e2fs_dtime != 0) vrecycle(vp, ap->a_p); return (error); } diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index 67182ceb655..5e66f0bf26c 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_inode.c,v 1.46 2024/07/12 08:15:19 beck Exp $ */ +/* $OpenBSD: ufs_inode.c,v 1.47 2024/07/13 14:37:56 beck Exp $ */ /* $NetBSD: ufs_inode.c,v 1.7 1996/05/11 18:27:52 mycroft Exp $ */ /* @@ -63,7 +63,6 @@ ufs_inactive(void *v) struct vnode *vp = ap->a_vp; struct inode *ip = VTOI(vp); mode_t mode; - int recycle_vnode = 0; int error = 0; #ifdef DIAGNOSTIC extern int prtactive; @@ -75,17 +74,10 @@ ufs_inactive(void *v) /* * Ignore inodes related to stale file handles. */ - if (ip->i_din1 == NULL || DIP(ip, mode) == 0) { - recycle_vnode = 1; - vdoom(vp); + if (ip->i_din1 == NULL || DIP(ip, mode) == 0) goto out; - } if (DIP(ip, nlink) <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { - /* lock this vnode and promise to vclean it */ - recycle_vnode = 1; - vdoom(vp); - if (getinoquota(ip) == 0) (void)ufs_quota_free_inode(ip, NOCRED); @@ -109,7 +101,7 @@ out: * If we are done with the inode, reclaim it * so that it can be reused immediately. */ - if (recycle_vnode) + if (ip->i_din1 == NULL || DIP(ip, mode) == 0) vrecycle(vp, ap->a_p); return (error); -- 2.20.1