From nobody Fri Mar 24 17:47:43 2023 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 4PjqRh0hZ8z40sjn; Fri, 24 Mar 2023 17:47:44 +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 4PjqRg7194z4Tg5; Fri, 24 Mar 2023 17:47:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679680064; 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=wN8aQ8G1kPjkYu3JYlHSAcWH7aMO1II6TygJYGkCeU4=; b=gKiWQ58M/A2iLvquL78HuF6GicfPPvyghFyDIge/OqNTXF1zXCs77Wy2eFDM+4e1wyxrYh ruLH9DbQgnNxkDtCSuL/bUIfC7glrCpR9IlbNNSHdpHGt5axmw6XTflBqlryrYcZx2+CCv aRB8nYzNkeIYhumOoWTSyRDOxBWa5AWZ8a9h4TSv82pamMWujuvwoYF4pFwKXG0OztW4nJ pjrIqaETbEUVwOU+ClvEh1N4WL6CnAtjetgZNQk+T1rreMGrf1TK8z/ATwO0upM4Iwl90E sTaeUfGIhsL0BYpHdYt8kZKz7c9AKZRGv7C1NKAcae6+LtLuQe9QmTQyKL7KNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679680064; 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=wN8aQ8G1kPjkYu3JYlHSAcWH7aMO1II6TygJYGkCeU4=; b=E02VVq3B9WL5ReX7HGYdSZ1sPANhsjjGiLNYTy2G08PdRi6+LxsFwGPqrD4tfm0VYuXJcd sK/cpW4fXkfkGd79s4pjlrODQGLrR41/hldFf6Q3PoYaBEC8+rV/y+Su9cqerrIvNf0jW6 vkzC8j3ap4nXh1NI79hXAQtUUsOcZ2YRAP0iPWqzLoWxYtRTkLTMkepN3ojamo7+3fLui/ 5OIdRjeHF6fcXYHcU39sba43rjLL2dEtafkYMOa9781ZsWJB5UOi0YZtMzxZzqMR7N4pCr 66v4+dwp+C8w+fDl6YgMXoB5oC4Xn0XLnWCjSnEXz7MDn8/DKG/jQaxs4Rw5Kg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679680064; a=rsa-sha256; cv=none; b=LRFPZItDY1NfR0khRVJ1cFMqpGbbA7cgaHsoFkMv8Vr1kQOIgWvMqelut+FRBCGgSiMxDh xGC5rBw+fDRhpt4qGwOo+cFAG+t0FUDu1jfSCp6gQYt+nkSf+a2+GB3Vpj+3QELSbcA7AB Wxb7ohB7JnPSQtP6vmcKVXgqV8lWzGK3PzexC+VAWexWIppx0eHmczI6IjiLkNVD6ND4XY 1M1T4kOMAJDDyS2KBf/7NDFEXqf5P1Tn1EfCIbVfqORBpFARGnOK2mVyJVLl9schcvVxsf vepTxSGG3D6AzxB0GJnm9zBdTC3ueo7GJEiv8GPJ1braiVt01Ioch6AqiF0mpA== 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 4PjqRg66dCzRVd; Fri, 24 Mar 2023 17:47:43 +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 32OHlhvB075524; Fri, 24 Mar 2023 17:47:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32OHlhph075523; Fri, 24 Mar 2023 17:47:43 GMT (envelope-from git) Date: Fri, 24 Mar 2023 17:47:43 GMT Message-Id: <202303241747.32OHlhph075523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 7dca8fd1cb3f - main - fdesc_lookup(): the condition to use vn_vget_ino() is always true 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7dca8fd1cb3f91e7a3c07b7f57af6d9d43d0c71c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7dca8fd1cb3f91e7a3c07b7f57af6d9d43d0c71c commit 7dca8fd1cb3f91e7a3c07b7f57af6d9d43d0c71c Author: Konstantin Belousov AuthorDate: 2023-03-23 19:28:08 +0000 Commit: Konstantin Belousov CommitDate: 2023-03-24 17:47:16 +0000 fdesc_lookup(): the condition to use vn_vget_ino() is always true The ix number for the fdescfs root is 1, while any fd vnode has the ix value at least 3. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39207 --- sys/fs/fdescfs/fdesc_vnops.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index beef9295f11b..2713b070426c 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -337,26 +337,24 @@ fdesc_lookup(struct vop_lookup_args *ap) goto bad; fdropped = false; - /* Make sure we're not looking up the dvp itself. */ - if (VTOFDESC(dvp)->fd_ix != FD_DESC + fd) { - /* - * Unlock our root node (dvp) when doing this, since we might - * deadlock since the vnode might be locked by another thread - * and the root vnode lock will be obtained afterwards (in case - * we're looking up the fd of the root vnode), which will be the - * opposite lock order. Vhold the root vnode first so we don't - * lose it. - */ - arg.ftype = Fdesc; - arg.fd_fd = fd; - arg.ix = FD_DESC + fd; - arg.fp = fp; - arg.td = td; - arg.fdropped = fdropped; - error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg, - LK_EXCLUSIVE, &fvp); - fdropped = arg.fdropped; - } + /* + * Make sure we do not deadlock looking up the dvp itself. + * + * Unlock our root node (dvp) when doing this, since we might + * deadlock since the vnode might be locked by another thread + * and the root vnode lock will be obtained afterwards (in case + * we're looking up the fd of the root vnode), which will be the + * opposite lock order. + */ + arg.ftype = Fdesc; + arg.fd_fd = fd; + arg.ix = FD_DESC + fd; + arg.fp = fp; + arg.td = td; + arg.fdropped = fdropped; + error = vn_vget_ino_gen(dvp, fdesc_get_ino_alloc, &arg, + LK_EXCLUSIVE, &fvp); + fdropped = arg.fdropped; if (!fdropped) { /*