Index: sys/nfs/nfs_bio.c =================================================================== RCS file: /home/netbsd/src/sys/nfs/nfs_bio.c,v retrieving revision 1.193 diff -p -u -r1.193 nfs_bio.c --- sys/nfs/nfs_bio.c 15 Jan 2020 17:55:44 -0000 1.193 +++ sys/nfs/nfs_bio.c 20 Feb 2020 07:13:56 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_bio.c,v 1.193 2020/01/15 17:55:44 ad Exp $ */ +/* $NetBSD: nfs_bio.c,v 1.188.2.1 2011/11/02 21:53:59 yamt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -1057,6 +1057,8 @@ again: nfs_merge_commit_ranges(vp); } else { nfs_add_committed_range(vp, off, cnt); + nfs_del_tobecommitted_range(vp, off, + cnt); } } } else { @@ -1098,6 +1100,7 @@ again: */ mutex_enter(&np->n_commitlock); nfs_add_tobecommitted_range(vp, off, cnt); + nfs_del_committed_range(vp, off, cnt); /* * if there can be too many uncommitted pages, commit them now. */ @@ -1133,7 +1136,7 @@ again: * pages are now on stable storage. */ mutex_enter(&np->n_commitlock); - nfs_del_committed_range(vp, off, cnt); + nfs_del_tobecommitted_range(vp, off, cnt); mutex_exit(&np->n_commitlock); mutex_enter(uobj->vmobjlock); for (i = 0; i < npages; i++) { Index: sys/nfs/nfs_subs.c =================================================================== RCS file: /home/netbsd/src/sys/nfs/nfs_subs.c,v retrieving revision 1.236 diff -p -u -r1.236 nfs_subs.c --- sys/nfs/nfs_subs.c 15 Dec 2019 21:11:34 -0000 1.236 +++ sys/nfs/nfs_subs.c 20 Feb 2020 07:15:31 -0000 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_subs.c,v 1.236 2019/12/15 21:11:34 ad Exp $ */ +/* $NetBSD: nfs_subs.c,v 1.221.2.1 2011/11/02 21:53:59 yamt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -1760,8 +1760,6 @@ nfs_clearcommit_selector(void *cl, struc np = VTONFS(vp); if (vp->v_type != VREG || vp->v_mount != c->mp || np == NULL) return false; - np->n_pushlo = np->n_pushhi = np->n_pushedlo = - np->n_pushedhi = 0; np->n_commitflags &= ~(NFS_COMMIT_PUSH_VALID | NFS_COMMIT_PUSHED_VALID); uvm_page_array_init(&a); @@ -1809,19 +1807,7 @@ nfs_merge_commit_ranges(struct vnode *vp struct nfsnode *np = VTONFS(vp); KASSERT(np->n_commitflags & NFS_COMMIT_PUSH_VALID); - - if (!(np->n_commitflags & NFS_COMMIT_PUSHED_VALID)) { - np->n_pushedlo = np->n_pushlo; - np->n_pushedhi = np->n_pushhi; - np->n_commitflags |= NFS_COMMIT_PUSHED_VALID; - } else { - if (np->n_pushlo < np->n_pushedlo) - np->n_pushedlo = np->n_pushlo; - if (np->n_pushhi > np->n_pushedhi) - np->n_pushedhi = np->n_pushhi; - } - - np->n_pushlo = np->n_pushhi = 0; + nfs_add_committed_range(vp, np->n_pushlo, np->n_pushhi - np->n_pushlo); np->n_commitflags &= ~NFS_COMMIT_PUSH_VALID; #ifdef NFS_DEBUG_COMMIT @@ -1872,11 +1858,15 @@ nfs_add_committed_range(struct vnode *vp np->n_pushedhi = hi; np->n_commitflags |= NFS_COMMIT_PUSHED_VALID; } else { - if (hi > np->n_pushedhi) + /* + * note that it's unsafe to add more than requested. + */ + if (hi > np->n_pushedhi && lo <= np->n_pushedhi) np->n_pushedhi = hi; - if (lo < np->n_pushedlo) + if (lo < np->n_pushedlo && hi >= np->n_pushedlo) np->n_pushedlo = lo; } + KASSERT(np->n_pushedhi >= np->n_pushedlo); #ifdef NFS_DEBUG_COMMIT printf("add: committed: %u - %u\n", (unsigned)np->n_pushedlo, (unsigned)np->n_pushedhi); @@ -1912,6 +1902,9 @@ nfs_del_committed_range(struct vnode *vp else np->n_pushedlo = hi; } + if (np->n_pushedhi <= np->n_pushedlo) { + np->n_commitflags &= ~NFS_COMMIT_PUSHED_VALID; + } #ifdef NFS_DEBUG_COMMIT printf("del: committed: %u - %u\n", (unsigned)np->n_pushedlo, (unsigned)np->n_pushedhi); @@ -1937,6 +1930,7 @@ nfs_add_tobecommitted_range(struct vnode if (hi > np->n_pushhi) np->n_pushhi = hi; } + KASSERT(np->n_pushhi >= np->n_pushlo); #ifdef NFS_DEBUG_COMMIT printf("add: tobecommitted: %u - %u\n", (unsigned)np->n_pushlo, (unsigned)np->n_pushhi); @@ -1964,6 +1958,10 @@ nfs_del_tobecommitted_range(struct vnode np->n_pushhi = lo; else { /* + * following can cause a lot of small (eg. 64KB) commit rpcs. + */ +#if 0 + /* * XXX There's only one range. If the deleted range * is in the middle, pick the largest of the * contiguous ranges that it leaves. @@ -1972,6 +1970,10 @@ nfs_del_tobecommitted_range(struct vnode np->n_pushhi = lo; else np->n_pushlo = hi; +#endif + } + if (np->n_pushhi <= np->n_pushlo) { + np->n_commitflags &= ~NFS_COMMIT_PUSH_VALID; } #ifdef NFS_DEBUG_COMMIT printf("del: tobecommitted: %u - %u\n", (unsigned)np->n_pushlo,