Sun May 25 13:46:58 2014 UTC ()
ext2fs_gro_genealogy: use vcache_get() to lookup DOTDOT.


(hannken)
diff -r1.6 -r1.7 src/sys/ufs/ext2fs/ext2fs_rename.c

cvs diff -r1.6 -r1.7 src/sys/ufs/ext2fs/ext2fs_rename.c (expand / switch to unified diff)

--- src/sys/ufs/ext2fs/ext2fs_rename.c 2014/01/28 13:02:56 1.6
+++ src/sys/ufs/ext2fs/ext2fs_rename.c 2014/05/25 13:46:58 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ext2fs_rename.c,v 1.6 2014/01/28 13:02:56 martin Exp $ */ 1/* $NetBSD: ext2fs_rename.c,v 1.7 2014/05/25 13:46:58 hannken Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc. 4 * Copyright (c) 2012 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 Taylor R Campbell. 8 * by Taylor R Campbell.
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.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * Ext2fs Rename 33 * Ext2fs Rename
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.6 2014/01/28 13:02:56 martin Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: ext2fs_rename.c,v 1.7 2014/05/25 13:46:58 hannken Exp $");
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/buf.h> 40#include <sys/buf.h>
41#include <sys/errno.h> 41#include <sys/errno.h>
42#include <sys/kauth.h> 42#include <sys/kauth.h>
43#include <sys/mount.h> 43#include <sys/mount.h>
44#include <sys/namei.h> 44#include <sys/namei.h>
45#include <sys/vnode.h> 45#include <sys/vnode.h>
46#include <sys/vnode_if.h> 46#include <sys/vnode_if.h>
47 47
48#include <miscfs/genfs/genfs.h> 48#include <miscfs/genfs/genfs.h>
49 49
50#include <ufs/ext2fs/ext2fs.h> 50#include <ufs/ext2fs/ext2fs.h>
@@ -836,40 +836,35 @@ ext2fs_gro_genealogy(struct mount *mp, k @@ -836,40 +836,35 @@ ext2fs_gro_genealogy(struct mount *mp, k
836 vput(vp); 836 vput(vp);
837 return error; 837 return error;
838 } 838 }
839 839
840 /* Did we find that fdvp is an ancestor of tdvp? */ 840 /* Did we find that fdvp is an ancestor of tdvp? */
841 if (VTOI(fdvp)->i_number == dotdot_ino) { 841 if (VTOI(fdvp)->i_number == dotdot_ino) {
842 /* Unlock vp, but keep it referenced. */ 842 /* Unlock vp, but keep it referenced. */
843 VOP_UNLOCK(vp); 843 VOP_UNLOCK(vp);
844 *intermediate_node_ret = vp; 844 *intermediate_node_ret = vp;
845 return 0; 845 return 0;
846 } 846 }
847 847
848 /* Neither -- keep ascending the family tree. */ 848 /* Neither -- keep ascending the family tree. */
849 849 error = vcache_get(mp, &dotdot_ino, sizeof(dotdot_ino), &dvp);
850 /* 850 vput(vp);
851 * Unlock vp so that we can lock the parent, but keep 851 if (error)
852 * vp referenced until after we have found the parent, 852 return error;
853 * so that dotdot_ino will not be recycled. 853 error = vn_lock(dvp, LK_EXCLUSIVE);
854 * 854 if (error) {
855 * XXX This guarantees that vp's inode number will not 855 vrele(dvp);
856 * be recycled, but why can't dotdot_ino be recycled? 
857 */ 
858 VOP_UNLOCK(vp); 
859 error = VFS_VGET(mp, dotdot_ino, &dvp); 
860 vrele(vp); 
861 if (error) 
862 return error; 856 return error;
 857 }
863 858
864 KASSERT(dvp != NULL); 859 KASSERT(dvp != NULL);
865 KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); 860 KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
866 vp = dvp; 861 vp = dvp;
867 862
868 if (vp->v_type != VDIR) { 863 if (vp->v_type != VDIR) {
869 /* 864 /*
870 * XXX Panic? Print a warning? Can this 865 * XXX Panic? Print a warning? Can this
871 * happen if we lose the race I suspect to 866 * happen if we lose the race I suspect to
872 * exist above, and the `..' inode number has 867 * exist above, and the `..' inode number has
873 * been recycled? 868 * been recycled?
874 */ 869 */
875 vput(vp); 870 vput(vp);