From nobody Tue Apr 18 01:35:41 2023 X-Original-To: dev-commits-src-main@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 4Q0mhZ2y5Hz45Vfb; Tue, 18 Apr 2023 01:35:42 +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 4Q0mhZ1457z3JyG; Tue, 18 Apr 2023 01:35:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681781742; 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=mIpWlQVr9yqEjnMaX1K/vs73/vusDRxAZaN889NIREM=; b=mNOhxLLa10eIKjdn/S1XpE0YdO9dHgC+BulqQDSjbXIJG6VO/z6cixE3zYQx1iJw4WRtZo J068BtpUXubTro+WscS6LuyDqMrBINhhQgAvlJGjpnfQmehVSJhOfTMqpKi6RbHA6y6ZlI 6UZDUq7omuZjzFmrcaK1SIPYjCaMMuotxMg+6Nl5SZeNUxKAIr4CPEbPtzq38gxQa4youI BYzQOH+9q+JwH1iuHGlnJ/aLW//fl7rQ4WxwSIxdZZCeJoo16dlA6LLZCp5V6aLMLzhUgX Noz+JautCvnPna9H9LUqjNDhUWA/K2v6Iyd73qIrd9FatqIuXFje11twzYYOuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681781742; 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=mIpWlQVr9yqEjnMaX1K/vs73/vusDRxAZaN889NIREM=; b=I/ZGRwvlT4mVUJ3y46Hj1kn3YiCXcrK0BtiE4/j6X1iG0AyULXMK3m5boTkXq2hqBnkA+6 o1sb4UIZlTLzzEtjjh7vk+K57TsL8o+O7Qr4OWDkOrQJ2yQamjeCzzDc+Cr+tEL4ynX7Fx kxDbOA5rVMwfBBwr8vaUJmaFfFA6GEPEUFYlf/RM3K8JjINcxRToziQJQZLoA0sMYEYiGE DL343GdelrbHuA5GooOwk5drlvQS+qSeQRdpVQ81Pai/B79C45OFRkbwWPvOAnSgyBKY9a bI6V1CHj/yBRTwBWQ9cVJSWP4Z1rejyxsqHwXOl/Fgm4/r8ihOLCDQyAw5XoAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681781742; a=rsa-sha256; cv=none; b=YCfoLRayDqW0xuXA2rXOWlLlda5BzVzF/UIDxwKMff8RDWEuHLpt2mEJvn6GFIQKHWrjvw kEO2vdFXj46Ea/4rBy4WHGnm1tGVVQpj+pFGkTvUsbsvePCOb7rhlCgFagMBgWZ2JgwvcT 9RMyKoDeMQ0U3FcojHiE/quB2nP5BsY1W4Kh+jg7mr7vrZJq0npY0zZIuqlOq1W1Uk5hd5 yOV0palD++FHh8QN8wT/T/qdNMSoShL3HWLFShRPOs1R8hx3/PK4Ebih84810rzLpr6Fqr mayjssez/9ndhRraVwMKbWbBg+cvib3phms9XN39F/SKF26xBcot4lyQe0mTTw== 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 4Q0mhZ09gFzsDQ; Tue, 18 Apr 2023 01:35:42 +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 33I1Zf6C042400; Tue, 18 Apr 2023 01:35:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33I1ZffK042399; Tue, 18 Apr 2023 01:35:41 GMT (envelope-from git) Date: Tue, 18 Apr 2023 01:35:41 GMT Message-Id: <202304180135.33I1ZffK042399@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: a18c403fbddb - main - unionfs: remove LK_UPGRADE if falling back to the standard lock List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: a18c403fbddb0fa9650f133a026f40ad33751134 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=a18c403fbddb0fa9650f133a026f40ad33751134 commit a18c403fbddb0fa9650f133a026f40ad33751134 Author: Jason A. Harmening AuthorDate: 2023-01-16 21:46:59 +0000 Commit: Jason A. Harmening CommitDate: 2023-04-18 01:31:40 +0000 unionfs: remove LK_UPGRADE if falling back to the standard lock The LK_UPGRADE operation may have temporarily dropped the upper or lower vnode's lock. If the unionfs vnode was reclaimed during that window, its lock field will be reset to no longer point at the upper/lower vnode lock, so the lock operation will use the standard lock stored in v_lock. Remove LK_UPGRADE from the flags in this case to avoid a lockmgr assertion, as this lock has not been previously owned by the calling thread. Reported by: pho Tested by: pho Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D39272 --- sys/fs/unionfs/union_vnops.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 04d788959892..f78e653280a4 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -2010,7 +2010,7 @@ unionfs_lock(struct vop_lock1_args *ap) vdrop(lvp); if (uhold != 0) vdrop(uvp); - return (vop_stdlock(ap)); + goto unionfs_lock_fallback; } } @@ -2043,7 +2043,7 @@ unionfs_lock(struct vop_lock1_args *ap) VOP_UNLOCK(lvp); vdrop(lvp); } - return (vop_stdlock(ap)); + goto unionfs_lock_fallback; } if (error != 0 && lvp != NULLVP) { /* rollback */ @@ -2065,6 +2065,22 @@ unionfs_lock(struct vop_lock1_args *ap) unionfs_lock_null_vnode: ap->a_flags |= LK_INTERLOCK; return (vop_stdlock(ap)); + +unionfs_lock_fallback: + /* + * If we reach this point, we've discovered the unionfs vnode + * has been reclaimed while the upper/lower vnode locks were + * temporarily dropped. Such temporary droppage may happen + * during the course of an LK_UPGRADE operation itself, and in + * that case LK_UPGRADE must be cleared as the unionfs vnode's + * lock has been reset to point to the standard v_lock field, + * which has not previously been held. + */ + if (flags & LK_UPGRADE) { + ap->a_flags &= ~LK_TYPE_MASK; + ap->a_flags |= LK_EXCLUSIVE; + } + return (vop_stdlock(ap)); } static int