From owner-svn-src-stable-12@freebsd.org Tue Sep 3 19:34:33 2019 Return-Path: Delivered-To: svn-src-stable-12@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 55913D4585; Tue, 3 Sep 2019 19:34:33 +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 46NHG11YW2z4DP2; Tue, 3 Sep 2019 19:34:33 +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 1879F7E4E; Tue, 3 Sep 2019 19:34:33 +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 x83JYWhP063570; Tue, 3 Sep 2019 19:34:32 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x83JYWh5063568; Tue, 3 Sep 2019 19:34:32 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201909031934.x83JYWh5063568@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 3 Sep 2019 19:34:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351778 - stable/12/sys/fs/unionfs X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/fs/unionfs X-SVN-Commit-Revision: 351778 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Sep 2019 19:34:33 -0000 Author: kib Date: Tue Sep 3 19:34:32 2019 New Revision: 351778 URL: https://svnweb.freebsd.org/changeset/base/351778 Log: MFC r350504: Try to decrease the number of bugs in unionfs after the VV_TEXT flag removal. Modified: stable/12/sys/fs/unionfs/union_subr.c stable/12/sys/fs/unionfs/union_vnops.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/unionfs/union_subr.c ============================================================================== --- stable/12/sys/fs/unionfs/union_subr.c Tue Sep 3 19:30:02 2019 (r351777) +++ stable/12/sys/fs/unionfs/union_subr.c Tue Sep 3 19:34:32 2019 (r351778) @@ -348,6 +348,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: stable/12/sys/fs/unionfs/union_vnops.c ============================================================================== --- stable/12/sys/fs/unionfs/union_vnops.c Tue Sep 3 19:30:02 2019 (r351777) +++ stable/12/sys/fs/unionfs/union_vnops.c Tue Sep 3 19:34:32 2019 (r351778) @@ -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, };