From nobody Thu Feb 03 02:58:21 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0305419A9201; Thu, 3 Feb 2022 02:58:22 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jq3JY5Q2sz4kLX; Thu, 3 Feb 2022 02:58:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643857101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ajZTlSI/bll6otOEfxBuEVmrqrLW4GGdm2iKneQiQdk=; b=lw2M5WFb0x/jnCA4sfb7XPEnGQySoZz5rvHTV1a5KdlroyTnVjiQ4Xc0ZMvzaYfFlEWjRq +2Fvzm40nKWxRKsgASY7zFirTO4XJC7gjoH2vQT6ZmAfUDzMhRajS1NzSQJZQHAR2QYbTa qjz888MZOSVvNnzqWgA2mmgy4bwxzYYrouV6tuis4vsYhHfM6Tz6ri2v7FATLIvSoz1FgE 1KtdEMoPn9TrftzbMuYM+jryxcgu8ul4RwQSfcVBGfpEJCW0aqv/EgbiynHGAVjJDvvaEM v2g4wTBiQjEGnYqG/UOOsXbnofTTrwEp+wc8N15V82BsiGtWyvN9SYkzYKJTfg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8C46A7CDF; Thu, 3 Feb 2022 02:58:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2132wLxC000492; Thu, 3 Feb 2022 02:58:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2132wLZh000491; Thu, 3 Feb 2022 02:58:21 GMT (envelope-from git) Date: Thu, 3 Feb 2022 02:58:21 GMT Message-Id: <202202030258.2132wLZh000491@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: 6ff167aa427c - main - unionfs: allow lock recursion when reclaiming the root vnode List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6ff167aa427c75d97153a4ffb343f8cbf93a22db Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643857101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ajZTlSI/bll6otOEfxBuEVmrqrLW4GGdm2iKneQiQdk=; b=KBjMrja3EDvIx7j7v8UKs9zsNhSPWfn6CE+J3QWNKb//Gz+CouDpk54VitwrktjIbP29pc GZQ9Fs4FaFea2GTGXlL418tFKJ8H9YiJhkKEWipw0hMOrhgoIaZhflkuaFxhKPTRJ0sDgE 0GkXiI2m3/tw/fLrD9A/Ts8yGAjeH9et43lXM0ABNnk/PMwBIrRrY5YVJ1sv5vE6yAt+vx 0nMYUDMhhbO6SATa1e8P0NlIoR2GOz853GIc4A6rmL+m2fyLQb1MIrMoj4z2s7c6oMwcxJ wjkkAtRG5JTD4XqrjlqZLzNOfoQdm7kXaLqekPoilzlcY1c8CHrAiB2D1MT6TA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643857101; a=rsa-sha256; cv=none; b=FBAhWfhZoYsExMW6CZIWFyHZBNJckoO5ujVPl/Canvautcm8gU8EmHP1L3Gd8td7YBUkQD q9kBiW3N/r47CEcqY94/KhJMnj/y1AZGDaXhysVsXLtMGtHIvHCHsrQxN695v1VkIq56S6 0KheUO9mdNhpYn+11rse1cawHHKHn1Wg/GzKQr0f3txQShcZz/dxesiFBdWp9mxm294WYP /4SOyPcjycPQJFgu7HHf6HKURzk0Xv3KINFtpurz7s4S0pRPNHAetE5Cb9kaG09GbtVxKe UCrZlQmGRJXYa4wbWnv2wBqjxXpI7aAfifgsyVKkJKlxIpBXX4+3VecJDc1Z/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=6ff167aa427c75d97153a4ffb343f8cbf93a22db commit 6ff167aa427c75d97153a4ffb343f8cbf93a22db Author: Jason A. Harmening AuthorDate: 2022-01-30 20:52:08 +0000 Commit: Jason A. Harmening CommitDate: 2022-02-03 03:08:17 +0000 unionfs: allow lock recursion when reclaiming the root vnode The unionfs root vnode will always share a lock with its lower vnode. If unionfs was mounted with the 'below' option, this will also be the vnode covered by the unionfs mount. During unmount, the covered vnode will be locked by dounmount() while the unionfs root vnode will be locked by vgone(). This effectively requires recursion on the same underlying like, albeit through two different vnodes. Reported by: pho Reviewed by: kib, markj, pho Differential Revision: https://reviews.freebsd.org/D34109 --- sys/fs/unionfs/union_subr.c | 13 +++++++++++-- sys/fs/unionfs/union_vnops.c | 7 +++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 557d4589df55..466c88c705f4 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -442,7 +442,16 @@ unionfs_noderem(struct vnode *vp) int count; int writerefs; - KASSERT(vp->v_vnlock->lk_recurse == 0, + /* + * The root vnode lock may be recursed during forcible, because + * it may share the same lock as the unionfs mount's covered vnode, + * which is locked across VFS_UNMOUNT(). This lock will then be + * recursively taken during the vflush() issued by unionfs_unmount(). + * But we still only need to lock the unionfs lock once, because only + * one of those lock operations was taken against a unionfs vnode and + * will be undone against a unionfs vnode. + */ + KASSERT(vp->v_vnlock->lk_recurse == 0 || (vp->v_vflag & VV_ROOT) != 0, ("%s: vnode %p locked recursively", __func__, vp)); if (lockmgr(&vp->v_lock, LK_EXCLUSIVE | LK_NOWAIT, NULL) != 0) panic("%s: failed to acquire lock for vnode lock", __func__); @@ -821,7 +830,7 @@ unionfs_node_update(struct unionfs_node *unp, struct vnode *uvp, VNASSERT(vp->v_writecount == 0, vp, ("%s: non-zero writecount", __func__)); /* - * Uppdate the upper vnode's lock state to match the lower vnode, + * Update the upper vnode's lock state to match the lower vnode, * and then switch the unionfs vnode's lock to the upper vnode. */ lockrec = lvp->v_vnlock->lk_recurse; diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 43378f709df7..28e306fdb3f8 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -1957,8 +1957,11 @@ unionfs_lock(struct vop_lock1_args *ap) flags |= LK_NOWAIT; /* - * Sometimes, lower or upper is already exclusive locked. - * (ex. vfs_domount: mounted vnode is already locked.) + * During unmount, the root vnode lock may be taken recursively, + * because it may share the same v_vnlock field as the vnode covered by + * the unionfs mount. The covered vnode is locked across VFS_UNMOUNT(), + * and the same lock may be taken recursively here during vflush() + * issued by unionfs_unmount(). */ if ((flags & LK_TYPE_MASK) == LK_EXCLUSIVE && (vp->v_vflag & VV_ROOT) != 0)