From nobody Sat Sep 02 14:47:37 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 4RdHn530JJz4rcl4; Sat, 2 Sep 2023 14:47:37 +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 4RdHn52Y05z3b8q; Sat, 2 Sep 2023 14:47:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693666057; 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=V+G3xrlvjQAeNxiB0sPDsORLXzT5rzQW6+Tgy/84eIk=; b=GFY0HLGd+6kZ9dZv0iNLXkDuFFKRAUhx4jlPuQRj/kAGQ+W8rjOvH0LAZ8HwMGF6piMrEd 7jBWEboYtN4uvsCizblfSATczDG3p8FBpEA+Ux1WJcwVP1pRCmGUtimQuWYiT2ildevY5B haXZXPT1sPD2Jo3ZQPmtAcSmbpjBQN7QUeFT2NmWgvQX6gUo/WdiGPFdxEBCiRgXaFeaKC LlExPx9qfnxiSmZ5NVpcX5TL5qM63O6H5sUgR7hJFTz0W3JxoJcm9pGQeK6PW+v+JLZy6x 3FzPls7BM2oTnXFUWIX/RwWeUGV6VPU7jcTDzZ9Jx8lr+wb+HJX9Y4zdt9ew+w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693666057; a=rsa-sha256; cv=none; b=P3lBgrQckVGBFFPoVCBoEn9Jh08kPD7C7obkrY1NYzTsl5Q3/UiMRy2hyAoUSEfPjQsPEh et3iubhFFjm0Rnd4yDoHhyTi9DULiREI6TcwPtqW7u/ZsG0OyLipcMSUMm2KUEX8G71/al tV762PZ1ti1eUsl/y6J1Hwfnh8V1eqVT6O/oOw7okCUBPPcQjmwQvXiA28rLylFSxazq/F AV7rNsGOA+4CeNcmzLVBRx45v1Yepzf0MS5n9oD3UOxXHf4/a1g+ogVKB079rAl7QBcGIC tVKeC/iPbHGv5xAyd7clWziTAXKQntAFH/1O2+CnXaodKZbFypO1xMfdG6kzAA== 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=1693666057; 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=V+G3xrlvjQAeNxiB0sPDsORLXzT5rzQW6+Tgy/84eIk=; b=pnnKwFvMMDED+AWEUk+mDoAYr8zh2IkiPAYhw94i6x8+piQ+V+b9R/AdfFCzBZsuQtP2Wt 6j3Eqffc+K61TzcmoHIdtdJ78V0CgB68z0gCpSSCaTxT/aMiCsXnpYCoDoX/asqqdmdDfK sI9Ero0ua/bCeSGOYajccWf6w32Nl8ApUHjxDrjhIsB7DeOxdWBmOtfUfjHqHc2ykEsRMQ Wj4mHmKhf4SiSqPWJyI1g2rkzvGv5y7yWm6rI1Wcm0BTjDqYKG3SkhC/STA7mX0Lm6QRvs gSAtfbSGvd3M9wioQzhodtcTg5QFuMr1/50pyxWr5QjCmMQiVb278B1lVvZd0A== 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 4RdHn51VLgzmp5; Sat, 2 Sep 2023 14:47:37 +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 382Elb63044602; Sat, 2 Sep 2023 14:47:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 382Elbs5044599; Sat, 2 Sep 2023 14:47:37 GMT (envelope-from git) Date: Sat, 2 Sep 2023 14:47:37 GMT Message-Id: <202309021447.382Elbs5044599@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: 32988c1499f8 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 32988c1499f8698b41e15ed40a46d271e757bba3 Auto-Submitted: auto-generated The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=32988c1499f8698b41e15ed40a46d271e757bba3 commit 32988c1499f8698b41e15ed40a46d271e757bba3 Author: Mateusz Guzik AuthorDate: 2023-09-02 14:27:33 +0000 Commit: Mateusz Guzik CommitDate: 2023-09-02 14:45:27 +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. --- 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);