From owner-svn-src-all@FreeBSD.ORG Tue Aug 20 07:11:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 11EC284C; Tue, 20 Aug 2013 07:11:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D927527DD; Tue, 20 Aug 2013 07:11:53 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7K7BrJS078589; Tue, 20 Aug 2013 07:11:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7K7Brun078586; Tue, 20 Aug 2013 07:11:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201308200711.r7K7Brun078586@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 20 Aug 2013 07:11:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r254550 - stable/9/sys/fs/tmpfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Tue, 20 Aug 2013 07:11:54 -0000 Author: kib Date: Tue Aug 20 07:11:53 2013 New Revision: 254550 URL: http://svnweb.freebsd.org/changeset/base/254550 Log: MFC r253967: Wait for the doomed vnode to be detached from the tmpfs node if sleepable allocation is requested. Modified: stable/9/sys/fs/tmpfs/tmpfs.h stable/9/sys/fs/tmpfs/tmpfs_subr.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/tmpfs/tmpfs.h ============================================================================== --- stable/9/sys/fs/tmpfs/tmpfs.h Tue Aug 20 06:46:40 2013 (r254549) +++ stable/9/sys/fs/tmpfs/tmpfs.h Tue Aug 20 07:11:53 2013 (r254550) @@ -327,6 +327,7 @@ LIST_HEAD(tmpfs_node_list, tmpfs_node); #define TMPFS_VNODE_ALLOCATING 1 #define TMPFS_VNODE_WANT 2 #define TMPFS_VNODE_DOOMED 4 +#define TMPFS_VNODE_WRECLAIM 8 /* --------------------------------------------------------------------- */ /* Modified: stable/9/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- stable/9/sys/fs/tmpfs/tmpfs_subr.c Tue Aug 20 06:46:40 2013 (r254549) +++ stable/9/sys/fs/tmpfs/tmpfs_subr.c Tue Aug 20 07:11:53 2013 (r254550) @@ -386,11 +386,32 @@ tmpfs_alloc_vp(struct mount *mp, struct loop: TMPFS_NODE_LOCK(node); +loop1: if ((vp = node->tn_vnode) != NULL) { MPASS((node->tn_vpstate & TMPFS_VNODE_DOOMED) == 0); VI_LOCK(vp); + if ((node->tn_type == VDIR && node->tn_dir.tn_parent == NULL) || + ((vp->v_iflag & VI_DOOMED) != 0 && + (lkflag & LK_NOWAIT) != 0)) { + VI_UNLOCK(vp); + TMPFS_NODE_UNLOCK(node); + error = ENOENT; + vp = NULL; + goto out; + } + if ((vp->v_iflag & VI_DOOMED) != 0) { + VI_UNLOCK(vp); + node->tn_vpstate |= TMPFS_VNODE_WRECLAIM; + while ((node->tn_vpstate & TMPFS_VNODE_WRECLAIM) != 0) { + msleep(&node->tn_vnode, TMPFS_NODE_MTX(node), + 0, "tmpfsE", 0); + } + goto loop1; + } TMPFS_NODE_UNLOCK(node); error = vget(vp, lkflag | LK_INTERLOCK, curthread); + if (error == ENOENT) + goto loop; if (error != 0) { vp = NULL; goto out; @@ -519,6 +540,9 @@ tmpfs_free_vp(struct vnode *vp) mtx_assert(TMPFS_NODE_MTX(node), MA_OWNED); node->tn_vnode = NULL; + if ((node->tn_vpstate & TMPFS_VNODE_WRECLAIM) != 0) + wakeup(&node->tn_vnode); + node->tn_vpstate &= ~TMPFS_VNODE_WRECLAIM; vp->v_data = NULL; }