From owner-svn-src-head@freebsd.org Tue Oct 27 18:13:10 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5E61E456C3F; Tue, 27 Oct 2020 18:13:10 +0000 (UTC) (envelope-from mjg@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CLKZG1nylz40C1; Tue, 27 Oct 2020 18:13:10 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2173AF93E; Tue, 27 Oct 2020 18:13:10 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09RID9Bc041757; Tue, 27 Oct 2020 18:13:09 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09RID9g2041756; Tue, 27 Oct 2020 18:13:09 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202010271813.09RID9g2041756@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Tue, 27 Oct 2020 18:13:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367090 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 367090 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2020 18:13:10 -0000 Author: mjg Date: Tue Oct 27 18:13:09 2020 New Revision: 367090 URL: https://svnweb.freebsd.org/changeset/base/367090 Log: vfs: tidy up vnlru_free Apart from cosmeatic changes make sure to only decrease the recycled counter if vtryrecycle succeeded. Tested by: pho Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Tue Oct 27 18:12:07 2020 (r367089) +++ head/sys/kern/vfs_subr.c Tue Oct 27 18:13:09 2020 (r367090) @@ -1226,9 +1226,11 @@ vnlru_free_locked(int count, struct vfsops *mnt_op) count = max_vnlru_free; ocount = count; mvp = vnode_list_free_marker; -restart: vp = mvp; - while (count > 0) { + for (;;) { + if (count == 0) { + break; + } vp = TAILQ_NEXT(vp, v_vnodelist); if (__predict_false(vp == NULL)) { TAILQ_REMOVE(&vnode_list, mvp, v_vnodelist); @@ -1237,17 +1239,16 @@ restart: } if (__predict_false(vp->v_type == VMARKER)) continue; - + if (vp->v_holdcnt > 0) + continue; /* * Don't recycle if our vnode is from different type * of mount point. Note that mp is type-safe, the * check does not reach unmapped address even if * vnode is reclaimed. - * Don't recycle if we can't get the interlock without - * blocking. */ - if (vp->v_holdcnt > 0 || (mnt_op != NULL && (mp = vp->v_mount) != NULL && - mp->mnt_op != mnt_op)) { + if (mnt_op != NULL && (mp = vp->v_mount) != NULL && + mp->mnt_op != mnt_op) { continue; } if (__predict_false(vp->v_type == VBAD || vp->v_type == VNON)) { @@ -1257,11 +1258,11 @@ restart: continue; TAILQ_REMOVE(&vnode_list, mvp, v_vnodelist); TAILQ_INSERT_AFTER(&vnode_list, vp, mvp, v_vnodelist); - count--; mtx_unlock(&vnode_list_mtx); - vtryrecycle(vp); + if (vtryrecycle(vp) == 0) + count--; mtx_lock(&vnode_list_mtx); - goto restart; + vp = mvp; } return (ocount - count); }