Revisão | d48c3a044537689866fe44e65d24c7d39a68868a (tree) |
---|---|
Hora | 2022-01-28 23:38:23 |
Autor | Juan Quintela <quintela@redh...> |
Commiter | Juan Quintela |
multifd: Use a single writev on the send side
Until now, we wrote the packet header with write(), and the rest of the
pages with writev(). Just increase the size of the iovec and do a
single writev().
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
@@ -646,7 +646,7 @@ static void *multifd_send_thread(void *opaque) | ||
646 | 646 | uint32_t used = p->pages->num; |
647 | 647 | uint64_t packet_num = p->packet_num; |
648 | 648 | uint32_t flags = p->flags; |
649 | - p->iovs_num = 0; | |
649 | + p->iovs_num = 1; | |
650 | 650 | |
651 | 651 | if (used) { |
652 | 652 | ret = multifd_send_state->ops->send_prepare(p, &local_err); |
@@ -666,20 +666,15 @@ static void *multifd_send_thread(void *opaque) | ||
666 | 666 | trace_multifd_send(p->id, packet_num, used, flags, |
667 | 667 | p->next_packet_size); |
668 | 668 | |
669 | - ret = qio_channel_write_all(p->c, (void *)p->packet, | |
670 | - p->packet_len, &local_err); | |
669 | + p->iov[0].iov_len = p->packet_len; | |
670 | + p->iov[0].iov_base = p->packet; | |
671 | + | |
672 | + ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num, | |
673 | + &local_err); | |
671 | 674 | if (ret != 0) { |
672 | 675 | break; |
673 | 676 | } |
674 | 677 | |
675 | - if (used) { | |
676 | - ret = qio_channel_writev_all(p->c, p->iov, p->iovs_num, | |
677 | - &local_err); | |
678 | - if (ret != 0) { | |
679 | - break; | |
680 | - } | |
681 | - } | |
682 | - | |
683 | 678 | qemu_mutex_lock(&p->mutex); |
684 | 679 | p->pending_job--; |
685 | 680 | qemu_mutex_unlock(&p->mutex); |
@@ -916,7 +911,8 @@ int multifd_save_setup(Error **errp) | ||
916 | 911 | p->packet->version = cpu_to_be32(MULTIFD_VERSION); |
917 | 912 | p->name = g_strdup_printf("multifdsend_%d", i); |
918 | 913 | p->tls_hostname = g_strdup(s->hostname); |
919 | - p->iov = g_new0(struct iovec, page_count); | |
914 | + /* We need one extra place for the packet header */ | |
915 | + p->iov = g_new0(struct iovec, page_count + 1); | |
920 | 916 | socket_send_channel_create(multifd_new_send_channel_async, p); |
921 | 917 | } |
922 | 918 |