]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - vss.c
vss: Don't prefault header.
[paraslash.git] / vss.c
diff --git a/vss.c b/vss.c
index e833543e785788876af91d691b73cf8876899de3..db1beeba17d080e08f306830bc0ce9dd0b7bf5e0 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -132,6 +132,7 @@ struct fec_group {
        uint16_t slice_bytes;
 };
 
+/** A FEC client is always in one of these states. */
 enum fec_client_state {
        FEC_STATE_NONE = 0,     /**< not initialized and not enabled */
        FEC_STATE_DISABLED,     /**< temporarily disabled */
@@ -1078,8 +1079,6 @@ static void vss_send(struct vss_task *vsst)
                        senders[i].send(mmd->current_chunk, mmd->chunks_sent,
                                buf, len, vsst->header_buf, vsst->header_len);
                }
-               mmd->chunks_sent++;
-               mmd->current_chunk++;
                /*
                 * Prefault next chunk(s)
                 *
@@ -1092,11 +1091,15 @@ static void vss_send(struct vss_task *vsst)
                 * eliminate the delays completely. Moreover, it is supported
                 * only on Linux. So we do our own read-ahead here.
                 */
-               buf += len;
-               for (i = 0; i < 5 && buf < vsst->map + mmd->size; i++) {
-                       __a_unused volatile char x = *buf;
-                       buf += 4096;
+               if (mmd->current_chunk > 0) { /* chunk 0 might be on the heap */
+                       buf += len;
+                       for (i = 0; i < 5 && buf < vsst->map + mmd->size; i++) {
+                               __a_unused volatile char x = *buf;
+                               buf += 4096;
+                       }
                }
+               mmd->chunks_sent++;
+               mmd->current_chunk++;
        }
 }