Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libperfuse Avoid a file resize serialization deadlock wh...



details:   https://anonhg.NetBSD.org/src/rev/26329c067eb7
branches:  trunk
changeset: 332202:26329c067eb7
user:      manu <manu%NetBSD.org@localhost>
date:      Thu Sep 11 04:05:52 2014 +0000

description:
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.

diffstat:

 lib/libperfuse/ops.c |  22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diffs (43 lines):

diff -r ce5108f4c8d9 -r 26329c067eb7 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Thu Sep 11 02:21:19 2014 +0000
+++ b/lib/libperfuse/ops.c      Thu Sep 11 04:05:52 2014 +0000
@@ -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 @@
                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 @@
                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__,



Home | Main Index | Thread Index | Old Index