From owner-p4-projects@FreeBSD.ORG Mon May 24 14:06:58 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 965E01065673; Mon, 24 May 2010 14:06:58 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42B871065674 for ; Mon, 24 May 2010 14:06:58 +0000 (UTC) (envelope-from gpf@FreeBSD.org) Received: from repoman.freebsd.org (unknown [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2FF3D8FC28 for ; Mon, 24 May 2010 14:06:58 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o4OE6vP6051550 for ; Mon, 24 May 2010 14:06:57 GMT (envelope-from gpf@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o4OE6v5B051548 for perforce@freebsd.org; Mon, 24 May 2010 14:06:57 GMT (envelope-from gpf@FreeBSD.org) Date: Mon, 24 May 2010 14:06:57 GMT Message-Id: <201005241406.o4OE6v5B051548@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gpf@FreeBSD.org using -f From: Efstratios Karatzas To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 178714 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 May 2010 14:06:58 -0000 http://p4web.freebsd.org/@@178714?ac=10 Change 178714 by gpf@gpf_desktop on 2010/05/24 14:06:34 * the second parameter from VOP_VPTOCNP() should be vdrop()ed after the call - done * dont really need exclusive locks; now I use shared locks * dir_ilookup() still only works for UFS, added a check so that the function will return if the fs is not ufs Affected files ... .. //depot/projects/soc2010/gpf_audit/vn_fullpath_nocache.c#3 edit Differences ... ==== //depot/projects/soc2010/gpf_audit/vn_fullpath_nocache.c#3 (text+ko) ==== @@ -75,11 +75,18 @@ KASSERT("dvp != NULL", "dir_ilookup: dvp == NULL"); KASSERT("name != NULL", "dir_ilookup: name == NULL"); + /* XXXgpf: temporary, must be a better way to check this than f_type or f_fstypename */ + if (strcmp(vp->v_mount->mnt_stat.f_fstypename, "ufs")) { + uprintf("only ufs supported\n"); + return 1; + } + foundit = 0; dirbuflen = ((struct inode *)dvp->v_data)->i_size; dirbuf = malloc(dirbuflen, M_TEMP, M_WAITOK); td = curthread; + /* prep the call to VOP_READDIR() */ iov.iov_base = dirbuf; iov.iov_len = dirbuflen; io.uio_iov = &iov; @@ -90,7 +97,7 @@ io.uio_rw = UIO_READ; io.uio_td = td; eofflag = 0; - + error = VOP_READDIR(dvp, &io, td->td_ucred, &eofflag, NULL, NULL); if (error) { uprintf("VOP_READDIR failure %d\n", error); @@ -146,9 +153,9 @@ * Retrieve the full filesystem path that corresponds to a vnode without use of the * name cache. * - A directory hint (UFS file_id of the directory that contains the vnode) may be - * supplied to facilitate the search is our target is not a directory itself. + * supplied to facilitate the search if our target is not a directory itself. * - flags should be set to PARENT_HINT, if the directory hint is supplied - * and to EXHAUSTIVE_SEARCH, if we are willing to go intro great trouble to get this path + * and to EXHAUSTIVE_SEARCH, if we are willing to go intro great trouble to get this path. * * Author's note: This only works for UFS filesystems (for now). * Oh, also EXHAUSTIVE_SEARCH will kernel panic :-D @@ -187,12 +194,11 @@ * - If our target is a directory, move on to the part where we traverse the '..' entries. * - If not, either use the directory_hint if it's available or do an exhaustive search on the fs (xD) so * that we can connect the vp with 'a' parent directory. - */ + */ if (vp->v_type != VDIR) { /* grab the parent directory using the directory_hint */ if ((flags & PARENT_HINT) && vp->v_type != VDIR) { - /* XXXgpf: should change the locktypes from excl to smth else */ - error = VFS_VGET(vp->v_mount, directory_hint, LK_EXCLUSIVE, &dvp); + error = VFS_VGET(vp->v_mount, directory_hint, LK_SHARED, &dvp); /* in case of failure, proceed to exhaustive search */ if (error) { uprintf("VFS_VGET failure %d\n", error); @@ -215,7 +221,7 @@ if ((flags & EXHAUSTIVE_SEARCH) && dvp == NULL) { /* * XXXgpf: this actually does not work because when the thread will try to sleep, - * e.g. in VOP_READDIR the kernel will panic because we have ilocked mp >.< + * e.g. in VOP_READDIR, the kernel will panic because we have ilocked mp >.< */ MNT_ILOCK(mp); if (!TAILQ_EMPTY(&mp->mnt_nvnodelist)) { @@ -223,7 +229,7 @@ TAILQ_FOREACH(tvp, &mp->mnt_nvnodelist, v_nmntvnodes) { if (tvp->v_type == VDIR) { - vn_lock(tvp, LK_EXCLUSIVE); + vn_lock(tvp, LK_SHARED); /* grab the name that is being used to reference vp */ error = dir_ilookup(vp, tvp, fname, &fnamelen); @@ -267,7 +273,7 @@ else { dvp = vp; vref(dvp); - vn_lock(dvp, LK_EXCLUSIVE); + vn_lock(dvp, LK_SHARED); } /* @@ -318,9 +324,10 @@ buf[--buflen] = '/'; if (dvp != NULL) vput(dvp); - + + vdrop(upper_dvp); dvp = upper_dvp; - vn_lock(dvp, LK_EXCLUSIVE); + vn_lock(dvp, LK_SHARED); vref(dvp); } /* while */