From nobody Thu Mar 24 11:22:33 2022 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 CADB41A467CC; Thu, 24 Mar 2022 11:22:34 +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 4KPN9k1YSFz4qQp; Thu, 24 Mar 2022 11:22:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648120954; 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=Ka04B08bQhEEUGCa1YKhiGjdwEsXzV+DJuRlByDU0V0=; b=niZVCl6qOX32GU3EhqSpMdJSpaDimgOHDriL8c+xXmagG4IkyrpnVN8t6SpsEJoIj7t2Hm lgkyCevgN7+veHqE/CHV5LelpVmqd4mjCC93LtsHiKh1bxGzXVnte28g+udAU3rtW02ZJt gNAPgyC+LkwSA8Y07p+a+QZkulsLe68OsUmt7qylNvQv64VsHR44Pi6esjeaYinSRHshGR Y7C11XfRo6TYfc58NEZ1L7TVPjxjmDxGOhgGfhKkTXu7gW9RH2NAJnc96iH7G/IAkz706y 5wR1qmwCR914JiwBGGbUSPLB5CIP3ew/vkWpj2m/Gs+t33/w/84zXTaS9sTb0A== 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 D187917227; Thu, 24 Mar 2022 11:22:33 +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 22OBMXKo084419; Thu, 24 Mar 2022 11:22:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22OBMXNP084418; Thu, 24 Mar 2022 11:22:33 GMT (envelope-from git) Date: Thu, 24 Mar 2022 11:22:33 GMT Message-Id: <202203241122.22OBMXNP084418@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: d9ea7e2b1e69 - main - vfs: factor FAILIFEXISTS handling out of vfs_lookup 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d9ea7e2b1e696697b532535678c05a10d6635084 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648120954; 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=Ka04B08bQhEEUGCa1YKhiGjdwEsXzV+DJuRlByDU0V0=; b=bwsYcKT+p5lOqT/NfPmXSyrdTsIfq5nwoO3A4DItA3t0BxDJfwltZxRb6xfpKpVnkQbfnD sdJwA8Nupj9RJepZdMBwZO2yfetqYhlbxxhc0v1Jkjv9j9P36Je/0PZjRA5wIKnFSUYLzk HEuyMNus6ohY/+RzLuFXJC3Fkp/a6ukpN1qjTmlE80tobdtyNsbv0asOqOGv8gzCTG3JPK 3oax66mesCBveakoXZQGnFoklRIrz9utMTIIjUzTODhQ5+xycRoY7y0d+jnpu5VZluBLYM QvPxV2pH5t6DeI/hYF+36hxqtOqYEOxQZJWUKe35pXu7bbWTRKk2FOKrH/qjtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648120954; a=rsa-sha256; cv=none; b=gSYaNinV4n5+NY8KdRQiYm/bCTEhLLfTfpiUDdg3dYh5h9jeuNBMGj7xNefnUPuz3x2569 AUDXBpPmfN3xhhrJxnOlQ7K3BwJOsV6P45Al0kwnI2OpAdzAPuzb77Dg7ql0pzbLM+sut6 FHqiqBGRldTuaWXFlAX5Ab44FrUTx/J2WI0azWlumBm5lc+Mcj/6rd5F5qIYIhUHk1QziV bndP97t7IaaYQSYPonyMNuRbaGYexUWgcK/6dDqnkTLdaAWd3jpKew2NVCSUXBuXNT7JYs xa8z1MUneeWgwq2QZs2KppuQ0W6nqjj8MLgbADb8ATWgrJVy9lS/VQePlRuuxQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=d9ea7e2b1e696697b532535678c05a10d6635084 commit d9ea7e2b1e696697b532535678c05a10d6635084 Author: Mateusz Guzik AuthorDate: 2022-03-13 17:36:51 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-24 11:22:20 +0000 vfs: factor FAILIFEXISTS handling out of vfs_lookup --- sys/kern/vfs_lookup.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index f4fabe55b06e..29db916382b1 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -853,6 +853,32 @@ bad: return (error); } +/* + * FAILIFEXISTS handling. + * + * XXX namei called with LOCKPARENT but not LOCKLEAF has the strange + * behaviour of leaving the vnode unlocked if the target is the same + * vnode as the parent. + */ +static int __noinline +vfs_lookup_failifexists(struct nameidata *ndp) +{ + struct componentname *cnp __diagused; + + cnp = &ndp->ni_cnd; + + MPASS((cnp->cn_flags & ISSYMLINK) == 0); + if (ndp->ni_vp == ndp->ni_dvp) + vrele(ndp->ni_dvp); + else + vput(ndp->ni_dvp); + vrele(ndp->ni_vp); + ndp->ni_dvp = NULL; + ndp->ni_vp = NULL; + NDFREE_PNBUF(ndp); + return (EEXIST); +} + /* * Search a pathname. * This is a very central and rather complicated routine. @@ -1388,7 +1414,7 @@ success_right_lock: if ((cnp->cn_flags & ISDOTDOT) == 0) nameicap_tracker_add(ndp, ndp->ni_vp); if ((cnp->cn_flags & (FAILIFEXISTS | ISSYMLINK)) == FAILIFEXISTS) - goto bad_eexist; + return (vfs_lookup_failifexists(ndp)); } return (0); @@ -1405,24 +1431,6 @@ bad: bad_unlocked: ndp->ni_vp = NULL; return (error); -bad_eexist: - /* - * FAILIFEXISTS handling. - * - * XXX namei called with LOCKPARENT but not LOCKLEAF has the strange - * behaviour of leaving the vnode unlocked if the target is the same - * vnode as the parent. - */ - MPASS((cnp->cn_flags & ISSYMLINK) == 0); - if (ndp->ni_vp == ndp->ni_dvp) - vrele(ndp->ni_dvp); - else - vput(ndp->ni_dvp); - vrele(ndp->ni_vp); - ndp->ni_dvp = NULL; - ndp->ni_vp = NULL; - NDFREE_PNBUF(ndp); - return (EEXIST); } /*