Module Name:    src
Committed By:   manu
Date:           Thu Sep 11 04:05:52 UTC 2014

Modified Files:
        src/lib/libperfuse: ops.c

Log Message:
Avoid a file resize serialization deadlock when writing with
PUFFS_IO_APPEND flag. The symptom was a hang when appending to
a file with a null size.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/lib/libperfuse/ops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libperfuse/ops.c
diff -u src/lib/libperfuse/ops.c:1.73 src/lib/libperfuse/ops.c:1.74
--- src/lib/libperfuse/ops.c:1.73	Fri Sep  5 15:20:16 2014
+++ src/lib/libperfuse/ops.c	Thu Sep 11 04:05:52 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.73 2014/09/05 15:20:16 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.74 2014/09/11 04:05:52 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3198,16 +3198,6 @@ perfuse_node_write2(struct puffs_usermou
 		requeue_request(pu, opc, PCQ_WRITE);
 	pnd->pnd_flags |= PND_INWRITE;
 
-	/* 
-	 * Serialize size access, see comment in perfuse_node_setattr().
-	 */
-	if ((u_quad_t)offset + *resid > vap->va_size) {
-		while (pnd->pnd_flags & PND_INRESIZE)
-			requeue_request(pu, opc, PCQ_RESIZE);
-		pnd->pnd_flags |= PND_INRESIZE;
-		inresize = 1;
-	}
-
 	/*
 	 * append flag: re-read the file size so that 
 	 * we get the latest value.
@@ -3219,6 +3209,16 @@ perfuse_node_write2(struct puffs_usermou
 		offset = vap->va_size;
 	}
 
+	/* 
+	 * Serialize size access, see comment in perfuse_node_setattr().
+	 */
+	if ((u_quad_t)offset + *resid > vap->va_size) {
+		while (pnd->pnd_flags & PND_INRESIZE)
+			requeue_request(pu, opc, PCQ_RESIZE);
+		pnd->pnd_flags |= PND_INRESIZE;
+		inresize = 1;
+	}
+
 #ifdef PERFUSE_DEBUG
 	if (perfuse_diagflags & PDF_RESIZE)
 		DPRINTF(">> %s %p %" PRIu64 "\n", __func__,

Reply via email to