[OpenAFS-devel] reproducible problem during cache flush

chas williams chas@cmf.nrl.navy.mil
Thu, 01 Aug 2002 12:32:49 -0400


just to beat this problem to death but as mentioned previously the
current fix provides somewhat poor performance on writes.  the following
should perform better.  its based on what the solaris client does.
the writepage checks to see if there are too many dirty blocks and
calls DoPartialWrite.  btw, should we grab avc->lock before the
afs_write()?

Index: src/afs/VNOPS/afs_vnop_write.c
===================================================================
RCS file: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v
retrieving revision 1.8.2.8
diff -u -d -b -w -r1.8.2.8 afs_vnop_write.c
--- src/afs/VNOPS/afs_vnop_write.c	2002/07/30 21:35:53	1.8.2.8
+++ src/afs/VNOPS/afs_vnop_write.c	2002/08/01 16:26:16
@@ -283,7 +283,7 @@
 	if (filePos > avc->m.Length)
 	    avc->m.Length = filePos;
 #endif
-#if !defined(AFS_VM_RDWR_ENV) || defined(AFS_LINUX22_ENV)
+#if !defined(AFS_VM_RDWR_ENV)
 	/*
 	 * If write is implemented via VM, afs_DoPartialWrite() is called from
 	 * the high-level write op.
@@ -580,7 +580,7 @@
 	}
 #endif
 	osi_UFSClose(tfile);
-#if !defined(AFS_VM_RDWR_ENV) || defined(AFS_LINUX22_ENV)
+#if !defined(AFS_VM_RDWR_ENV)
 	/*
 	 * If write is implemented via VM, afs_DoPartialWrite() is called from
 	 * the high-level write op.
Index: src/afs/LINUX/osi_vnodeops.c
===================================================================
RCS file: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v
retrieving revision 1.29.2.16
diff -u -d -b -w -r1.29.2.16 osi_vnodeops.c
--- src/afs/LINUX/osi_vnodeops.c	2002/07/30 21:27:18	1.29.2.16
+++ src/afs/LINUX/osi_vnodeops.c	2002/08/01 16:26:16
@@ -1391,7 +1391,7 @@
     struct vcache *vcp = ITOAFS(ip);
     char *buffer;
     loff_t base;
-    int code = 0;
+    int code = 0, code2 = 0;
     cred_t *credp;
     uio_t tuio;
     struct iovec iovec;
@@ -1405,13 +1405,27 @@
               ICL_TYPE_POINTER, pp,
               ICL_TYPE_INT32, atomic_read(&pp->count),
               ICL_TYPE_INT32, 99999);
+
     setup_uio(&tuio, &iovec, buffer, base, count, UIO_WRITE, AFS_UIOSYS);
 
     code = afs_write(vcp, &tuio, f_flags, credp, 0);
 
     vcache2inode(vcp);
 
+    if (!code && afs_stats_cmperf.cacheCurrDirtyChunks > afs_stats_cmperf.cacheMaxDirtyChunks) {
+	struct vrequest treq;
+	int code2 = 0;
+
+        ObtainWriteLock(&vcp->lock, 533);
+	if (!afs_InitReq(&treq, credp))
+		code2 = afs_DoPartialWrite(vcp, &treq);
+        ReleaseWriteLock(&vcp->lock);
+    }
+    if (code2)
+	code = -code2;
+    else
     code = code ? -code : count - tuio.uio_resid;
+
     afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
               ICL_TYPE_POINTER, pp,
               ICL_TYPE_INT32, atomic_read(&pp->count),