From nobody Sun Sep 24 21:46:47 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 4Rv02b71fCz4tX89; Sun, 24 Sep 2023 21:46:47 +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 4Rv02b6Rdmz4Ys8; Sun, 24 Sep 2023 21:46:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695592007; 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=W9LM3rfhSVlF/BkaVxDnU2UlcrtWDPgpMbhKeC6tLhI=; b=aAqcDNyWt7AOsQpdRIr/ldgPDJZy7vYsv2TrfbF9BmRMwUZl+5FWpJkv5tnQaiNeM2Ofyy E3jXgG82rY4q2RX4P+6pULLkvOpiYoHUqOqyRIQh5SYX1oYtrGIWpqWwuimQHjieaYjiUE 1vEGut5bF35U9HACWHfkriMDscPjLCVyGWmvgLiUn4obreLF+G0i/jaZTkpX+U0mERvGMd AF7kwV0Z4IJmBW3OUrgHNFqRT2oKHyMK0wTIm7u4BA3DPdxsT1elFzYjzfQ3JOpd9wmVfX LBrKj7BW89UOS2YVCjEKYY65QOYdimDhZD7TGeUC4OBUrOgan096wgF0ZnfDpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695592007; a=rsa-sha256; cv=none; b=ck/VIiZP/P0cRqFDEUD1IFPWXDZbtqUiJEaoLVxFNUubqa5m0EcCi+DtS/ZxVA8545UIOy t2RmQLRQ/UusoqmQklQXnMsqMJyHXYpK/2nllcW/p5M8DVIP/VO5jJKg/qyjfGkEIj6pLW qEVO/1WO1f5SERx+kqjcrACoT6HAZIZ0mRUX1+oKLPKpJwtlStFbVo74pq0Pt1r732aZ3Q 9CtU6rBSxMNIePt+9h6wCZj/PKAVc+lJVv1CldYLH/tYBu4AXXAESa3mubMW+t10Mb1kik op4oEr5YD0qxTuK3aS0yCB02zSL2ssXifeY8ozMbAfPsHHjs36bFCf5sltWdjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695592007; 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=W9LM3rfhSVlF/BkaVxDnU2UlcrtWDPgpMbhKeC6tLhI=; b=HpHwSLshLkFNnfeWeXYbnoHDSrtkRpVzF3Nk9xKaikqergKsrGx3hdGRHHgPRNj7s8Np2v jydDCgR4MYWJ4XZSUsiyfeqEkAjwma3SWOj1wcCiHhgFHxQnnh37tVqO28tBHf19kwFRBr 57JSGm97q2fz0ovdqEb+3eGg7IPReQ47Ye9GvYZ5YnpSjYLxgR2UxgU/9j8Z5hOmsubPc5 TA4/lGqkK59y95PwwZfcvCGu+P/ZGLEmd06+uq4MfuD2WhIJMybFESEAG8g8DZzoxvRTPt d0zNon8t4Bg0fWUnFs0OSwrAIkvwwSi4C3Okd/Mdio7VeJbnyWCIo3EMDJUYeg== 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 4Rv02b5YS7z13fg; Sun, 24 Sep 2023 21:46:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38OLkl68030348; Sun, 24 Sep 2023 21:46:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38OLkluf030345; Sun, 24 Sep 2023 21:46:47 GMT (envelope-from git) Date: Sun, 24 Sep 2023 21:46:47 GMT Message-Id: <202309242146.38OLkluf030345@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 2701cbf16165 - releng/14.0 - vfs cache: fix a hang when bumping vnode limit too high 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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 2701cbf16165adbd782c6eea816d4b7214a1d2b8 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=2701cbf16165adbd782c6eea816d4b7214a1d2b8 commit 2701cbf16165adbd782c6eea816d4b7214a1d2b8 Author: Mateusz Guzik AuthorDate: 2023-09-02 14:27:33 +0000 Commit: Mateusz Guzik CommitDate: 2023-09-24 21:45:23 +0000 vfs cache: fix a hang when bumping vnode limit too high Overflow in cache_changesize would make the value flip to 0 and stay there as 0 << 1 does not do anything. Note callers limit the outcome to something below u_int. Also note there entire vnode handling thing both in vfs layer as a whole and this file can't decide whether to long, u_long or u_int. Approved by: re (gjb) (cherry picked from commit 32988c1499f8698b41e15ed40a46d271e757bba3) (cherry picked from commit 41fad6503c1e5259e65d4f14110a5decb7653b02) --- sys/kern/vfs_cache.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 92c926a16afb..5b0cd64146ad 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2597,10 +2597,10 @@ cache_enter_time_flags(struct vnode *dvp, struct vnode *vp, struct componentname cache_enter_time(dvp, vp, cnp, tsp, dtsp); } -static u_int -cache_roundup_2(u_int val) +static u_long +cache_roundup_2(u_long val) { - u_int res; + u_long res; for (res = 1; res <= val; res <<= 1) continue; @@ -2616,7 +2616,7 @@ nchinittbl(u_long elements, u_long *hashmask) hashsize = cache_roundup_2(elements) / 2; - hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl), M_VFSCACHE, M_WAITOK); + hashtbl = malloc(hashsize * sizeof(*hashtbl), M_VFSCACHE, M_WAITOK); for (i = 0; i < hashsize; i++) CK_SLIST_INIT(&hashtbl[i]); *hashmask = hashsize - 1; @@ -2762,7 +2762,7 @@ cache_changesize(u_long newmaxvnodes) struct namecache *ncp; uint32_t hash; u_long newncsize; - int i; + u_long i; newncsize = newmaxvnodes * ncsizefactor; newmaxvnodes = cache_roundup_2(newmaxvnodes * 2);