From nobody Sun Oct 10 18:24:38 2021 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 15DE717EAC14; Sun, 10 Oct 2021 18:24:39 +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 4HS9Lt2LPLz3my3; Sun, 10 Oct 2021 18:24:38 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2B56712855; Sun, 10 Oct 2021 18:24:38 +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 19AIOcHg024488; Sun, 10 Oct 2021 18:24:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19AIOc18024487; Sun, 10 Oct 2021 18:24:38 GMT (envelope-from git) Date: Sun, 10 Oct 2021 18:24:38 GMT Message-Id: <202110101824.19AIOc18024487@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: 93e0523499fe - main - vfs: add predicts to getvnode and getvnode_path 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: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 93e0523499fecb2ce1ca434c8ab96b58559771f3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=93e0523499fecb2ce1ca434c8ab96b58559771f3 commit 93e0523499fecb2ce1ca434c8ab96b58559771f3 Author: Mateusz Guzik AuthorDate: 2021-10-10 18:17:50 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-10 18:24:29 +0000 vfs: add predicts to getvnode and getvnode_path --- sys/kern/vfs_syscalls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 1b355eea7d6a..82a8125ece95 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4316,7 +4316,7 @@ getvnode_path(struct thread *td, int fd, cap_rights_t *rightsp, * other thread to dereference it. Guard against the race by * checking f_ops. */ - if (fp->f_vnode == NULL || fp->f_ops == &badfileops) { + if (__predict_false(fp->f_vnode == NULL || fp->f_ops == &badfileops)) { fdrop(fp, td); return (EINVAL); } @@ -4336,12 +4336,14 @@ getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) int error; error = getvnode_path(td, fd, rightsp, fpp); + if (__predict_false(error != 0)) + return (error); /* * Filter out O_PATH file descriptors, most getvnode() callers * do not call fo_ methods. */ - if (error == 0 && (*fpp)->f_ops == &path_fileops) { + if (__predict_false((*fpp)->f_ops == &path_fileops)) { fdrop(*fpp, td); error = EBADF; }