From: semarie Date: Mon, 13 May 2024 11:17:40 +0000 (+0000) Subject: vfs: VOP_REMOVE: move vnode unlocking and ref dropping to FS-indep part X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=aa47c49a2e9a5112e6a4bc79c916fa4f62fbda97;p=openbsd vfs: VOP_REMOVE: move vnode unlocking and ref dropping to FS-indep part while here, ensure all vop_remove field are set, and always call the function. the change is very conservative: it only adds vnode ref drop/unlock where it was absent because it should be unreachable (and if it wasn't, it should fix things). ok miod@ --- diff --git a/sys/isofs/udf/udf_vnops.c b/sys/isofs/udf/udf_vnops.c index 244c781a0dd..c7ffaf58ef7 100644 --- a/sys/isofs/udf/udf_vnops.c +++ b/sys/isofs/udf/udf_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_vnops.c,v 1.71 2024/05/12 16:51:05 semarie Exp $ */ +/* $OpenBSD: udf_vnops.c,v 1.72 2024/05/13 11:17:40 semarie Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long @@ -84,7 +84,7 @@ const struct vops udf_vops = { .vop_fsync = NULL, .vop_link = NULL, .vop_mknod = NULL, - .vop_remove = NULL, + .vop_remove = eopnotsupp, .vop_rename = NULL, .vop_revoke = NULL, .vop_mkdir = NULL, diff --git a/sys/kern/vfs_sync.c b/sys/kern/vfs_sync.c index 4412725a90c..a97a5b49fd4 100644 --- a/sys/kern/vfs_sync.c +++ b/sys/kern/vfs_sync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_sync.c,v 1.71 2024/05/12 16:51:05 semarie Exp $ */ +/* $OpenBSD: vfs_sync.c,v 1.72 2024/05/13 11:17:40 semarie Exp $ */ /* * Portions of this code are: @@ -238,7 +238,7 @@ const struct vops sync_vops = { .vop_read = NULL, .vop_readdir = NULL, .vop_readlink = NULL, - .vop_remove = NULL, + .vop_remove = eopnotsupp, .vop_rename = NULL, .vop_revoke = NULL, .vop_mkdir = NULL, diff --git a/sys/kern/vfs_vops.c b/sys/kern/vfs_vops.c index 3d08b2ec5ca..c4e9cb1f3d1 100644 --- a/sys/kern/vfs_vops.c +++ b/sys/kern/vfs_vops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vops.c,v 1.35 2022/06/26 05:20:42 visa Exp $ */ +/* $OpenBSD: vfs_vops.c,v 1.36 2024/05/13 11:17:40 semarie Exp $ */ /* * Copyright (c) 2010 Thordur I. Bjornsson * @@ -319,6 +319,7 @@ VOP_FSYNC(struct vnode *vp, struct ucred *cred, int waitfor, int VOP_REMOVE(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) { + int error; struct vop_remove_args a; a.a_dvp = dvp; a.a_vp = vp; @@ -327,10 +328,15 @@ VOP_REMOVE(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) ASSERT_VP_ISLOCKED(dvp); ASSERT_VP_ISLOCKED(vp); - if (dvp->v_op->vop_remove == NULL) - return (EOPNOTSUPP); + error = dvp->v_op->vop_remove(&a); + + if (dvp == vp) + vrele(vp); + else + vput(vp); + vput(dvp); - return ((dvp->v_op->vop_remove)(&a)); + return error; } int diff --git a/sys/miscfs/fuse/fuse_vnops.c b/sys/miscfs/fuse/fuse_vnops.c index 173d70562f6..8c38ab55c41 100644 --- a/sys/miscfs/fuse/fuse_vnops.c +++ b/sys/miscfs/fuse/fuse_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_vnops.c,v 1.68 2024/03/25 17:57:07 guenther Exp $ */ +/* $OpenBSD: fuse_vnops.c,v 1.69 2024/05/13 11:17:40 semarie Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon * @@ -1512,11 +1512,6 @@ fusefs_remove(void *v) fb_delete(fbuf); out: pool_put(&namei_pool, cnp->cn_pnbuf); - if (dvp == vp) - vrele(vp); - else - vput(vp); - vput(dvp); return (error); } diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index 12d22a95ce0..5e912766d5e 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vnops.c,v 1.140 2023/09/08 20:00:28 mvs Exp $ */ +/* $OpenBSD: msdosfs_vnops.c,v 1.141 2024/05/13 11:17:40 semarie Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */ /*- @@ -810,12 +810,6 @@ msdosfs_remove(void *v) printf("msdosfs_remove(), dep %p, v_usecount %d\n", dep, ap->a_vp->v_usecount); #endif - if (ddep == dep) - vrele(ap->a_vp); - else - vput(ap->a_vp); /* causes msdosfs_inactive() to be called - * via vrele() */ - vput(ap->a_dvp); return (error); } diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 7bb05c1f633..698f8b303b2 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_vnops.c,v 1.198 2024/05/01 13:15:59 jsg Exp $ */ +/* $OpenBSD: nfs_vnops.c,v 1.199 2024/05/13 11:17:40 semarie Exp $ */ /* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */ /* @@ -1725,11 +1725,6 @@ nfs_remove(void *v) NFS_INVALIDATE_ATTRCACHE(np); VN_KNOTE(vp, NOTE_DELETE); VN_KNOTE(dvp, NOTE_WRITE); - if (vp == dvp) - vrele(vp); - else - vput(vp); - vput(dvp); return (error); } diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c index af3a9898af7..ad9da143aa6 100644 --- a/sys/ntfs/ntfs_vnops.c +++ b/sys/ntfs/ntfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_vnops.c,v 1.48 2024/05/12 16:51:05 semarie Exp $ */ +/* $OpenBSD: ntfs_vnops.c,v 1.49 2024/05/13 11:17:40 semarie Exp $ */ /* $NetBSD: ntfs_vnops.c,v 1.6 2003/04/10 21:57:26 jdolecek Exp $ */ /* @@ -689,7 +689,7 @@ const struct vops ntfs_vops = { .vop_link = NULL, .vop_mknod = NULL, .vop_readlink = NULL, - .vop_remove = NULL, + .vop_remove = eopnotsupp, .vop_rename = NULL, .vop_revoke = NULL, .vop_mkdir = NULL, diff --git a/sys/tmpfs/tmpfs_vnops.c b/sys/tmpfs/tmpfs_vnops.c index b1c68fdebba..bed42030ed8 100644 --- a/sys/tmpfs/tmpfs_vnops.c +++ b/sys/tmpfs/tmpfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmpfs_vnops.c,v 1.54 2024/03/25 17:57:07 guenther Exp $ */ +/* $OpenBSD: tmpfs_vnops.c,v 1.55 2024/05/13 11:17:41 semarie Exp $ */ /* $NetBSD: tmpfs_vnops.c,v 1.100 2012/11/05 17:27:39 dholland Exp $ */ /* @@ -692,8 +692,6 @@ tmpfs_remove(void *v) tmpfs_dirent_t *de; int error; - KASSERT(VOP_ISLOCKED(dvp)); - KASSERT(VOP_ISLOCKED(vp)); KASSERT(cnp->cn_flags & HASBUF); if (vp->v_type == VDIR) { @@ -742,13 +740,6 @@ tmpfs_remove(void *v) error = 0; out: pool_put(&namei_pool, cnp->cn_pnbuf); - /* Drop the references and unlock the vnodes. */ - vput(vp); - if (dvp == vp) { - vrele(dvp); - } else { - vput(dvp); - } return error; } diff --git a/sys/ufs/ext2fs/ext2fs_vnops.c b/sys/ufs/ext2fs/ext2fs_vnops.c index 0097f2380c5..c3f049e9993 100644 --- a/sys/ufs/ext2fs/ext2fs_vnops.c +++ b/sys/ufs/ext2fs/ext2fs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vnops.c,v 1.93 2024/04/13 23:44:11 jsg Exp $ */ +/* $OpenBSD: ext2fs_vnops.c,v 1.94 2024/05/13 11:17:41 semarie Exp $ */ /* $NetBSD: ext2fs_vnops.c,v 1.1 1997/06/11 09:34:09 bouyer Exp $ */ /* @@ -410,11 +410,6 @@ ext2fs_remove(void *v) ip->i_flag |= IN_CHANGE; } out: - if (dvp == vp) - vrele(vp); - else - vput(vp); - vput(dvp); return (error); } diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index d3292849907..098814a995a 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vnops.c,v 1.161 2024/03/25 17:57:07 guenther Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.162 2024/05/13 11:17:41 semarie Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -595,11 +595,6 @@ ufs_remove(void *v) VN_KNOTE(vp, NOTE_DELETE); VN_KNOTE(dvp, NOTE_WRITE); out: - if (dvp == vp) - vrele(vp); - else - vput(vp); - vput(dvp); return (error); }