[CRIU] Re: [PATCH 2/2] sckets: reorganize queues restore
Pavel Emelyanov
xemul at parallels.com
Mon Mar 5 11:02:48 EST 2012
On 03/02/2012 06:36 PM, Kinsbursky Stanislav wrote:
> First move peer packets to another list, then go over it without checks.
> This allow to add some more usefull debug prints (nr of packets, for example).
> It also allows to restore sockets queues in parallel (which cound be usefull
> later).
How? This list is local.
And it allows to properly compare the queue lenght with socket buf, which is
a) not mentioned in comment
b) done in a wrong manner in the patch -- you should instead raise one to
bigger value and then decrease it back to initial value (to a value from
socket image in the future)
> Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
>
> ---
> sockets.c | 34 +++++++++++++++++++++++++++-------
> 1 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/sockets.c b/sockets.c
> index 1902d20..f1896fa 100644
> --- a/sockets.c
> +++ b/sockets.c
> @@ -756,17 +756,37 @@ static int restore_socket_queue(struct sk_packets_pool *pool, int fd,
> {
> struct sk_packet *pkt, *tmp;
> int ret;
> -
> - pr_info("%d: Restoring recv queue for %u: ", pool->pid, peer_id);
> + int size_size, queue_size, pkt_nr = 0, pkts_size = 0;
> + socklen_t len = sizeof(queue_size);
> + LIST_HEAD(peer_packets);
>
> list_for_each_entry_safe(pkt, tmp, &pool->packets_list, list) {
> - struct sk_packet_entry *entry = &pkt->entry;
> -
> - if (entry->id_for != peer_id)
> + if (pkt->entry.id_for != peer_id)
> continue;
> + list_move_tail(&pkt->list, &peer_packets);
> + pkts_size += pkt->entry.length;
> + pkt_nr++;
> + }
> +
> + if (!pkt_nr)
> + return 0;
> +
> + pr_info("%d: Restoring recv queue for %u: %d packets (overall size: %d bytes)\n", pool->pid, peer_id, pkt_nr, pkts_size);
>
> - pr_info("\tRestoring %d-bytes skb for %u\n",
> - entry->length, peer_id);
> + ret = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &queue_size, &len);
> + if (ret < 0) {
> + pr_perror("%d: Failed to get snd buffer size", pool->pid);
> + return -1;
> + }
> +
> + if (pkts_size > queue_size) {
> + pr_err("%d: Can't restore queue - not enough space: %d (required %d)\n",
> + pool->pid, queue_size, pkts_size);
> + return -1;
> + }
> +
> + list_for_each_entry_safe(pkt, tmp, &peer_packets, list) {
> + struct sk_packet_entry *entry = &pkt->entry;
>
> ret = sendfile(fd, pool->img_fd, &pkt->img_off, entry->length);
> if (ret < 0) {
>
More information about the CRIU
mailing list