Module Name: src
Committed By: christos
Date: Fri Jan 14 19:19:35 UTC 2022
Modified Files:
src/sys/nfs: nfs_clntsubs.c
Log Message:
This is a temporary hack to avoid nfs crashes related to nfs_delaytruncate.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_clntsubs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.4 src/sys/nfs/nfs_clntsubs.c:1.5
--- src/sys/nfs/nfs_clntsubs.c:1.4 Sun Feb 23 10:46:41 2020
+++ src/sys/nfs/nfs_clntsubs.c Fri Jan 14 14:19:34 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_clntsubs.c,v 1.4 2020/02/23 15:46:41 ad Exp $ */
+/* $NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.4 2020/02/23 15:46:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_nfs.h"
@@ -360,9 +360,20 @@ nfs_delayedtruncate(struct vnode *vp)
np->n_flag &= ~NTRUNCDELAYED;
genfs_node_wrlock(vp);
rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
+
+ /*
+ * This is disgusting but we can be called from VOP_UNLOCK
+ * where the interlock is sometimes held, and we want to
+ * make sure that it is unlocked when we call VOP_PUTPAGES
+ * and uvm_vnp_setsize.
+ */
+ int got = mutex_tryenter(vp->v_interlock);
+ mutex_exit(vp->v_interlock);
(void)VOP_PUTPAGES(vp, 0,
0, PGO_SYNCIO | PGO_CLEANIT | PGO_FREE | PGO_ALLPAGES);
uvm_vnp_setsize(vp, np->n_size);
+ if (!got)
+ mutex_enter(vp->v_interlock);
genfs_node_unlock(vp);
}
}