FreeBSD/sys/fs/unionfs/union_subr.c
/*
 * Add the new vnode into cache.
 */
Add the new vnode into cache.
Add the new vnode into cache .
static struct vnode *
unionfs_ins_cached_vnode(struct unionfs_node *uncp,
			struct vnode *dvp, char *path)
{
	struct unionfs_node_hashhead *hd;
	struct unionfs_node *unp;
	struct vnode   *vp;
	KASSERT((uncp->un_uppervp==NULLVP || uncp->un_uppervp->v_type==VDIR),
	    ("unionfs_ins_cached_vnode: v_type != VDIR"));
	KASSERT((uncp->un_lowervp==NULLVP || uncp->un_lowervp->v_type==VDIR),
	    ("unionfs_ins_cached_vnode: v_type != VDIR"));
	VI_LOCK(dvp);
	hd = unionfs_get_hashhead(dvp, path);
	LIST_FOREACH(unp, hd, un_hash) {
		if (!strcmp(unp->un_path, path)) {
			vp = UNIONFSTOV(unp);
			VI_LOCK_FLAGS(vp, MTX_DUPOK);
			vp->v_iflag &= ~VI_OWEINACT;
			if ((vp->v_iflag & (VI_DOOMED | VI_DOINGINACT)) != 0) {
				LIST_INSERT_HEAD(hd, uncp, un_hash);
				VI_UNLOCK(vp);
				vp = NULLVP;
			} else
				VI_UNLOCK(vp);
			VI_UNLOCK(dvp);
			return (vp);
		}
	}
	LIST_INSERT_HEAD(hd, uncp, un_hash);
	VI_UNLOCK(dvp);
	return (NULLVP);
}
static struct vnode * unionfs_ins_cached_vnode ( struct unionfs_node * uncp , struct vnode * dvp , char * path ) { struct unionfs_node_hashhead * hd ; struct unionfs_node * unp ; struct vnode * vp ; KASSERT ( ( uncp -> un_uppervp == NULLVP || uncp -> un_uppervp -> v_type == VDIR ) , ( " " ) ) ; KASSERT ( ( uncp -> un_lowervp == NULLVP || uncp -> un_lowervp -> v_type == VDIR ) , ( " " ) ) ; VI_LOCK ( dvp ) ; hd = unionfs_get_hashhead ( dvp , path ) ; LIST_FOREACH ( unp , hd , un_hash ) { if ( ! strcmp ( unp -> un_path , path ) ) { vp = UNIONFSTOV ( unp ) ; VI_LOCK_FLAGS ( vp , MTX_DUPOK ) ; vp -> v_iflag &= ~ VI_OWEINACT ; if ( ( vp -> v_iflag & ( VI_DOOMED | VI_DOINGINACT ) ) != 0 ) { LIST_INSERT_HEAD ( hd , uncp , un_hash ) ; VI_UNLOCK ( vp ) ; vp = NULLVP ; } else VI_UNLOCK ( vp ) ; VI_UNLOCK ( dvp ) ; return ( vp ) ; } } LIST_INSERT_HEAD ( hd , uncp , un_hash ) ; VI_UNLOCK ( dvp ) ; return ( NULLVP ) ; }
Add the new vnode into cache.
Add the new vnode into cache .