All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH lttng-tools] kernel consumer should empty the input splice pipe
@ 2012-07-10  0:09 Mathieu Desnoyers
  0 siblings, 0 replies; only message in thread
From: Mathieu Desnoyers @ 2012-07-10  0:09 UTC (permalink / raw)
  To: dgoulet, jdesfossez; +Cc: lttng-dev

When the splice pipe output cannot push all the data placed into the
pipe by the first splice call, we should continue writing data out to
the output file descriptor until we reach the amount of data that was
placed into the pipe.

This is probably the cause of the network streaming issues currently
encountered.

Testing is welcome.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
---
diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c
index bbc31f8..cc16f9f 100644
--- a/src/common/kernel-consumer/kernel-consumer.c
+++ b/src/common/kernel-consumer/kernel-consumer.c
@@ -101,6 +101,8 @@ ssize_t lttng_kconsumer_on_read_subbuffer_splice(
 	int outfd = stream->out_fd;
 
 	while (len > 0) {
+		ssize_t tosplice;
+
 		DBG("splice chan to pipe offset %lu (fd : %d)",
 				(unsigned long)offset, fd);
 		ret = splice(fd, &offset, ctx->consumer_thread_pipe[1], NULL, len,
@@ -111,20 +113,28 @@ ssize_t lttng_kconsumer_on_read_subbuffer_splice(
 			perror("Error in relay splice");
 			goto splice_error;
 		}
-
-		ret = splice(ctx->consumer_thread_pipe[0], NULL, outfd, NULL, ret,
-				SPLICE_F_MOVE | SPLICE_F_MORE);
-		DBG("splice pipe to file %zd", ret);
-		if (ret < 0) {
-			errno = -ret;
-			perror("Error in file splice");
-			goto splice_error;
+		tosplice = ret;
+		len -= tosplice;
+
+		while (tosplice > 0) {
+			ret = splice(ctx->consumer_thread_pipe[0], NULL, outfd,
+					NULL, tosplice,
+					SPLICE_F_MOVE | SPLICE_F_MORE);
+			DBG("splice pipe to file %zd", ret);
+			if (ret < 0) {
+				errno = -ret;
+				perror("Error in file splice");
+				goto splice_error;
+			}
+			tosplice -= ret;
+			/*
+			 * This won't block, but will start writeout
+			 * asynchronously.
+			 */
+			lttng_sync_file_range(outfd, stream->out_fd_offset, ret,
+					SYNC_FILE_RANGE_WRITE);
+			stream->out_fd_offset += ret;
 		}
-		len -= ret;
-		/* This won't block, but will start writeout asynchronously */
-		lttng_sync_file_range(outfd, stream->out_fd_offset, ret,
-				SYNC_FILE_RANGE_WRITE);
-		stream->out_fd_offset += ret;
 	}
 	lttng_consumer_sync_trace_file(stream, orig_offset);
 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-10  0:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-10  0:09 [RFC PATCH lttng-tools] kernel consumer should empty the input splice pipe Mathieu Desnoyers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.