From owner-svn-src-all@FreeBSD.ORG Wed Jan 21 14:51:38 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF9D4106564A; Wed, 21 Jan 2009 14:51:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 92EB48FC08; Wed, 21 Jan 2009 14:51:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0LEpcOD080590; Wed, 21 Jan 2009 14:51:38 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0LEpcN3080587; Wed, 21 Jan 2009 14:51:38 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200901211451.n0LEpcN3080587@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 21 Jan 2009 14:51:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187528 - in head/sys: kern sys ufs/ufs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2009 14:51:39 -0000 Author: kib Date: Wed Jan 21 14:51:38 2009 New Revision: 187528 URL: http://svn.freebsd.org/changeset/base/187528 Log: Move the code from ufs_lookup.c used to do dotdot lookup, into the helper function. It is supposed to be useful for any filesystem that has to unlock dvp to walk to the ".." entry in lookup routine. Requested by: jhb Tested by: pho MFC after: 1 month Modified: head/sys/kern/vfs_vnops.c head/sys/sys/vnode.h head/sys/ufs/ufs/ufs_lookup.c Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Wed Jan 21 14:43:35 2009 (r187527) +++ head/sys/kern/vfs_vnops.c Wed Jan 21 14:51:38 2009 (r187528) @@ -1286,3 +1286,35 @@ vn_extattr_rm(struct vnode *vp, int iofl return (error); } + +int +vn_vget_ino(struct vnode *vp, ino_t ino, int lkflags, struct vnode **rvp) +{ + struct mount *mp; + int ltype, error; + + mp = vp->v_mount; + ltype = VOP_ISLOCKED(vp); + KASSERT(ltype == LK_EXCLUSIVE || ltype == LK_SHARED, + ("vn_vget_ino: vp not locked")); + for (;;) { + error = vfs_busy(mp, MBF_NOWAIT); + if (error == 0) + break; + VOP_UNLOCK(vp, 0); + pause("vn_vget", 1); + vn_lock(vp, ltype | LK_RETRY); + if (vp->v_iflag & VI_DOOMED) + return (ENOENT); + } + VOP_UNLOCK(vp, 0); + error = VFS_VGET(mp, ino, lkflags, rvp); + vfs_unbusy(mp); + vn_lock(vp, ltype | LK_RETRY); + if (vp->v_iflag & VI_DOOMED) { + if (error == 0) + vput(*rvp); + error = ENOENT; + } + return (error); +} Modified: head/sys/sys/vnode.h ============================================================================== --- head/sys/sys/vnode.h Wed Jan 21 14:43:35 2009 (r187527) +++ head/sys/sys/vnode.h Wed Jan 21 14:51:38 2009 (r187528) @@ -636,6 +636,9 @@ int vn_extattr_set(struct vnode *vp, int const char *attrname, int buflen, char *buf, struct thread *td); int vn_extattr_rm(struct vnode *vp, int ioflg, int attrnamespace, const char *attrname, struct thread *td); +int vn_vget_ino(struct vnode *vp, ino_t ino, int lkflags, + struct vnode **rvp); + int vfs_cache_lookup(struct vop_lookup_args *ap); void vfs_timestamp(struct timespec *); void vfs_write_resume(struct mount *mp); Modified: head/sys/ufs/ufs/ufs_lookup.c ============================================================================== --- head/sys/ufs/ufs/ufs_lookup.c Wed Jan 21 14:43:35 2009 (r187527) +++ head/sys/ufs/ufs/ufs_lookup.c Wed Jan 21 14:51:38 2009 (r187528) @@ -157,7 +157,6 @@ ufs_lookup(ap) int nameiop = cnp->cn_nameiop; ino_t ino; int ltype; - struct mount *mp; bp = NULL; slotoffset = -1; @@ -578,27 +577,7 @@ found: */ pdp = vdp; if (flags & ISDOTDOT) { - ltype = VOP_ISLOCKED(pdp); - mp = pdp->v_mount; - for (;;) { - error = vfs_busy(mp, MBF_NOWAIT); - if (error == 0) - break; - VOP_UNLOCK(pdp, 0); - pause("ufs_dd", 1); - vn_lock(pdp, ltype | LK_RETRY); - if (pdp->v_iflag & VI_DOOMED) - return (ENOENT); - } - VOP_UNLOCK(pdp, 0); /* race to get the inode */ - error = VFS_VGET(mp, ino, cnp->cn_lkflags, &tdp); - vfs_unbusy(mp); - vn_lock(pdp, ltype | LK_RETRY); - if (pdp->v_iflag & VI_DOOMED) { - if (error == 0) - vput(tdp); - error = ENOENT; - } + error = vn_vget_ino(pdp, ino, cnp->cn_lkflags, &tdp); if (error) return (error); *vpp = tdp;