From owner-svn-src-stable-7@FreeBSD.ORG Sun Feb 22 10:25:07 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA920106564A; Sun, 22 Feb 2009 10:25:07 +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 C68AF8FC23; Sun, 22 Feb 2009 10:25:07 +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 n1MAP7bN093861; Sun, 22 Feb 2009 10:25:07 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1MAP7rl093858; Sun, 22 Feb 2009 10:25:07 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200902221025.n1MAP7rl093858@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 22 Feb 2009 10:25:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188911 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb fs/tmpfs X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Feb 2009 10:25:09 -0000 Author: kib Date: Sun Feb 22 10:25:07 2009 New Revision: 188911 URL: http://svn.freebsd.org/changeset/base/188911 Log: MFC r188318: Lookup up the directory entry for the tmpfs node that are deleted by both node pointer and name component. This does the right thing for hardlinks to the same node in the same directory. PR: kern/131356 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/fs/tmpfs/tmpfs.h stable/7/sys/fs/tmpfs/tmpfs_subr.c stable/7/sys/fs/tmpfs/tmpfs_vnops.c Modified: stable/7/sys/fs/tmpfs/tmpfs.h ============================================================================== --- stable/7/sys/fs/tmpfs/tmpfs.h Sun Feb 22 10:17:10 2009 (r188910) +++ stable/7/sys/fs/tmpfs/tmpfs.h Sun Feb 22 10:25:07 2009 (r188911) @@ -408,9 +408,8 @@ int tmpfs_alloc_file(struct vnode *, str void tmpfs_dir_attach(struct vnode *, struct tmpfs_dirent *); void tmpfs_dir_detach(struct vnode *, struct tmpfs_dirent *); struct tmpfs_dirent * tmpfs_dir_lookup(struct tmpfs_node *node, + struct tmpfs_node *f, struct componentname *cnp); -struct tmpfs_dirent *tmpfs_dir_search(struct tmpfs_node *node, - struct tmpfs_node *f); int tmpfs_dir_getdotdent(struct tmpfs_node *, struct uio *); int tmpfs_dir_getdotdotdent(struct tmpfs_node *, struct uio *); struct tmpfs_dirent * tmpfs_dir_lookupbycookie(struct tmpfs_node *, off_t); Modified: stable/7/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- stable/7/sys/fs/tmpfs/tmpfs_subr.c Sun Feb 22 10:17:10 2009 (r188910) +++ stable/7/sys/fs/tmpfs/tmpfs_subr.c Sun Feb 22 10:25:07 2009 (r188911) @@ -572,7 +572,8 @@ tmpfs_dir_detach(struct vnode *vp, struc * Returns a pointer to the entry when found, otherwise NULL. */ struct tmpfs_dirent * -tmpfs_dir_lookup(struct tmpfs_node *node, struct componentname *cnp) +tmpfs_dir_lookup(struct tmpfs_node *node, struct tmpfs_node *f, + struct componentname *cnp) { boolean_t found; struct tmpfs_dirent *de; @@ -584,6 +585,8 @@ tmpfs_dir_lookup(struct tmpfs_node *node found = 0; TAILQ_FOREACH(de, &node->tn_dir.tn_dirhead, td_entries) { + if (f != NULL && de->td_node != f) + continue; MPASS(cnp->cn_namelen < 0xffff); if (de->td_namelen == (uint16_t)cnp->cn_namelen && memcmp(de->td_name, cnp->cn_nameptr, de->td_namelen) == 0) { @@ -596,20 +599,6 @@ tmpfs_dir_lookup(struct tmpfs_node *node return found ? de : NULL; } -struct tmpfs_dirent * -tmpfs_dir_search(struct tmpfs_node *node, struct tmpfs_node *f) -{ - struct tmpfs_dirent *de; - - TMPFS_VALIDATE_DIR(node); - node->tn_status |= TMPFS_NODE_ACCESSED; - TAILQ_FOREACH(de, &node->tn_dir.tn_dirhead, td_entries) { - if (de->td_node == f) - return (de); - } - return (NULL); -} - /* --------------------------------------------------------------------- */ /* Modified: stable/7/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- stable/7/sys/fs/tmpfs/tmpfs_vnops.c Sun Feb 22 10:17:10 2009 (r188910) +++ stable/7/sys/fs/tmpfs/tmpfs_vnops.c Sun Feb 22 10:25:07 2009 (r188911) @@ -104,7 +104,7 @@ tmpfs_lookup(struct vop_cachedlookup_arg *vpp = dvp; error = 0; } else { - de = tmpfs_dir_lookup(dnode, cnp); + de = tmpfs_dir_lookup(dnode, NULL, cnp); if (de == NULL) { /* The entry was not found in the directory. * This is OK if we are creating or renaming an @@ -771,7 +771,7 @@ tmpfs_remove(struct vop_remove_args *v) dnode = VP_TO_TMPFS_DIR(dvp); node = VP_TO_TMPFS_NODE(vp); tmp = VFS_TO_TMPFS(vp->v_mount); - de = tmpfs_dir_search(dnode, node); + de = tmpfs_dir_lookup(dnode, node, v->a_cnp); MPASS(de != NULL); /* Files marked as immutable or append-only cannot be deleted. */ @@ -918,7 +918,7 @@ tmpfs_rename(struct vop_rename_args *v) } fdnode = VP_TO_TMPFS_DIR(fdvp); fnode = VP_TO_TMPFS_NODE(fvp); - de = tmpfs_dir_search(fdnode, fnode); + de = tmpfs_dir_lookup(fdnode, fnode, fcnp); /* Avoid manipulating '.' and '..' entries. */ if (de == NULL) { @@ -1030,7 +1030,7 @@ tmpfs_rename(struct vop_rename_args *v) * from the target directory. */ if (tvp != NULL) { /* Remove the old entry from the target directory. */ - de = tmpfs_dir_search(tdnode, tnode); + de = tmpfs_dir_lookup(tdnode, tnode, tcnp); tmpfs_dir_detach(tdvp, de); /* Free the directory entry we just deleted. Note that the @@ -1118,7 +1118,7 @@ tmpfs_rmdir(struct vop_rmdir_args *v) /* Get the directory entry associated with node (vp). This was * filled by tmpfs_lookup while looking up the entry. */ - de = tmpfs_dir_search(dnode, node); + de = tmpfs_dir_lookup(dnode, node, v->a_cnp); MPASS(TMPFS_DIRENT_MATCHES(de, v->a_cnp->cn_nameptr, v->a_cnp->cn_namelen));