From nobody Tue Mar 15 21:15:34 2022 X-Original-To: dev-commits-src-branches@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 30B501A24BCB; Tue, 15 Mar 2022 21:15:35 +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 4KJ5m70K2Mz3JfW; Tue, 15 Mar 2022 21:15:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647378935; 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=W4ep/MOBTSe8sp9v2z0svAVDLma/9g0qY2oKKPjvzHk=; b=W+lcja7ivg+X9s4ZOrHD0m8j7CnZPdzkIiHNyAViknJ7TO0xd91QPAex3fQan82RFnNJl1 dwgIwGFi5zGrzMYBkdjhv9VtgMJoNTEgwce7C3cNfk3X3OmAGD/TTgNIXo5NwuCDh8PXej ObFeviiRQQDKnctVEq3ThNVmaORx7Vj7go7Vcud2hBgyO/g34JKYwOmXfX2XpQ9CEod+ZJ 5eoS1q6F52k1MrD9PztTghnzOAXNLUKVhoTBNamFzl5fXo4FRrpxB0MU0W2i0p9UgbyuQC fg3jFnAL0T3W1dbEqMSn/KfudiP2x5sbdNfD1cfz6ifbRgNj4GAgNnX57nAEhg== 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 DF230AFC; Tue, 15 Mar 2022 21:15:34 +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 22FLFYVX018616; Tue, 15 Mar 2022 21:15:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22FLFY9d018615; Tue, 15 Mar 2022 21:15:34 GMT (envelope-from git) Date: Tue, 15 Mar 2022 21:15:34 GMT Message-Id: <202203152115.22FLFY9d018615@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: aa49e413a866 - stable/13 - vfs: [1/2] fix stalls in vnode reclaim by not requeieing from vnlru List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: aa49e413a8661c4a855fa798094c8ae19b9fe6c9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647378935; 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=W4ep/MOBTSe8sp9v2z0svAVDLma/9g0qY2oKKPjvzHk=; b=RA4cTpR7Q8T3V5cKiTiCr1Y5I3nunZ9Mr7TOyqlLIvNWKdZwF1TwHypLYi5vjKNd9gB9Qp fOsP1Q+XlXIjepBsQkPxyEysc4DrYX2oBVlcowS8c1DOU5zg4a7i/k5nZaGXFNPI2jas88 n36SdMvYSasNiD+aNRT0cjpn/OTUVJ0dmQ7Y5gMpnXA5MhNHarOQvIC5FzzBF6ndAZP90N fz8pj3TLEECbajCHlJPO55fxVid1EWTMnoj8dybz5iBC1m3zSVErIIIKdTnNcknJlS7VgS 5+w/Fpgz10+LE76tT1s1Sa/X0zw19ISQWSOCL26ankawlDIraBQv0m0uA9xa7Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647378935; a=rsa-sha256; cv=none; b=XtzuDK58B5pHRwwyK3/Ltp4AcchCvbkOJhbssCm/DIWz2UvjI4eh1ux2M0ZOw21WD7NHF0 pvshEkwaehvavcCXRD4HcbLfLAieOy9nH9mKSRHT4D4nhQoom9obkF1Fad4jm3o4r7Ndr0 FzRraZLDF27WSlHS88kcPNPMYlJRRuFDR4d2OrO7x7teZs/Mhxka+n3U3Y4M+SbqQPMP3Q intGGSOgjl1hA/KkJrk19tOjldxY0G4uzVPTiWOVc9Nt6ZV4YgYwD7dQxHZUImHVSLfSzD 79xMbCK1Nkpu1zAK7SgttdI/BUuXh/nkfToSfI1BqSTQR+GX0qsdv/puKaGdLQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=aa49e413a8661c4a855fa798094c8ae19b9fe6c9 commit aa49e413a8661c4a855fa798094c8ae19b9fe6c9 Author: Mateusz Guzik AuthorDate: 2022-03-07 10:33:59 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-15 21:12:43 +0000 vfs: [1/2] fix stalls in vnode reclaim by not requeieing from vnlru Reported by: pho (cherry picked from commit c35ec1efdcb2978bc3b6a0098c2b412be8d33e39) --- sys/kern/vfs_subr.c | 55 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index a7a432d31a55..5c5faf455f2b 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -113,6 +113,8 @@ static void vn_seqc_init(struct vnode *); static void vn_seqc_write_end_free(struct vnode *vp); static void vgonel(struct vnode *); static bool vhold_recycle_free(struct vnode *); +static void vdropl_recycle(struct vnode *vp); +static void vdrop_recycle(struct vnode *vp); static void vfs_knllock(void *arg); static void vfs_knlunlock(void *arg); static void vfs_knl_assert_lock(void *arg, int what); @@ -1203,11 +1205,11 @@ restart: mtx_unlock(&vnode_list_mtx); if (vn_start_write(vp, &mp, V_NOWAIT) != 0) { - vdrop(vp); + vdrop_recycle(vp); goto next_iter_unlocked; } if (VOP_LOCK(vp, LK_EXCLUSIVE|LK_NOWAIT) != 0) { - vdrop(vp); + vdrop_recycle(vp); vn_finished_write(mp); goto next_iter_unlocked; } @@ -1218,14 +1220,14 @@ restart: (vp->v_object != NULL && vp->v_object->handle == vp && vp->v_object->resident_page_count > trigger)) { VOP_UNLOCK(vp); - vdropl(vp); + vdropl_recycle(vp); vn_finished_write(mp); goto next_iter_unlocked; } counter_u64_add(recycles_count, 1); vgonel(vp); VOP_UNLOCK(vp); - vdropl(vp); + vdropl_recycle(vp); vn_finished_write(mp); done++; next_iter_unlocked: @@ -1636,7 +1638,7 @@ vtryrecycle(struct vnode *vp) CTR2(KTR_VFS, "%s: impossible to recycle, vp %p lock is already held", __func__, vp); - vdrop(vp); + vdrop_recycle(vp); return (EWOULDBLOCK); } /* @@ -1647,7 +1649,7 @@ vtryrecycle(struct vnode *vp) CTR2(KTR_VFS, "%s: impossible to recycle, cannot start the write for %p", __func__, vp); - vdrop(vp); + vdrop_recycle(vp); return (EBUSY); } /* @@ -1659,7 +1661,7 @@ vtryrecycle(struct vnode *vp) VI_LOCK(vp); if (vp->v_usecount) { VOP_UNLOCK(vp); - vdropl(vp); + vdropl_recycle(vp); vn_finished_write(vnmp); CTR2(KTR_VFS, "%s: impossible to recycle, %p is already referenced", @@ -1671,7 +1673,7 @@ vtryrecycle(struct vnode *vp) vgonel(vp); } VOP_UNLOCK(vp); - vdropl(vp); + vdropl_recycle(vp); vn_finished_write(vnmp); return (0); } @@ -3624,8 +3626,8 @@ vdrop(struct vnode *vp) vdropl(vp); } -void -vdropl(struct vnode *vp) +static void __always_inline +vdropl_impl(struct vnode *vp, bool enqueue) { ASSERT_VI_LOCKED(vp, __func__); @@ -3653,6 +3655,39 @@ vdropl(struct vnode *vp) vdbatch_enqueue(vp); } +void +vdropl(struct vnode *vp) +{ + + vdropl_impl(vp, true); +} + +/* + * vdrop a vnode when recycling + * + * This is a special case routine only to be used when recycling, differs from + * regular vdrop by not requeieing the vnode on LRU. + * + * Consider a case where vtryrecycle continuously fails with all vnodes (due to + * e.g., frozen writes on the filesystem), filling the batch and causing it to + * be requeued. Then vnlru will end up revisiting the same vnodes. This is a + * loop which can last for as long as writes are frozen. + */ +static void +vdropl_recycle(struct vnode *vp) +{ + + vdropl_impl(vp, false); +} + +static void +vdrop_recycle(struct vnode *vp) +{ + + VI_LOCK(vp); + vdropl_recycle(vp); +} + /* * Call VOP_INACTIVE on the vnode and manage the DOINGINACT and OWEINACT * flags. DOINGINACT prevents us from recursing in calls to vinactive.