From 1814dddf208e92828e42a08e1b41505556db18d3 Mon Sep 17 00:00:00 2001 From: mckusick Date: Fri, 2 Feb 2018 01:28:14 +0000 Subject: [PATCH] MFC of 328444. Eliminate "fsync: giving up on dirty" messages. git-svn-id: svn://svn.freebsd.org/base/stable/10@328765 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/kern/vfs_default.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 166ed65b1..1cfa8bf3c 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -639,13 +639,21 @@ vop_stdfsync(ap) struct thread *a_td; } */ *ap; { - struct vnode *vp = ap->a_vp; - struct buf *bp; + struct vnode *vp; + struct buf *bp, *nbp; struct bufobj *bo; - struct buf *nbp; - int error = 0; - int maxretry = 1000; /* large, arbitrarily chosen */ + struct mount *mp; + int error, maxretry; + error = 0; + maxretry = 10000; /* large, arbitrarily chosen */ + vp = ap->a_vp; + mp = NULL; + if (vp->v_type == VCHR) { + VI_LOCK(vp); + mp = vp->v_rdev->si_mountpt; + VI_UNLOCK(vp); + } bo = &vp->v_bufobj; BO_LOCK(bo); loop1: @@ -688,6 +696,8 @@ vop_stdfsync(ap) bremfree(bp); bawrite(bp); } + if (maxretry < 1000) + pause("dirty", hz < 1000 ? 1 : hz / 1000); BO_LOCK(bo); goto loop2; } @@ -709,7 +719,8 @@ vop_stdfsync(ap) TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs) if ((error = bp->b_error) == 0) continue; - if (error == 0 && --maxretry >= 0) + if ((mp != NULL && mp->mnt_secondary_writes > 0) || + (error == 0 && --maxretry >= 0)) goto loop1; error = EAGAIN; } -- 2.45.0