Wed Apr 1 20:03:11 2015 UTC ()
Don't use dvp after vput(dvp).

Still don't understand why the fstrans_done must happen after the
vput, and that will cause trouble once we move responsibility for the
vrele and unlock outside the vop as it seems obvious we ought to do
-- it's the caller's reference, not the vop's.


(riastradh)
diff -r1.227 -r1.228 src/sys/ufs/ufs/ufs_vnops.c

cvs diff -r1.227 -r1.228 src/sys/ufs/ufs/ufs_vnops.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_vnops.c 2015/03/27 19:47:14 1.227
+++ src/sys/ufs/ufs/ufs_vnops.c 2015/04/01 20:03:11 1.228
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_vnops.c,v 1.227 2015/03/27 19:47:14 riastradh Exp $ */ 1/* $NetBSD: ufs_vnops.c,v 1.228 2015/04/01 20:03:11 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Wasabi Systems, Inc. 8 * by Wasabi Systems, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -56,27 +56,27 @@ @@ -56,27 +56,27 @@
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95 65 * @(#)ufs_vnops.c 8.28 (Berkeley) 7/31/95
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.227 2015/03/27 19:47:14 riastradh Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.228 2015/04/01 20:03:11 riastradh Exp $");
70 70
71#if defined(_KERNEL_OPT) 71#if defined(_KERNEL_OPT)
72#include "opt_ffs.h" 72#include "opt_ffs.h"
73#include "opt_quota.h" 73#include "opt_quota.h"
74#endif 74#endif
75 75
76#include <sys/param.h> 76#include <sys/param.h>
77#include <sys/systm.h> 77#include <sys/systm.h>
78#include <sys/namei.h> 78#include <sys/namei.h>
79#include <sys/resourcevar.h> 79#include <sys/resourcevar.h>
80#include <sys/kernel.h> 80#include <sys/kernel.h>
81#include <sys/file.h> 81#include <sys/file.h>
82#include <sys/stat.h> 82#include <sys/stat.h>
@@ -713,57 +713,60 @@ ufs_chown(struct vnode *vp, uid_t uid, g @@ -713,57 +713,60 @@ ufs_chown(struct vnode *vp, uid_t uid, g
713 return (0); 713 return (0);
714} 714}
715 715
716int 716int
717ufs_remove(void *v) 717ufs_remove(void *v)
718{ 718{
719 struct vop_remove_args /* { 719 struct vop_remove_args /* {
720 struct vnode *a_dvp; 720 struct vnode *a_dvp;
721 struct vnode *a_vp; 721 struct vnode *a_vp;
722 struct componentname *a_cnp; 722 struct componentname *a_cnp;
723 } */ *ap = v; 723 } */ *ap = v;
724 struct vnode *vp, *dvp; 724 struct vnode *vp, *dvp;
725 struct inode *ip; 725 struct inode *ip;
 726 struct mount *mp;
726 int error; 727 int error;
727 struct ufs_lookup_results *ulr; 728 struct ufs_lookup_results *ulr;
728 729
729 vp = ap->a_vp; 730 vp = ap->a_vp;
730 dvp = ap->a_dvp; 731 dvp = ap->a_dvp;
731 ip = VTOI(vp); 732 ip = VTOI(vp);
 733 mp = dvp->v_mount;
 734 KASSERT(mp == vp->v_mount);
732 735
733 /* XXX should handle this material another way */ 736 /* XXX should handle this material another way */
734 ulr = &VTOI(dvp)->i_crap; 737 ulr = &VTOI(dvp)->i_crap;
735 UFS_CHECK_CRAPCOUNTER(VTOI(dvp)); 738 UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
736 739
737 fstrans_start(dvp->v_mount, FSTRANS_SHARED); 740 fstrans_start(mp, FSTRANS_SHARED);
738 if (vp->v_type == VDIR || (ip->i_flags & (IMMUTABLE | APPEND)) || 741 if (vp->v_type == VDIR || (ip->i_flags & (IMMUTABLE | APPEND)) ||
739 (VTOI(dvp)->i_flags & APPEND)) 742 (VTOI(dvp)->i_flags & APPEND))
740 error = EPERM; 743 error = EPERM;
741 else { 744 else {
742 error = UFS_WAPBL_BEGIN(dvp->v_mount); 745 error = UFS_WAPBL_BEGIN(mp);
743 if (error == 0) { 746 if (error == 0) {
744 error = ufs_dirremove(dvp, ulr, 747 error = ufs_dirremove(dvp, ulr,
745 ip, ap->a_cnp->cn_flags, 0); 748 ip, ap->a_cnp->cn_flags, 0);
746 UFS_WAPBL_END(dvp->v_mount); 749 UFS_WAPBL_END(mp);
747 } 750 }
748 } 751 }
749 VN_KNOTE(vp, NOTE_DELETE); 752 VN_KNOTE(vp, NOTE_DELETE);
750 VN_KNOTE(dvp, NOTE_WRITE); 753 VN_KNOTE(dvp, NOTE_WRITE);
751 if (dvp == vp) 754 if (dvp == vp)
752 vrele(vp); 755 vrele(vp);
753 else 756 else
754 vput(vp); 757 vput(vp);
755 vput(dvp); 758 vput(dvp);
756 fstrans_done(dvp->v_mount); 759 fstrans_done(mp);
757 return (error); 760 return (error);
758} 761}
759 762
760/* 763/*
761 * ufs_link: create hard link. 764 * ufs_link: create hard link.
762 */ 765 */
763int 766int
764ufs_link(void *v) 767ufs_link(void *v)
765{ 768{
766 struct vop_link_args /* { 769 struct vop_link_args /* {
767 struct vnode *a_dvp; 770 struct vnode *a_dvp;
768 struct vnode *a_vp; 771 struct vnode *a_vp;
769 struct componentname *a_cnp; 772 struct componentname *a_cnp;