From owner-svn-src-head@freebsd.org Thu Aug 1 14:40:38 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B01A7BF929; Thu, 1 Aug 2019 14:40:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 45ztJ64BVJz3FMM; Thu, 1 Aug 2019 14:40:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 574B11BB76; Thu, 1 Aug 2019 14:40:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x71EecRT041783; Thu, 1 Aug 2019 14:40:38 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x71Eeb8b041781; Thu, 1 Aug 2019 14:40:37 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201908011440.x71Eeb8b041781@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 1 Aug 2019 14:40:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350504 - head/sys/fs/unionfs X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/fs/unionfs X-SVN-Commit-Revision: 350504 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 45ztJ64BVJz3FMM X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-0.17 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.30)[-0.297,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_SPAM_SHORT(0.12)[0.123,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Aug 2019 14:40:38 -0000 Author: kib Date: Thu Aug 1 14:40:37 2019 New Revision: 350504 URL: https://svnweb.freebsd.org/changeset/base/350504 Log: Try to decrease the number of bugs in unionfs after the VV_TEXT flag removal. - Provide unionfs_add_writecount() which passes the writecount to the lower or upper vnode as appropriate. - In unionfs VOP_RECLAIM() implementation, annulate unionfs writecounts from upper or lower vnode. It is not clear that it is always correct to remove the all references from either lower or upper vnode, but we currently do not track which vnode get how many refs anyway. Reported and tested by: t_uemura@macome.co.jp MFC after: 1 week Sponsored by: The FreeBSD Foundation Modified: head/sys/fs/unionfs/union_subr.c head/sys/fs/unionfs/union_vnops.c Modified: head/sys/fs/unionfs/union_subr.c ============================================================================== --- head/sys/fs/unionfs/union_subr.c Thu Aug 1 14:39:26 2019 (r350503) +++ head/sys/fs/unionfs/union_subr.c Thu Aug 1 14:40:37 2019 (r350504) @@ -349,6 +349,13 @@ unionfs_noderem(struct vnode *vp, struct thread *td) vp->v_vnlock = &(vp->v_lock); vp->v_data = NULL; vp->v_object = NULL; + if (vp->v_writecount > 0) { + if (uvp != NULL) + VOP_ADD_WRITECOUNT(uvp, -vp->v_writecount); + else if (lvp != NULL) + VOP_ADD_WRITECOUNT(lvp, -vp->v_writecount); + } else if (vp->v_writecount < 0) + vp->v_writecount = 0; VI_UNLOCK(vp); if (lvp != NULLVP) Modified: head/sys/fs/unionfs/union_vnops.c ============================================================================== --- head/sys/fs/unionfs/union_vnops.c Thu Aug 1 14:39:26 2019 (r350503) +++ head/sys/fs/unionfs/union_vnops.c Thu Aug 1 14:40:37 2019 (r350504) @@ -2511,6 +2511,33 @@ unionfs_vptofh(struct vop_vptofh_args *ap) return (EOPNOTSUPP); } +static int +unionfs_add_writecount(struct vop_add_writecount_args *ap) +{ + struct vnode *tvp, *vp; + struct unionfs_node *unp; + int error; + + vp = ap->a_vp; + unp = VTOUNIONFS(vp); + tvp = unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp; + VI_LOCK(vp); + /* text refs are bypassed to lowervp */ + VNASSERT(vp->v_writecount >= 0, vp, ("wrong null writecount")); + VNASSERT(vp->v_writecount + ap->a_inc >= 0, vp, + ("wrong writecount inc %d", ap->a_inc)); + if (tvp != NULL) + error = VOP_ADD_WRITECOUNT(tvp, ap->a_inc); + else if (vp->v_writecount < 0) + error = ETXTBSY; + else + error = 0; + if (error == 0) + vp->v_writecount += ap->a_inc; + VI_UNLOCK(vp); + return (error); +} + struct vop_vector unionfs_vnodeops = { .vop_default = &default_vnodeops, @@ -2559,4 +2586,5 @@ struct vop_vector unionfs_vnodeops = { .vop_whiteout = unionfs_whiteout, .vop_write = unionfs_write, .vop_vptofh = unionfs_vptofh, + .vop_add_writecount = unionfs_add_writecount, };