From owner-dev-commits-src-all@freebsd.org Fri Feb 12 01:07:32 2021 Return-Path: Delivered-To: dev-commits-src-all@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 0A01253D889; Fri, 12 Feb 2021 01:07:32 +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 4DcFhz2yzTz3NPT; Fri, 12 Feb 2021 01:07:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 71F8A1B224; Fri, 12 Feb 2021 01:07:27 +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 11C17RMB070868; Fri, 12 Feb 2021 01:07:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11C17ROP070867; Fri, 12 Feb 2021 01:07:27 GMT (envelope-from git) Date: Fri, 12 Feb 2021 01:07:27 GMT Message-Id: <202102120107.11C17ROP070867@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 28703d27130c - main - ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 28703d27130c9cb7e7830ff53155c379a502c248 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2021 01:07:32 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=28703d27130c9cb7e7830ff53155c379a502c248 commit 28703d27130c9cb7e7830ff53155c379a502c248 Author: Konstantin Belousov AuthorDate: 2021-01-31 18:39:49 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-12 01:02:22 +0000 ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage Such vnodes prevent inode reuse, and should be force-cleared when ffs_valloc() is unable to find a free inode. Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- sys/ufs/ffs/ffs_softdep.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ sys/ufs/ffs/softdep.h | 2 ++ 2 files changed, 63 insertions(+) diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 8c52139687f9..786fb43c7d81 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1311,6 +1311,7 @@ static int softdep_flushcache = 0; /* Should we do BIO_FLUSH? */ */ static int stat_flush_threads; /* number of softdep flushing threads */ static int stat_worklist_push; /* number of worklist cleanups */ +static int stat_delayed_inact; /* number of delayed inactivation cleanups */ static int stat_blk_limit_push; /* number of times block limit neared */ static int stat_ino_limit_push; /* number of times inode limit neared */ static int stat_blk_limit_hit; /* number of times block slowdown imposed */ @@ -1344,6 +1345,8 @@ SYSCTL_INT(_debug_softdep, OID_AUTO, flush_threads, CTLFLAG_RD, &stat_flush_threads, 0, ""); SYSCTL_INT(_debug_softdep, OID_AUTO, worklist_push, CTLFLAG_RW | CTLFLAG_STATS, &stat_worklist_push, 0,""); +SYSCTL_INT(_debug_softdep, OID_AUTO, delayed_inactivations, CTLFLAG_RD, + &stat_delayed_inact, 0, ""); SYSCTL_INT(_debug_softdep, OID_AUTO, blk_limit_push, CTLFLAG_RW | CTLFLAG_STATS, &stat_blk_limit_push, 0,""); SYSCTL_INT(_debug_softdep, OID_AUTO, ino_limit_push, @@ -13707,6 +13710,37 @@ softdep_slowdown(vp) return (1); } +static int +softdep_request_cleanup_filter(struct vnode *vp, void *arg __unused) +{ + return ((vp->v_iflag & VI_OWEINACT) != 0 && vp->v_usecount == 0 && + ((vp->v_vflag & VV_NOSYNC) != 0 || VTOI(vp)->i_effnlink == 0)); +} + +static void +softdep_request_cleanup_inactivate(struct mount *mp) +{ + struct vnode *vp, *mvp; + int error; + + MNT_VNODE_FOREACH_LAZY(vp, mp, mvp, softdep_request_cleanup_filter, + NULL) { + vholdl(vp); + vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK | LK_RETRY); + VI_LOCK(vp); + if (vp->v_data != NULL && vp->v_usecount == 0) { + while ((vp->v_iflag & VI_OWEINACT) != 0) { + error = vinactive(vp); + if (error != 0 && error != ERELOOKUP) + break; + } + atomic_add_int(&stat_delayed_inact, 1); + } + VOP_UNLOCK(vp); + vdropl(vp); + } +} + /* * Called by the allocation routines when they are about to fail * in the hope that we can free up the requested resource (inodes @@ -13819,6 +13853,33 @@ retry: stat_worklist_push += 1; FREE_LOCK(ump); } + + /* + * Check that there are vnodes pending inactivation. As they + * have been unlinked, inactivating them will free up their + * inodes. + */ + ACQUIRE_LOCK(ump); + if (resource == FLUSH_INODES_WAIT && + fs->fs_cstotal.cs_nifree <= needed && + fs->fs_pendinginodes <= needed) { + if ((ump->um_softdep->sd_flags & FLUSH_DI_ACTIVE) == 0) { + ump->um_softdep->sd_flags |= FLUSH_DI_ACTIVE; + FREE_LOCK(ump); + softdep_request_cleanup_inactivate(mp); + ACQUIRE_LOCK(ump); + ump->um_softdep->sd_flags &= ~FLUSH_DI_ACTIVE; + wakeup(&ump->um_softdep->sd_flags); + } else { + while ((ump->um_softdep->sd_flags & + FLUSH_DI_ACTIVE) != 0) { + msleep(&ump->um_softdep->sd_flags, + LOCK_PTR(ump), PVM, "ffsvina", hz); + } + } + } + FREE_LOCK(ump); + /* * If we still need resources and there are no more worklist * entries to process to obtain them, we have to start flushing diff --git a/sys/ufs/ffs/softdep.h b/sys/ufs/ffs/softdep.h index 868ada00f2dc..3493aadafc98 100644 --- a/sys/ufs/ffs/softdep.h +++ b/sys/ufs/ffs/softdep.h @@ -1086,6 +1086,8 @@ struct mount_softdeps { #define FLUSH_CLEANUP 0x0002 /* need to clear out softdep structures */ #define FLUSH_STARTING 0x0004 /* flush thread not yet started */ #define FLUSH_RC_ACTIVE 0x0008 /* a thread is flushing the mount point */ +#define FLUSH_DI_ACTIVE 0x0010 /* a thread is processing delayed + inactivations */ /* * Keep the old names from when these were in the ufsmount structure.