server: add vectored fio_send_cmd_ext_pdu()

And use it for the multi segment continue type sending that
the iolog handler uses.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/server.c b/server.c
index 73e36a5..2da0c83 100644
--- a/server.c
+++ b/server.c
@@ -279,7 +279,7 @@
 	return cmdret;
 }
 
-void fio_net_cmd_crc_pdu(struct fio_net_cmd *cmd, void *pdu)
+void fio_net_cmd_crc_pdu(struct fio_net_cmd *cmd, const void *pdu)
 {
 	uint32_t pdu_len;
 
@@ -881,13 +881,33 @@
 	}
 }
 
+/*
+ * Send a command with a separate PDU, not inlined in the command
+ */
+static int fio_send_cmd_ext_pdu(int sk, uint16_t opcode, const void *buf,
+				off_t size, uint64_t tag, uint32_t flags)
+{
+	struct fio_net_cmd cmd;
+	struct iovec iov[2];
+
+	iov[0].iov_base = &cmd;
+	iov[0].iov_len = sizeof(cmd);
+	iov[1].iov_base = (void *) buf;
+	iov[1].iov_len = size;
+
+	__fio_init_net_cmd(&cmd, opcode, size, tag);
+	cmd.flags = __cpu_to_le32(flags);
+	fio_net_cmd_crc_pdu(&cmd, buf);
+
+	return fio_sendv_data(server_fd, iov, 2);
+}
+
 int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name)
 {
 	struct cmd_iolog_pdu pdu;
-	struct fio_net_cmd cmd;
 	z_stream stream;
 	void *out_pdu;
-	int i;
+	int i, ret = 0;
 
 	pdu.nr_samples = __cpu_to_le32(log->nr_samples);
 	pdu.log_type = cpu_to_le32(log->log_type);
@@ -914,24 +934,24 @@
 	stream.opaque = Z_NULL;
 
 	if (deflateInit(&stream, Z_DEFAULT_COMPRESSION) != Z_OK) {
-		free(out_pdu);
-		return 1;
+		ret = 1;
+		goto err;
 	}
 
 	/*
 	 * Send header first, it's not compressed.
 	 */
-	__fio_init_net_cmd(&cmd, FIO_NET_CMD_IOLOG, sizeof(pdu), 0);
-	cmd.flags = __cpu_to_le32(FIO_NET_CMD_F_MORE);
-	fio_net_cmd_crc_pdu(&cmd, &pdu);
-	fio_send_data(server_fd, &cmd, sizeof(cmd));
-	fio_send_data(server_fd, &pdu, sizeof(pdu));
+	ret = fio_send_cmd_ext_pdu(server_fd, FIO_NET_CMD_IOLOG, &pdu,
+					sizeof(pdu), 0, FIO_NET_CMD_F_MORE);
+	if (ret)
+		goto err_zlib;
 
 	stream.next_in = (void *) log->log;
 	stream.avail_in = log->nr_samples * sizeof(struct io_sample);
 
 	do {
-		unsigned int this_len;
+		unsigned int this_len, flags = 0;
+		int ret;
 
 		stream.avail_out = FIO_SERVER_MAX_FRAGMENT_PDU;
 		stream.next_out = out_pdu;
@@ -939,20 +959,20 @@
 
 		this_len = FIO_SERVER_MAX_FRAGMENT_PDU - stream.avail_out;
 
-		__fio_init_net_cmd(&cmd, FIO_NET_CMD_IOLOG, this_len, 0);
-
 		if (stream.avail_in)
-			cmd.flags = __cpu_to_le32(FIO_NET_CMD_F_MORE);
+			flags = FIO_NET_CMD_F_MORE;
 
-		fio_net_cmd_crc_pdu(&cmd, out_pdu);
-
-		fio_send_data(server_fd, &cmd, sizeof(cmd));
-		fio_send_data(server_fd, out_pdu, this_len);
+		ret = fio_send_cmd_ext_pdu(server_fd, FIO_NET_CMD_IOLOG,
+					   out_pdu, this_len, 0, flags);
+		if (ret)
+			goto err_zlib;
 	} while (stream.avail_in);
 
-	free(out_pdu);
+err_zlib:
 	deflateEnd(&stream);
-	return 0;
+err:
+	free(out_pdu);
+	return ret;
 }
 
 void fio_server_send_add_job(struct thread_options *o, const char *ioengine)