From nobody Wed Oct 04 12:09:00 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 4S0tlK2vSlz4vp90; Wed, 4 Oct 2023 12:09:01 +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 4S0tlJ6brqz3JVX; Wed, 4 Oct 2023 12:09:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696421340; 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=ZLfdZ0njH2L1zL6QPRIlsbzydtKUoGhXXCiegzEf5OU=; b=smSte5hmJsG0jt+8pNV5n4qT0x4v/yu/MoVvAzg2GzwLDgf6XyF06boVO4x7rw3EzgyTVI ahwL+1nhXQqdzDQ/Flk37CzFjJnribOFa9IfP20ID+Hcu+7W8pGcfxokzBEcXQbJCky5VL S9H1RWP9QbfDlF4UC5AZAqSHLXYUaOhVDPmWC++G7g9DJYimb3bDL7VCxucVbiMvDjoSjQ zxBjHBLZywIUws44IirhKqHvQfC2hxVM1F0X3uBhVbvgKUwVhpEZ7cGVnZeIRgwQauMIMs TswVxkteBOQ3LlI7j/Xoo2+87mJ6VKCAineFcWAt6RMvtY3gfFbjCCMnktZkbg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696421340; a=rsa-sha256; cv=none; b=A+jZJAm4eT7e82pOVG3UgP51vi5v2Loo1W+QxEtK5sbZidICe197tt3xW7jviZ31JSw0Lx tG8oERTq/KR/JLLWAF4Iq5gRvK1ZxBl8r4KZBg0CmxvMUjBi1FDFHa8Y2IP0s75ZT0Wr8c Uhl4mTqgqMqpxoufMtVR5dFKffHDvm/5x364UioHEpBu+igGYXth/qhElq6zb85st2vU6s F/RF4fT9LZFh/yms2DzB5kaAeS8111w8nUK5Wmn0SQP7TP1AjH5n3ZSIudavDTHzqmFF2G rhh6Lmh+Fs3oBmHNnZ+4qdLz3hey1ocerRxd1L4ZQkFT+HnomjfKkToe9vlrrA== 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=1696421340; 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=ZLfdZ0njH2L1zL6QPRIlsbzydtKUoGhXXCiegzEf5OU=; b=IEl4BKeb0bAO8mmxmKbzgWZZCTN/CN0vUkDsUPByCgBeq831rG1bsCdGujXkDQYGAXd//d v0ZXw8BpjhoBZb5eE0H5SJrxyO1XonSp2Y9+ag8lT58OqaQUkpagXCzoh+a5XIwP+bfImy aeC6w9LmCQGnPV0d4jgN2vRTNQdezE1IfH6/GmiIDuxV73WB9azyQOcuCijLj8ql2ZWj+G shnN4ny47YPU86byb1qDxNKwYeaUtmnckn7Ur03tcKN5DgS4T6sa06WZbR6D8SrB9Cc2nE vVN7bDoPOR4DUAvTXUvz7arUlaW9CgLk6lX5YYN3r8megvTXKXdwVU/QCUn3EQ== 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 4S0tlJ5jhxzcgW; Wed, 4 Oct 2023 12:09:00 +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 394C90ml053628; Wed, 4 Oct 2023 12:09:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 394C900T053625; Wed, 4 Oct 2023 12:09:00 GMT (envelope-from git) Date: Wed, 4 Oct 2023 12:09:00 GMT Message-Id: <202310041209.394C900T053625@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: 8d5b00a5713d - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 8d5b00a5713d91c18fa726fe832fb4df3751b419 Auto-Submitted: auto-generated The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=8d5b00a5713d91c18fa726fe832fb4df3751b419 commit 8d5b00a5713d91c18fa726fe832fb4df3751b419 Author: Mateusz Guzik AuthorDate: 2023-09-02 14:27:33 +0000 Commit: Mateusz Guzik CommitDate: 2023-10-04 12:05:58 +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. (cherry picked from commit 32988c1499f8698b41e15ed40a46d271e757bba3) --- 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 62698cdb2141..151d0d2ac8a1 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2601,10 +2601,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; @@ -2620,7 +2620,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; @@ -2766,7 +2766,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);